syslib.c
来自「WINDRIVER SBC7410 BSP」· C语言 代码 · 共 1,097 行 · 第 1/3 页
C
1,097 行
/*************************************************************************** ** sysAltivecProbe - Check if the CPU has ALTIVEC unit.** This routine returns OK it the CPU has an ALTIVEC unit in it.* Presently it checks for 7400* RETURNS: OK - for 7400 Processor type* ERROR - otherwise.*/int sysAltivecProbe ( void ) { ULONG regVal; int altivecUnitPresent = ERROR; /* The CPU type is indicated in the Processor Version Register (PVR) */ regVal = CPU_TYPE; switch ( regVal ) { case CPU_TYPE_7400: case CPU_TYPE_7410: altivecUnitPresent = OK; break; default: altivecUnitPresent = ERROR; break; } /* switch */ return(altivecUnitPresent); }#endif /* INCLUDE_ALTIVEC *//*************************************************************************** ** sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board. The returned string* depends on the board model and CPU version being used.** RETURNS: A pointer to the string.*/char * sysModel ( void ) { UINT cpu; char cpuStr[80]; /* Determine CPU type and build display string */ cpu = CPU_TYPE; switch ( cpu ) { case CPU_TYPE_750: sprintf(cpuStr, "750"); break; case CPU_TYPE_755: sprintf(cpuStr, "755"); break; case CPU_TYPE_7400: sprintf(cpuStr, "7400"); break; case CPU_TYPE_7410: sprintf(cpuStr, "7410"); break; default: sprintf (cpuStr, "7xx"); break; } sprintf (sysModelStr, "Motorola PowerPC %s - Wind River SBC%s Board", cpuStr, cpuStr); return(sysModelStr); }/*************************************************************************** ** 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 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 ) { sysLedInit() ; sysCpuCheck (); /* Validate CPU type */ sysGt64260Init(); /* * 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. */#ifdef INCLUDE_MMU /* run-time update of the MMU entry for main RAM */ sysPhysMemDesc[0].len = (UINT)sysPhysMemTop ();#endif /* INCLUDE_MMU */ if ( (CPU_TYPE == CPU_TYPE_7400) || (CPU_TYPE == CPU_TYPE_7410) ) {#if defined(INCLUDE_CACHE_SUPPORT) && defined(INCLUDE_CACHE_L2) sysL2CacheDisable ();#endif }#if defined (INCLUDE_PCI) /* standalone PCI mode: PCI slot and PMC slots 1-3 are available on the board via PCI_1 in the GT64260 */ if ( pciConfigLibInit (PCI_MECHANISM_0, (ULONG)sysPciConfigRead, (ULONG)sysPciConfigWrite, 0)!=OK ) { sysLedSet(3,LED_ON); while ( 1 ); }#if defined (INCLUDE_PCI_STANDALONE) sysGt64260PciInit (1); /* configure local PCI bus */#else sysGt64260PciInit (0); /* configure off board cPCI bus */#endif /* INCLUDE_PCI_STANDALONE */#ifdef INCLUDE_PCI_AUTOCONF sysPciAutoConfig ();#else #warning performing manual PCI bus configuration! #if defined(INCLUDE_FEI82557END) && defined(INCLUDE_GEI_END) #error Cannot define both fei and gei drivers at the same time on pci-1 interface! #elif defined(INCLUDE_FEI82557END) || defined(INCLUDE_GEI_END) #warning Manually configuring fei pci config registers. /* Standalone: we know ahead of time where the pci card is; local pci slot IDSEL = AD17 = devNo 7 */ { int pciBusNo = 0 ; int pciDevNo = 0 ; int pciFuncNo = 0 ; STATUS retcode; #if defined(INCLUDE_FEI82557END) retcode = pciFindDevice(FEI_PCI_VENDOR_ID, FEI_PCI_DEVICE_ID, 0, &pciBusNo, &pciDevNo, &pciFuncNo); #else retcode = pciFindDevice(GEI_PCI_VENDOR_ID, GEI_PCI_DEVICE_ID, 0, &pciBusNo, &pciDevNo, &pciFuncNo); #endif /* INCLUDE_FEI82557END */ if( retcode != ERROR ) { (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo, PCI_IO_GEIFEI_ADRS, PCI_MEM_GEIFEI_ADRS, (PCI_CMD_MASTER_ENABLE | PCI_CMD_MEM_ENABLE)); pciConfigOutLong (pciBusNo, pciDevNo, pciFuncNo, 0x18, 0); pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_DEV_INT_LINE, GEIFEI_INT_LVL); pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_CACHE_LINE_SIZE, 8); pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_LATENCY_TIMER, 0x40); } else { sysLedSet(2,LED_ON); } } #endif /* INCLUDE_GEI_END || INCLUDE_FEI82557END */#endif /* INCLUDE_PCI_AUTOCONF */#else#warning --------------------- NO INCLUDE_PCI#endif /* INCLUDE_PCI */ sysGt64260IntrInit() ; sysSerialHwInit ();#ifdef INCLUDE_NETWORK sysNetHwInit ();#endif /* INCLUDE_NETWORK */#ifdef FORCE_DEFAULT_BOOT_LINE strncpy (sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);#endif /* FORCE_DEFAULT_BOOT_LINE */ /* 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; 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.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?