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

📄 syslib.c

📁 标准powerpc bsp vxworks模板
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysLib.c - generic PPC  system-dependent library *//* Copyright 1984-2001 Wind River Systems, Inc. *//*TODO -	Remove the template modification history and begin a new history	starting with version 01a and growing the history upward with	each revision.modification history--------------------01j,15oct01,dat  70855, adding sysNanoDelay01i,08apr99,dat  SPR 26491, PCI macros01h,09feb99,mas  negated Guard bit comment for Flash memory region (SPR 24893)01g,02feb99,tm   added PCI AutoConfig support to template BSPs (SPR 24733)01f,29jan99,mas  added GUARDED attributes to non-local memory areas mapped in                 sysPhysMemDesc[]. (SPR 23674)01e,14jan99,mas  added use of USER_D_CACHE_MODE in sysPhysMemDesc[] (SPR 24319)01d,21jul98,db   added sysLanIntEnable(), sysLanIntDisable() and		 sysLanEnetAddrGet(). 01c,09jun98,dat  changed private/vmLibP.h to vmLib.h, removed motorola		 copyright01b,21aug97,dat  code review comments from thierrym01a,08jul97,dat  written (from mv2603/sysLib.c, ver 01r)*//*DESCRIPTIONThis library provides board-specific routines.  The chip drivers included are:    templateSio.c - template SIO driver    templateTimer.c - Zilog Z8536 timer library (auxiliary clock)    nullNvRam.c - byte-oriented generic non-volatile RAM library    nullVme.c - byte-oriented generic non-volatile RAM library    templateIntrCtl.c - template interrrupt controller deviceINCLUDE 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 "logLib.h"#include "taskLib.h"#include "vxLib.h"#include "tyLib.h"#include "vmLib.h"#include "arch/ppc/mmu603Lib.h"#include "arch/ppc/vxPpcLib.h"/* defines */#define ZERO	0#define SYS_MODEL	"template BSP"/* 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: 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 */    ((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 2 */    ((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 3 */    ((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 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 */    ((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 2 */    ((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 3 */    ((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)    };/* * Decode USER_D_CACHE_MODE to determine main memory cache mode. * The macro MEM_STATE will be used to specify the cache state for * the sysPhysMemDesc table entry that describes the main memory * region. */#if (USER_D_CACHE_MODE & CACHE_COPYBACK)#   define MEM_STATE VM_STATE_CACHEABLE#elif (USER_D_CACHE_MODE & CACHE_WRITETHOUGH)#   define MEM_STATE VM_STATE_CACHEABLE_WRITETHROUGH#else#   define MEM_STATE VM_STATE_CACHEABLE_NOT#endif/* * 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_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT    },    {    /* Local DRAM - MUST be second entry in table, see sysHwInit */    (void *) RAM_LOW_ADRS,    (void *) RAM_LOW_ADRS,    LOCAL_MEM_SIZE -  RAM_LOW_ADRS, /* Dynamically changed by sysHwInit */    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,    VM_STATE_VALID      | VM_STATE_WRITABLE      | MEM_STATE    },    /* TODO - EPROM space */#ifdef INCLUDE_PCI    /* 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_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT    },    /* PCI MEMIO 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_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT    },    /* PCI MEM space */    {    (void *) PCI_MSTR_MEM_LOCAL,    (void *) PCI_MSTR_MEM_LOCAL,    PCI_MSTR_MEM_SIZE,    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT    },    /*     * TODO: Add additional mappings as needed to support special PCI     * functions like memory mapped configuration space, or special IACK     * register space.     */#endif#ifdef INCLUDE_VME    {    (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    },    {    (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    },    {    (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    },#endif    /* TODO - other I/O register spaces with GUARDED bit set */#ifdef INCLUDE_FLASH    /* TODO - flash memory space with *NO* GUARDED bit set */#endif    };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 *//* locals */LOCAL char sysModelStr[80] = SYS_MODEL;LOCAL char wrongCpuMsg[] = WRONG_CPU_MSG; /* forward declarations */void	sysSpuriousIntHandler(void);void	sysCpuCheck (void);char *  sysPhysMemTop (void);int	sysGetBusSpd (void);/* externals */IMPORT void   sysOutByte (ULONG, UCHAR);IMPORT UCHAR  sysInByte (ULONG);/* BSP DRIVERS */#ifdef INCLUDE_PCI#   include "pci/pciConfigLib.c"#   include "pci/pciIntLib.c"#   ifdef INCLUDE_PCI_AUTOCONF#       include "pci/pciAutoConfigLib.c"#       include "./sysBusPci.c"#   endif#endif#include "mem/nullNvRam.c"#include "vme/nullVme.c"#include "timer/templateTimer.c"#include "sysSerial.c"#include "sysScsi.c"#include "sysNet.c"#include "sysCache.c"	/* special cache setup *//******************************************************************************** sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.  The returned string* depends on the board model and CPU version being used, for example,* "Motorola MVME2600 - MPC 604e".** RETURNS: A pointer to the string.*/char * sysModel (void)    {    return (sysModelStr);    }/********************************************************************************* sysBspRev - return the BSP version and revision number** This routine returns a pointer to a BSP version and revision number, for* example, 1.1/0. BSP_REV is concatenated 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 features of the board.* It is the first board-specific C code executed, and runs with* interrupts masked in the processor.* This routine resets all devices to a quiescent state, typically* by calling driver initialization routines.** NOTE: Because this routine will be called from sysToMonitor, it must* shutdown all potential DMA master devices.  If a device is doing DMA* at reboot time, the DMA could interfere with the reboot. For devices* on non-local busses, this is easy if the bus reset or sysFail line can* be asserted.** NOTE: This routine should not be called directly by the user application.** RETURNS: N/A*/void sysHwInit (void)    {    /*     * TODO - add initialization code for all devices and     * for the interrupt controller.     * Note: the interrupt controller should mask all interrupts here.     * Interrupts are unmasked later on a per-device basis:     *     device                     where unmasked     *     ------                     --------------     * abort switch, clock            sysHwInit2()     * serial                         sysSerialHwInit2()     * SCSI                           sysScsiInit()     * LAN                            sysLanIntEnable()     */    /* Validate CPU type */    sysCpuCheck();#if defined(INCLUDE_MMU)    /* run-time update of the MMU entry for main RAM */    sysPhysMemDesc[1].len = (UINT)(sysPhysMemTop () - RAM_LOW_ADRS);#endif#ifdef INCLUDE_NETWORK    sysNetHwInit();		/* network interface */#endif#ifdef INCLUDE_SERIAL

⌨️ 快捷键说明

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