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

📄 syslib.c

📁 VxWorks 5.4嵌入式操作系统, Tornado II开发平台BSP包的移植
💻 C
📖 第 1 页 / 共 3 页
字号:
/* sysLib.c - PC 386/486 system-dependent library */

/* Copyright 1984-1996 Wind River Systems, Inc. */
#include "copyright_wrs.h"

/*
modification history
--------------------
02x,17mar98,sbs  using macro for dummy mmu entry.
                 added forward declaration for sysMmuMapAdd().
                 changed sysIntIdtType and sysWarmType to use macros.  
                 documentation update.
02y,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().
02x,02mar98,sbs  removed device specific mmu entries and added dynamic entries
                 in sysPhysMemDesc table.
                 added sysMmuMapAdd().
                 added initialization of sysPhysMemDescNumEnt in sysHwInit().
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 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 - 
    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
    

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"

#ifdef	INCLUDE_8472
#include "d:\wj\new\hdlc\bt8472.c"
#endif
/* To make man pages for network support routines */

#ifdef  DOC
#define INCLUDE_EEX32
#define INCLUDE_FEI
#endif

/* imports */
IMPORT	void sys8474PciInit();
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);

/* forward declarations */

char *sysPhysMemTop (void);
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
    },

    /* entries for dynamic mappings - create sufficient entries */
#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

    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,
    DUMMY_MMU_ENTRY,

    };

int sysPhysMemDescNumEnt; 	/* number Mmu entries to be mapped */

#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	= SYS_INT_TRAPGATE; /* IDT entry type */
UINT	sysProcessor	= NONE;		/* 0=386, 1=486, 2=Pentium */
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    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 */

LOCAL void sysStrayInt		(void);
#if	FALSE  /* they are called at entry and exit of intVecSet() */ 
LOCAL void sysIntVecSetEnt	(FUNCPTR *vector, FUNCPTR function);
LOCAL void sysIntVecSetExit	(FUNCPTR *vector, FUNCPTR function);

⌨️ 快捷键说明

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