⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syslib.c

📁 vxworks mv2100 vxworks BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
/* sysLib.c - Motorola MVME2100 board series system-dependent library *//* Copyright 1984-2002 Wind River Systems, Inc. *//* Copyright 1996-2000 Motorola, Inc. All Rights Reserved *//*modification history--------------------01w,16apr02,dat  Update for T2.2 release01v,23oct01,mil  Added guarded bit to non cacheable regions in sysPhysMemDesc                 (SPR 64317) and fixed build without networking (SPR 64423).01u,14jul00,rcs  fixed path to pciConfigShow.c01t,15jun00,dmw  updated following WRS code review.01s,08feb00,rhk  Modified sysMemProbeBus to allow the vxMemProbe call		 to work properly.01r,25jun99,srr  remove #ifdef INCLUDE_PCI_AUTOCONF around sysDynEnetFind.01q,24jun99,srr  reset the EPIC in sysToMonitor.01p,23jun99,srr  restored call to sysUniverseInit2 in sysProcNumSet.01o,21jun99,srr  added support for running PCI Auto Config in bootrom only.01n,04jun99,rhk  removed the "ifdef INCLUDE_END"s, changed dec214x to		 dec21x40, removed the routine sysDec21x40EnetAddrGet, 		 removed addition of SERIAL_INTERRUPT_BASE value from 		 calculations of ivec and ilevel, moved the sysUniverseInit2		 call from sysProcNumSet to sysHwInit2.01m,29apr99,rhk  changes to support the Tornado 2 environment and SENS.01l,28apr99,dmw  Removed trigraph in sysPhysMemTop and replaced dynamic                 memory sizing with a real routine.01k,16apr99,rhk  changed PCI_xxx define names, changed page table window		 sizes, changed VME LM define names.01j,08apr99,dmw  added VPD code.01i,05apr99,rhk  removed legacy code, moved the xxxSpd routines to 		 sysSpeed.c.01h,12mar99,rhk  changes for Shared memory support, removed EIEIO_SYNC macro		 and replaced with SYNC macro.01g,24feb99,rhk  added PCI autoconfiguration support, setup UNIVERSE for PCI                 autoconfig and removed UNIV I legacy code.01f,17feb99,srr  Added SENS support.01e,17feb99,rhk  removed speed functions.01d,15feb99,rhk  removed last instances of IBC references.01c,12feb99,rhk  more legacy cleanup, setup for auxclk, used the MV2400		 version of sysLib.c as a basis for mods.01b,08feb98,rhk  updated the page table entries (sysPhysMemDesc) for mv2100		 and started removing legacy code.01a,11dec98,srr  created. (from ver 02h of mv2600/sysLib.c bsp)*//*DESCRIPTIONThis library provides board-specific routines.  The chip drivers included are:    i8250Sio.c - Intel 8250 UART driver     ppcDecTimer.c - PowerPC decrementer timer library (system clock)    byteNvRam.c - byte-oriented generic non-volatile RAM library    pciConfigLib.c - PCI configuration library    universe.c - Tundra Universe chip VME-to-PCI interface library    kahluaEpic.c - Kahlua Interrupt Controller    sysI2cDrv.c - Kahlua I2C interface driverINCLUDE FILES: sysLib.hSEE 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 "esf.h"#include "excLib.h"#include "logLib.h"#include "taskLib.h"#include "vxLib.h"#include "tyLib.h"#include "drv/end/dec21x40End.h"#include "arch/ppc/archPpc.h"#include "arch/ppc/mmu603Lib.h"#include "arch/ppc/vxPpcLib.h"#include "arch/ppc/excPpcLib.h"#include "private/vmLibP.h"#include "drv/pci/pciConfigLib.h"#include "kahluaMemParam.h"#include "sysMotVpd.h"/* defines */#define ZERO	0/* 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. * * The BAT configuration for 4xx/6xx-based PPC boards is as follows: * All BATs point to PROM/FLASH memory so that end customer may configure * them as required. * * [Ref: PowerPC Programming Reference, 7-25, 7.4.1] */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 */    0, 0,    /* D BAT 1 */    0, 0,    /* 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, memory mapped PCI bus, memory mapped * VME A16 space and local PROM/FLASH 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_MASK_MEM_COHERENCY,    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE |    VM_STATE_MEM_COHERENCY    },    {    /* Local DRAM */    (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    },    /* Access to PCI ISA I/O space */    {    (void *) ISA_MSTR_IO_LOCAL,    (void *) ISA_MSTR_IO_LOCAL,    ISA_MSTR_IO_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    },    /* Access to PCI I/O space */    {    (void *) PCI_MSTR_IO_LOCAL,    (void *) PCI_MSTR_IO_LOCAL,    PCI_MSTR_IO_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    },    /* Access to PCI ISA memory space */    {    (void *) PCI_MSTR_MEMIO_LOCAL,    (void *) PCI_MSTR_MEMIO_LOCAL,    PCI_MSTR_MEMIO_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    },    /* Access to PCI memory space */    {    (void *) PCI_DYNAMIC_MEM_LOCAL,    (void *) PCI_DYNAMIC_MEM_LOCAL,    PCI_DYNAMIC_MEM_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    },    {    /* MODIFY A32 VME WINDOW HERE */    (void *) VME_A32_MSTR_LOCAL,    (void *) VME_A32_MSTR_LOCAL,    VME_A32_MSTR_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    },    {    (void *) VME_A24_MSTR_LOCAL,    (void *) VME_A24_MSTR_LOCAL,    VME_A24_MSTR_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    },    {    /* Off-board VME LM/SIG/Semaphore Regs */    (void *) VME_LM_MSTR_LOCAL,    (void *) VME_LM_MSTR_LOCAL,    VME_LM_MSTR_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    },    {    /* Kahlua registers */    (void *) KAHLUA_EUMB_BASE,    (void *) KAHLUA_EUMB_BASE,    KAHLUA_EUMB_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    },    {    (void *) VME_A16_MSTR_LOCAL,    (void *) VME_A16_MSTR_LOCAL,    VME_A16_MSTR_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    },    {    /* PCI interrupt acknowledge */    (void *) PCI_MSTR_IACK_WNDW_ADRS,    (void *) PCI_MSTR_IACK_WNDW_ADRS,    PCI_MSTR_IACK_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    },#ifdef CHRP_ADRS_MAP    {    /* PCI Configuration Address Register */    (void *) PCI_MSTR_PRIMARY_CAR,    (void *) PCI_MSTR_PRIMARY_CAR,    PCI_MSTR_PRIMARY_CAR_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    },    {    /* PCI Configuration Data Register */    (void *) PCI_MSTR_PRIMARY_CDR,    (void *) PCI_MSTR_PRIMARY_CDR,    PCI_MSTR_PRIMARY_CDR_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    },#endif#ifndef CHRP_ADRS_MAP /* if PReP address map */    {    /* map in direct access of PCI configuration space */    (void *) PCI_MSTR_DIRECT_MAP_ADRS,    (void *) PCI_MSTR_DIRECT_MAP_ADRS,    PCI_MSTR_DIRECT_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    },#endif    {    (void *) FLASH_BASE_ADRS,    (void *) FLASH_BASE_ADRS,    FLASH_MEM_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      = VME_BUS;		/* system bus type */int    sysCpu      = CPU;		/* system CPU type (MC680x0) */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 */UINT   sysVectorIRQ0  = INT_VEC_IRQ0;	/* vector for IRQ0 */BOOL   sysVmeEnable   = FALSE;		/* by default no VME */int    pciToVmeDev;			/* PCI to VME Bridge Device *//* last 5 nibbles are board specific, initialized in sysHwInit */unsigned char lnEnetAddr [6] = { 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00 };unsigned char clearWd [1]  = { 0x00 };#if defined(INCLUDE_PMC_SPAN) && !defined(INCLUDE_PCI_AUTOCONF)/* * PMC Span (DEC21150 PCI-to-PCI Bridge) Configuration Parameter Array * * This array MUST contain the parameters in the order which they will * be set. */PMC_SPAN sysPmcSpanParm [] ={  {PCI_CFG_COMMAND, 2,   P2P_PMC_DISABLE},  {PCI_CFG_STATUS,  2,   P2P_CLR_STATUS >> 16},  {PCI_CFG_BRIDGE_CONTROL, 2, P2P_SEC_BUS_RESET},  {PCI_CFG_CACHE_LINE_SIZE, 2, P2P_CACHE_LINE_SIZE | P2P_PRIM_LATENCY},  {PCI_CFG_PRIMARY_BUS,     1, PCI_PRIMARY_BUS},  {PCI_CFG_SECONDARY_BUS,   1, PCI_SECONDARY_BUS},  {PCI_CFG_SUBORDINATE_BUS, 1, PCI_SUBORD_BUS},  {PCI_CFG_SEC_STATUS, 2,   P2P_CLR_STATUS >> 16},  {PCI_CFG_IO_BASE, 2,   ((P2P_IO_BASE & 0x0000F000) >> 8) |                         ((P2P_IO_BASE + P2P_IO_SIZE - 1) & 0x0000F000)},  {PCI_CFG_MEM_BASE, 2,  ((P2P_NONPREF_MEM_BASE & 0xFFF00000) >> 16)},  {PCI_CFG_MEM_LIMIT, 2, ((P2P_NONPREF_MEM_BASE + P2P_NONPREF_MEM_SIZE - 1) & \                          0xFFF00000) >> 16},  {PCI_CFG_PRE_MEM_BASE, 2, ((P2P_PREF_MEM_BASE & 0xFFF00000) >> 16)},  {PCI_CFG_PRE_MEM_LIMIT, 2, ((P2P_PREF_MEM_BASE + P2P_PREF_MEM_SIZE - 1) & \                              0xFFF00000) >> 16},  {PCI_CFG_PRE_MEM_BASE_U,  4, P2P_PREF_HI32_BASE},  /* only < 4GB space */  {PCI_CFG_PRE_MEM_LIMIT_U, 4, P2P_PREF_HI32_BASE},  {PCI_CFG_IO_BASE_U,  2, ((P2P_IO_BASE & 0xFFFF0000) >> 16)},  {PCI_CFG_IO_LIMIT_U, 2, ((P2P_IO_BASE + P2P_IO_SIZE - 1) & 0xFFFF0000) >> 16},  {PCI_CFG_BRIDGE_CONTROL, 2, 0},  {PCI_CFG_DEC21150_SEC_CLK,   2, P2P_CLK_ENABLE},  {PCI_CFG_DEC21150_SERR_STAT, 1, (P2P_CLR_STATUS >> 16) & 0xFF},  {PCI_CFG_STATUS,  2,  P2P_CLR_STATUS >> 16},  {PCI_CFG_COMMAND, 2,  P2P_PMC_ENABLE}};#define NUM_PMC_SPAN_PARMS      (sizeof(sysPmcSpanParm) / sizeof(PMC_SPAN))#endif /* INCLUDE_PMC_SPAN) & !INCLUDE_PCI_AUTOCONF *//* locals */LOCAL char sysModelStr[80];LOCAL char wrongCpuMsg[] = WRONG_CPU_MSG; /* forward declarations */void	sysSpuriousIntHandler(void);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -