📄 syslib.c
字号:
intUnlock (oldLvl); return (TRUE); /* exclusive access obtained */ }/******************************************************************************** sysBusTasClear - clear a location set by sysBusTas()** This routine clears a bus test and set location. This routine is only* required if the sysBusTas() routine uses special semaphore techniques (such* as bus locking). Since the sysBusTas routine doesn't use any special* semaphore techniques, this routine is a no-op.** If used, the BSP activates this routine by placing its address into the* global variable 'smUtilTasClearRtn'.** RETURNS: N/A** SEE ALSO: sysBusTas()*/void sysBusTasClear ( volatile char * address /* address to be tested-and-cleared */ ) { }#ifdef INCLUDE_MOT_FEC/********************************************************************************* sysFecEnetEnable - enable the MII interface of the Fast Ethernet controller** This routine is expected to perform any target specific functions required* to enable the Ethernet device and the MII interface of the Fast Ethernet* controller. These functions include setting the MII-compliant signals on* Port D and disabling the IRQ7 signal.*** RETURNS: OK, or ERROR if the Fast Ethernet controller cannot be enabled.*/STATUS sysFecEnetEnable ( UINT32 motCpmAddr /* base address of the on-chip RAM */ ) { int intLevel = intLock(); /* * Step 17: Set Port D PDPAR Register - enable MII mode by * writing 0x1FFF to the PDPAR. Setting each bit in the * register specifies these pins are dedicated on-chip * peripheral pins. */ *PDPAR(motCpmAddr) = PDPAR_MII_BITS; /* * Step 18: Set Port D PDDIR Register - enable MII mode by * writing either a 0x1C58 or 0x1FFF (if rev. D.4 or greater) * to the PDDIR. */ if (sysRevNumGet () >= REV_D_4) *PDDIR(motCpmAddr) = PDDIR_D4_MII; else *PDDIR(motCpmAddr) = PDDIR_PRE_D4_MII; /* mask IRQ7 off, as it is shared with MII_TX_CLK */ *SIMASK (motCpmAddr) &= ~SIMASK_IRM7; /* also clear any pending interrupt */ *SIPEND (motCpmAddr) |= SIPEND_IRQ7; /* U-BUS arbitration priority 5 (BR5) */ *SDCR(motCpmAddr) = SDCR_RAID_BR5; intUnlock (intLevel); return (OK); }/********************************************************************************* sysFecEnetDisable - disable MII interface to the Fast Ethernet controller** This routine is expected to perform any target specific functions required* to disable the Ethernet device and the MII interface to the Fast Ethernet* controller. This involves restoring the default values for all the Port* D signals.** RETURNS: OK, always.*/STATUS sysFecEnetDisable ( UINT32 motCpmAddr /* base address of the on-chip RAM */ ) { int intLevel = intLock(); /* Reset the FEC */ if (sysRevNumGet () >= REV_D_3) *FEC_ECNTRL(motCpmAddr) = (FEC_ECNTRL_RESET | FEC_ECNTRL_PINMUX); else *FEC_ECNTRL(motCpmAddr) = FEC_ECNTRL_RESET; /* configure all Port D pins as general purpose input pins */ *PDPAR (motCpmAddr) = 0x0; *PDDIR (motCpmAddr) = 0x0; intUnlock (intLevel); return (OK); }/********************************************************************************* sysFecEnetAddrGet - get the hardware Ethernet address** This routine provides the six byte Ethernet hardware address that will be* used by each individual Ethernet device unit. This routine must copy* the six byte address to the space provided by <addr>.** RETURNS: OK, or ERROR if the Ethernet address cannot be returned.*/STATUS sysFecEnetAddrGet ( UINT32 motCpmAddr, /* base address of the on-chip RAM */ UCHAR * address /* where to put the ethernet address bytes */ ) { bcopy ((char *) sysFecEnetAddr, (char *) address, sizeof (sysFecEnetAddr)); return (OK); }#endif /* INCLUDE_MOT_FEC *//******************************************************************************** sysPciTrap - trap handler for PCI exception** This routine is called from the excConnectCode stub if the PCI configuration* access generates an exception. By default, sysIn... returns the value read.* This code changes the PC to sysPciErr which sets the return value to -1.* NOTE: The QSpan PCI Bridge causes machine check exceptions to* occur when a non-present device address is put into the* configuration register. This is why the sysPciTrap routine* is essential.** RETURNS: N/A*/void sysPciTrap ( ESFPPC * pEsf /* pointer to exception stack frame */ ) { REG_SET *pRegSet = &pEsf->regSet; pRegSet->pc = (_RType)sysPciErr; /* sysPciErr forces a -1 return */ }/******************************************************************************** sysMsDelay - delay for the specified amount of time (MS)** This routine will delay for the specified amount of time by counting* decrementer ticks.** This routine is not dependent on a particular rollover value for* the decrementer, it should work no matter what the rollover* value is.** A small amount of count may be lost at the rollover point resulting in* the sysMsDelay() causing a slightly longer delay than requested.** This routine will produce incorrect results if the delay time requested* requires a count larger than 0xffffffff to hold the decrementer* elapsed tick count. For an CPV3060 40MHz board that amounts to about* 1716 seconds (thus not considered too severe a restriction).** RETURNS: N/A*/void sysMsDelay ( UINT delay /* length of time in MS to delay */ ) { register UINT oldval; /* decrementer value */ register UINT newval; /* decrementer value */ register UINT totalDelta; /* Dec. delta for entire delay period */ register UINT decElapsed; /* cumulative decrementer ticks */ /* Calculate delta of decrementer ticks for desired elapsed time. */ totalDelta = ((sysCpuSpeed / DEC_CLK_TO_INC) / 1000) * delay; /* * Now keep grabbing decrementer value and incrementing "decElapsed" until * we hit the desired delay value. Compensate for the fact that we may * read the decrementer at 0xffffffff before the interrupt service * routine has a chance to set in the rollover value. */ decElapsed = 0; oldval = sysDecGet (); while (decElapsed < totalDelta) { newval = sysDecGet (); if ( DELTA(oldval,newval) < 1000 ) decElapsed += DELTA(oldval,newval); /* no rollover */ else if (newval > oldval) decElapsed += abs((int)oldval); /* rollover */ oldval = newval; } }/********************************************************************************* sysIntEnablePIC - enable an ISA/PCI interrupt** This function call is used by certain vxWorks device drivers. It * calls the system routine intConnect.** RETURNS: OK or ERROR*/STATUS sysIntEnablePIC ( int intNum /* interrupt level to enable */ ) { return (intEnable (intNum) == 0 ? OK : ERROR); }/******************************************************************************** sysDelay - delay for approx. 1ms** This implements an unsupported system call to support drivers* ported from Intel platforms.** RETURNS: N/A*/void sysDelay (void) { sysMsDelay (1); }/******************************************************************************** sysCpvIntConnect - generic interrupt connect call for CPV3060** This functions intercepts the system call: intConnect and determines* which of the specific interrupt connect routines to call, either the* ppc860IntrCtl or the w83c553f.** RETURNS: OK or ERROR if interrupt is not for SIU, CPM, PCI or ISA */LOCAL STATUS sysCpvIntConnect ( VOIDFUNCPTR * vector, /* interrupt vector to attach to */ VOIDFUNCPTR routine, /* routine to be called */ int parameter /* parameter to be passed to routine */ ) { STATUS result; int intClass = INT_CLASS((int)vector); switch (intClass) { case INT_CLASS_PPC860: case INT_CLASS_CPM: case INT_CLASS_DEC2155X: result = ppc860IntConnect (vector, routine, parameter); break; case INT_CLASS_RES: result = ERROR; break; default: result = ERROR; } return (result); }/********************************************************************************* sysCpvIntEnable - enable a CPV3060 interrupt level** This routine enables a specified CPV3060 interrupt level.** RETURNS: OK or ERROR if interrupt level not supported*/int sysCpvIntEnable ( int intLevel /* interrupt level to enable */ ) { int retVal; int intClass = INT_CLASS(intLevel); switch (intClass) { case INT_CLASS_PPC860: case INT_CLASS_CPM: ppc860IntEnable (intLevel); retVal = OK; break; case INT_CLASS_RES: retVal = ERROR; break;#ifdef INCLUDE_DEC2155X case INT_CLASS_DEC2155X: retVal = sysDec2155xIntEnable (intLevel); break;#endif /* INCLUDE_DEC2155X */ default: retVal = ERROR; } return (retVal); }/********************************************************************************* sysCpvIntDisable - disable a CPV3060 interrupt level** This routine disables a specified CPV3060 interrupt level.** RETURNS: OK or ERROR if interrupt level not supported*/int sysCpvIntDisable ( int (intLevel) /* interrupt level to disable */ ) { int retVal; int intClass = INT_CLASS(intLevel); switch (intClass) { case INT_CLASS_PPC860: case INT_CLASS_CPM: ppc860IntDisable (intLevel); retVal = OK; break; case INT_CLASS_RES: retVal = ERROR; break;#ifdef INCLUDE_DEC2155X case INT_CLASS_DEC2155X: retVal = sysDec2155xIntDisable (intLevel); break;#endif /* INCLUDE_DEC2155X */ default: retVal = ERROR; } return (retVal); }/******************************************************************************* sysInByteString - reads a string of bytes from an io address.** This function reads a byte string from a specified io address.** RETURNS: N/A*/void sysInByteString ( UINT32 * ioAddr, /* I/O address */ char * bufPtr, /* pointer to data buffer */ int nBytes /* number of bytes to read */ ) { int loopCtr; for (loopCtr = 0; loopCtr < nBytes; loopCtr++) *bufPtr++ = *(char *)ioAddr; }/******************************************************************************* sysOutByteString - writes a string of bytes to an io address.** This function writes a byte string to a specified io address.** RETURNS: N/A*/void sysOutByteString ( UINT32 * ioAddr, /* I/O address */ char * bufPtr, /* pointer to data buffer */ int nBytes /* number of bytes to write */ ) { int loopCtr; for (loopCtr = 0; loopCtr < nBytes; loopCtr++) *(char *)ioAddr = *bufPtr++; }/******************************************************************************* sysInWordString - reads a string of words from an io address.** This function reads a word string from a specified io address.** RETURNS: N/A*/void sysInWordString ( ULONG ioAddr, /* I/O address */ UINT16 * bufPtr, /* pointer to data buffer */ int nWords /* number of 2 byte words to read */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -