📄 cisshow.c
字号:
/* cisShow.c - PCMCIA CIS show library *//* Copyright 1984-2001 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01e,10oct01,dat SPR 70829, add note about VX_FP_TASK being necessary01d,21jun00,rsh upgrade to dosFs 2.001c,28mar96,jdi doc: cleaned up language and format.01b,22feb96,hdn cleaned up01a,09feb95,hdn written.*//*DESCRIPTIONThis library provides a show routine for CIS tuples. This is providedfor engineering debug use.This module uses floating point calculations. Any task calling cisShow()needs to have the VX_FP_TASK bit set in the task flags.*/#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "drv/pcmcia/pcmciaLib.h"#include "drv/pcmcia/cisLib.h"/* defines *//* imports */IMPORT PCMCIA_CTRL pcmciaCtrl;/* globals *//* locals */LOCAL u_char cisFuncid = 0;LOCAL CIS_TUPLE *cisCdefault = (CIS_TUPLE *)0;LOCAL u_char systemInitByte = 0;LOCAL u_int deviceInfos = 0;LOCAL double speedMantisa [] = {0.0, 1.0, 1.2, 1.3, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0 };LOCAL double speedExponent [] = {1.0e-9, 10.0e-9, 100.0e-9, 1.0e-6, 10.0e-6, 100.0e-6, 1.0e-3, 10.0e-3 };LOCAL u_int deviceSize [] = {512, 2000, 8000, 32000, 128000, 512000, 2000000, 0 };LOCAL char *interfaceType[] = {"memory", "IO", "reserved", "reserved", "custom interface 0", "custom interface 1", "custom interface 2", "custom interface 3" };/* forward declarations */LOCAL void cisTupleShow (int sock);LOCAL void cisConfigShow (int sock);LOCAL void cisShowDevice (CIS_TUPLE *pTuple);LOCAL void cisShowVers1 (CIS_TUPLE *pTuple);LOCAL void cisShowVers2 (CIS_TUPLE *pTuple);LOCAL void cisShowFormat (CIS_TUPLE *pTuple);LOCAL void cisShowGeometry (CIS_TUPLE *pTuple);LOCAL void cisShowJedec (CIS_TUPLE *pTuple);LOCAL void cisShowDevgeo (CIS_TUPLE *pTuple);LOCAL void cisShowManfid (CIS_TUPLE *pTuple);LOCAL void cisShowFuncid (CIS_TUPLE *pTuple);LOCAL void cisShowFunce (CIS_TUPLE *pTuple);LOCAL void cisShowFunceSerial (CIS_TUPLE *pTuple);LOCAL void cisShowFunceModem (CIS_TUPLE *pTuple);LOCAL void cisShowFunceDmodem (CIS_TUPLE *pTuple);LOCAL void cisShowFunceFmodem (CIS_TUPLE *pTuple);LOCAL void cisShowFunceVmodem (CIS_TUPLE *pTuple);LOCAL void cisShowConfig (CIS_TUPLE *pTuple);LOCAL void cisShowCtable (CIS_TUPLE *pTuple);LOCAL u_char *cisShowCpower (u_char *pChar, u_char featureSelection);LOCAL u_char *cisShowCtiming (u_char *pChar, u_char featureSelection);LOCAL u_char *cisShowCio (u_char *pChar, u_char featureSelection);LOCAL u_char *cisShowCirq (u_char *pChar, u_char featureSelection);LOCAL u_char *cisShowCmem (u_char *pChar, u_char featureSelection);LOCAL u_char *cisShowCmisc (u_char *pChar, u_char featureSelection);LOCAL void cisShowCsub (CIS_TUPLE *pTuple);/********************************************************************************* cisShow - show CIS information** This routine shows CIS information.** NOTE: This routine uses floating point calculations. The calling task needs* to be spawned with the VX_FP_TASK flag. If this is not done, the data* printed by cisShow may be corrupted and unreliable.** RETURNS: N/A*/void cisShow ( int sock /* socket no. */ ) { cisTupleShow (sock); cisConfigShow (sock); }/********************************************************************************* cisTupleShow - Traverse the tuple link list, and show information in a tuple.** This routine traverses the link list of tuples and shows CIS (Configuration* Information Structure) in each tuple.** RETURNS: N/A*/LOCAL void cisTupleShow ( int sock /* socket no. */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CARD *pCard = &pCtrl->card[sock]; DL_LIST *pList = &pCard->cisTupleList; DL_NODE *pNode; CIS_TUPLE *pTuple; for (pNode = DLL_FIRST(pList); pNode != NULL; pNode = DLL_NEXT(pNode)) { pTuple = (CIS_TUPLE *)((char *)pNode + sizeof(DL_NODE)); switch (pTuple->code) { case CISTPL_DEVICE: printf ("Device information tuple for common memory\n"); cisShowDevice (pTuple); break; case CISTPL_DEVICE_A: printf ("Device information tuple for attribute memory\n"); cisShowDevice (pTuple); break; case CISTPL_VERS_1: printf ("Level-1 version/product-information tuple\n"); cisShowVers1 (pTuple); break; case CISTPL_GEOMETRY: printf ("Geometry tuple\n"); cisShowGeometry (pTuple); break; case CISTPL_JEDEC_C: printf ("JEDEC tuple for common memory\n"); cisShowJedec (pTuple); break; case CISTPL_JEDEC_A: printf ("JEDEC tuple for attribute memory\n"); cisShowJedec (pTuple); break; case CISTPL_DEVICE_GEO: printf ("Device geometry tuple for common memory\n"); cisShowDevgeo (pTuple); break; case CISTPL_DEVICE_GEO_A: printf ("Device geometry tuple for attribute memory\n"); cisShowDevgeo (pTuple); break; case CISTPL_MANFID: printf ("Manufacturer identification tuple\n"); cisShowManfid (pTuple); break; case CISTPL_FUNCID: printf ("Function identification tuple\n"); cisShowFuncid (pTuple); break; case CISTPL_FUNCE: printf ("Function extension tuple\n"); cisShowFunce (pTuple); break; case CISTPL_CONFIG: printf ("Configuration tuple\n"); cisShowConfig (pTuple); break; case CISTPL_CFTABLE_ENTRY: printf ("Configuration table entry tuple\n"); cisShowCtable (pTuple); break; case CISTPL_VERS_2: printf ("Level-2 version/product-information tuple\n"); cisShowVers2 (pTuple); break; case CISTPL_FORMAT: printf ("Format tuple\n"); cisShowFormat (pTuple); break; case CISTPL_NULL: case CISTPL_LONGLINK_A: case CISTPL_LONGLINK_C: case CISTPL_NO_LINK: case CISTPL_END: case CISTPL_CHECKSUM: break; default: printf ("Unsupported tuple 0x%x\n", pTuple->code); } } }/********************************************************************************* cisConfigShow - Show information in a configuration table link list.** This routine traverses the link list of configuration table and shows * information in each entry.** RETURNS: N/A*/LOCAL void cisConfigShow ( int sock /* socket no. */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CARD *pCard = &pCtrl->card[sock]; DL_LIST *pList = &pCard->cisConfigList; DL_NODE *pNode; CIS_CONFIG *pConfig; int ix; printf ("socket = %d\n", sock); printf ("configReg base= 0x%-8x mask = 0x%-8x\n", pCard->regBase, pCard->regMask); for (pNode = DLL_FIRST(pList); pNode != NULL; pNode = DLL_NEXT(pNode)) { pConfig = (CIS_CONFIG *)pNode; printf ("index = 0x%-8x\n", pConfig->index); printf ("interface = 0x%-8x\n", pConfig->interfaceType); printf ("Vcc nom = 0x%-8x min = 0x%-8x max = 0x%-8x\n", pConfig->vcc[0], pConfig->vcc[1], pConfig->vcc[2]); printf ("Vpp1 nom = 0x%-8x min = 0x%-8x max = 0x%-8x\n", pConfig->vpp1[0], pConfig->vpp1[1], pConfig->vpp1[2]); printf ("Vpp2 nom = 0x%-8x min = 0x%-8x max = 0x%-8x\n", pConfig->vpp2[0], pConfig->vpp2[1], pConfig->vpp2[2]); printf ("IO Bus width = 0x%-8x Lines = 0x%-8x Ranges = 0x%-8x\n", pConfig->ioBuswidth, pConfig->ioAddrlines, pConfig->ioRanges); for (ix = 0; ix < pConfig->ioRanges; ix++) printf (" start = 0x%-8x stop = 0x%-8x\n", pConfig->io[ix].start, pConfig->io[ix].stop); printf ("IRQ Mode = 0x%-8x Mask = 0x%-8x\n", pConfig->irqMode, pConfig->irqMask); printf ("IRQ Level = 0x%-8x Special = 0x%-8x Bitmap = 0x%4x\n", pConfig->irqLevel, pConfig->irqSpecial, pConfig->irqBit.s); for (ix = 0; ix < 8; ix++) { if ((pConfig->mem[ix].length == 0) && (pConfig->mem[ix].cAddr == 0) && (pConfig->mem[ix].hAddr == 0)) continue; printf (" length = 0x%-8x cAddr = 0x%-8x hAddr = 0x%-8x\n", pConfig->mem[ix].length, pConfig->mem[ix].cAddr, pConfig->mem[ix].hAddr); } printf ("twins = 0x%-8x audio = 0x%-8x\n", pConfig->twins, pConfig->audio); printf ("readonly = 0x%-8x pwrdown = 0x%-8x\n\n", pConfig->readonly, pConfig->pwrdown); } }/********************************************************************************* cisShowDevice - Show information in device information tuple.** This routine shows CIS in the device information tuple. Uses floating* point calculations. The calling task needs to have VX_FP_TASK bit set* in its task flags.** RETURNS: N/A*/LOCAL void cisShowDevice ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char *pEnd = pChar + pTuple->link; BOOL speedExtended = FALSE; BOOL typeExtended = FALSE; u_char unit; u_int size; double speed; while ((pChar < pEnd) && (*pChar != 0xff)) { deviceInfos++; switch (*pChar & 0xf0) { case DTYPE_NULL: printf (" Not a memory device\n"); break; case DTYPE_ROM: printf (" Masked ROM\n"); break; case DTYPE_OTPROM: printf (" One-time programmable ROM\n"); break; case DTYPE_EPROM: printf (" UV EPROM\n"); break; case DTYPE_EEPROM: printf (" EEPROM\n"); break; case DTYPE_FLASH: printf (" Flash EPROM\n"); break; case DTYPE_SRAM: printf (" SRAM\n"); break; case DTYPE_DRAM: printf (" DRAM\n"); break; case DTYPE_FUNCSPEC: printf (" Function-specific memory address range\n"); break; case DTYPE_EXTEND: typeExtended = TRUE; break; default: printf (" Reserved device type\n"); } if (*pChar & 0x08) printf (" Always writable\n"); else printf (" WPS and WP signal indicates it\n"); switch (*pChar & 0x07) { case DSPEED_NULL: break; case DSPEED_250NS: printf (" 250ns\n"); break; case DSPEED_200NS: printf (" 200ns\n"); break; case DSPEED_150NS: printf (" 150ns\n"); break; case DSPEED_100NS: printf (" 100ns\n"); break; case DSPEED_EXT: speedExtended = TRUE; break; default: printf (" Reserved device speed\n"); } pChar++; while (speedExtended) { if ((*pChar & 0x80) == 0x00) speedExtended = FALSE; speed = speedMantisa[(*pChar & 0x78) >> 3] * speedExponent[(*pChar & 0x07)]; printf (" Speed=%1.9f\n", speed); pChar++; } while (typeExtended) { if ((*pChar & 0x80) == 0x00) typeExtended = FALSE; pChar++; } unit = ((*pChar & 0xf8) >> 3) + 1; size = deviceSize[*pChar & 0x07]; printf (" Device size = %d * 0x%x = 0x%x\n", unit, size, unit * size); pChar++; } }/********************************************************************************* cisShowVers1 - Show information in level-1 version/product information tuple.** This routine shows CIS in the level-1 version/product information tuple.** RETURNS: N/A*/LOCAL void cisShowVers1 ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char *pEnd = pChar + pTuple->link; printf (" Major version number = %d\n", *pChar++); printf (" Minor version number = %d\n ", *pChar++); while ((pChar < pEnd) && (*pChar != 0xff)) pChar += printf ("%s", pChar) + 1; printf ("\n"); }/********************************************************************************* cisShowGeometry - Show information in geometry tuple.** This routine shows CIS in the geometry tuple.** RETURNS: N/A*/LOCAL void cisShowGeometry ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); CIS_BYTE2 cylinder; printf (" Sectors/track = %d\n", *pChar++); printf (" Tracks/cylinder = %d\n", *pChar++); cylinder.c[0] = *pChar++; cylinder.c[1] = *pChar++; printf (" Cylinder = %d\n", cylinder.s); }/********************************************************************************* cisShowJedec - Show information in JEDEC programming information tuple.** This routine shows CIS in the JEDEC programming information tuple.** RETURNS: N/A*/LOCAL void cisShowJedec ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char *pEnd = pChar + pTuple->link; while ((pChar < pEnd) && (deviceInfos-- != 0)) { printf (" Manufacturer ID = 0x%x\n", *pChar++); printf (" Manufacturer's info = 0x%x\n", *pChar++); } }/********************************************************************************* cisShowDevgeo - Show information in Device geometry tuple.** This routine shows CIS in the Device geometry tuple.** RETURNS: N/A*/LOCAL void cisShowDevgeo ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char *pEnd = pChar + pTuple->link; while ((pChar < pEnd) && (*pChar != 0xff)) { printf (" Internal bus width of card = %d bytes\n", 1 << (*pChar++ - 1)); printf (" Erase geometry block size = %d\n", 1 << (*pChar++ - 1)); printf (" Read geometry block size = %d\n", 1 << (*pChar++ - 1)); printf (" Write geometry block size = %d\n", 1 << (*pChar++ - 1)); printf (" Partition size = %d\n", 1 << (*pChar++ - 1)); printf (" Interleave size = %d\n", 1 << (*pChar++ - 1)); } }/********************************************************************************* cisShowManfid - Show information in Manufacturer ID tuple.** This routine shows CIS in the Manufacturer ID tuple.** RETURNS: N/A*/LOCAL void cisShowManfid ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); CIS_BYTE2 manufacturerCode; CIS_BYTE2 manufacturerInfo; manufacturerCode.c[0] = *pChar++; manufacturerCode.c[1] = *pChar++; manufacturerInfo.c[0] = *pChar++; manufacturerInfo.c[1] = *pChar++; printf (" Manufacturer code = 0x%x\n", manufacturerCode.s); printf (" Manufacturer info = 0x%x\n", manufacturerInfo.s); }/********************************************************************************* cisShowFuncid - Show information in Function ID tuple.** This routine shows CIS in the Function ID tuple.** RETURNS: N/A*/LOCAL void cisShowFuncid ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); switch (*pChar++) { case FUNC_MULTI: cisFuncid = FUNC_MULTI; printf (" Multi function\n"); break; case FUNC_MEMORY: cisFuncid = FUNC_MEMORY; printf (" Memory\n"); break; case FUNC_SERIAL: cisFuncid = FUNC_SERIAL; printf (" Serial port\n"); break; case FUNC_PARALLEL: cisFuncid = FUNC_PARALLEL; printf (" Parallel port\n"); break; case FUNC_FIXEDDISK: cisFuncid = FUNC_FIXEDDISK; printf (" Fixed disk\n"); break; case FUNC_VIDEO: cisFuncid = FUNC_VIDEO; printf (" Video adaptor\n"); break; case FUNC_LAN:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -