📄 syslib.c
字号:
char * sysBspRev ( void ) { return (BSP_VERSION BSP_REV); }/********************************************************************************* sysHwInit - initialize the system hardware** This routine initializes various features of the board.* It is the first board-specific C code executed, and runs with* interrupts masked in the processor.* This routine resets all devices to a quiescent state, typically* by calling driver initialization routines.** NOTE: Because this routine will be called from sysToMonitor, it must* shutdown all potential DMA master devices. If a device is doing DMA* at reboot time, the DMA could interfere with the reboot. For devices* on non-local busses, this is easy if the bus reset or sysFail line can* be asserted.** NOTE: This routine should not be called directly by the user application.** RETURNS: N/A*/void sysHwInit ( void ) { sysCpuCheck (); /* Validate CPU type */ if ((CPU_TYPE == CPU_TYPE_7400) || (CPU_TYPE == CPU_TYPE_7410)) {#if defined(INCLUDE_CACHE_SUPPORT) && defined(INCLUDE_CACHE_L2) sysL2CacheDisable ();#endif } /* Setup MPC107 Controller */ sysMpc107PciInit (); pciConfigLibInit (PCI_MECHANISM_0, (ULONG)sysPciConfigRead, (ULONG)sysPciConfigWrite, 0); /* * 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. */ /* run-time update of the MMU entry for main RAM */ sysPhysMemDesc[0].len = (UINT)sysPhysMemTop (); #ifdef INCLUDE_PCI_AUTOCONF sysPciAutoConfig ();#endif sysMpc107EpicInit (); sysSerialHwInit ();#ifdef INCLUDE_NETWORK sysNetHwInit ();#endif /* INCLUDE_NETWORK */#ifdef FORCE_DEFAULT_BOOT_LINE strncpy (sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);#else#ifdef INCLUDE_VWARE_LAUNCH sysVwareBuildBootLine (0);#endif /* INCLUDE_VWARE_LAUNCH */#endif /* FORCE_DEFAULT_BOOT_LINE */ sysClearBATsInvalidateTLBs (); /* L2 Cache setup */#ifdef INCLUDE_CACHE_SUPPORT #ifdef INCLUDE_CACHE_L2 sysL2CacheInit (); #if (L2_CACHE_MODE == CACHE_WRITETHROUGH) sysL2CacheSetWT(); #endif /* L2_CACHE_MODE == CACHE_WRITETHROUGH */ _pSysL2CacheInvFunc = sysL2CacheGlobalInv; _pSysL2CacheEnable = sysL2CacheEnable; _pSysL2CacheDisable = sysL2CacheDisable; if ((CPU_TYPE == CPU_TYPE_7400) || (CPU_TYPE == CPU_TYPE_7410)) _pSysL2CacheFlush = sysL2CacheHWFlush; else _pSysL2CacheFlush = sysL2CacheSWFlush; #else sysL2CacheDisable (); #endif /* INCLUDE_CACHE_L2 */#endif /* INCLUDE_CACHE_SUPPORT */ }/********************************************************************************* 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 INCLUDE_AUX_CLK sysAuxClkInit ();#endif /* INCLUDE_AUX_CLK */ sysSerialHwInit2 (); /* connect serial interrupts */#ifdef INCLUDE_NETWORK sysNetHwInit2 ();#endif /* INCLUDE_NETWORK */#ifdef INCLUDE_ALTIVEC _func_altivecProbeRtn = sysAltivecProbe;#endif /* INCLUDE_ALTIVEC */ } }/********************************************************************************* 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 * physTop = NULL; if (physTop == NULL) {#ifdef LOCAL_MEM_AUTOSIZE /* TODO - If auto-sizing is possible, this would be the spot. */#error "Dynamic memory sizing not supported"#else /* Don't do autosizing, if size is given */ physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */ } 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.*/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.** The entry point for a warm boot is defined by the macro ROM_WARM_ADRS* in config.h. We do an absolute jump to this address to enter the* ROM code.** 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 */ intLock (); /* disable interrupts */#if defined(INCLUDE_CACHE_SUPPORT) && defined(INCLUDE_CACHE_L2) sysL2CacheGlobalInv (); if ((CPU_TYPE == CPU_TYPE_7400) || (CPU_TYPE == CPU_TYPE_7410)) sysL2CacheHWFlush (); else sysL2CacheSWFlush (); sysL2CacheDisable(); /* Disable the L2 Cache */#endif#ifdef INCLUDE_AUX_CLK sysAuxClkDisable ();#endif /* INCLUDE_AUX_CLK */ cacheDisable (INSTRUCTION_CACHE); /* Disable the Instruction Cache */ cacheDisable (DATA_CACHE); /* Disable the Data Cache */ sysHwInit (); /* disable all sub systems to a quiet state */ vxMsrSet (0); /* Clear the MSR */ (*pRom) (startType); /* jump to romInit.s */ return(OK); /* in case we 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.** For bus systems, it is assumes that processor 0 is the bus master and* exports its memory to the bus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet ( int procNum /* processor number */ ) { sysProcNum = procNum; if (procNum == 0) {#ifdef INCLUDE_PCI /* TODO - Enable/Initialize the interface as bus slave */#endif } }/********************************************************************************* 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_750) || (cpuType == CPU_TYPE_755) || (cpuType == CPU_TYPE_7400) || (cpuType == CPU_TYPE_7410)) { 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); }#ifdef DEBUG/********************************************************************************* sysDebug - print message using polled serial driver** Use the polled driver to print debug messages. Useful before the full* hardware initialization is complete (but only after sysHwInit).** RETURNS: N/A.** NOMANUAL*/void sysDebug ( char *str ) { int msgSize; int msgIx; LOCAL SIO_CHAN * pSioChan; /* serial I/O channel */ LOCAL BOOL beenHere = FALSE; msgSize = strlen (str); if (!beenHere) { sysSerialHwInit (); pSioChan = sysSerialChanGet (0); sioIoctl (pSioChan, SIO_BAUD_SET, (void *)CONSOLE_BAUD_RATE); sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL); beenHere = TRUE; } for (msgIx = 0; msgIx < msgSize; msgIx++) { while (sioPollOutput (pSioChan, str[msgIx]) == EAGAIN) /* do nothing */; } }#endif /* DEBUG */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -