📄 syslib.c
字号:
/* sysLib.c - Motorola ads 8260 board system-dependent library *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01q,14mar00,ms_ add support for PILOT revision of board01p,04mar00,mtl minor changes in macros to be consistent01o,18oct99,ms_ vxImmrGet must return only bits 14:0 (SPR 28533)01n,18sep99,ms_ fix comment for ram on 60x bus01m,16sep99,ms_ sysMotFccEnd.c is local to bsp after all...01l,16sep99,ms_ fix include files path01k,16sep99,ms_ some included files come from src/drv instead of locally01j,16sep99,ms_ get miiLib.h from h/drv instead of locally01i,13sep99,cn added sysMiiOptRegsHandle () (SPR# 28305).01g,08jun99,ms_ remove definition of M8260_SIUMCR that doesn't belong in here01f,17apr99,ms_ unnesessary setting of MAMR01e,17apr99,cn added a temporary fix to initialize the boot line.01d,17apr99,ms_ final cleanup for EAR01c,14apr99,cn added support for motFccEnd01b,06apr99,ms_ reset the CPM in sysHwInit()01a,28jan99,ms_ adapted from ads860/sysLib.c version 01j*//*DESCRIPTIONThis library provides board-specific routines. The chip drivers included are:SEE ALSO:.pG "Configuration"*//* includes */#include "vxWorks.h"#include "vme.h"#include "memLib.h"#include "cacheLib.h"#include "sysLib.h"#include "config.h"#include "string.h"#include "intLib.h"#include "logLib.h"#include "stdio.h"#include "taskLib.h"#include "vxLib.h"#include "tyLib.h"#include "arch/ppc/mmu603Lib.h"#include "arch/ppc/vxPpcLib.h"#include "private/vmLibP.h"#include "drv/mem/m8260Siu.h"#include "drv/timer/m8260Clock.h"#include "drv/sio/m8260CpmMux.h"#include "miiLib.h"#include "ads8260.h"/* globals *//* * sysBatDesc[] is used to initialize the block address translation (BAT) * registers within the PowerPC 603/604 MMU. BAT hits take precedence * over Page Table Entry (PTE) hits and are faster. Overlap of memory * coverage by BATs and PTEs is permitted in cases where either the IBATs * or the DBATs do not provide the necessary mapping (PTEs apply to both * instruction AND data space, without distinction). * * The primary means of memory control for VxWorks is the MMU PTE support * provided by vmLib and cacheLib. Use of BAT registers will conflict * with vmLib support. User's may use BAT registers for i/o mapping and * other purposes but are cautioned that conflicts with cacheing and mapping * through vmLib may arise. Be aware that memory spaces mapped through a BAT * are not mapped by a PTE and any vmLib() or cacheLib() operations on such * areas will not be effective, nor will they report any error conditions. * * Note: BAT registers CANNOT be disabled - they are always active. * For example, setting them all to zero will yield four identical data * and instruction memory spaces starting at local address zero, each 128KB * in size, and each set as write-back and cache-enabled. Hence, the BAT regs * MUST be configured carefully. * * With this in mind, it is recommended that the BAT registers be used * to map LARGE memory areas external to the processor if possible. * If not possible, map sections of high RAM and/or PROM space where * fine grained control of memory access is not needed. This has the * beneficial effects of reducing PTE table size (8 bytes per 4k page) * and increasing the speed of access to the largest possible memory space. * Use the PTE table only for memory which needs fine grained (4KB pages) * control or which is too small to be mapped by the BAT regs. * * All BATs point to PROM/FLASH memory so that end customer may configure * them as required. * * [Ref: chapter 7, PowerPC Microprocessor Family: The Programming Environments] */UINT32 sysBatDesc [2 * (_MMU_NUM_IBAT + _MMU_NUM_DBAT)] = { /* I BAT 0 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* I BAT 1 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* I BAT 2 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* I BAT 3 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* D BAT 0 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* D BAT 1 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* D BAT 2 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* D BAT 3 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT) };/* * sysPhysMemDesc[] is used to initialize the Page Table Entry (PTE) array * used by the MMU to translate addresses with single page (4k) granularity. * PTE memory space should not, in general, overlap BAT memory space but * may be allowed if only Data or Instruction access is mapped via BAT. * * Address translations for local RAM, the Board Control and Status registers, * the MPC8260 Internal Memory Map, and local FLASH RAM are set here. * * PTEs are held, strangely enough, in a Page Table. Page Table sizes are * integer powers of two based on amount of memory to be mapped and a * minimum size of 64 kbytes. The MINIMUM recommended Page Table sizes * for 32-bit PowerPCs are: * * Total mapped memory Page Table size * ------------------- --------------- * 8 Meg 64 K * 16 Meg 128 K * 32 Meg 256 K * 64 Meg 512 K * 128 Meg 1 Meg * . . * . . * . . * * [Ref: chapter 7, PowerPC Microprocessor Family: The Programming Environments] * */PHYS_MEM_DESC sysPhysMemDesc [] = { { /* Vector Table and Interrupt Stack */ (void *) LOCAL_MEM_LOCAL_ADRS, (void *) LOCAL_MEM_LOCAL_ADRS, RAM_LOW_ADRS, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT }, { /* RAM on 60x bus - Must be second entry for Auto Sizing */ (void *) RAM_LOW_ADRS, (void *) RAM_LOW_ADRS, LOCAL_MEM_SIZE - RAM_LOW_ADRS, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE | VM_STATE_MASK_MEM_COHERENCY, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE | VM_STATE_MEM_COHERENCY }, { /* MPC8260 Internal Memory Map */ (void *) DEFAULT_IMM_ADRS, (void *) DEFAULT_IMM_ADRS, IMM_SIZE, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE | VM_STATE_MASK_GUARDED, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT | VM_STATE_GUARDED }, { /* xiyong ,cubit */ (void *) CUBIT_BASE_ADRS, (void *) CUBIT_BASE_ADRS, CUBIT_SIZE, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT }, { /* xiyong: RAM on local bus - Must be second entry for Auto Sizing */ (void *) LOC_BASE_ADRS, (void *) LOC_BASE_ADRS, LOC_SIZE, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE | VM_STATE_MASK_MEM_COHERENCY, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE | VM_STATE_MEM_COHERENCY }, { /* Flash */ (void *) ROM_BASE_ADRS, (void *) ROM_BASE_ADRS, ROM_SIZE, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT }, { /* Flash2 */ (void *) FLASH2_BASE_ADRS, (void *) FLASH2_BASE_ADRS, FLASH2_SIZE, VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT } };int sysPhysMemDescNumEnt = NELEMENTS (sysPhysMemDesc);int sysBus = BUS; /* system bus type (VME_BUS, etc) */int sysCpu = CPU; /* system CPU type (PPC8260) */char *sysBootLine = BOOT_LINE_ADRS; /* address of boot line */char *sysExcMsg = EXC_MSG_ADRS; /* catastrophic message area */int sysProcNum; /* processor number of this CPU */int sysFlags; /* boot flags */char sysBootHost [BOOT_FIELD_LEN]; /* name of host from which we booted */char sysBootFile [BOOT_FIELD_LEN]; /* name of file from which we booted */BOOL sysVmeEnable = FALSE; /* by default no VME *//* locals */LOCAL UINT32 *immrAddress = (UINT32 *) IMMR_ADDRESS_RESET_VALUE;#include "sysSerial.c"#include "intrCtl/m8260IntrCtl.c"#include "timer/m8260Timer.c"#include "sio/m8260Sio.c"#include "mem/nullNvRam.c"/* #include "mem/m8260Flash.c"*/#ifdef INCLUDE_MOT_FCC/* set the following array to a unique Ethernet hardware address */ /* last 5 nibbles are board specific, initialized in sysHwInit */ unsigned char sysFccEnetAddr [6] = {0x08, 0x00, 0x3e, 0x03, 0x02, 0x01}; STATUS sysFccEnetAddrGet (UINT32 immrVal, UINT8 fccNum, UCHAR * address);STATUS sysFccEnetEnable (UINT32 immrVal, UINT8 fccNum);STATUS sysFccMiiBitWr (UINT32 immrVal, UINT8 fccNum, INT32 bitVal);STATUS sysFccMiiBitRd (UINT32 immrVal, UINT8 fccNum, INT8 * bitVal);STATUS sysMiiOptRegsHandle (PHY_INFO * pPhyInfo); #endif /* INCLUDE_MOT_FCC */ /* locals */STATUS sysFccEnetDisable (UINT32 immrVal, UINT8 fccNum);void sysControlLED ( int LED, int on);/* defines */#define ZERO 0#define SYS_MODEL "Motorola XPC8260 BCNG"/* needed to enable timer base */#define M8260_DPPC_MASK 0x0C000000 /* bits 4 and 5 */#define M8260_DPPC_VALUE 0x08000000 /* bits (4,5) should be (1,0) */#include "drv/sio/m8260Sio.h"#ifdef INCLUDE_MOT_FCC#include "sysMotFccEnd.c"#endif /* INCLUDE_MOT_FCC */ UINT32 vxImmrGet (void);void vxImmrSet (UINT32 value);/******************************************************************************** sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.** RETURNS: A pointer to the string.*/char * sysModel (void) { return (SYS_MODEL); }/******************************************************************************** sysBspRev - return the bsp version with the revision eg 1.0/<x>** This function returns a pointer to a bsp version with the revision.* for eg. 1.0/<x>. BSP_REV defined in config.h is concatanated 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 feature of the MPC8260 ADS board. It sets up* the control registers, initializes various devices if they are present.** NOTE: This routine should not be called directly by the user.** RETURNS: NA*/void sysHwInit (void) { int immrVal = vxImmrGet(); /* set the BRGCLK division factor */ * M8260_SCCR(immrVal) = 0x00000000; /* set DPPC in SIUMCR to 10 so that timer is enabled (TBEN) */ * M8260_SIUMCR(immrVal) &= ~M8260_DPPC_MASK; /* clear the dppc */ * M8260_SIUMCR(immrVal) |= M8260_DPPC_VALUE; /* 0x08000000 or in the desired value */ /* reset the Communications Processor */ *M8260_CPCR(immrVal) = 0x80010000; CACHE_PIPE_FLUSH(); /* Reset serial channels */ sysSerialHwInit(); /* Initialize interrupts */ m8260IntrInit(); /* handle the LXT970 properly */#ifdef INCLUDE_MOT_FCC miiPhyOptFuncSet ((FUNCPTR) sysMiiOptRegsHandle); #endif /* INCLUDE_MOT_FCC */ /* * The power management mode is initialized here. Reduced power mode * is activated only when the kernel is iddle (cf vxPowerDown). * Power management mode is selected via vxPowerModeSet(). * DEFAULT_POWER_MGT_MODE is defined in config.h. */ vxPowerModeSet (DEFAULT_POWER_MGT_MODE); }/********************************************************************************* 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.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/char * sysPhysMemTop (void) { LOCAL char * physTop = NULL; if (physTop == NULL) { physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE); } 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) { LOCAL 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 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 + 8); /* Warm reboot */ intLock(); cacheDisable(INSTRUCTION_CACHE); cacheDisable(DATA_CACHE); sysAuxClkDisable(); /* disable both RS232 ports on the board *//* *BCSR1 |= (BCSR1_RS232EN_1_L); *BCSR1 |= (BCSR1_RS232EN_2_L);*/ sysSerialReset(); /* reset the serial device */ vxMsrSet (0); (*pRom) (startType); /* jump to bootrom entry point */ return (OK); /* in case we ever continue from ROM monitor */ }/******************************************************************************** sysHwInit2 - additional system configuration and initialization** This routine connects system interrupts and does any additional* configuration necessary.** RETURNS: NA*/void sysHwInit2 (void) { LOCAL BOOL configured = FALSE; int immrVal = vxImmrGet(); CACHE_PIPE_FLUSH(); if (!configured) { /* initialize serial interrupts */ sysSerialHwInit2(); * M8260_SCCR(immrVal) &= ~M8260_SCCR_TBS; CACHE_PIPE_FLUSH(); configured = TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -