📄 cislib.c
字号:
dllInit ((DL_LIST *)&pConfig->node); } dllAdd (&pCard->cisConfigList, &pConfig->node); pConfig->index = *pChar & 0x3f; if (*pChar++ & 0x80) pConfig->interfaceType = *pChar++ & 0x0f; featureSelection = *pChar++; if (featureSelection & 0x03) /* power description */ { for (ix=1; ix <= (featureSelection & 0x03); ix++) { if (ix == 1) pv = &pConfig->vcc[0]; else if (ix == 2) pv = &pConfig->vpp1[0]; else pv = &pConfig->vpp2[0]; parameterSelection = *pChar++; if (parameterSelection & 0x01) { *pv++ = powerMantissa[(*pChar & 0x78) >> 3] * powerExponent[(*pChar & 0x07)]; while (*pChar++ & 0x80) ; } if (parameterSelection & 0x02) { *pv++ = powerMantissa[(*pChar & 0x78) >> 3] * powerExponent[(*pChar & 0x07)]; while (*pChar++ & 0x80) ; } if (parameterSelection & 0x04) { *pv++ = powerMantissa[(*pChar & 0x78) >> 3] * powerExponent[(*pChar & 0x07)]; while (*pChar++ & 0x80) ; } if (parameterSelection & 0x08) { while (*pChar++ & 0x80) ; } if (parameterSelection & 0x10) { while (*pChar++ & 0x80) ; } if (parameterSelection & 0x20) { while (*pChar++ & 0x80) ; } if (parameterSelection & 0x40) { while (*pChar++ & 0x80) ; } } } if (featureSelection & 0x04) /* timing description */ { waitScale = *pChar & 0x03; busyScale = (*pChar & 0x1c) >> 2; reservedScale = (*pChar & 0xe0) >> 5; pChar++; if (waitScale != 0x03) while (*pChar++ & 0x80) ; if (busyScale != 0x03) while (*pChar++ & 0x80) ; if (reservedScale != 0x03) while (*pChar++ & 0x80) ; } if (featureSelection & 0x08) /* IO description */ { pConfig->ioAddrlines = *pChar & 0x1f; pConfig->ioBuswidth = (*pChar & 0x60) >> 5; pConfig->ioRanges = 0; if (*pChar++ & 0x80) { pConfig->ioRanges = (*pChar & 0x07) + 1; addrSize = (*pChar & 0x30) >> 4; lengthSize = (*pChar & 0xc0) >> 6; pChar++; for (ix = 0; ix < pConfig->ioRanges; ix++) { addr.l = 0; if (addrSize == 1) addr.c[0] = *pChar++; else if (addrSize == 2) { addr.c[0] = *pChar++; addr.c[1] = *pChar++; } else if (addrSize == 3) { addr.c[0] = *pChar++; addr.c[1] = *pChar++; addr.c[2] = *pChar++; addr.c[3] = *pChar++; } length.l = 0; if (lengthSize == 1) length.c[0] = *pChar++; else if (lengthSize == 2) { length.c[0] = *pChar++; length.c[1] = *pChar++; } else if (lengthSize == 3) { length.c[0] = *pChar++; length.c[1] = *pChar++; length.c[2] = *pChar++; length.c[3] = *pChar++; } pConfig->io[ix].start = addr.l; pConfig->io[ix].stop = addr.l + length.l; } } } if (featureSelection & 0x10) /* IRQ description */ { pConfig->irqMode = (*pChar & 0xe0) >> 5; pConfig->irqMask = (*pChar & 0x10) >> 4; if (pConfig->irqMask == 1) { pConfig->irqSpecial = *pChar++ & 0x0f; pConfig->irqBit.c[0] = *pChar++; pConfig->irqBit.c[1] = *pChar++; } else { pConfig->irqSpecial = 0; pConfig->irqBit.c[0] = 0; pConfig->irqBit.c[1] = 0; pConfig->irqLevel = *pChar++ & 0x0f; } } if (featureSelection & 0x60) /* memory description */ { if ((featureSelection & 0x60) == 0x20) { length.l = 0; length.c[0] = *pChar++; length.c[1] = *pChar++; pConfig->mem[0].length = length.l; pConfig->mem[0].cAddr = 0; pConfig->mem[0].hAddr = 0; } 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++; pConfig->mem[0].length = length.l; pConfig->mem[0].cAddr = cAddr.l; pConfig->mem[0].hAddr = 0; } else if ((featureSelection & 0x60) == 0x60) { windows = (*pChar & 0x07) + 1; lengthSize = (*pChar & 0x18) >> 3; addrSize = (*pChar & 0x60) >> 5; hostaddr = *pChar & 0x80; for (ix = 0; ix < windows; ix++) { length.l = 0; cAddr.l = 0; hAddr.l = 0; if (lengthSize == 1) length.c[0] = *pChar++; else if (lengthSize == 2) { length.c[0] = *pChar++; length.c[1] = *pChar++; } else 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++; else if (addrSize == 2) { cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; } else 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) cAddr.c[0] = *pChar++; else if (addrSize == 2) { cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; } else if (addrSize == 3) { cAddr.c[0] = *pChar++; cAddr.c[1] = *pChar++; cAddr.c[2] = *pChar++; cAddr.c[3] = *pChar++; } } pConfig->mem[ix].length = length.l; pConfig->mem[ix].cAddr = cAddr.l; pConfig->mem[ix].hAddr = hAddr.l; } } } if (featureSelection & 0x80) /* misc info. description */ { pConfig->twins = *pChar & 0x07; pConfig->audio = (*pChar & 0x08) >> 3; pConfig->readonly = (*pChar & 0x10) >> 4; pConfig->pwrdown = (*pChar & 0x20) >> 5; } break; } } return (OK); }/********************************************************************************* cisResourceGet - config the PC card from the configuration table link list** Config the PC card from the configuration table link list.** RETURNS: OK, or ERROR if the enabler couldn't initialize the PC card.*/LOCAL STATUS cisResourceGet ( int sock /* socket no. */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CARD *pCard = &pCtrl->card[sock]; STATUS status = ERROR; PCCARD_ENABLER *pEnabler; int ix; for (ix = 0; ix < pccardEnablerNumEnt; ix++) { pEnabler = &pccardEnabler[ix]; if (pEnabler->enableRtn != NULL) { if ((pCard->initStatus = (* pEnabler->enableRtn) ( sock, pEnabler->pResource, pEnabler->resourceNumEnt, pEnabler->showRtn)) == ERROR_FIND) { continue; } else { break; } } } if (pCard->initStatus == OK) status = OK; return (status); }/********************************************************************************* cisFree - free tuples from the linked list** This routine free tuples from the linked list.** RETURNS: N/A** INTERNAL* This funcion should not do it by itself, it should called an enabler* supplied destroy function to delete the device (if possible) in device* dependent manner.*/void cisFree ( int sock /* socket no. */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CHIP *pChip = &pCtrl->chip; PCMCIA_CARD *pCard = &pCtrl->card[sock]; PCMCIA_IOWIN iowin; PCMCIA_MEMWIN memwin; DL_NODE *pNode; DL_NODE *pTemp; int ix; semTake (&cisMuteSem, WAIT_FOREVER); /* mutual exclusion begin */ (void) (* pChip->cscOff) (sock, pChip->intLevel); pCard->type = 0; pCard->sock = 0; pCard->ctrl = 0; pCard->detected = FALSE; pCard->installed = FALSE; pCard->changed = TRUE; pCard->regBase = 0; pCard->regMask = 0; pCard->initStatus = 0; pCard->cscIntr = NULL; pCard->showRtn = NULL; pCard->pResource = NULL; if (pCard->pBlkDev != NULL) pCard->pBlkDev->bd_readyChanged = TRUE ; if (pCard->pNetIf != NULL) free ((char *)pCard->pNetIf); /* XXX - lrn */ pCard->pNetIf = NULL; if (pCard->pDos != NULL) {#if FALSE /* DosFs 2.0 - can not remove dos device */ iosDevDelete (&pCard->pDos->dosvd_devHdr); free ((char *)pCard->pDos);#endif /*FALSE*/ } pCard->pDos = NULL; for (pNode = DLL_FIRST(&pCard->cisTupleList); pNode != NULL; pNode = pTemp) { pTemp = DLL_NEXT(pNode); free (pNode); } dllInit (&pCard->cisTupleList); for (pNode = DLL_FIRST(&pCard->cisConfigList); pNode != NULL; pNode = pTemp) { pTemp = DLL_NEXT(pNode); free (pNode); } dllInit (&pCard->cisConfigList); (void) (* pChip->irqSet) (sock, 0); (void) (* pChip->flagSet) (sock, PC_PWR_AUTO); memwin.window = 0; memwin.flags = 0; memwin.extraws = 0; memwin.start = 0; memwin.stop = 0; memwin.cardstart = 0; for (ix = 0; ix < pChip->memWindows; ix++) { memwin.window = ix; (void) (* pChip->memwinSet) (sock, &memwin); } iowin.window = 0; iowin.flags = 0; iowin.extraws = 0; iowin.start = 0; iowin.stop = 0; for (ix = 0; ix < pChip->ioWindows; ix++) { iowin.window = ix; (void) (* pChip->iowinSet) (sock, &iowin); } (void) (* pChip->cscPoll) (sock); (void) (* pChip->cscOn) (sock, pChip->intLevel); semGive (&cisMuteSem); /* mutual exclusion end */ }/********************************************************************************* cisConfigregGet - get the PCMCIA configuration register** This routine gets that PCMCIA configuration register.** RETURNS: OK, or ERROR if it cannot set a value on the PCMCIA chip.*/STATUS cisConfigregGet ( int sock, /* socket no. */ int reg, /* configuration register no. */ int *pValue /* content of the register */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CHIP *pChip = &pCtrl->chip; PCMCIA_CARD *pCard = &pCtrl->card[sock]; PCMCIA_MEMWIN memWin; char *pReg; if ((pCard->regBase == 0) || ((pCard->regMask & (1 << reg)) == 0) || (pChip->installed != TRUE)) return (ERROR); memWin.window = PCMCIA_CIS_WINDOW; memWin.flags = MAP_ACTIVE | MAP_16BIT | MAP_ATTRIB; memWin.extraws = 2; memWin.start = pcmciaMemwin[CIS_MEM_CONFIG].start; memWin.stop = pcmciaMemwin[CIS_MEM_CONFIG].stop; memWin.cardstart = pCard->regBase; if ((* pChip->memwinSet)(sock, &memWin) != OK) return (ERROR); pReg = (char *)memWin.start + (pCard->regBase & 0xfff) + (reg * 2) + pCtrl->memBase; *pValue = *pReg; memWin.window = 0; memWin.flags = 0; memWin.extraws = 0; memWin.start = 0; memWin.stop = 0; memWin.cardstart = 0; if ((* pChip->memwinSet)(sock, &memWin) != OK) return (ERROR); return (OK); }/********************************************************************************* cisConfigregSet - set the PCMCIA configuration register** This routine sets the PCMCIA configuration register.** RETURNS: OK, or ERROR if it cannot set a value on the PCMCIA chip.*/STATUS cisConfigregSet ( int sock, /* socket no. */ int reg, /* register no. */ int value /* content of the register */ ) { PCMCIA_CTRL *pCtrl = &pcmciaCtrl; PCMCIA_CHIP *pChip = &pCtrl->chip; PCMCIA_CARD *pCard = &pCtrl->card[sock]; PCMCIA_MEMWIN memWin; char *pReg; if ((pCard->regBase == 0) || ((pCard->regMask & (1 << reg)) == 0) || (pChip->installed != TRUE)) return (ERROR); memWin.window = PCMCIA_CIS_WINDOW; memWin.flags = MAP_ACTIVE | MAP_16BIT | MAP_ATTRIB; memWin.extraws = 2; memWin.start = pcmciaMemwin[CIS_MEM_CONFIG].start; memWin.stop = pcmciaMemwin[CIS_MEM_CONFIG].stop; memWin.cardstart = pCard->regBase; if ((* pChip->memwinSet)(sock, &memWin) != OK) return (ERROR); pReg = (char *)memWin.start + (pCard->regBase & 0xfff) + (reg * 2) + pCtrl->memBase; *pReg = value; memWin.window = 0; memWin.flags = 0; memWin.extraws = 0; memWin.start = 0; memWin.stop = 0; memWin.cardstart = 0; if ((* pChip->memwinSet)(sock, &memWin) != OK) return (ERROR); return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -