📄 syslib.c
字号:
#ifdef INCLUDE_SCSI# include "sysScsi.c" /* sysScsiInit routine */#endif /* INCLUDE_SCSI */#ifdef INCLUDE_RTC /* RTC and alarm clock routines */# include "sysRtc.c"#endif /* INCLUDE_RTC */#ifdef INCLUDE_FAILSAFE /* Failsafe timer routines */# include "sysFailsafe.c"#endif /* INCLUDE_FAILSAFE */#include "m48t37.c" /* M48T37 Timekeeper SRAM */#ifdef INCLUDE_ATA# include "sysAta.c" /* sysAtaInit routine */#endif /* INCLUDE_ATA */#include "mpc107Epic.c"#ifdef INCLUDE_AUXCLK# include "mpc107AuxClk.c"#endif#include "./pci/pciAutoConfigLib.c"#include "./sysBusPci.c"#include "sysCache.c"/* defines for sysBusTas() and sysBusTasClear() */#define CPU_CLOCKS_PER_LOOP 10#define LOCK_TIMEOUT 10#define UNLOCK_TIMEOUT 10000/******************************************************************************** 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, for example,* "Motorola MVME2600 - MPC 604e".** RETURNS: A pointer to the string.*/char * sysModel (void) { int cpu; char cpuStr[80]; /* Determine CPU type and build display string */ cpu = CPU_TYPE; switch (cpu) { case CPU_TYPE_603P: sprintf(cpuStr, "603p"); break; case CPU_TYPE_603E: sprintf(cpuStr, "603e"); break; case CPU_TYPE_604E: sprintf(cpuStr, "604e"); break; case CPU_TYPE_604R: sprintf(cpuStr, "604r"); break; case CPU_TYPE_750: sprintf(cpuStr, "750"); break; case CPU_TYPE_NITRO: sprintf(cpuStr, "7410"); break; case CPU_TYPE_MAX: if (CPU_REV < CPU_REV_NITRO) sprintf(cpuStr, "7400"); else sprintf(cpuStr, "7410"); break; default: sprintf (cpuStr, "60%d", cpu); break; } sprintf (sysModelStr, "Motorola %s - MPC %s", sysProductStr, 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.1/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); }/******************************************************************************** sysIn16 - reads a 16-bit unsigned value from an address.** This function reads a 16-bit unsigned value from a specified address, and* performs a SYNC operation to clear the processor.** RETURNS: 16-bit unsigned value from address.*/UINT16 sysIn16 (UINT16 *addr) { UINT16 data; data = * addr; SYNC; return (data); }/******************************************************************************** sysOut16 - writes a 16-bit unsigned value to an address.** This function writes a 16-bit unsigned value to a specified address, and* performs a SYNC operation to clear the processor.** RETURNS: N/A*/void sysOut16 (UINT16 *addr, UINT16 data) { *addr = data; SYNC; }/******************************************************************************** sysIn32 - reads a 32-bit unsigned value from an address.** This function reads a 32-bit unsigned value from a specified address, and* performs a SYNC operation to clear the processor.** RETURNS: 32-bit unsigned value from address.*/UINT32 sysIn32 (UINT32 *addr) { UINT32 data; data = * addr; SYNC; return (data); }/******************************************************************************** sysOut32 - writes a 32-bit unsigned value to an address.** This function writes a 32-bit unsigned value to a specified address, and* performs a SYNC operation to clear the processor.** RETURNS: N/A*/void sysOut32 (UINT32 *addr, UINT32 data) { *addr = data; SYNC; }/******************************************************************************** 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. */ 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; } }/******************************************************************************** sysDelay - delay for approximately one millisecond** Delay for approximately one milli-second.** RETURNS: N/A*/void sysDelay (void) { sysMsDelay (1); }/******************************************************************************** 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) { int pciBusNo; /* PCI bus number */ int pciDevNo; /* PCI device number */ int pciFuncNo; /* PCI function number */ /* Initialize the VPD information */ (void) sysVpdInit (); /* * Validate CPU type */ sysCpuCheck(); /* * If MPC7400 (Max): * Setup exception addresses. * Disable & invalidate if L2 enabled. */ if (CPU_TYPE == CPU_TYPE_MAX) { vmxExcLoad ();#if defined(INCLUDE_CACHE_L2) sysL2CacheDisable ();#endif } /* * Initialize PCI driver library. */ if (pciConfigLibInit (PCI_MECHANISM_1, PCI_MSTR_PRIMARY_CAR, PCI_MSTR_PRIMARY_CDR, 0) != OK) { sysToMonitor (BOOT_NO_AUTOBOOT); } /* Auto-Configure the PCI busses/devices. */ /* * Test to determine if we need to configure the PCI busses with * sysPciAutoConfig(). If we are coming up from a ROM-based image * then we need to reconfigure. If we have been booted from a ROM * image then we don't need to reconfigure since the bootrom will * already have reconfigured the PCI busses. We must avoid * configuring the PCI busses twice on startup. */ if ( !PCI_AUTOCONFIG_DONE ) { /* in ROM boot phase, OK to continue and configure PCI busses.*/ sysPciAutoConfig (); PCI_AUTOCONFIG_FLAG++; /* Remember that PCI is configured */ }#ifdef INCLUDE_ATA /* * Initialize the Standard PCI Header of the ATA/EIDE device * if present. */ if (pciFindDevice ((PCI_ID_IDE & 0xFFFF), (PCI_ID_IDE >> 16) & 0xFFFF, 0, &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR) { sysAtaInit (pciBusNo, pciDevNo, pciFuncNo); }#endif /* INCLUDE_ATA */ /* * The IBC powers up with most of the PCI Header values * being correct. So, only registers that do not power-up * in the correct state are modified here. */ if (pciFindDevice ((PCI_ID_IBC & 0xFFFF), (PCI_ID_IBC >> 16) & 0xFFFF, 0, &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR) { /* * Enable Guaranteed Access Timing (default), the Arbiter Timeout * Timer, and Bus Lock (locks PCI Bus when PCI LOCK# signal asserted) */ pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IBC_ARB_CTL, (ARB_CTL_GAT | ARB_CTL_TIMEOUT_TIMER | ARB_CTL_BUS_LOCK)); /* * Handle errata for PCI bus deadlock if ISA DMA buffer is full * and CPU accesses ISA space. */ pciConfigModifyByte (pciBusNo, pciDevNo, pciFuncNo, SL82565_PCI_CFG_PCI_CTL, SL82565_PCI_CTL_RETRYE, SL82565_PCI_CTL_RETRYE); /* * Initialize the non-PCI Config Space registers of the * IBC which doesn't have a true device driver. */ sysIbcInit(); } /* initialize the address translation unit (ATU) */ sysAtuInit(); /* Initialize the EPIC. */ sysEpicInit(); /* * The LANCE has a real driver associated with it, so * no additional initialization is done here. It's done * at kernel init time. */ /* set pointer to bus probing hook */ _func_vxMemProbeHook = (FUNCPTR)sysBusProbe; /* Initialize COM1, COM2, and COM3 serial channels */ sysSerialHwInit(); /* Disable the failsafe timer */ m48t37FailsafeCancel(); /* * 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 (); /* Upon completion, clear the Board Fail LED */ FAIL_LED_OFF; }/********************************************************************************* 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) {#ifdef LOCAL_MEM_AUTOSIZE sramConfigReg MemControlReg;#endif static char * sysPhysMemSize = NULL; /* ptr to top of mem + 1 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -