📄 syslib.c
字号:
/* sysLib.c - PC 386/486/Pentium/Pentiumpro system-dependent library *//* Copyright 1984-1999 Wind River Systems, Inc. */#include "copyright_wrs.h" /* modification history --------------------06a,2003-4-2 13:19,donleo,使得vxWorks可以使用USB #define INCLUDE_06A03m,21apr99,hdn added conditional tffsDrv.h inclusion (SPR# 26922)03l,12mar99,cn added support for el3c90xEnd driver (SPR# 25327).03k,09mar99,sbs ad ded support for ne2000End driver added support for ultraEnd driver added support for elt3c509End driver03j,01feb99,jkf added END support for AMD 7997x PCI card.03i,26jan99,jkf changed sysHwInit2 to use INCLUDE_ADD_BOOTMEM and removed ATA_MEM_DOSFS from sysToMonitor. SPR#2133803h,31mar98,cn Added Enhanced Network Driver support.03g,04jun98,hdn made sysIntLevel() faster. added sysIntCount[] for debug.03f,28may98,hdn added support for APIC.03e,12may98,hdn merged with pcPentium/sysLib.c. obsolete INCLUDE_IDE.03d,23apr98,yp merged TrueFFS support.03c,16apr98,hdn added sysCpuid[] for sysCpuProbe().03b,17mar98,sbs using macro for dummy mmu entry. added forward declaration for sysMmuMapAdd(). changed sysIntIdtType and sysWarmType to use macros. documentation update.03a,12mar98,sbs moved PCI initialization from sysPhysMemTop() to sysHwInit(). changed the PCI library calls to the new updated library API. moved sys557PciInit() from sysPhysMemTop() to sysHwInit(). added sysAic7880PciInit().02z,02mar98,sbs removed device specific mmu entries and added dynamic entries in sysPhysMemDesc table. added sysMmuMapAdd(). added initialization of sysPhysMemDescNumEnt in sysHwInit().02y,06jan98,hdn included tffsDrv.h.02x,15dec97,hdn added support for warm start from TFFS device.02w,10jul97,dds added SCSI-2 support.02v,24mar97,mas added sysPhysMemTop(); removed NOMANUAL from sysHwInit2(); parameterized the sysWarm* reboot variables (SPR 7806, 7850).02u,03dec96,hdn added sys557PciInit(). moved PCI initialization from sysHwInit2() to sysMemTop().02t,22nov96,dat added sysNetif.c, for all network support rtns. (if_eex32.c and if_i82557 were combined into sysNetif.c)02s,20nov96,db conditionally defined INCLUDE_EEX32 for man page(SPR #6190).02r,20nov96,hdn added support for PRO100B. 02q,01nov96,hdn added support for PCMCIA. 02p,21oct96,hdn removed lptTimeout, added lptResources[].02o,14oct96,dat removed ref to i8253TimerTS.c, merged from windview102.02n,24sep96,hdn fixed by removing IMPORT ATA_RESOURCE ataResources[].02m,03sep96,hdn added the compression support. changed constants to ROM_WARM_HIGH and ROM_WARM_LOW.02l,09aug96,hdn renamed INT_VEC_IRQ0 to INT_NUM_IRQ0.02k,26jul96,hdn shut off warning message: "implicit declaration of function"02j,18jul96,hdn added support for INCLUDE_ATA.02i,19jul96,wlf doc: cleanup.02h,25jun96,hdn added support for TIMESTAMP timer.02g,17jun96,hdn initialized sysProcessor to NONE02f,14jun96,hdn added support for PCI bus.02e,28may96,hdn renamed PIT_INT_xxx to PIT0_INT_xxx.02d,28sep95,dat new BSP revision id02c,27sep95,hdn fixed a typo by changing IO_ADRS_ULTRA to IO_ADRS_ELC.02b,14jun95,hdn added a global variable sysCodeSelector. added a local function sysIntVecSetEnt(), sysIntVecSetExit(). renamed pSysEndOfInt to intEOI. moved global function declarations to sysLib.h.02a,14jun95,myz moved serial configuration to sysSerial.c01z,07jan95,hdn added an accurate memory size checking.01y,31oct94,hdn changed sysMemTop() to find out a memory size. deleted sysGDT and used sysGdt in sysALib.s. added the Intel EtherExpress32 driver. deleted a conditional macro for INCLUDE_LPT. swapped 1st and 2nd parameter of fdDevCreate(). imported globals to timeout IDE and LPT.01x,12oct94,hdn deleted sysBootType. added a conditional macro for INCLUDE_LPT.01w,29may94,hdn moved sysCpuProbe() to cacheArchLib.c. added open and read bootrom.dat in sysToMonitor().01v,22apr94,hdn moved sysVectorIRQ0 from i8259Pic.c. made new globals sysFdBuf and sysFdBufSize. supported the warm start from the EPROM.01u,06apr94,hdn added sysCpuProbe().01t,17feb94,hdn deleted memAddToPool() in sysHwInit2(). added a conditional statement in sysMemTop(). changed sysWarmType 0 to 1.01s,03feb94,hdn added MMU conditional macro for the limit in the GDT.01r,29nov93,hdn added sysBspRev () routine.01q,22nov93,hdn added xxdetach () routine for warm start.01p,16nov93,hdn added sysWarmType which controls warm start device.01o,09nov93,hdn added warm start (control X).01n,08nov93,vin added support pc console drivers.01m,27oct93,hdn added memAddToPool stuff to sysHwInit2().01l,12oct93,hdn changed PIT_INT_VEC_NUM to PIT_INT_VEC.01k,05sep93,hdn moved PIC related functions to intrCtl/i8259Pic.c. added sysDelay ().01j,12aug93,hdn changed a global descriptor table sysGDT. deleted sysGDTSet.01i,11aug93,hdn added a global sysVectorIRQ0.01h,03aug93,hdn changed a mapping IRQ to Vector Table.01g,26jul93,hdn added a memory descriptor table sysPhysMemDesc[].01f,25jun93,hdn changed sysToMonitor() to call sysReboot.01e,24jun93,hdn changed the initialization of PIC.01d,17jun93,hdn updated to 5.1.01c,08apr93,jdi doc cleanup.01d,07apr93,hdn renamed Compaq to PC.01c,26mar93,hdn added the global descriptor table, memAddToPool. moved enabling A20 to romInit.s. added cacheClear for 486.01b,18nov92,hdn supported nested interrupt.01a,15may92,hdn written based on frc386 version.*//*DESCRIPTIONThis library provides board-specific routines. The chip drivers included are: i8250Sio.c - Intel 8250 UART tty driver i8253Timer.c - Intel 8253 timer driver i8259Intr.c - Intel 8259 Programmable Interrupt Controller (PIC) library nullNvRam.c - null NVRAM library nullVme.c - null VMEbus library if_eex32.c - Intel Ether Express (EISA) Ethernet network interface driver pciConfigLib.c - PCI configuration space access support for PCI drivers pciIntLib.c - PCI shared interrupt support pciConfigShow.c - Show routines for PCI configuration library if_fei.c - Intel 82557 Ethernet network interface driver aic7880Lib.c - Adaptec 7880 SCSI Host Adapter Library sysEl3c90xEnd.c - system configuration module for el3c90xEnd driver INCLUDE FILES: sysLib.hSEE ALSO:.pG "Configuration"*//* includes */#include "vxWorks.h"#include "vme.h"#include "memLib.h"#include "sysLib.h"#include "string.h"#include "intLib.h"#include "config.h"#include "logLib.h"#include "taskLib.h"#include "vxLib.h"#include "errnoLib.h"#include "dosFsLib.h"#include "stdio.h"#include "cacheLib.h"#include "private/vmLibP.h"#include "arch/i86/pentiumLib.h"#ifdef INCLUDE_TFFS#include "tffs/tffsDrv.h"#endif /* INCLUDE_TFFS *//*06a*/#define INCLUDE_06A 0/**//* To make man pages for network support routines */#ifdef DOC#define INCLUDE_EEX32#define INCLUDE_FEI#define INCLUDE_FEI_END#endif/* imports */IMPORT char end; /* end of system, created by ld */IMPORT GDT sysGdt[]; /* the global descriptor table */IMPORT void elcdetach (int unit);IMPORT void ultradetach (int unit);IMPORT VOIDFUNCPTR intEoiGet; /* function used in intConnect() for B/EOI */IMPORT void intEnt (void);STATUS sysMmuMapAdd(void *address, UINT len, UINT initialStateMask, UINT initialState);/* globals *//* include rtl81x9End driver support routines *//*bluewind for end*/#ifdef INCLUDE_RTL_81X9_ENDIMPORT STATUS sysRtl81x9PciInit (void);#endif /* INCLUDE_RTL_81X9_END */PHYS_MEM_DESC sysPhysMemDesc [] = { /* adrs and length parameters must be page-aligned (multiples of 4KB/4MB) */#if (VM_PAGE_SIZE == PAGE_SIZE_4KB) /* lower memory */ { (void *) LOCAL_MEM_LOCAL_ADRS, (void *) LOCAL_MEM_LOCAL_ADRS, 0xa0000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_OS }, /* video ram, etc */ { (void *) 0xa0000, (void *) 0xa0000, 0x60000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO }, /* upper memory for OS */ { (void *) 0x100000, (void *) 0x100000, 0x080000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_OS }, /* upper memory for Application */ { (void *) 0x180000, (void *) 0x180000, LOCAL_MEM_SIZE - 0x180000, /* it is changed in sysMemTop() */ VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_APPLICATION }, /* entries for dynamic mappings - create sufficient entries *//*for mediaGx*/ { (void *) 0x40800000, (void *) 0x40800000, 0x400000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO }, /*bluewind for mediaGX*/ DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY,#else /* (VM_PAGE_SIZE == PAGE_SIZE_4KB) */ /* 1st 4MB: lower memory + video ram etc + upper memory for OS */ { (void *) LOCAL_MEM_LOCAL_ADRS, (void *) LOCAL_MEM_LOCAL_ADRS, 0x400000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_OS }, /* 2nd 4MB: upper memory for Application */ { (void *) 0x400000, (void *) 0x400000, LOCAL_MEM_SIZE - 0x400000, /* it is changed in sysMemTop() */ VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_APPLICATION }, /* entries for dynamic mappings - create sufficient entries */ { (void *) 0x40800000, (void *) 0x40800000, 0x400000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO }, /*bluewind for mediaGX*/ DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY, DUMMY_MMU_ENTRY,#endif /* (VM_PAGE_SIZE == PAGE_SIZE_4KB) */ };int sysPhysMemDescNumEnt; /* number Mmu entries to be mapped */#ifdef INCLUDE_PC_CONSOLEPC_CON_DEV pcConDv [N_VIRTUAL_CONSOLES] = { {{{{NULL}}}, FALSE, NULL, NULL}, {{{{NULL}}}, FALSE, NULL, NULL} };#endif /* INCLUDE_PC_CONSOLE */#ifdef INCLUDE_FDIMPORT STATUS usrFdConfig (int type, int drive, char *fileName);FD_TYPE fdTypes[] = { {2880,18,2,80,2,0x1b,0x54,0x00,0x0c,0x0f,0x02,1,1,"1.44M"}, {2400,15,2,80,2,0x24,0x50,0x00,0x0d,0x0f,0x02,1,1,"1.2M"}, };UINT sysFdBuf = FD_DMA_BUF_ADDR; /* floppy disk DMA buffer address */UINT sysFdBufSize = FD_DMA_BUF_SIZE; /* floppy disk DMA buffer size */#endif /* INCLUDE_FD */#ifdef INCLUDE_ATAIMPORT STATUS usrAtaConfig (int ctrl, int drive, char *fileName);ATA_TYPE ataTypes[ATA_MAX_CTRLS][ATA_MAX_DRIVES] = { {{761, 8, 39, 512, 0xff}, /* ctrl 0 drive 0 */ {761, 8, 39, 512, 0xff}}, /* ctrl 0 drive 1 */ {{761, 8, 39, 512, 0xff}, /* ctrl 1 drive 0 */ {761, 8, 39, 512, 0xff}}, /* ctrl 1 drive 1 */ };ATA_RESOURCE ataResources[ATA_MAX_CTRLS] = { { { 5, 0, {ATA0_IO_START0, ATA0_IO_START1}, {ATA0_IO_STOP0, ATA0_IO_STOP1}, 0, 0, 0, 0, 0, 0 }, IDE_LOCAL, 1, ATA0_INT_VEC, ATA0_INT_LVL, ATA0_CONFIG, ATA_SEM_TIMEOUT, ATA_WDG_TIMEOUT, 0, 0 }, /* ctrl 0 */ { { 5, 0, {ATA1_IO_START0, ATA1_IO_START1}, {ATA1_IO_STOP0, ATA1_IO_STOP1}, 0, 0, 0, 0, 0, 0 }, ATA_PCMCIA, 1, ATA1_INT_VEC, ATA1_INT_LVL, ATA1_CONFIG, ATA_SEM_TIMEOUT, ATA_WDG_TIMEOUT, 0, 0 } /* ctrl 1 */ };/*ATA_PCMCIA to IDE_LOCAL :BLUEWIND*/#endif /* INCLUDE_ATA */#ifdef INCLUDE_LPTLPT_RESOURCE lptResources[LPT_CHANNELS] = { {LPT0_BASE_ADRS, LPT_INT_VEC, LPT_INT_LVL, TRUE, 10000, 10000, 1, 1}, };#endif /* INCLUDE_LPT */int sysBus = BUS; /* system bus type (VME_BUS, etc) */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 sysIntIdtType = SYS_INT_TRAPGATE; /* IDT entry type */UINT sysProcessor = NONE; /* 0=386, 1=486, 2=P5, 3=ns486, 4=P6 */UINT sysCoprocessor = 0; /* 0=none, 1=387, 2=487 */int sysWarmType = SYS_WARM_TYPE; /* system warm boot type */int sysWarmFdDrive = SYS_WARM_FD_DRIVE; /* 0 = drive a:, 1 = b: */int sysWarmFdType = SYS_WARM_FD_TYPE; /* 0 = 3.5" 2HD, 1 = 5.25" 2HD */int sysWarmAtaCtrl = SYS_WARM_ATA_CTRL; /* controller 0 or 1 */int sysWarmAtaDrive = SYS_WARM_ATA_DRIVE; /* Hd drive 0 (c:), 1 (d:) */int sysWarmTffsDrive= SYS_WARM_TFFS_DRIVE; /* TFFS drive 0 (DOC) */UINT sysStrayIntCount = 0; /* Stray interrupt count */char *memTopPhys = NULL; /* top of memory */GDT *pSysGdt = (GDT *)(LOCAL_MEM_LOCAL_ADRS + GDT_BASE_OFFSET);int sysCodeSelector = CODE_SELECTOR;/* code selector for context switch */CPUID sysCpuId = {0,0,{0}}; /* CPUID version and feature *//* locals */LOCAL short *sysRomBase[] = { (short *)0xce000, (short *)0xce800, (short *)0xcf000, (short *)0xcf800 };#define ROM_SIGNATURE_SIZE 16LOCAL char sysRomSignature[ROM_SIGNATURE_SIZE] = { 0x55,0xaa,0x01,0x90,0x90,0x90,0x90,0x90, 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90 };#if (CPU == PENTIUM) /* * The cache control flags and MTRRs operate hierarchically for restricting * caching. That is, if the CD flag is set, caching is prevented globally. * If the CD flag is clear, either the PCD flags and/or the MTRRs can be * used to restrict caching. If there is an overlap of page-level caching * control and MTRR caching control, the mechanism that prevents caching * has precedence. For example, if an MTRR makes a region of system memory * uncachable, a PCD flag cannot be used to enable caching for a page in * that region. The converse is also true; that is, if the PCD flag is * set, an MTRR cannot be used to make a region of system memory cacheable. * If there is an overlap in the assignment of the write-back and write- * through caching policies to a page and a region of memory, the write- * through policy takes precedence. The write-combining policy takes * precedence over either write-through or write-back.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -