📄 syslib.c
字号:
/* sysLib.c - Motorola ads 8260 board system-dependent library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01u,12dec01,jrs Add BAT table entry to correct mem map.01t,10dec01,jrs change copyright date01s,30nov01,gls fixed sysBatDesc definition (SPR #20321)01r,17oct01,jrs Upgrade to veloce set M8260_SCCR to BRGCLK_DIV_FACTOR, added global variable baudRateGenClk - set by sysBaudClkFreq(), added sysCpmFreqGet() and sysBaudClkFreq() functions, added 8260 Reset Configuration Table - SPR66989 changed INCLUDE_MOT_FCC to INCLUDE_MOTFCCEND - SPR #3391401q,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_1M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* I BAT 1 */ 0, 0, /* I BAT 2 */ 0, 0, /* I BAT 3 */ 0, 0, /* D BAT 0 */ ((ROM_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_1M | _MMU_UBAT_VS | _MMU_UBAT_VP), ((ROM_BASE_ADRS & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT), /* D BAT 1 */ /* use DBAT1 to map CPM DPRAM and internal registers into data space */ /* NOTE! the internal space cannot be cached and should be guarded */ ((INTERNAL_MEM_MAP_ADDR & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_128K | _MMU_UBAT_VS | _MMU_UBAT_VP), ((INTERNAL_MEM_MAP_ADDR & _MMU_LBAT_BRPN_MASK) | _MMU_LBAT_PP_RW | _MMU_LBAT_CACHE_INHIBIT | _MMU_LBAT_GUARDED), /* D BAT 2 */ 0, 0, /* D BAT 3 */ 0,0 };/* * 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 }, { /* Board Control and Status Registers */ (void *) BCSR_BASE_ADRS, (void *) BCSR_BASE_ADRS, BCSRS_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 }, { /* 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 }, { /* 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_MASK_GUARDED, VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT | VM_STATE_GUARDED } };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 */UINT32 baudRateGenClk; /* 8260 Reset Configuration Table (From page 9-2 in Rev0 of 8260 book) */#define END_OF_TABLE 0struct config_parms { UINT32 inputFreq; /* MODCK_H */ UINT8 modck_h; /* | */ UINT8 modck13; /* |MODCK[1-3] */ UINT32 cpmFreq; /* Input | | CPM Core */ UINT32 coreFreq; /* | | | | | */ } modckH_modck13[] = {/* V V V V V */ {FREQ_33_MHZ, 1, 0, FREQ_66_MHZ, FREQ_133_MHZ}, {FREQ_33_MHZ, 1, 1, FREQ_66_MHZ, FREQ_166_MHZ}, {FREQ_33_MHZ, 1, 2, FREQ_66_MHZ, FREQ_200_MHZ}, {FREQ_33_MHZ, 1, 3, FREQ_66_MHZ, FREQ_233_MHZ}, {FREQ_33_MHZ, 1, 4, FREQ_66_MHZ, FREQ_266_MHZ}, {FREQ_33_MHZ, 1, 5, FREQ_100_MHZ, FREQ_133_MHZ}, {FREQ_33_MHZ, 1, 6, FREQ_100_MHZ, FREQ_166_MHZ}, {FREQ_33_MHZ, 1, 7, FREQ_100_MHZ, FREQ_200_MHZ}, {FREQ_33_MHZ, 2, 0, FREQ_100_MHZ, FREQ_233_MHZ}, {FREQ_33_MHZ, 2, 1, FREQ_100_MHZ, FREQ_266_MHZ}, {FREQ_33_MHZ, 2, 2, FREQ_133_MHZ, FREQ_133_MHZ}, {FREQ_33_MHZ, 2, 3, FREQ_133_MHZ, FREQ_166_MHZ}, {FREQ_33_MHZ, 2, 4, FREQ_133_MHZ, FREQ_200_MHZ}, {FREQ_33_MHZ, 2, 5, FREQ_133_MHZ, FREQ_233_MHZ}, {FREQ_33_MHZ, 2, 6, FREQ_133_MHZ, FREQ_266_MHZ}, {FREQ_33_MHZ, 2, 7, FREQ_166_MHZ, FREQ_133_MHZ}, {FREQ_33_MHZ, 3, 0, FREQ_166_MHZ, FREQ_166_MHZ}, {FREQ_33_MHZ, 3, 1, FREQ_166_MHZ, FREQ_200_MHZ}, {FREQ_33_MHZ, 3, 2, FREQ_166_MHZ, FREQ_233_MHZ}, {FREQ_33_MHZ, 3, 3, FREQ_166_MHZ, FREQ_266_MHZ}, {FREQ_33_MHZ, 3, 4, FREQ_200_MHZ, FREQ_133_MHZ}, {FREQ_33_MHZ, 3, 5, FREQ_200_MHZ, FREQ_166_MHZ}, {FREQ_33_MHZ, 3, 6, FREQ_200_MHZ, FREQ_200_MHZ}, {FREQ_33_MHZ, 3, 7, FREQ_200_MHZ, FREQ_233_MHZ}, {FREQ_33_MHZ, 4, 0, FREQ_200_MHZ, FREQ_266_MHZ}, {FREQ_40_MHZ, 5, 7, FREQ_80_MHZ, FREQ_120_MHZ}, {FREQ_66_MHZ, 5, 5, FREQ_133_MHZ, FREQ_133_MHZ}, {FREQ_66_MHZ, 5, 6, FREQ_133_MHZ, FREQ_166_MHZ}, {FREQ_66_MHZ, 5, 7, FREQ_133_MHZ, FREQ_200_MHZ}, {FREQ_66_MHZ, 6, 0, FREQ_133_MHZ, FREQ_233_MHZ}, {FREQ_66_MHZ, 6, 1, FREQ_133_MHZ, FREQ_266_MHZ}, {FREQ_66_MHZ, 6, 2, FREQ_133_MHZ, FREQ_300_MHZ}, {FREQ_66_MHZ, 6, 3, FREQ_166_MHZ, FREQ_133_MHZ}, {FREQ_66_MHZ, 6, 4, FREQ_166_MHZ, FREQ_166_MHZ}, {FREQ_66_MHZ, 6, 5, FREQ_166_MHZ, FREQ_200_MHZ}, {FREQ_66_MHZ, 6, 6, FREQ_166_MHZ, FREQ_233_MHZ}, {FREQ_66_MHZ, 6, 7, FREQ_166_MHZ, FREQ_266_MHZ}, {FREQ_66_MHZ, 7, 0, FREQ_166_MHZ, FREQ_300_MHZ}, {FREQ_66_MHZ, 7, 1, FREQ_200_MHZ, FREQ_133_MHZ}, {FREQ_66_MHZ, 7, 2, FREQ_200_MHZ, FREQ_166_MHZ}, {FREQ_66_MHZ, 7, 3, FREQ_200_MHZ, FREQ_200_MHZ}, {FREQ_66_MHZ, 7, 4, FREQ_200_MHZ, FREQ_233_MHZ}, {FREQ_66_MHZ, 7, 5, FREQ_200_MHZ, FREQ_266_MHZ}, {FREQ_66_MHZ, 7, 6, FREQ_200_MHZ, FREQ_300_MHZ}, {FREQ_66_MHZ, 7, 7, FREQ_233_MHZ, FREQ_133_MHZ}, {FREQ_66_MHZ, 8, 0, FREQ_233_MHZ, FREQ_166_MHZ}, {FREQ_66_MHZ, 8, 1, FREQ_233_MHZ, FREQ_200_MHZ}, {FREQ_66_MHZ, 8, 2, FREQ_233_MHZ, FREQ_233_MHZ}, {FREQ_66_MHZ, 8, 3, FREQ_233_MHZ, FREQ_266_MHZ}, {FREQ_66_MHZ, 8, 4, FREQ_233_MHZ, FREQ_300_MHZ}, {END_OF_TABLE,0,0,0,0} };/* 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_MOTFCCEND/* 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, 0x33, 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_MOTFCCEND */ /* locals */STATUS sysFccEnetDisable (UINT32 immrVal, UINT8 fccNum);void sysControlLED ( int LED, int on);/* defines */#define ZERO 0#define SYS_MODEL "Motorola MPC8260 ADS"/* 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_MOTFCCEND# include "sysMotFccEnd.c"#endif /* INCLUDE_MOTFCCEND */ UINT32 vxImmrGet (void);/******************************************************************************** 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -