📄 syslib.c
字号:
* sysBspRev - return the BSP version and revision number** This routine returns a pointer to a BSP version and revision number, for* example, 1.2/0. BSP_REV is concatenated to BSP_VERSION and returned.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev ( void ) { return (BSP_VERSION BSP_REV); }/************************************************************************* sysHwInit - initialize the system hardware** This routine initializes various features of the CPU board. It is called* by usrInit() in usrConfig.c. This routine sets up the control registers* and initializes various devices if they are present.** NOTE: This routine should not be called directly by the user application. It* cannot be used to initialize interrupt vectors.** RETURNS: N/A*/void sysHwInit ( void ) { sysCpuCheck (); /* Validate CPU type */ /* Initialize PCI driver library. Must be done before sysEpicInit() */ if ((sysPciInit()) != OK) { /* * Note, bailing to sysToMonitor() in here will probally cause * an endless loop but there is little alternative at this stage. * Watch the bus access lights to help detect this condition. */ sysToMonitor (BOOT_NO_AUTOBOOT); /* BAIL */ } pciConfigOutByte (0,0,0,0xc0,0); /* disable errors in ErrEnR1 */ pciConfigOutByte (0,0,0,0xc4,0); /* disable errors in ErrEnR2 */ pciConfigOutLong (0,0,0,0xac,0); /* clear PICR2 */ pciConfigOutByte (0,0,0,0x73,0xff); /* alter ODCR to our liking */ pciConfigOutWord (0,0,0,0x46,0x8080);/* set PCIARB */ /* Initialize EPIC interrupt controller */ pciConfigOutLong (0,0,0,0x78,EUMB); sysEpicInit (); /* configure the sbc8240 PCI slot and UART signals */ /* PCI slot J3 - level sensitive, active low */ *M8240_EPIC_EISVP0(EUMB) |= LONGSWAP(EPIC_INT_SENSE) ; *M8240_EPIC_EISVP0(EUMB) &= LONGSWAP(~EPIC_INT_POLARITY) ; /* PCI slot J2 - level sensitive, active low */ *M8240_EPIC_EISVP1(EUMB) |= LONGSWAP(EPIC_INT_SENSE) ; *M8240_EPIC_EISVP1(EUMB) &= LONGSWAP(~EPIC_INT_POLARITY) ; /* UART - level sensitive, active high */ *M8240_EPIC_EISVP3(EUMB) |= LONGSWAP(EPIC_INT_SENSE | EPIC_INT_POLARITY) ; /* Initialize COM1 and COM2 serial channels */ sysSerialHwInit (); /* * 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 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 */ #ifdef INCLUDE_NETWORK sysNetHwInit (); #endif /* INCLUDE_NETWORK */ sysClearBATsInvalidateTLBs (); }/************************************************************************* 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; sysSerialHwInit2 (); /* initialize serial interrupts */ #ifdef INCLUDE_AUX_CLK /* * initialize and start auxiliary clock support */ sysAuxClkEnable (); #endif /* INCLUDE_AUX_CLK */ #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 */ cacheDisable (INSTRUCTION_CACHE); /* Disable the Instruction Cache */ cacheDisable (DATA_CACHE); /* Disable the Data Cache */#ifdef INCLUDE_AUX_CLK sysAuxClkDisable ();#endif /* INCLUDE_AUX_CLK */ 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_8240) || (cpuType == CPU_TYPE_8245)) { 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); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -