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

📄 syslib.c.bak

📁 该源码为mpc8248处理器的BSP
💻 BAK
📖 第 1 页 / 共 3 页
字号:
/* sysLib.c - Motorola ads 827x board system-dependent library *//* Copyright 1984-2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01h,04oct04,dtr  Add support for latest security engine drivers01g,28jan04,dtr  Use m82xxSio.c from target/src/drv/sio.01f,08jan04,dtr  Add MMU mapping for security processor.01e,08dec03,dtr  Modified for ads827x BSP.01d,08oct03,dee  nvram routines check limits of nvram offset01c,01oct03,dee  use sysHwInit to adjust mmu tables depending on size of SDRAM01b,08jan03,dtr  Added support for PCI DMA and Error Handling.                 Implemented workaround for PCI Bridge read errata.01w,13jul02,dtr  Add support for PCI.01v,08mar02,jnz  add support for ads826601u,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/mem/m8260Memc.h"#include "drv/timer/m8260Clock.h"#include "drv/sio/m8260Cp.h"#include "drv/sio/m8260CpmMux.h"#include "drv/mem/m82xxDpramLib.h"#include "miiLib.h"#ifdef INCLUDE_PCI#    include "drv/pci/pciConfigLib.h"#    include "drv/pci/pciIntLib.h"#endif /* INCLUDE_PCI *//* 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 */    ((FLASH_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M |    _MMU_UBAT_VS | _MMU_UBAT_VP),    ((FLASH_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 */    ((FLASH_BASE_ADRS & _MMU_UBAT_BEPI_MASK) | _MMU_UBAT_BL_8M |    _MMU_UBAT_VS | _MMU_UBAT_VP),    ((FLASH_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, memory mapped PCI bus, 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 - LOCAL_MEM_LOCAL_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 *) INTERNAL_MEM_MAP_ADDR,    (void *) INTERNAL_MEM_MAP_ADDR,    INTERNAL_MEM_MAP_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 INCLUDE_PCI    {    (void*)CPU_PCI_MEM_ADRS,    (void*)CPU_PCI_MEM_ADRS,    CPU_PCI_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    },    {    (void*)CPU_PCI_MEMIO_ADRS,    (void*)CPU_PCI_MEMIO_ADRS,    CPU_PCI_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    },    {    (void*)CPU_PCI_IO_ADRS,    (void*)CPU_PCI_IO_ADRS,    CPU_PCI_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    },    {    /* MPC8266 PCI Interrupt Controller  */    (void *) PCI_BRIDGE_INTR_CTL_BA,    (void *) PCI_BRIDGE_INTR_CTL_BA,    PCI_BRIDGE_INTR_CTL_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 *) PCI_AGENT_IMMR_BA,    (void *) PCI_AGENT_IMMR_BA,    PCI_AGENT_IMMR_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#ifdef INCLUDE_SECURITY_ENGINE    {    (void *) SEC_ENG_BASE_ADRS,    (void *) SEC_ENG_BASE_ADRS,    SEC_ENG_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 /* INCLUDE_SECURITY_ENGINE */#if 1 /*CTDB_MPC8280*/     {    /* BIOS */    (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    },#endif    };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;/* forward declarations */uint32_t sysDecGet(void);#ifdef INCLUDE_PCISTATUS sysPciSpecialCycle (int busNo, UINT32 message);STATUS sysPciConfigRead   (int busNo, int deviceNo, int funcNo,			         int offset, int width, void * pData);STATUS sysPciConfigWrite  (int busNo, int deviceNo, int funcNo,			         int offset, int width, ULONG data);#ifdef PCI_BRIDGE_READ_ERRATA_WORKAROUND/* Partial Fix for Errata on read access to PCI bridge registers *//* Uses IDMA2 to access instead of direct read.  */	UINT8   pciBridgeRegisterReadByte(int);	UINT16  pciBridgeRegisterReadWord(int);	UINT32  pciBridgeRegisterReadLong(int);#	undef  PCI_IN_BYTE#	undef  PCI_IN_WORD#	undef  PCI_IN_LONG#	define PCI_IN_BYTE(x) pciBridgeRegisterReadByte(x)#	define PCI_IN_WORD(x) pciBridgeRegisterReadWord(x)#	define PCI_IN_LONG(x) pciBridgeRegisterReadLong(x)#endif  /* PCI_BRIDGE_READ_ERRATA_WORKAROUND */ULONG sysPciConfAddr = (PCI_CFG_ADR_REG | INTERNAL_MEM_MAP_ADDR);          /* PCI Configuration Address */ULONG sysPciConfData = (PCI_CFG_DATA_REG | INTERNAL_MEM_MAP_ADDR);          /* PCI Configuration Data */#include "pci/pciIntLib.c"           /* PCI int support */#include "pci/pciConfigLib.c"        /* pci configuration library *//* use show routine */#ifdef INCLUDE_SHOW_ROUTINES#include "pci/pciConfigShow.c"       /* pci configuration show routines */#endif

⌨️ 快捷键说明

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