📄 syslib.c
字号:
* NOTE: Do not 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/* auto-sizing is possible */ physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + sysPhysMemSize ());#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 memory** This routine returns the address of the first missing byte of memory,* which indicates the top of memory.** RETURNS: The address of the top of memory.*/char *sysMemTop (void) {#ifdef LOCAL_MEM_AUTOSIZE/* auto-sizing is possible */ return((char *)LOCAL_MEM_LOCAL_ADRS + (sysPhysMemSize () - USER_RESERVED_MEM));#else/* Don't do autosizing, if size is given */ return((char *)LOCAL_MEM_LOCAL_ADRS + (LOCAL_MEM_SIZE - USER_RESERVED_MEM));#endif /* LOCAL_MEM_AUTOSIZE */ } /******************************************************************************** sysToMonitorColdReboot - Perform a "cold" reset of the board.** This routine reboots the board by using the watchdog timer reset* functionality. ** RETURNS: Does not return.*/PRIVATE void sysToMonitorColdReboot(void) { volatile UINT32 *watchDogTmrKeyReg = (UINT32 *)IXP425_OSWK; volatile UINT32 *watchDogTmrEnableReg = (UINT32 *)IXP425_OSWE; volatile UINT32 *watchDogTmrReg = (UINT32 *)IXP425_OSWT; /* Write the key-value to the watch dog key register to allow * configuration of the watch dog timer */ *watchDogTmrKeyReg = IXP425_OSW_ENABLE_REG_WRITE_KEY_VALUE; /* Enable the watch dog timer and enable the system reset */ *watchDogTmrEnableReg = IXP425_OSW_RESET_ENABLE | IXP425_OSW_COUNT_ENABLE; /* Load zero into the Watchdog register so that the system resets * immediately */ *watchDogTmrReg = 0; while(1) { /* wait here until the Watchdog reset takes affect */ DEBUG_OUT_VAL(INFO_CODE_E1); } } /********************************************************************************* sysToMonitor - transfer control to the ROM monitor** This routine transfers control to the ROM monitor. It is usually called* only by reboot() -- which services ^X -- and bus errors at interrupt* level. However, in some circumstances, the user may wish to introduce a* new <startType> to enable special boot ROM facilities.** startType - passed to ROM to tell it how to boot** RETURNS: Does not return.*/STATUS sysToMonitor (int startType) {#if (_BYTE_ORDER == _LITTLE_ENDIAN) FUNCPTR sysToMonitorLEWarmRebootAddrCoherent; UINT32 *memSwap;#else FUNCPTR pRom;#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */#if defined(INCLUDE_END) END_OBJ * pEnd; UINT32 i;#endif /* INCLUDE_END */#if defined(INCLUDE_END)#ifdef INCLUDE_FEI82557END /* * If the Ethernet driver were left alone, the controller chip might * alter memory, so we stop the controller before jumping to the bootrom. */ for (i = 0; i < IXP425_PCI_MAX_DEV; i++) { if ( (pEnd = endFindByName ("fei", i)) != NULL) pEnd->pFuncTable->stop(pEnd->devObject.pDevice); }#endif /* INCLUDE_FEI82557END */#ifdef INCLUDE_IXETHACCEND for (i = 0; i < IX_ETH_ACC_NUMBER_OF_PORTS; i++) { if ( (pEnd = endFindByName ("ixe", i)) != NULL) pEnd->pFuncTable->stop(pEnd->devObject.pDevice); } ixRebootHook(0);#endif /* INCLUDE_IXETHACCEND */#endif /* INCLUDE_END */#ifdef INCLUDE_SERIAL sysSerialReset (); /* put serial devices into quiet state */#endif /* INCLUDE_SERIAL */ sysClkDisable(); intIFLock (); IXP425_MASK_ALL_INTERRUPTS() /* If this is a cold reboot, then we want to use the watchdog to reset * the system so that it is nice and clean */ if (startType == BOOT_COLD) { sysToMonitorColdReboot(); } else /* Warm reboot required */ {#if (_BYTE_ORDER == _LITTLE_ENDIAN) DEBUG_OUT_VAL(INFO_CODE_E2); /* Add the SDRAM alias to the sysToMonitorLEWarmReboot func so that * when this function is called from the offset address it is accessed * in address cohernet mode. This is required as the MMU is being turnd * off. Also as this function will now be executed in address coherent * mode the function needs to be byte swapped */ sysToMonitorLEWarmRebootAddrCoherent = (FUNCPTR)((&sysToMonitorLEWarmReboot) + IXP425_SDRAM_BASE_ALT); memSwap = (UINT32 *)(&sysToMonitorLEWarmReboot); while (memSwap < (UINT32 *)(&sysToMonitorLEWarmRebootEnd)) { *memSwap = ntohl(*memSwap); memSwap++; } memSwap = (UINT32 *)(&prepWarmReboot); while (memSwap < (UINT32 *)(&prepWarmRebootEnd)) { *memSwap = ntohl(*memSwap); memSwap++; } /* Flush the data cache and invalidate the instruction cache for all of * SDRAM */ cacheTextUpdate((UINT32 *)LOCAL_MEM_LOCAL_ADRS, /* Virtual Address */ LOCAL_MEM_SIZE); /* # Bytes to sync*/ #endif /* _BYTE_ORDER == _LITTLE_ENDIAN */#ifdef INCLUDE_MMU cacheArmXSCALEDClearDisable (); cacheArmXSCALEIClearDisable (); mmuArmXSCALETLBIDFlushAll (); DEBUG_OUT_VAL(INFO_CODE_E3); /* Want to control the MMU switch off more carefully when in * LE mode */#if (_BYTE_ORDER != _LITTLE_ENDIAN) mmuArmXSCALEADisable ();#endif /* _BYTE_ORDER != _LITTLE_ENDIAN */#endif /* INCLUDE_MMU */ /* The problem at this point is that the ROM is mapped to an alternate * position and ram is at zero. We need to jump to an aliased version * of the SDRAM. Then put the flash back to zero. Then jump to the real * ROM_TEXT_ADRS. * When running in LE mode the sysToMonitorLEWarmRebootAddrCoherent * function is used. When in BE mode the sysToMonSwitchFlashRam function * is used. */#if (_BYTE_ORDER == _LITTLE_ENDIAN) DEBUG_OUT_VAL(INFO_CODE_E4); (*sysToMonitorLEWarmRebootAddrCoherent)();#else /* Running in big endian */ sysToMonSwitchFlashRam(); /* Now running on aliased memory and flash at 0 and requiring warm reboot*/ pRom = (FUNCPTR) (0x1000 + 4); /* warm boot */ (*pRom)(BOOT_WARM_AUTOBOOT); /* jump to boot ROM */#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ } return OK; /* in case we ever continue from ROM monitor */ }/* The following function must only be called when running in Little * Endian mode, and the system is requesting a warm reboot */#if (_BYTE_ORDER == _LITTLE_ENDIAN)PRIVATE void sysToMonitorLEWarmReboot(void) { FUNCPTR pRom; prepWarmReboot (IXP425_EXP_CONFIG_BASE, IXP425_EXP_CNFG0_REG_OFFSET); /* Now running on aliased memory and flash at 0 */ pRom = (FUNCPTR) (0x1000 + 4); /* warm boot */ (*pRom)(BOOT_WARM_AUTOBOOT); /* jump to boot ROM */ }PRIVATE void sysToMonitorLEWarmRebootEnd(void) { /* N.B. This function must follow sysToMonitorLEWarmReboot and * must never be called directly. It is only used to calculate * the size of the sysToMonitorLEWarmReboot function */ assert(0); return; }#endif /* _BYTE_ORDER == _LITTLE_ENDIAN *//*** BSP Info Routines ***//****************************************************************************** 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** Set the processor number for the CPU board. Processor numbers should be* unique on a single backplane.** NOTE* By convention, only processor 0 should dual-port its memory.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet(int procNum /* processor number */) { sysProcNum = procNum; }/********************************************************************************* sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.** RETURNS: A pointer to a string identifying the board and CPU.*/char *sysModel (void) { return(BOARD_DESC); }/********************************************************************************* sysBspRev - return the bsp version with the revision eg 1.1/<x>** This function returns a pointer to a bsp version with the revision.* for eg. 1.1/<x>. BSP_REV is concatanated to BSP_VERSION to form the* BSP identification string.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev (void) { return(BSP_VERSION BSP_REV); }/********************************************************************************* ixp425BoardRev - returns board revision** RETURNS: the 4bit integer value contained in the board revision register*/int ixp425BoardRev (void) { return(0x0); /* Return a dummy version for the simulator */ }/* Wrappers *//********************************************************************************* sysIntDisable - disable an external interrupt level** This routine disables a specified interrupt level.** .nT** RETURNS: OK, or ERROR if <intLevel> is out of range.** SEE ALSO: sysIntEnable(),* .sA*/STATUS sysIntDisable(int intLevel /* interrupt level to disable */) { return(ixp425IntLvlDisable (intLevel)); /* see ixp425IntrCtl.c */ }/********************************************************************************* sysIntEnable - enable an interrupt level** This routine enables a specified IXP425 interrupt level.** .nT** RETURNS: OK, or ERROR if <intLevel> is out of range.** SEE ALSO: sysIntDisable(),* .sA*/STATUS sysIntEnable(int intLevel /* interrupt level to enable (1-31) */) { return(ixp425IntLvlEnable (intLevel)); /* see ixp425IntrCtl.c */ }/******************************************************************************** sysFlashWriteEnable - enable writes to flash ** This routine enables the writes to cs0** .nT** RETURNS: N/A** SEE ALSO: sysFlashWriteDisable(),* .sA*/void sysFlashWriteEnable(void) { unsigned volatile long *ptr; ptr = (unsigned long *) IXP425_EXP_CS0_REG; *ptr = IXDP425_FLASH_CS_SETTING_WR_EN; }/******************************************************************************** sysFlashWriteDisable - Disable writes to flash ** This routine Disable the writes to cs0** .nT** RETURNS: void ** SEE ALSO: sysFlashWriteEnable(),* .sA*/void sysFlashWriteDisable(void) { unsigned volatile long *ptr; ptr = (unsigned long *)IXP425_EXP_CS0_REG; *ptr = (unsigned long )IXDP425_FLASH_CS_DEFAULT; return; }#define MAX_LINE 160 /* max line length for input to 'm' routine */#define MAX_ADR_SIZE 6 LOCAL STATUS modMac(UINT8* storage, char *inline) { UINT8 line[8]; UINT8 *pLine,*pInline = inline; UINT32 value; /* value found in line */ UINT8 excess; UINT32 i; for (i = 0; i < 6; i++) { bcopy(pInline, line,2); line[2] = 0; for (pLine = line; isspace ((int) *pLine); ++pLine) /* skip leading spaces*/ ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -