📄 syslib2.c
字号:
/* sysLib.c - PC 386/486 system-dependent library */
/* Copyright 1984-1996 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
02x,06jan98,hdn included tffsDrv.h.
02w,15dec97,hdn added support for warm start from TFFS device.
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 NONE
02f,14jun96,hdn added support for PCI bus.
02e,28may96,hdn renamed PIT_INT_xxx to PIT0_INT_xxx.
02d,28sep95,dat new BSP revision id
02c,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.c
01z,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.
*/
/*
DESCRIPTION
This library provides board-specific routines. The chip drivers included are:
i8250Sio.c - Intel 8250 UART tty driver
i8253Timer.c - Intel 8253 timer driver
i8259Pic.c - Intel 8259 Programmable Interrupt Controller (PIC) library
nullNvRam.c - null NVRAM library
nullVme.c - null VMEbus library
if_eex32.c -
pciTomapLib.c -
pciTomapShow.c -
INCLUDE FILES: sysLib.h
SEE 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/mmuI86Lib.h"
#include "tffs/tffsDrv.h"
#include "d:\wj\new\hdlc\bt8472.c"
/* To make man pages for network support routines */
#ifdef DOC
#define INCLUDE_EEX32
#define INCLUDE_FEI
#endif
/* imports */
IMPORT char end; /* end of system, created by ld */
IMPORT GDT sysGdt[]; /* the global descriptor table */
IMPORT VOIDFUNCPTR intEOI; /* pointer to a function sysIntEOI() */
IMPORT VOIDFUNCPTR intVecSetEnt; /* entry hook for intVecSet() */
IMPORT VOIDFUNCPTR intVecSetExit; /* exit hook for intVecSet() */
IMPORT void elcdetach (int unit);
IMPORT void ultradetach (int unit);
STATUS sysMmuMapAdd(void *address, UINT len, UINT initialStateMask,
UINT initialState);
/* globals */
PHYS_MEM_DESC sysPhysMemDesc [] =
{
/* adrs and length parameters must be page-aligned (multiples of 0x1000) */
/* lower memory */
{
(void *) LOCAL_MEM_LOCAL_ADRS,
(void *) LOCAL_MEM_LOCAL_ADRS,
0xa0000,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE
},
/* video ram, etc */
{
(void *) 0xa0000,
(void *) 0xa0000,
0x60000,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
/* upper memory */
{
(void *) 0x100000,
(void *) 0x100000,
LOCAL_MEM_SIZE - 0x100000, /* it is changed in sysMemTop() */
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE
},
#ifdef INCLUDE_PCI
{
(void *) FEI0_MEMBASE0,
(void *) FEI0_MEMBASE0,
FEI0_MEMSIZE0,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
{
(void *) FEI1_MEMBASE0,
(void *) FEI1_MEMBASE0,
FEI1_MEMSIZE0,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
{
(void *) FEI2_MEMBASE0,
(void *) FEI2_MEMBASE0,
FEI2_MEMSIZE0,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
{
(void *) FEI3_MEMBASE0,
(void *) FEI3_MEMBASE0,
FEI3_MEMSIZE0,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
#endif /* INCLUDE_PCI */
#ifdef INCLUDE_8472
{
(void *) BT_MEMBASE0,
(void *) BT_MEMBASE0,
BT_MEMSIZE0,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
{
(void *) BT_MEMBASE1,
(void *) BT_MEMBASE1,
BT_MEMSIZE1,
VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT
},
#endif
};
int sysPhysMemDescNumEnt = NELEMENTS (sysPhysMemDesc);
#ifdef INCLUDE_PC_CONSOLE
PC_CON_DEV pcConDv [N_VIRTUAL_CONSOLES] =
{
{{{{NULL}}}, FALSE, NULL, NULL},
{{{{NULL}}}, FALSE, NULL, NULL}
};
#endif /* INCLUDE_PC_CONSOLE */
#ifdef INCLUDE_FD
IMPORT 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_IDE
IMPORT STATUS usrIdeConfig (int drive, char *fileName);
IDE_TYPE ideTypes[] =
{
{761, 8, 39, 512, 0xff}, /* drive 0 */
{0, 0, 0, 0, 0} /* drive 1 */
};
#endif /* INCLUDE_IDE */
#ifdef INCLUDE_ATA
IMPORT 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 */
};
#endif /* INCLUDE_ATA */
#ifdef INCLUDE_LPT
LPT_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 = 0x0000ef00; /* trap gate, 0x0000ee00=int gate */
UINT sysProcessor = NONE; /* 0=386, 1=486, 2=Pentium */
UINT sysCoprocessor = 0; /* 0=none, 1=387, 2=487 */
int sysWarmType = SYS_WARM_TYPE; /* 0=BIOS, 1=FD, 2=ATA, 3=TFFS */
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 sysVectorIRQ0 = INT_NUM_IRQ0; /* vector number for IRQ0 */
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 */
/* locals */
LOCAL short *sysRomBase[] =
{
(short *)0xce000, (short *)0xce800, (short *)0xcf000, (short *)0xcf800
};
#define ROM_SIGNATURE_SIZE 16
LOCAL char sysRomSignature[ROM_SIGNATURE_SIZE] =
{
0x55,0xaa,0x01,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
};
/* forward declarations */
char *sysPhysMemTop (void);
LOCAL void sysStrayInt (void);
#if FALSE
LOCAL void sysIntVecSetEnt (FUNCPTR *vector, FUNCPTR function);
LOCAL void sysIntVecSetExit (FUNCPTR *vector, FUNCPTR function);
#endif /* FALSE */
#include "intrCtl/i8259Pic.c"
#include "mem/nullNvRam.c"
#include "vme/nullVme.c"
#include "sysSerial.c"
#include "timer/i8253Timer.c" /* includes timestamp driver */
#ifdef INCLUDE_PCI
# include "pci/pciIomapLib.c"
# ifdef INCLUDE_SHOW_ROUTINES
# include "pci/pciIomapShow.c"
# endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_PCI */
#ifdef INCLUDE_PCMCIA
# include "pcmcia/pccardLib.c"
# include "pcmcia/pccardShow.c"
#endif /* INCLUDE_PCMCIA */
#include "sysNetif.c" /* network driver support */
/*******************************************************************************
*
* sysModel - return the model name of the CPU board
*
* This routine returns the model name of the CPU board.
*
* RETURNS: A pointer to the string "PC 386" or "PC 486".
*/
char *sysModel (void)
{
#if CPU==I80486
return ("PC 486");
#else
return ("PC 386");
#endif /* CPU==I80486 */
}
/*******************************************************************************
*
* 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 i386/i486 board.
* It is called from usrInit() in usrConfig.c.
*
* NOTE: This routine should not be called directly by the user application.
*
* RETURNS: N/A
*/
void sysHwInit (void)
{
#ifdef INCLUDE_IDE
{
IMPORT int ideWdSec;
IMPORT int ideSemSec;
ideWdSec = 5; /* 5 seconds to timeout initialize */
ideSemSec = 5; /* 5 seconds to timeout each IDE command */
}
#endif /* INCLUDE_IDE */
/* initialize the PIC (Programmable Interrupt Controller) */
sysIntInitPIC ();
/* set the global function pointer to sysIntEOI() */
intEOI = sysIntEOI;
#if FALSE
intVecSetEnt = sysIntVecSetEnt;
intVecSetExit = sysIntVecSetExit;
#endif /* FALSE */
/* initializes the serial devices */
sysSerialHwInit (); /* initialize serial data structure */
}
/*******************************************************************************
*
* sysHwInit2 - additional system configuration and initialization
*
* This routine connects system interrupts and does any additional
* configuration necessary.
*
* RETURNS: N/A
*/
void sysHwInit2 (void)
{
/* connect sys clock interrupt and auxiliary clock interrupt*/
(void)intConnect (INUM_TO_IVEC (PIT0_INT_VEC), sysClkInt, 0);
(void)intConnect (INUM_TO_IVEC (RTC_INT_VEC), sysAuxClkInt, 0);
/* connect serial interrupt */
sysSerialHwInit2();
/* connect stray interrupt XXX */
(void)intConnect (INUM_TO_IVEC(LPT_INT_VEC), sysStrayInt, 0);
#ifdef INCLUDE_PC_CONSOLE
/* connect keyboard Controller 8042 chip interrupt */
(void) intConnect (INUM_TO_IVEC (KBD_INT_VEC), kbdIntr, 0);
#endif /* INCLUDE_PC_CONSOLE */
}
/*******************************************************************************
*
* sysPhysMemTop - get the address of the top of physical memory
*
* This routine returns the address of the first missing byte of memory,
* which indicates the top of physical memory.
*
* Memory probing begins at the end of BSS; at every 4K boundary a byte
* is read until it finds one that cannot be read, or 4MB have been probed,
* whichever is first.
*
* RETURNS: The address of the top of physical memory.
*
* INTERNAL
* This routine is used by sysHwInit() to differentiate between models.
* It is highly questionable whether vxMemProbe() can be used during the
* initial stage of booting.
*/
char *sysPhysMemTop (void)
{
#define TEST_PATTERN 0x12345678
#define SYS_PAGE_SIZE 0x10000
#define N_TIMES 3
static char *memTop = NULL; /* top of memory */
int delta = SYS_PAGE_SIZE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -