📄 syslib.c
字号:
/* sysLib.c - PC [34]86/Pentium/Pentium[234] system-dependent library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------05c,21jun02,pai Linker-defined <end> symbol is now cast to an unsigned integer instead of a signed integer where needed. Updated commentary and page-sized stride in sysPhysMemTop() memory auto-size algorithm (SPR 79525).05b,12jul02,dmh include sysNvRam.c based value of NV_RAM_SIZE instead of IACSF05a,11jul02,dmh remove SFL_START_ADDR for iacsfl-based BSPs.04z,04jul02,hdn added the checksum to the FAST_REBOOT mechanism.04y,18jun02,hdn cleaned up sysPhysMemDesc[] and new reboot mechanism.04x,03jun02,pai Updated sysMmuMapAdd() documentation. Modified file I/O status messages in sysToMonitor().04w,05jun02,hdn added 2MB page size support for 36Bit MMU04v,25may02,hdn updated sysMmuMapAdd to align VM_PAGE_SIZE (spr 77530) added intLock/Unlock in sysIntLock/Unlock (spr 75694)04u,24may02,hdn replaced PAGE_SIZE with VM_PAGE_SIZE for 4MB page04t,23may02,pai Add WindML device initialization to sysHwInit().04s,20may02,rhe added USB support for ohci cards. SPR# 7630804r,09may02,hdn added Pentium4 Asymmetric Multi Processor configuration04q,29apr02,pai Complete the fix for (SPR 8385). Modified sysPhysMemTop() will now auto-size a larger address space.04p,28apr02,hdn added optional new i8259 PIC specific features (spr 76411)04o,22apr02,pai Removed configuration related to obsolete SMC Ultra Netif driver.04n,09apr02,pai Reworked ATA configuration and documentation (SPR# 73848). Added sysHwInit0() for the (SPR 74951) fix implementation.04m,01apr02,jkf Added _WRS_BSP_DEBUG_NULL_ACCESS to generate exception when code accesses to lower page of memory, null ptr, occur.04l,25mar02,pai Conditionally include MTRR table based upon PENTIUM2/3/4 CPU types - a modification to the version 04k implementation.04k,22mar02,pai Do not include <sysMtrr> table for P5/PENTIUM builds (SPR# 73939).04j,21mar02,pai Make pciConfigShow configurable based upon the INCLUDE_PCI_CFGSHOW component (SPR 74274).04i,12mar02,hdn replaced redTable[] with sysInumTbl[] for HTT (spr 73738)04h,07mar02,hdn excluded MTRR code from P5 (spr 73939)04g,03dec01,jkf sysToMonitor: checks if device exists before creation, and using new macros for device and file name strings.04f,27nov01,dmh move include of iacsfl.h from sysLib.c to config.h04e,16nov01,ahm added power management mode initialization (SPR#32599)04d,06nov01,hdn added PIRQ[n] and IOAPIC support for Pentium404c,02nov01,dmh add nvram for iacsfl boards. SPR# 7043304b,01nov01,hdn added MSRs init, reset PM, enabled MCA w pentiumMcaEnable()04a,01nov01,jln added support for gei82543End driver03z,22oct01,dmh replace iPiix4 support with pciAutoConfig. SPR# 65192.03y,17oct01,hdn removed duplicate sysMmuMapAdd() prototype. moved enabling MC exception into excArchLib. added LOCAL_MEM_AUTOSIZE in sysPhysMemTop(). made LOWER_MEM_TOP configurable to preserve the MP table.03x,11oct01,pai Updating details related to BSP NIC driver support. Removed INCLUDE_EEX32 and INCLUDE_FEI definition conditional on DOC macro. Updated description of BSP driver config routines. Added PCI library customization and BSP-specific PCI support. Implemented new PCI Ethernet controller initialization (SPR# 35716) and (SPR# 69775).03w,01oct01,hdn replaced INT_NUM_GET(LPT0_INT_LVL) with INT_NUM_LPT003v,26sep01,pai Added support for dec21x40End driver. Added sysLn97xEnd driver configuration file. Added WindML BSP routines. sysToMonitor() now opens bootrom.sys as RDONLY (SPR 23057).03u,24sep01,pai Updated LPT resource table and macros (SPR 30067).03t,11sep01,hdn renamed XXX_INT_VEC to INT_NUM_XXX as vector no of XXX updated sysIntEoiGet() as APIC's INT_LVL got cleaned up updated CPUID structure for PENTIUM4 removed sysCodeSelector.03s,16aug01,hdn added PENTIUM2/3/4 support03r,15aug01,hdn included iacsfl.h if INCLUDE_IACSFL is defined.03q,15jun00,jkf release floppy disk on reboot(), SPR#3028003p,15jun00,jkf sysPhysMemTop() loop changed to report all found memory.03o,03may00,mks modified sysHwInit and sysToMonitor to support SFL based boot process.03n,07sep99,stv macros for including END driver components are conditioned according to SPR# 26296.03m,21apr99,hdn added conditional tffsDrv.h inclusion (SPR# 26922)03l,12mar99,cn added support for el3c90xEnd driver (SPR# 25327).03k,09mar99,sbs added 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 device configurationmodules and device drivers included are: i8253Timer.c - Intel 8253 timer driver i8259Intr.c - Intel 8259 Programmable Interrupt Controller (PIC) library ioApicIntr.c - Intel IO APIC/xAPIC driver ioApicIntrShow.c - Intel IO APIC/xAPIC driver show routines iPiix4Pci.c - low level initalization code for PCI ISA/IDE Xcelerator loApicIntr.c - Intel Pentium[234] Local APIC/xAPIC driver loApicIntrShow.c - Intel Local APIC/xAPIC driver show routines loApicTimer.c - Intel Pentium2/3/4 Local APIC timer library nullNvRam.c - null NVRAM library nullVme.c - null VMEbus library pccardLib.c - PC CARD enabler library pccardShow.c - PC CARD show library pciCfgStub.c - customizes pciConfigLib for the BSP pciCfgIntStub.c - customizes pciIntLib for the BSP pciConfigLib.c - PCI configuration space access support for PCI drivers pciIntLib.c - PCI shared interrupt support pciConfigShow.c - Show routines for PCI configuration library sysDec21x40End.c - system configuration module for dec21x40End driver sysEl3c509End.c - system configuratin module for elt3c509End driver sysEl3c90xEnd.c - system configuration module for el3c90xEnd driver sysFei82557End.c - system configuration module for fei82557End driver sysGei82543End.c - system configuration module for gei82543End driver sysLn97xEnd.c - system configuration module for ln97xEnd driver sysNe2000End.c - system configuration module for ne2000End driver sysUltraEnd.c - system configuration module for SMC Elite ultraEnd driver sysWindML.c - WindML BSP support routinesINCLUDE FILES: sysLib.hSEE ALSO:.pG "Configuration"*//* includes (header file) */#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 */#ifdef INCLUDE_SMCFDC37B78X# include "drv/multi/smcFdc37b78x.h"# ifndef PRJ_BUILD# include "multi/smcFdc37b78x.c"# endif /* PRJ_BUILD */#endif /* INCLUDE_SMCFDC37B78X */#if defined(INCLUDE_PC_CONSOLE) && defined(INCLUDE_CTB69000VGA)# ifndef PRJ_BUILD# include "video/ctB69000Vga.c"# endif /* PRJ_BUILD */#endif /* INCLUDE_PC_CONSOLE && INCLUDE_CTB69000VGA *//* defines */#define ROM_SIGNATURE_SIZE 16#if (VM_PAGE_SIZE == PAGE_SIZE_4KB)# if (LOCAL_MEM_LOCAL_ADRS >= 0x00100000)# define LOCAL_MEM_SIZE_OS 0x00180000 /* n * VM_PAGE_SIZE */# else# define LOCAL_MEM_SIZE_OS 0x00080000 /* n * VM_PAGE_SIZE */# endif /* (LOCAL_MEM_LOCAL_ADRS >= 0x00100000) */#else /* VM_PAGE_SIZE is 2/4MB */# define LOCAL_MEM_SIZE_OS VM_PAGE_SIZE /* n * VM_PAGE_SIZE */#endif /* (VM_PAGE_SIZE == PAGE_SIZE_4KB) */#if defined (TGT_CPU) && defined (BOOTCODE_IN_RAM)# ifndef FAST_REBOOT# define FAST_REBOOT /* fast reboot */# endif#endif /* defined (TGT_CPU) && defined (BOOTCODE_IN_RAM) *//* * IA-32 protected mode physical address space 4GB (2^32) and protected * mode physical address space extension 64GB (2^36) size constants. */#define SIZE_ADDR_SPACE_32 (0x100000000ull)#define SIZE_ADDR_SPACE_36 (0x1000000000ull)/* maximum address space probed when using memory auto-sizing */#define PHYS_MEM_MAX (SIZE_ADDR_SPACE_32)#define HALF(x) (((x) + 1) >> 1)/* sysPhysMemTop() memory test patterns */#define TEST_PATTERN_A (0x57696E64)#define TEST_PATTERN_B (0x52697665)#define TEST_PATTERN_C (0x72537973)#define TEST_PATTERN_D (0x74656D73)/* imports */IMPORT char end; /* linker defined end-of-image */IMPORT GDT sysGdt[]; /* the global descriptor table */IMPORT void elcdetach (int unit);IMPORT VOIDFUNCPTR intEoiGet; /* BOI/EOI function pointer */IMPORT void intEnt (void);IMPORT int sysCpuProbe (void); /* set a type of CPU family */IMPORT VOID sysUsbOhciPciInit (void); /* USB OHCI Init *//* include rtl81x9End driver support routines */#ifdef INCLUDE_RTL_81X9_ENDIMPORT STATUS sysRtl81x9PciInit (void);#endif /* INCLUDE_RTL_81X9_END *//* include dm9102 End driver support routines */#ifdef INCLUDE_DM_9102_ENDIMPORT STATUS sysDm9102PciInit (void);#endif /* INCLUDE_DM_9102_END *//* globals */PHYS_MEM_DESC sysPhysMemDesc [] = { /* adrs and length parameters must be page-aligned (multiples of 4KB/4MB) */#if (VM_PAGE_SIZE == PAGE_SIZE_4KB) /* * Defining _WRS_BSP_DEBUG_NULL_ACCESS for debugging configuration. * Doing so explicitly marks some lower memory invalid. * Any code access to the invalid address range will generate * a MMU exception and the offending task will be suspended. * Then use l(), lkAddr, ti(), and tt() to find the NULL access. * Defining _WRS_BSP_DEBUG_NULL_ACCESS adds an entry to the front * of the sysPhysMemDesc[] array. Any code which alters this table * will need adjustment (for example: sysPhysMemTop() is altered * to account for another entry into the sysPhysMemDesc[] array * when _WRS_BSP_DEBUG_NULL_ACCESS is defined. */ /* lower memory for invalid access */ { (void *) 0x0, (void *) 0x0, _WRS_BSP_VM_PAGE_OFFSET,# ifdef _WRS_BSP_DEBUG_NULL_ACCESS VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE, VM_STATE_VALID_NOT | VM_STATE_WRITABLE_NOT | VM_STATE_CACHEABLE_NOT# else VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_OS# endif /* _WRS_BSP_DEBUG_NULL_ACCESS */ }, /* lower memory for valid access */ { (void *) _WRS_BSP_VM_PAGE_OFFSET, (void *) _WRS_BSP_VM_PAGE_OFFSET, 0xa0000 - _WRS_BSP_VM_PAGE_OFFSET, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_MEM_OS }, /* video ram, etc */ { (void *) 0x000a0000, (void *) 0x000a0000, 0x00060000, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO },# if (LOCAL_MEM_LOCAL_ADRS >= 0x00100000)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -