📄 syslib.c
字号:
/* Initialize serial channels */ sysSerialHwInit ();#ifdef INCLUDE_BESTCOMM_INIT sysSdmaInit();#endif /* INCLUDE_BESTCOMM_INIT */ /* * If mmu tables are used, this is where we would dynamically * update the entry describing main memory, using sysPhysMemTop(). * We must call sysPhysMemTop () at sysHwInit() time to do * the memory autosizing if available. */ sysPhysMemTop ();#ifdef INCLUDE_PCI_AUTOCONF sysPciAutoConfig ();#endif /* INCLUDE_PCI_AUTOCONF */#ifdef INCLUDE_NETWORK /* Initialize network channels */ sysNetHwInit ();#endif#ifdef FORCE_DEFAULT_BOOT_LINE strncpy (sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);#elif defined(INCLUDE_VWARE_LAUNCH) sysVwareBuildBootLine (0);#endif /* FORCE_DEFAULT_BOOT_LINE */ /* USB 1 only */ { ULONG * pStdPortConfig; pStdPortConfig = (ULONG *)(GPIO_STD_BASE_ADRS + GPIO_STD_PORT_CONFIG); *pStdPortConfig &= ~GPIO_STD_PC_USB_MASK; *pStdPortConfig |= GPIO_STD_PC_USB_1_ONLY | GPIO_STD_PC_USB_DM_MODE; *CDM_DIVIDER = CDM_DIV_VALUE; } #ifdef INCLUDE_ATA sysAtaInit(0);#endif /* INCLUDE_ATA */ }/************************************************************************* sysHwInit2 - initialize additional system hardware** This routine connects system interrupt vectors and configures any * required features not configured by sysHwInit. It is called from usrRoot()* in usrConfig.c after the multitasking kernel has started.** RETURNS: N/A*/void sysHwInit2 ( void ) { static int initialized; /* must protect against double call! */ if (!initialized) { initialized = TRUE;#ifdef LOCAL_MEM_ADD_LOCAL_ADRS memPartAddToPool (memSysPartId, (void *)LOCAL_MEM_ADD_LOCAL_ADRS, LOCAL_MEM_ADD_SIZE);#endif sysSerialHwInit2 (); /* initialize serial interrupts */ #ifdef INCLUDE_PCI sysPciInit2();#endif#ifdef INCLUDE_NETWORK sysNetHwInit2 ();#endif /* INCLUDE_NETWORK */ } }/************************************************************************* 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.** Normally, the user specifies the amount of physical memory with the* macro LOCAL_MEM_SIZE in config.h. BSPs that support run-time* memory sizing do so only if the macro LOCAL_MEM_AUTOSIZE is defined.* If not defined, then LOCAL_MEM_SIZE is assumed to be, and must be, the* true size of physical memory.** NOTE: Do no adjust LOCAL_MEM_SIZE to reserve memory for application* use. See sysMemTop() for more information on reserving memory.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/char * sysPhysMemTop ( void ) { static char * sysPhysMemSize = NULL; /* ptr to top of mem + 1 */ if (sysPhysMemSize == NULL) {#ifdef LOCAL_MEM_AUTOSIZE /* To Do Autosizeing stuff */ /* This BSP is not supporting Autosizing */#else /* not LOCAL_MEM_AUTOSIZE */ /* Don't do auto-sizing, use defined constants. */ sysPhysMemSize = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */ } return sysPhysMemSize; }/************************************************************************* 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.*/char * sysMemTop ( void ) { static char * memTop = NULL; if (memTop == NULL) { memTop = sysPhysMemTop () - USER_RESERVED_MEM; } 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 by 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.*/STATUS sysToMonitor ( int startType /* parameter passed to ROM to tell it how to boot */ ) { FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4); /* Warm reboot */#ifdef INCLUDE_CACHE_SUPPORT cacheDisable (INSTRUCTION_CACHE); /* Disable the Instruction Cache */ cacheDisable (DATA_CACHE); /* Disable the Data Cache */#endif#ifdef INCLUDE_AUX_CLK sysAuxClkDisable ();#endif /* INCLUDE_AUX_CLK */#ifdef INCLUDE_NETWORK sysNetHwInit (); /* reset network devices */#endif sysSerialReset (); /* reset serial devices */ /* Clear the MSR */ vxMsrSet (0); (*pRom) (startType); return (OK); /* in case we ever continue from ROM monitor */ }/************************************************************************* 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.** 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. It also maps local resources onto* the VMEbus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()**/void sysProcNumSet ( int procNum /* processor number */ ) { /* * Init global variable - this needs to be done before * calling sysUniverseInit2() because it calls sysProcNumGet() * via the MACRO definition. */ sysProcNum = procNum; }/******************************************************************************** sysCpuCheck - confirm the CPU type** This routine validates the cpu type. If the wrong cpu type is discovered* a message is printed using the serial channel in polled mode.** RETURNS: N/A.*/void sysCpuCheck (void) { int msgSize; int msgIx; SIO_CHAN * pSioChan; /* serial I/O channel */ int cpuType; cpuType = CPU_TYPE; /* Check for a valid CPU type; If one is found, just return */ if ((cpuType == CPU_TYPE_5200)) { return; } /* Invalid CPU type; print error message and terminate */ msgSize = strlen (wrongCpuMsg); sysSerialHwInit (); pSioChan = sysSerialChanGet (0); sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL); for (msgIx = 0; msgIx < msgSize; msgIx++) { while (sioPollOutput (pSioChan, wrongCpuMsg[msgIx]) == EAGAIN); } sysToMonitor (BOOT_NO_AUTOBOOT); }/********************************************************************************* sysDelay - delay for approximately one millisecond** Delay for approximately one milli-second.** RETURNS: N/A*/void sysDelay (void) { sysMsDelay (1); }/********************************************************************************* 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 a System Bus Speed of 67 MHZ this amounts to* about 258 seconds.** 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. * The macro DEC_CLOCK_FREQ MUST REFLECT THE PROPER 6xx BUS SPEED. */ totalDelta = ((DEC_CLOCK_FREQ / 4) / 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 = vxDecGet (); while (decElapsed < totalDelta) { newval = vxDecGet (); if ( DELTA(oldval,newval) < 1000 ) decElapsed += DELTA(oldval,newval); /* no rollover */ else if (newval > oldval) decElapsed += abs((int)oldval); /* rollover */ oldval = newval; } }/********************************************************************************* sysEieio - make eieio instruction available for driver code.** RETURNS: N/A*/void sysEieio (void) { EIEIO; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -