ataShow.c
资源名称:ixp425BSP.rar [点击查看]
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:10k
源码类别:
VxWorks
开发平台:
C/C++
- /* ataShow.c - ATA/IDE (LOCAL and PCMCIA) disk device driver show routine */
- /* Copyright 1989-2002 Wind River Systems, Inc. */
- #include "copyright_wrs.h"
- /*
- modification history
- --------------------
- 01k,09dec01,jkf changed copyright to 2002
- 01j,09nov01,jac SPR#67795, added support to display ATAPI CDROM device info.
- 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-PCMCIAn");
- else
- printf ("ATA-LOCALn");
- if (pDrive->type == ATA_TYPE_ATA)
- printf ("ATA devicen");
- else if (pDrive->type == ATA_TYPE_ATAPI)
- printf ("ATAPI devicen");
- else if (pDrive->type == ATA_TYPE_NONE)
- printf ("NO device presentn");
- else if (pDrive->type == ATA_TYPE_INIT)
- printf ("UNINITIALIZED devicen");
- else
- printf ("UNRECOGNIZED devicen");
- printf ("device state =");
- if (pDrive->state == ATA_DEV_OK)
- printf ("OKn");
- else if (pDrive->state == ATA_DEV_NONE)
- printf ("absent or does not respondn");
- else if (pDrive->state == ATA_DEV_DIAG_F)
- printf ("diagnostic failed: diagCode=0x%02xn", pDrive->diagCode);
- else if (pDrive->state == ATA_DEV_PREAD_F)
- printf ("read parameters failedn");
- else if (pDrive->state == ATA_DEV_MED_CH)
- printf ("medium have been changedn");
- else if (pDrive->state == ATA_DEV_INIT)
- printf ("uninitializedn");
- else
- printf ("illegaln");
- if (pDrive->type == ATA_TYPE_ATA) {
- printf ("pAtaDev =%pn", pDrive->pAtaDev);
- printf (" intCount =%-8d intStatus =0x%-8xn",
- pCtrl->intCount, pCtrl->intStatus);
- printf ("ataTypesn");
- printf (" cylinders =%-8d heads =%-8dn",
- pType->cylinders, pType->heads);
- printf (" sectorsTrack =%-8d bytesSector =%-8dn",
- pType->sectors, pType->bytes);
- printf (" precomp =0x%-8xn", pType->precomp);
- printf ("ataParamsn");
- printf (" cylinders =%-8d heads =%-8dn",
- (USHORT)pParam->cylinders, (USHORT)pParam->heads);
- printf (" sectorsTrack =%-8d bytesSector =%-8dn",
- (USHORT)pParam->sectors, (USHORT)pParam->bytesSec);
- printf (" config =0x%-8x removcyl =0x%-8xn",
- (USHORT)pParam->config, (USHORT)pParam->removcyl);
- printf (" bytesTrack =0x%-8x bytesGap =0x%-8xn",
- (USHORT)pParam->bytesTrack, (USHORT)pParam->bytesGap);
- printf (" bytesSync =0x%-8x vendstat =0x%-8xn",
- (USHORT)pParam->bytesSync, (USHORT)pParam->vendstat);
- }
- else
- {
- printf (" config =0x%04xn",(USHORT)pParam->config);
- }
- 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");
- if (pDrive->type == ATA_TYPE_ATA)
- {
- printf (" type =0x%-8x size =0x%-8xn",
- (USHORT)pParam->type, (USHORT)pParam->size);
- printf (" bytesEcc =0x%-8xn",
- (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");
- if (pDrive->type == ATA_TYPE_ATA)
- {
- printf (" multiSecs =0x%-8x capabilty =0x%-8xn",
- (USHORT)pParam->multiSecs, (USHORT)pParam->capabilities);
- printf (" pioMode =0x%-8x dmaMode =0x%-8xn",
- (USHORT)pParam->pioMode, (USHORT)pParam->dmaMode);
- printf (" valid =0x%-8x curr-cyl =%-8dn",
- (USHORT)pParam->valid, (USHORT)pParam->currentCylinders);
- printf (" curr-head =%-8d curr-sector =%-8dn",
- (USHORT)pParam->currentHeads, (USHORT)pParam->currentSectors);
- printf (" capacity0 =0x%-8x capacity1 =0x%-8dn",
- (USHORT)pParam->capacity0, (USHORT)pParam->capacity1);
- printf (" multiSet =0x%-8x sectors0 =0x%-8xn",
- (USHORT)pParam->multiSet, (USHORT)pParam->sectors0);
- printf (" sectors1 =0x%-8x singleDma =0x%-8xn",
- (USHORT)pParam->sectors1, (USHORT)pParam->singleDma);
- printf (" multiDma =0x%-8x advancedPio =0x%-8xn",
- (USHORT)pParam->multiDma, (USHORT)pParam->advancedPio);
- printf (" cycleDma =%-8d cycleMulti =%-8dn",
- (USHORT)pParam->cycletimeDma, (USHORT)pParam->cycletimeMulti);
- printf (" cyclePio-wo =%-8d cyclePio-w =%-8dn",
- (USHORT)pParam->cycletimePioNoIordy,
- (USHORT)pParam->cycletimePioIordy);
- }
- else
- {
- printf (" pioMode =0x%04x dmaMode =0x%04xn",
- (USHORT)pParam->pioMode, (USHORT)pParam->dmaMode);
- printf (" validity =0x%04xn", (USHORT)pParam->valid);
- printf (" singleDma =0x%04x multiDma =0x%04xn",
- (USHORT)pParam->singleDma, (USHORT)pParam->multiDma);
- if (pParam->valid & FIELDS_VALID)
- {
- printf (" advancedPio =0x%04xn",
- (USHORT)pParam->advancedPio);
- printf (" cycleDma =%-4d cycleMulti =%-4dn",
- (USHORT)pParam->cycletimeDma,
- (USHORT)pParam->cycletimeMulti);
- printf (" cyclePio-wo =%-4d cyclePio-w =%-4dn",
- (USHORT)pParam->cycletimePioNoIordy,
- (USHORT)pParam->cycletimePioIordy);
- }
- else
- printf(" words 64-70 not validn");
- printf (" relOverTime =%-4d relServTime =%-4dn",
- (USHORT)pParam->pktCmdRelTime, (USHORT)pParam->servCmdRelTime);
- printf (" majorRevNum =0x%04x minorVerNum =%-4dn",
- (USHORT)pParam->majorRevNum, (USHORT)pParam->minorVersNum);
- }
- printf ("Capabilityn");
- printf (" MULTI: %s, IORDY: %s, DMA: %s, LBA: %sn",
- pDrive->okMulti ? "TRUE" : "FALSE",
- pDrive->okIordy ? "TRUE" : "FALSE",
- pDrive->okDma ? "TRUE" : "FALSE",
- pDrive->okLba ? "TRUE" : "FALSE");
- printf (" multiSectors =0x%-8x pioMode =0x%-8xn",
- (USHORT)pDrive->multiSecs, (USHORT)pDrive->pioMode);
- printf (" singleDma =0x%-8x multiDma =0x%-8xn",
- (USHORT)pDrive->singleDmaMode, (USHORT)pDrive->multiDmaMode);
- printf ("Configurationn");
- 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 =%-8sn",
- pMode, (pDrive->rwBits == ATA_BITS_16) ? "16BITS " : "32BITS ");
- printf (" rwPio =%-8s rwDma =%-8sn",
- (pDrive->rwPio == ATA_PIO_SINGLE) ? "SINGLE " : "MULTI ",
- (pDrive->rwDma == ATA_DMA_SINGLE) ? "SINGLE " : "MULTI ");
- return (OK);
- }