📄 cisshow.c
字号:
else printf (" RdyBsy Inactive\n"); if (*pChar & 0x80) printf (" M Wait Required\n"); else printf (" M Wait Not required\n"); pChar++; } featureSelection = *pChar++; if (featureSelection & 0x03) { printf (" Power description\n"); pChar = cisShowCpower (pChar, featureSelection); } if (featureSelection & 0x04) { printf (" Timing description\n"); pChar = cisShowCtiming (pChar, featureSelection); } if (featureSelection & 0x08) { printf (" IOspace description\n"); pChar = cisShowCio (pChar, featureSelection); } if (featureSelection & 0x10) { printf (" IRQ description\n"); pChar = cisShowCirq (pChar, featureSelection); } if (featureSelection & 0x60) { printf (" MEMspace description\n"); pChar = cisShowCmem (pChar, featureSelection); } if (featureSelection & 0x80) { printf (" Misc description\n"); pChar = cisShowCmisc (pChar, featureSelection); } cisShowCsub ((CIS_TUPLE *)pChar); }/********************************************************************************* cisShowCpower - Show information in Power description structure.** This routine shows CIS in the Power description structure.** RETURNS: A pointer to next entry.*/LOCAL u_char *cisShowCpower ( u_char *pChar, /* pointer to power description */ u_char featureSelection /* feature selection byte */ ) { u_char parameterSelection; char *pV = ""; u_int ix; featureSelection &= 0x03; for (ix = 1; ix <= featureSelection; ix++) { if (ix == 1) pV = "Vcc"; if ((ix == 2) && (featureSelection == 2)) pV = "Vpp"; if ((ix == 2) && (featureSelection == 3)) pV = "Vpp1"; if (ix == 3) pV = "Vpp2"; parameterSelection = *pChar++; if (parameterSelection & 0x01) do { printf (" %s nominal V = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x02) do { printf (" %s minimum V = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x04) do { printf (" %s maximum V = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x08) do { printf (" %s static I = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x10) do { printf (" %s average I = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x20) do { printf (" %s no peak I = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); if (parameterSelection & 0x40) do { printf (" %s power down I = 0x%x\n", pV, *pChar++ & 0x7f); } while (*(pChar-1) & 0x80); } return (pChar); }/********************************************************************************* cisShowCtiming - Show information in Timing description structure.** This routine shows CIS in the Timing description structure.** RETURNS: A pointer to next entry.* ARGSUSED*/LOCAL u_char *cisShowCtiming ( u_char *pChar, /* pointer to timing description */ u_char featureSelection /* feature selection byte */ ) { u_int waitScale = *pChar & 0x03; u_int busyScale = (*pChar & 0x1c) >> 2; u_int reservedScale = (*pChar & 0xe0) >> 5; BOOL speedExtended; double waitTime; double busyTime; double reservedTime; pChar++; if (waitScale != 0x03) { speedExtended = TRUE; while (speedExtended) { if ((*pChar & 0x80) == 0x00) speedExtended = FALSE; waitTime = speedMantisa [(*pChar & 0x78) >> 3] * speedExponent [(*pChar & 0x07)] * waitScale; printf (" Wait time = %1.9f\n", waitTime); pChar++; } } else printf (" Wait signal is not used\n"); if (busyScale != 0x07) { speedExtended = TRUE; while (speedExtended) { if ((*pChar & 0x80) == 0x00) speedExtended = FALSE; busyTime = speedMantisa [(*pChar & 0x78) >> 3] * speedExponent [(*pChar & 0x07)] * busyScale; printf (" Busy time = %1.9f\n", busyTime); pChar++; } } else printf (" Ready/Busy signal is not used\n"); if (reservedScale != 0x07) { speedExtended = TRUE; while (speedExtended) { if ((*pChar & 0x80) == 0x00) speedExtended = FALSE; reservedTime = speedMantisa [(*pChar & 0x78) >> 3] * speedExponent [(*pChar & 0x07)] * reservedScale; printf (" Reserved time = %1.9f\n", reservedTime); pChar++; } } else printf (" No reserved-time is defined\n"); return (pChar); }/********************************************************************************* cisShowCio - Show information in IO description structure.** This routine shows CIS in the IO description structure.** RETURNS: A pointer to next entry.*/LOCAL u_char *cisShowCio ( u_char *pChar, /* pointer to IO description */ u_char featureSelection /* feature selection byte */ ) { CIS_BYTE4 addr; CIS_BYTE4 length; u_int ioRanges; u_int addrSize; u_int lengthSize; printf (" IO address lines = %d\n", *pChar & 0x1f); printf (" Bus width = "); if (*pChar & 0x20) printf ("8 "); if (*pChar & 0x40) printf ("16 "); printf ("\n"); if (*pChar++ & 0x80) { ioRanges = (*pChar & 0x07) + 1; addrSize = (*pChar & 0x30) >> 4; lengthSize = (*pChar & 0xc0) >> 6; pChar++; while (ioRanges--) { addr.l = 0; length.l = 0; if (addrSize == 1) addr.c[0] = *pChar++; if (addrSize == 2) { addr.c[0] = *pChar++; addr.c[1] = *pChar++; } if (addrSize == 3) { addr.c[0] = *pChar++; addr.c[1] = *pChar++; addr.c[2] = *pChar++; addr.c[3] = *pChar++; } if (lengthSize == 1) length.c[0] = *pChar++; if (lengthSize == 2) { length.c[0] = *pChar++; length.c[1] = *pChar++; } if (lengthSize == 3) { length.c[0] = *pChar++; length.c[1] = *pChar++; length.c[2] = *pChar++; length.c[3] = *pChar++; } printf (" Addr = 0x%x length = 0x%x\n", addr.l, length.l + 1); } } return (pChar); }/********************************************************************************* cisShowCirq - Show information in IRQ description structure.** This routine shows CIS in the IRQ description structure.** RETURNS: A pointer to next entry.*/LOCAL u_char *cisShowCirq ( u_char *pChar, /* pointer to IRQ description */ u_char featureSelection /* feature selection byte */ ) { u_int ix; printf (" Interrupt request mode is "); if (*pChar & 0x80) printf ("Share "); if (*pChar & 0x40) printf ("Pulse "); if (*pChar & 0x20) printf ("Level "); printf ("\n"); printf (" Interrupt request line is "); if (*pChar & 0x10) { if (*pChar & 0x08) printf ("VEND "); if (*pChar & 0x04) printf ("BERR "); if (*pChar & 0x02) printf ("IOCK "); if (*pChar & 0x01) printf ("NMI "); for (ix = 0; ix < 8; ix++) if (*(pChar+1) & (1 << ix)) printf ("%d ", ix); for (ix = 0; ix < 8; ix++) if (*(pChar+2) & (1 << ix)) printf ("%d ", ix + 8); pChar += 3; } else { printf ("%d", *pChar & 0x0f); pChar++; } printf ("\n"); return (pChar); }/********************************************************************************* cisShowCmem - Show information in Memory description structure.** This routine shows CIS in the Memory description structure.** RETURNS: A pointer to next entry.*/LOCAL u_char *cisShowCmem ( u_char *pChar, /* pointer to memory description */ u_char featureSelection /* feature selection byte */ ) { u_char addrSize; u_char lengthSize; u_char windows; u_char hostaddr; CIS_BYTE4 cAddr; CIS_BYTE4 hAddr; CIS_BYTE4 length; if ((featureSelection & 0x60) == 0x20) { length.l = 0; length.c[0] = *pChar++; length.c[1] = *pChar++; printf (" Length = 0x%x cardAddress = 0\n", length.l * 256); } else if ((featureSelection & 0x60) == 0x40) { length.l = 0; cAddr.l = 0; length.c[0] = *pChar++; length.c[1] = *pChar++; cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; printf (" Length = 0x%x cardAddress = 0x%x\n", length.l * 256, cAddr.l * 256); } else if ((featureSelection & 0x60) == 0x60) { windows = (*pChar & 0x07) + 1; lengthSize = (*pChar & 0x18) >> 3; addrSize = (*pChar & 0x60) >> 5; hostaddr = *pChar & 0x80; while (windows--) { length.l = 0; cAddr.l = 0; hAddr.l = 0; if (lengthSize == 1) length.c[0] = *pChar++; if (lengthSize == 2) { length.c[0] = *pChar++; length.c[1] = *pChar++; } if (lengthSize == 3) { length.c[0] = *pChar++; length.c[1] = *pChar++; length.c[2] = *pChar++; length.c[3] = *pChar++; } if (addrSize == 1) cAddr.c[0] = *pChar++; if (addrSize == 2) { cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; } if (addrSize == 3) { cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; cAddr.c[2] = *pChar++; cAddr.c[3] = *pChar++; } if (hostaddr == 0x80) { if (addrSize == 1) hAddr.c[0] = *pChar++; if (addrSize == 2) { hAddr.c[0] = *pChar++; hAddr.c[1] = *pChar++; } if (addrSize == 3) { hAddr.c[0] = *pChar++; hAddr.c[1] = *pChar++; hAddr.c[2] = *pChar++; hAddr.c[3] = *pChar++; } } printf (" Length = 0x%x cardAddress = 0x%x hostAddress = 0x%x\n", length.l * 256, cAddr.l * 256, hAddr.l * 256); } } return (pChar); }/********************************************************************************* cisShowCmisc - Show information in Misc description structure.** This routine shows CIS in the Misc description structure.** RETURNS: A pointer to next entry.*/LOCAL u_char *cisShowCmisc ( u_char *pChar, /* pointer to misc description */ u_char featureSelection /* feature selection byte */ ) { BOOL extension = TRUE; while (extension) { if ((*pChar & 0x80) == 0x00) extension = FALSE; printf (" Max twins = %d\n", *pChar & 0x07); if (*pChar & 0x08) printf (" Audio\n"); if (*pChar & 0x10) printf (" Read only\n"); if (*pChar & 0x20) printf (" Power down bit is supported\n"); if (*pChar & 0x40) printf (" Reserved\n"); pChar++; } return (pChar); }/********************************************************************************* cisShowCsub - Show information in Sub tuple.** This routine shows CIS in the Sub tuple.** RETURNS: N/A*/LOCAL void cisShowCsub ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char *pEnd = pChar + pTuple->link; while ((pTuple->code == 0xc0) || (pTuple->code == 0xc1)) { printf (" Configuration subtuple\n"); printf (" "); while ((pChar < pEnd) && (*pChar != 0xff)) pChar += printf ("%s", pChar) + 1; printf ("\n"); pTuple = (CIS_TUPLE *)pEnd; } }/********************************************************************************* cisShowVers2 - Show information in level-2 version/product information tuple.** This routine shows CIS in the level-2 version/product information tuple.** RETURNS: N/A*/LOCAL void cisShowVers2 ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); CIS_BYTE2 index; pChar++; printf (" Level of compliance = %d\n", *pChar++); index.c[0] = *pChar++; index.c[1] = *pChar++; printf (" Address of first data byte in card = 0x%x\n", index.s); pChar += 2; printf (" Vender specific bytes = 0x%x 0x%x\n", *pChar++, *pChar++); printf (" Number of copies of the CIS = 0x%x\n", *pChar++); printf (" "); pChar += printf ("%s", pChar) + 1; printf ("\n "); printf ("%s\n", pChar); }/********************************************************************************* cisShowFormat - Show information in format tuple.** This routine shows CIS in the format tuple.** RETURNS: N/A*/LOCAL void cisShowFormat ( CIS_TUPLE *pTuple /* pointer to a tuple */ ) { u_char *pChar = (u_char *)pTuple + sizeof(CIS_TUPLE); u_char type; u_char flag; u_char edc; CIS_BYTE4 offset; CIS_BYTE4 nBytes; CIS_BYTE4 nBlocks; CIS_BYTE4 edcLoc; CIS_BYTE4 addr; CIS_BYTE2 blockSize; type = *pChar++; if (type == 0) printf (" Format type = Disk\n"); else if (type == 0) printf (" Format type = Memory\n"); else printf (" Format type = Vender specific 0x%x\n", type); edc = *pChar++; printf (" EDC type = 0x%x\n", (edc & 0x78) >> 3); printf (" EDC length = 0x%x\n", (edc & 0x07)); offset.c[0] = *pChar++; offset.c[1] = *pChar++; offset.c[2] = *pChar++; offset.c[3] = *pChar++; printf (" Address of first data byte = 0x%x\n", offset.l); nBytes.c[0] = *pChar++; nBytes.c[1] = *pChar++; nBytes.c[2] = *pChar++; nBytes.c[3] = *pChar++; printf (" Number of data bytes = 0x%x\n", nBytes.l); if (type == 0) { blockSize.c[0] = *pChar++; blockSize.c[1] = *pChar++; nBlocks.c[0] = *pChar++; nBlocks.c[1] = *pChar++; nBlocks.c[2] = *pChar++; nBlocks.c[3] = *pChar++; printf (" Block size = %d\n", 1 << blockSize.s); printf (" Number of data blocks = %d\n", nBlocks.l); edcLoc.c[0] = *pChar++; edcLoc.c[1] = *pChar++; edcLoc.c[2] = *pChar++; edcLoc.c[3] = *pChar++; if ((edc == 1) || (edc == 2)) printf (" EDC Location = 0x%x\n", edcLoc.l); else if (edc == 3) printf (" EDC PCC = 0x%x\n", edcLoc.c[0]); } else if (type == 1) { flag = *pChar++; pChar++; addr.c[0] = *pChar++; addr.c[1] = *pChar++; addr.c[2] = *pChar++; addr.c[3] = *pChar++; edcLoc.c[0] = *pChar++; edcLoc.c[1] = *pChar++; edcLoc.c[2] = *pChar++; edcLoc.c[3] = *pChar++; printf (" Flags = 0x%x\n", flag); if (flag & 1) printf (" Mapped physical address = 0x%x\n", addr.l); printf (" EDC location = 0x%x\n", edcLoc.l); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -