📄 syslib.c
字号:
/********************************************************************************* sysPhysMemTop - get the address of the top of physical memory** This routine returns the address of the first missing byte of memory,* which indicates the top of memory.** RETURNS: The address of the top of physical memory.** ERRNO** SEE ALSO: sysMemTop()*/char * sysPhysMemTop (void) { static char * physTop = NULL; if (physTop == NULL) { physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE); } return (physTop) ; }/********************************************************************************* sysMemTop - get the address of the top of VxWorks memory** This routine returns a pointer to the first byte of memory not* controlled or used by VxWorks.** The user can reserve memory space by defining the macro USER_RESERVED_MEM* in config.h. This routine returns the address of the reserved memory* area. The value of USER_RESERVED_MEM is in bytes.** RETURNS: The address of the top of VxWorks memory.** ERRNO*/char * sysMemTop (void) { static char * memTop = NULL; if (memTop == NULL) { memTop = sysPhysMemTop () - USER_RESERVED_MEM;#ifdef INCLUDE_EDR_PM /* account for ED&R persistent memory */ memTop = memTop - PM_RESERVED_MEM;#endif } return memTop; }/******************************************************************************** sysToMonitor - transfer control to the ROM monitor** This routine transfers control to the ROM monitor. Normally, it is called* only by reboot()--which services ^X--and bus errors at interrupt level.* However, in some circumstances, the user may wish to introduce a* <startType> to enable special boot ROM facilities.** RETURNS: Does not return.** ERRNO*/STATUS sysToMonitor ( int startType /* parameter passed to ROM to tell it how to boot */ ) { FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4); /* Warm reboot */ intLock (); /* disable interrupts */#ifdef INCLUDE_BRANCH_PREDICTION disableBranchPrediction();#endif /* INCLUDE_BRANCH_PREDICTION */ cacheDisable(INSTRUCTION_CACHE); cacheDisable(DATA_CACHE); sysClkDisable();#ifdef INCLUDE_AUX_CLK sysAuxClkDisable();#endif /* sysHwInit(); */ /* reset the serial device */ vxMsrSet (0); /* ??? */ (*pRom) (startType); /* jump to bootrom entry point */ return (OK); /* in case we ever continue from ROM monitor */ }/******************************************************************************** sysHwInit2 - additional system configuration and initialization** This routine connects system interrupts and does any additional* configuration necessary.** RETURNS: N/A** ERRNO*/void sysHwInit2 (void) {#ifdef INCLUDE_VXBUS vxbDevInit();#endif /* INCLUDE_VXBUS */ excIntConnect ((VOIDFUNCPTR *) _EXC_OFF_DECR, (VOIDFUNCPTR) sysClkInt); sysClkEnable();#ifdef INCLUDE_AUX_CLK excIntConnect ((VOIDFUNCPTR *) _EXC_OFF_FIT, (VOIDFUNCPTR) sysAuxClkInt);#endif#ifdef INCLUDE_L1_IPARITY_HDLR_INBSP memcpy((void*)_EXC_OFF_L1_PARITY, (void *)jumpIParity, sizeof(INSTR)); cacheTextUpdate((void *)_EXC_OFF_L1_PARITY, sizeof(INSTR)); sysIvor1Set(_EXC_OFF_L1_PARITY); cacheDisable(INSTRUCTION_CACHE); vxL1CSR1Set(vxL1CSR1Get() | _PPC_L1CSR_CPE); cacheEnable(INSTRUCTION_CACHE);#endif /* INCLUDE_L1_IPARITY_HDLR_INBSP */ /* initialize the EPIC interrupts */ sysEpicIntrInit ();#ifdef INCLUDE_CPM sysCpmHwInit2();#endif#ifdef INCLUDE_ECC intConnect ( (VOIDFUNCPTR*)EPIC_DDR_INT_VEC, ddrDeviceIntHandler, 0);#endif /* INCLUDE_ECC */#if defined(INCLUDE_VXBUS) && defined(INCLUDE_SIO_UTILS) sysSerialConnectAll();#ifdef DRV_SIO_NS16550 { int retVal; int sysConsolePollCounter = 0; static char str[] = "\r\n[Enter]\r\n"; char * pStr = &str[0]; /* * The external DUART sometimes need an input interrupt in order * to generate output interrupt. Poll out some characters to * hint user at terminal for input, if necessary. */ while (*pStr != '\0') { do retVal = sioPollOutput(sysSerialChanGet(0), *pStr); while (( retVal == EAGAIN ) && ( sysConsolePollCounter++ < 5000 )); pStr++; }#ifdef INCLUDE_MEZZ_COM2 /* * NOTE: The external DUART also needs to poll out some initial * characters (using "\n" here) to start printing. Both COM1 and * COM2 needs this trick if mezzanine card with COM2 is present. * However, polling out to COM2 when mezzanine card is not present * also causes serial on COM1 to hang. Hence INCLUDE_MEZZ_COM2 * should be properly defined in config.h. */ do retVal = sioPollOutput(sysSerialChanGet(0), '\n'); while (( retVal == EAGAIN ) && ( sysConsolePollCounter++ < 5000 )); #endif /* INCLUDE_MEZZ_COM2 */ }#endif /* DRV_SIO_NS16550 */#endif /* INCLUDE_VXBUS && INCLUDE_SIO_UTILS */#if defined (INCLUDE_SPE) _func_speProbeRtn = sysSpeProbe;#endif /* INCLUDE_SPE */#ifdef INCLUDE_VXBUS taskSpawn("tDevConn", 11, 0, 10000, vxbDevConnect, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);#endif /* INCLUDE_VXBUS */ }/******************************************************************************** sysProcNumGet - get the processor number** This routine returns the processor number for the CPU board, which is* set with sysProcNumSet().* * RETURNS: The processor number for the CPU board.** ERRNO** SEE ALSO: sysProcNumSet()*/int sysProcNumGet (void) { return (sysProcNum); }/******************************************************************************** sysProcNumSet - set the processor number** This routine sets the processor number for the CPU board. Processor numbers* should be unique on a single backplane.** Not applicable for this board.** RETURNS: N/A** ERRNO** SEE ALSO: sysProcNumGet()*/void sysProcNumSet ( int procNum /* processor number */ ) { sysProcNum = procNum; }/******************************************************************************** sysLocalToBusAdrs - convert a local address to a bus address** This routine gets the VMEbus address that accesses a specified local* memory address.** Not applicable for this board.** RETURNS: ERROR, always.** ERRNO** SEE ALSO: sysBusToLocalAdrs()*/ STATUS sysLocalToBusAdrs ( int adrsSpace, /* bus address space where busAdrs resides */ char * localAdrs, /* local address to convert */ char ** pBusAdrs /* where to return bus address */ ) { return (ERROR); }/******************************************************************************** sysBusToLocalAdrs - convert a bus address to a local address** This routine gets the local address that accesses a specified VMEbus* physical memory address.** Not applicable for this board.** RETURNS: ERROR, always.** ERRNO** SEE ALSO: sysLocalToBusAdrs()*/STATUS sysBusToLocalAdrs ( int adrsSpace, /* bus address space where busAdrs resides */ char * busAdrs, /* bus address to convert */ char ** pLocalAdrs /* where to return local address */ ) { return(ERROR); }/******************************************************************************** sysBusTas - test and set a location across the bus** This routine does an atomic test-and-set operation across the backplane.** Not applicable for this board.** RETURNS: FALSE, always.** ERRNO** SEE ALSO: vxTas()*/BOOL sysBusTas ( char * adrs /* address to be tested-and-set */ ) { return (FALSE); }/******************************************************************************** sysBusClearTas - test and clear ** This routine is a null function.** RETURNS: N/A** ERRNO*/void sysBusClearTas ( volatile char * address /* address to be tested-and-cleared */ ) { } #ifdef INCLUDE_MOT_FCC_END/********************************************************************************* sysFccEnetAddrGet - get the hardware Ethernet address** This routine provides the six byte Ethernet hardware address that will be* used by each individual FCC 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.** ERRNO*/STATUS sysFccEnetAddrGet ( int unit, /* base address of the on-chip RAM */ UCHAR * addr /* where to copy the Ethernet address */ ) { bcopy ((char *) &sysFccEnetAddr[unit][0], (char *) addr, 6); return (OK); }#endif /* INCLUDE_MOT_FCC_END *//******************************************************************************** sysUsDelay - delay at least the specified amount of time (in microseconds)** This routine will delay for at least the specified amount of time using the* lower 32 bit "word" of the Time Base register as the timer. ** NOTE: This routine will not relinquish the CPU; it is meant to perform a* busy loop delay. The minimum delay that this routine will provide is* approximately 10 microseconds. The maximum delay is approximately the* size of UINT32; however, there is no roll-over compensation for the total* delay time, so it is necessary to back off two times the system tick rate* from the maximum.** RETURNS: N/A** ERRNO*/void sysUsDelay ( int delay /* length of time in microsec to delay */ ) { register UINT baselineTickCount; register UINT curTickCount; register UINT terminalTickCount; register int actualRollover = 0; register int calcRollover = 0; UINT ticksToWait; UINT requestedDelay; UINT oneUsDelay; /* Exit if no delay count */ if ((requestedDelay = delay) == 0) return; /* * Get the Time Base Lower register tick count, this will be used * as the baseline. */ baselineTickCount = sysTimeBaseLGet(); /* * Calculate number of ticks equal to 1 microsecond * * The Time Base register and the Decrementer count at the same rate: * once per 8 System Bus cycles. * * e.g., 199999999 cycles 1 tick 1 second 25 ticks * ---------------- * ------ * -------- ~ -------- * second 8 cycles 1000000 microsec microsec */ /* add to round up before div to provide "at least" */ oneUsDelay = ((sysTimerClkFreq + 1000000) / 1000000); /* Convert delay time into ticks */ ticksToWait = requestedDelay * oneUsDelay; /* Compute when to stop */ terminalTickCount = baselineTickCount + ticksToWait; /* Check for expected rollover */ if (terminalTickCount < baselineTickCount) { calcRollover = 1; } do { /* * Get current Time Base Lower register count. * The Time Base counts UP from 0 to * all F's. */ curTickCount = sysTimeBaseLGet(); /* Check for actual rollover */ if (curTickCount < baselineTickCount) { actualRollover = 1; } if (((curTickCount >= terminalTickCount) && (actualRollover == calcRollover)) || ((curTickCount < terminalTickCount) && (actualRollover > calcRollover))) { /* Delay time met */ break; } } while (TRUE); /* breaks above when delay time is met */ }void sysMsDelay ( UINT delay /* length of time in MS to delay */ ) { sysUsDelay ( (UINT32) delay * 1000 ); }/*********************************************************************** sysDelay - fixed 1ms delay** This routine is a fixed 1ms delay. It just calls sysMsDelay.** RETURNS : NONE*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -