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

📄 pc386-systffs.c

📁 vxworks tffs for x86
💻 C
📖 第 1 页 / 共 3 页
字号:
    {    }/********************************************************************************* docSetMappingContext - sets the window mapping register to a card address** This routine sets the window mapping register to a card address.* The window should be set to the value of 'vol.window.currentPage',* which is the card address divided by 4 KB. An address over 128MB,* (page over 32K) specifies an attribute-space address.** The page to map is guaranteed to be on a full window-size boundary.** RETURNS: N/A*/LOCAL void docSetMappingContext    (    FLSocket vol,		/* pointer identifying drive */    unsigned page		/* page to be mapped */    )    {    }/********************************************************************************* docGetAndClearCardChangeIndicator - return the hardware card-change indicator** This routine returns the hardware card-change indicator and clears it if set.** RETURNS: FALSE, or TRUE if the card has been changed*/LOCAL FLBoolean docGetAndClearCardChangeIndicator    (    FLSocket vol		/* pointer identifying drive */    )    {    return (FALSE);    }/********************************************************************************* docWriteProtected - return the write-protect state of the media** This routine returns the write-protect state of the media** RETURNS: FALSE, or TRUE if the card is write-protected*/LOCAL FLBoolean docWriteProtected    (    FLSocket vol		/* pointer identifying drive */    )    {    return (FALSE);    }#ifdef EXIT/********************************************************************************* docFreeSocket - free resources that were allocated for this socket.** This routine free resources that were allocated for this socket.* This function is called when FLite exits.** RETURNS: N/A*/LOCAL void docFreeSocket    (    FLSocket vol		/* pointer identifying drive */    )    {    }#endif  /* EXIT */#endif	/* INCLUDE_SOCKET_DOC */#if	defined (INCLUDE_SOCKET_PCIC0) || defined (INCLUDE_SOCKET_PCIC1)/********************************************************************************* pcRegister - install routines for the PCIC socket controller.** This routine installs necessary functions for the PCIC socket controller.* This routine also determines the window base addresses for the* sockets registered. these values are received as parameters. if 0 is* received, default values are selected (D8000h and DA000h).** RETURNS: flOK, or flTooManyComponents if there're too many drivers,*		 or flAdapterNotFound if there's no controller.*/LOCAL FLStatus pcRegister     (    int socketNo,		/* socket number */    unsigned int baseAddress	/* base addr of socket, 4KB aligned */    )    {    FLSocket vol = flSocketOf (noOfDrives);    if (noOfDrives >= DRIVES)        return (flTooManyComponents);    vol.serialNo = socketNo;    if (socketNo == 0)      {      vol.window.baseAddress = baseAddress ? 			       baseAddress >> 12 : PC_BASE_ADRS_0 >> 12 ;      tffsSocket[noOfDrives] = PC_SOCKET_NAME_0;      }    else if (socketNo == 1)      {      vol.window.baseAddress = baseAddress ? 			       baseAddress >> 12 : PC_BASE_ADRS_1 >> 12 ;      tffsSocket[noOfDrives] = PC_SOCKET_NAME_1;      }    else      return (flAdapterNotFound);    pcDriveNo[socketNo] = noOfDrives;	/* drive no. for the socket */    vol.cardDetected =		pcCardDetected;    vol.VccOn =			pcVccOn;    vol.VccOff =		pcVccOff;#ifdef SOCKET_12_VOLTS    vol.VppOn =			pcVppOn;    vol.VppOff =		pcVppOff;#endif    vol.initSocket =		pcInitSocket;    vol.setWindow =		pcSetWindow;    vol.setMappingContext =	pcSetMappingContext;    vol.getAndClearCardChangeIndicator = pcGetAndClearCardChangeIndicator;    vol.writeProtected =	pcWriteProtected;#ifdef EXIT    vol.freeSocket =		pcFreeSocket;#endif    noOfDrives++;    return (flOK);    }#ifdef	INCLUDE_PCMCIA/********************************************************************************* pcCardDetected - detect if a card is present (inserted)** This routine detects if a card is present (inserted).** RETURNS: TRUE, or FALSE if the flash card is not present.*/LOCAL FLBoolean pcCardDetected    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    if ((pCard->type == PCCARD_FLASH) && (pCard->detected))	return (TRUE);    else	return (FALSE);    }/********************************************************************************* pcVccOn - turn on Vcc (3.3/5 Volts)** This routine turns on Vcc (3.3/5 Volts). Vcc must be known to be good * on exit.** RETURNS: N/A*/LOCAL void pcVccOn    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    int flag		= (*pChip->flagGet) (vol.serialNo);    int status		= (PC_READY | PC_POWERON);    UINT32 timeout	= flMsecCounter + 2000;    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return;    flag = (flag & ~PC_VCC_MASK) | (PC_PWR_AUTO | PC_VCC_5V);    (*pChip->flagSet) (vol.serialNo, flag);    while ((((*pChip->status) (vol.serialNo) & status) != status) &&	   (flMsecCounter < timeout))	;    }/********************************************************************************* pcVccOff - turn off Vcc (3.3/5 Volts)** This routine turns off Vcc (3.3/5 Volts).** RETURNS: N/A*/LOCAL void pcVccOff    (    FLSocket vol		/* pointer identifying drive */    )    {#if	FALSE    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    int flag		= (*pChip->flagGet) (vol.serialNo);    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return;    flag = (flag & ~PC_VCC_MASK) | PC_PWR_AUTO;    (*pChip->flagSet) (vol.serialNo, flag);#endif    }#ifdef SOCKET_12_VOLTS/********************************************************************************* pcVppOn - turn on Vpp (12 Volts)** This routine turns on Vpp (12 Volts). Vpp must be known to be good on exit.** RETURNS: flOK, or flDriveNotAvailable if it failed*/LOCAL FLStatus pcVppOn    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    int flag		= (*pChip->flagGet) (vol.serialNo);    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return (flDriveNotAvailable);    flag = (flag & ~PC_VPP_MASK) | (PC_PWR_AUTO | PC_VPP_12V);    (*pChip->flagSet) (vol.serialNo, flag);    flDelayMsecs (VPP_DELAY_MSEC);	/* wait for Vpp to ramp up */    return (flOK);    }/********************************************************************************* pcVppOff - turn off Vpp (12 Volts)** This routine turns off Vpp (12 Volts).** RETURNS: N/A*/LOCAL void pcVppOff    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    int flag		= (*pChip->flagGet) (vol.serialNo);    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return;    flag = (flag & ~PC_VPP_MASK) | (PC_PWR_AUTO | PC_VPP_5V);    (*pChip->flagSet) (vol.serialNo, flag);    }#endif	/* SOCKET_12_VOLTS *//********************************************************************************* pcInitSocket - perform all necessary initializations of the socket** This routine performs all necessary initializations of the socket.** RETURNS: flOK, or ERROR if it failed*/LOCAL FLStatus pcInitSocket    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    int flag		= (PC_PWR_AUTO | PC_VCC_5V);    if (pcDriveNo[vol.serialNo] != NONE)        (*pChip->flagSet) (vol.serialNo, flag);    return (flOK);    }/********************************************************************************* pcSetWindow - set current window attributes, Base address, size, etc** This routine sets current window hardware attributes: Base address, size,* speed and bus width.  The requested settings are given in the 'vol.window' * structure.  If it is not possible to set the window size requested in* 'vol.window.size', the window size should be set to a larger value, * if possible. In any case, 'vol.window.size' should contain the * actual window size (in 4 KB units) on exit.** RETURNS: N/A*/LOCAL void pcSetWindow    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    PCMCIA_MEMWIN memwin;    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return;    memwin.window = PC_WINDOW;    if (vol.window.busWidth == 16)	memwin.flags = MAP_ACTIVE | MAP_16BIT;    else	memwin.flags = MAP_ACTIVE;    memwin.extraws	= PC_EXTRAWS;    memwin.start	= vol.window.baseAddress << 12;    memwin.stop		= (vol.window.baseAddress << 12) + vol.window.size - 1;    memwin.cardstart	= 0;	/* it is set in pcSetMappingContext() */    (*pChip->memwinSet) (vol.serialNo, &memwin);    }/********************************************************************************* pcSetMappingContext - sets the window mapping register to a card address** This routine sets the window mapping register to a card address.* The window should be set to the value of 'vol.window.currentPage',* which is the card address divided by 4 KB. An address over 128MB,* (page over 32K) specifies an attribute-space address.** The page to map is guaranteed to be on a full window-size boundary.** RETURNS: N/A*/LOCAL void pcSetMappingContext    (    FLSocket vol,		/* pointer identifying drive */    unsigned page		/* page to be mapped */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    PCMCIA_MEMWIN memwin;    unsigned int mapRegValue = page & 0x3fff;    if ((pCard->type != PCCARD_FLASH) || (!pCard->detected))	return;    memwin.window = PC_WINDOW;    if (vol.window.busWidth == 16)	memwin.flags = MAP_ACTIVE | MAP_16BIT;    else	memwin.flags = MAP_ACTIVE;    if (page & ATTRIBUTE_SPACE_MAPPED)	memwin.flags |= MAP_ATTRIB;    memwin.extraws	= PC_EXTRAWS;    memwin.start	= vol.window.baseAddress << 12;    memwin.stop		= (vol.window.baseAddress << 12) + vol.window.size - 1;    memwin.cardstart	= mapRegValue << 12;    (*pChip->memwinSet) (vol.serialNo, &memwin);    }/********************************************************************************* pcGetAndClearCardChangeIndicator - return the hardware card-change indicator** This routine returns the hardware card-change indicator and clears it if set.** RETURNS: FALSE, or TRUE if the card has been changed*/LOCAL FLBoolean pcGetAndClearCardChangeIndicator    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CARD * pCard	= &pCtrl->card[vol.serialNo];    if (pCard->cardStatus & PC_DETECT)        return (TRUE);    else         return (FALSE);    }/********************************************************************************* pcWriteProtected - return the write-protect state of the media** This routine returns the write-protect state of the media** RETURNS: FALSE, or TRUE if the card is write-protected*/LOCAL FLBoolean pcWriteProtected    (    FLSocket vol		/* pointer identifying drive */    )    {    PCMCIA_CTRL * pCtrl	= &pcmciaCtrl;    PCMCIA_CHIP * pChip	= &pCtrl->chip;    int status         	= (*pChip->status) (vol.serialNo);    if (status & PC_WRPROT)	return (TRUE);    else	return (FALSE);    }#else	/* INCLUDE_PCMCIA *//********************************************************************************* flInportb - read byte to I/O port** This routine read byte to I/O port.** RETURNS: data byte read from I/O port*/LOCAL unsigned char flInportb     (    unsigned portId		/* I/O port number */    )    {    return (sysInByte (portId));    }/*******************************************************************************

⌨️ 快捷键说明

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