⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atashow.c

📁 这个软件主要是介绍Vxwork驱动编写
💻 C
字号:
/* ataShow.c - ATA/IDE (LOCAL and PCMCIA) disk device driver show routine */

/* Copyright 1989-1999 Wind River Systems, Inc. */
#include "copyright_wrs.h"

/*
modification history
--------------------
01i,18mar99,jdi  doc: updated w/ info about proj facility (SPR 25727).
01h,15jan99,jkf  added endian ifdef to properly display revision
                 and model strings on big endian arches.
01g,11nov96,dgp  doc: final formatting
01f,11nov96,hdn  removed NOMANUAL from ataShowInit() and ataShow().
01e,01nov96,hdn  added support for PCMCIA.
01d,25sep96,hdn  added support for ATA-2.
01c,18mar96,hdn  added ataShowInit().
01b,01mar96,hdn  cleaned up.
01a,02mar95,hdn  written based on ideDrv.c.
*/

/*
DESCRIPTION
This library contains a driver show routine for the ATA/IDE (PCMCIA and LOCAL) 
devices supported on the IBM PC.

*/

#include "vxWorks.h"
#include "taskLib.h"
#include "ioLib.h"
#include "memLib.h"
#include "stdlib.h"
#include "errnoLib.h"
#include "stdio.h"
#include "string.h"
#include "private/semLibP.h"
#include "intLib.h"
#include "iv.h"
#include "wdLib.h"
#include "sysLib.h"
#include "sys/fcntlcom.h"
#include "drv/pcmcia/pcmciaLib.h"
#include "drv/hdisk/ataDrv.h"

/* imports */

IMPORT ATA_CTRL		ataCtrl [ATA_MAX_CTRLS];
IMPORT ATA_TYPE		ataTypes [ATA_MAX_CTRLS][ATA_MAX_DRIVES];
IMPORT ATA_RESOURCE	ataResources [ATA_MAX_CTRLS];
IMPORT BOOL		ataDrvInstalled;


/* globals */


/* locals */


/* function prototypes */


/*******************************************************************************
*
* ataShowInit - initialize the ATA/IDE disk driver show routine
*
* This routine links the ATA/IDE disk driver show routine into the VxWorks
* system.  It is called automatically when this show facility is configured
* into VxWorks using either of the following methods:
* .iP
* If you use the configuration header files, define
* INCLUDE_SHOW_ROUTINES in config.h.
* .iP
* If you use the Tornado project facility, select INCLUDE_ATA_SHOW.
*
* RETURNS: N/A
*/

void ataShowInit (void)
    {
    }

/*******************************************************************************
*
* ataShow - show the ATA/IDE disk parameters
*
* This routine shows the ATA/IDE disk parameters.  Its first argument is a
* controller number, 0 or 1; the second argument is a drive number, 0 or 1.
*
* RETURNS: OK, or ERROR if the parameters are invalid.
*/

STATUS ataShow
    (
    int ctrl,
    int drive
    )
    {
    ATA_CTRL *pCtrl		= &ataCtrl[ctrl];
    ATA_DRIVE *pDrive		= &pCtrl->drive[drive];
    ATA_PARAM *pParam		= &pDrive->param;
    ATA_RESOURCE *pResource	= &ataResources[ctrl];
    ATA_TYPE *pType		= &ataTypes[ctrl][drive];
    char *pMode			= "UNKNOWN";
    int ix;

    if ((ctrl >= ATA_MAX_CTRLS) || (drive >= ATA_MAX_DRIVES) ||
        !ataDrvInstalled || !pCtrl->installed)
	return (ERROR);

    if (pResource->ctrlType == ATA_PCMCIA)
        printf ("ATA-PCMCIA\n");
    else
        printf ("ATA-LOCAL\n");

    printf ("  intCount     =%-8d    intStatus   =0x%-8x\n",
    	    pCtrl->intCount, pCtrl->intStatus);
    printf ("ataTypes\n");
    printf ("  cylinders    =%-8d    heads       =%-8d\n",
    	    pType->cylinders, pType->heads);
    printf ("  sectorsTrack =%-8d    bytesSector =%-8d\n",
    	    pType->sectors, pType->bytes);
    printf ("  precomp      =0x%-8x\n", pType->precomp);

    printf ("ataParams\n");
    printf ("  cylinders    =%-8d    heads       =%-8d\n",
    	    (USHORT)pParam->cylinders, (USHORT)pParam->heads);	
    printf ("  sectorsTrack =%-8d    bytesSector =%-8d\n",
    	    (USHORT)pParam->sectors, (USHORT)pParam->bytesSec);
    printf ("  config       =0x%-8x  removcyl    =0x%-8x\n",
    	    (USHORT)pParam->config, (USHORT)pParam->removcyl);
    printf ("  bytesTrack   =0x%-8x  bytesGap    =0x%-8x\n",
    	    (USHORT)pParam->bytesTrack, (USHORT)pParam->bytesGap);
    printf ("  bytesSync    =0x%-8x  vendstat    =0x%-8x\n",
    	    (USHORT)pParam->bytesSync, (USHORT)pParam->vendstat);
    printf ("  serial       =");
    for (ix = 0; ix < 10; ix++)
	{
#if (_BYTE_ORDER == _LITTLE_ENDIAN)
        printf ("%c", pParam->serial[ix * 2 + 1]);
        printf ("%c", pParam->serial[ix * 2]);
#else
        printf ("%c", pParam->serial[ix * 2]);
        printf ("%c", pParam->serial[ix * 2 + 1]);
#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */

	}
    printf ("\n");
    printf ("  type         =0x%-8x  size        =0x%-8x\n",
    	    (USHORT)pParam->type, (USHORT)pParam->size);
    printf ("  bytesEcc     =0x%-8x\n",
    	    (USHORT)pParam->bytesEcc);
    printf ("  rev          =");

    for (ix = 0; ix < 4; ix++)
	{
#if (_BYTE_ORDER == _LITTLE_ENDIAN)
        printf ("%c", pParam->rev[ix * 2 + 1]);
        printf ("%c", pParam->rev[ix * 2]);
#else
        printf ("%c", pParam->rev[ix * 2]);
        printf ("%c", pParam->rev[ix * 2 + 1]);
#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */
	}

    printf ("\n");
    printf ("  model        =");

    for (ix = 0; ix < 20; ix++)
	{
#if (_BYTE_ORDER == _LITTLE_ENDIAN)
        printf ("%c", pParam->model[ix * 2 + 1]);
        printf ("%c", pParam->model[ix * 2]);
#else
        printf ("%c", pParam->model[ix * 2]);
        printf ("%c", pParam->model[ix * 2 + 1]);
#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */
	}

    printf ("\n");
    printf ("  multiSecs    =0x%-8x  capabilty   =0x%-8x\n",
	    (USHORT)pParam->multiSecs, (USHORT)pParam->capabilities);
    printf ("  pioMode      =0x%-8x  dmaMode     =0x%-8x\n",
	    (USHORT)pParam->pioMode, (USHORT)pParam->dmaMode);
    printf ("  valid        =0x%-8x  curr-cyl    =%-8d\n",
	    (USHORT)pParam->valid, (USHORT)pParam->currentCylinders);
    printf ("  curr-head    =%-8d    curr-sector =%-8d\n",
	    (USHORT)pParam->currentHeads, (USHORT)pParam->currentSectors);
    printf ("  capacity0    =0x%-8x  capacity1   =0x%-8d\n",
	    (USHORT)pParam->capacity0, (USHORT)pParam->capacity1);
    printf ("  multiSet     =0x%-8x  sectors0    =0x%-8x\n",
	    (USHORT)pParam->multiSet, (USHORT)pParam->sectors0);
    printf ("  sectors1     =0x%-8x  singleDma   =0x%-8x\n",
	    (USHORT)pParam->sectors1, (USHORT)pParam->singleDma);
    printf ("  multiDma     =0x%-8x  advancedPio =0x%-8x\n",
	    (USHORT)pParam->multiDma, (USHORT)pParam->advancedPio);
    printf ("  cycleDma     =%-8d    cycleMulti  =%-8d\n",
	    (USHORT)pParam->cycletimeDma, (USHORT)pParam->cycletimeMulti);
    printf ("  cyclePio-wo  =%-8d    cyclePio-w  =%-8d\n",
	    (USHORT)pParam->cycletimePioNoIordy, 
	    (USHORT)pParam->cycletimePioIordy);
    printf ("Capability\n");
    printf ("  MULTI: %s, IORDY: %s, DMA: %s, LBA: %s\n",
	    pDrive->okMulti ? "TRUE" : "FALSE",
	    pDrive->okIordy ? "TRUE" : "FALSE",
	    pDrive->okDma ? "TRUE" : "FALSE",
	    pDrive->okLba ? "TRUE" : "FALSE");
    printf ("  multiSectors =0x%-8x  pioMode     =0x%-8x\n",
	    (USHORT)pDrive->multiSecs, (USHORT)pDrive->pioMode);
    printf ("  singleDma    =0x%-8x  multiDma    =0x%-8x\n",
	    (USHORT)pDrive->singleDmaMode, (USHORT)pDrive->multiDmaMode);
    printf ("Configuration\n");
	    switch (pDrive->rwMode)
		{
		case ATA_PIO_DEF_W:
		    pMode = "PIO_DEF0";
		    break;
		case ATA_PIO_DEF_WO:
		    pMode = "PIO_DEF1";
		    break;
		case ATA_PIO_W_0:
		    pMode = "PIO_0";
		    break;
		case ATA_PIO_W_1:
		    pMode = "PIO_1";
		    break;
		case ATA_PIO_W_2:
		    pMode = "PIO_2";
		    break;
		case ATA_PIO_W_3:
		    pMode = "PIO_3";
		    break;
		case ATA_PIO_W_4:
		    pMode = "PIO_4";
		    break;
		case ATA_DMA_SINGLE_0:
		case ATA_DMA_MULTI_0:
		    pMode = "DMA_0";
		    break;
		case ATA_DMA_SINGLE_1:
		case ATA_DMA_MULTI_1:
		    pMode = "DMA_1";
		    break;
		case ATA_DMA_SINGLE_2:
		case ATA_DMA_MULTI_2:
		    pMode = "DMA_2";
		    break;
		}
    printf ("  rwMode       =%-8s    rwBits      =%-8s\n",
	    pMode, (pDrive->rwBits == ATA_BITS_16) ? "16BITS  " : "32BITS  ");
    printf ("  rwPio        =%-8s    rwDma       =%-8s\n",
	    (pDrive->rwPio == ATA_PIO_SINGLE) ? "SINGLE  " : "MULTI   ",
	    (pDrive->rwDma == ATA_DMA_SINGLE) ? "SINGLE  " : "MULTI   ");

    return (OK);
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -