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

📄 syslib.c

📁 VxWorks 5.4嵌入式操作系统, Tornado II开发平台BSP包的移植
💻 C
📖 第 1 页 / 共 3 页
字号:
#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/pciConfigLib.c"
#   include "pci/pciIntLib.c"
#   ifdef	INCLUDE_SHOW_ROUTINES
#	include "pci/pciConfigShow.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 */
#include "sysScsi.c"		/* scsi 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)
    {
    PHYS_MEM_DESC *pMmu;
    int ix = 0;

#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 number of active mappings (sysPhysMemDescNumEnt) */

    pMmu = &sysPhysMemDesc[0];

    for (ix = 0; ix < NELEMENTS (sysPhysMemDesc); ix++) 
        if (pMmu->virtualAddr != (void *)DUMMY_VIRT_ADDR)
            pMmu++;
        else
            break;

    sysPhysMemDescNumEnt = ix;

    /* initialize the PIC (Programmable Interrupt Controller) */

    sysIntInitPIC ();

    /* initialize PCI and related devices */

#ifdef  INCLUDE_PCI

    pciConfigLibInit (PCI_MECHANISM_1, PCI_CONFIG_ADDR, PCI_CONFIG_DATA, NONE);
    pciIntLibInit ();

    /* 
     * PCI-to-PCI bridge initialization should be done here, if it is.
     * It is not necessary for Intel 430HX PCISET, which splits
     * the extended memory area as follows:
     *   - Flash BIOS area from 4GByte to (4GB - 512KB)
     *   - DRAM memory from 1MB to a maximum of 512MB
     *   - PCI memory space from the top of DRAM to (4GB - 512KB)
     */

#ifdef	INCLUDE_FRAME
		sys8474PciInit();
#endif

#ifdef  INCLUDE_FEI
    sys557PciInit ();
#endif  /* INCLUDE_FEI */


#ifdef INCLUDE_SCSI
#ifdef  INCLUDE_AIC_7880
    sysAic7880PciInit ();
#endif  /* INCLUDE_AIC_7880 */
#endif  /* INCLUDE_SCSI */

#endif /* INCLUDE_PCI */


    /* set the global function pointer to sysIntEOI() */

    intEOI		= sysIntEOI;

#if	FALSE   /* they are called at entry and exit of intVecSet() */
    intVecSetEnt	= sysIntVecSetEnt;	/* entry hook for intVecSet() */
    intVecSetExit	= sysIntVecSetExit;	/* exit  hook for intVecSet() */
#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;
    BOOL found		= FALSE;
    PHYS_MEM_DESC *pMmu;
    int temp[N_TIMES];
    char gdtr[6];
    char *p;
    int ix;

    if (memTop != NULL)
	return (memTop);

    /* if (&end) is in upper memory, we assume it is VxWorks image.
     * if not, it is Boot image */

    if ((int)&end > 0x100000)
        p = (char *)(((int)&end + (delta - 1)) & (~ (delta - 1)));
    else
	p = (char *)0x100000;

    /* find out the actual size of the memory (max 1GB) */

    for (; (int)p < 0x40000000; p += delta)
	{
	for (ix=0; ix<N_TIMES; ix++)			/* save and write */
	    {
	    temp[ix] = *((int *)p + ix);
	    *((int *)p + ix) = TEST_PATTERN;
	    }
	cacheFlush (DATA_CACHE, p, 4 * sizeof(int));	/* for 486, Pentium */

	if (*(int *)p != TEST_PATTERN)			/* compare */
	    {
	    p -= delta;
	    if (delta == VM_PAGE_SIZE)
		{
                memTop = p;
	        found = TRUE;
	        break;
		}
	    delta = VM_PAGE_SIZE;
	    }

	for (ix=0; ix<N_TIMES; ix++)			/* restore */
	    *((int *)p + ix) = temp[ix];
	}
    
    if (!found)		/* we are fooled by write-back external cache */
        memTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);

    /* copy the global descriptor table from RAM/ROM to RAM */

    bcopy ((char *)sysGdt, (char *)pSysGdt, GDT_ENTRIES * sizeof(GDT));
    *(short *)&gdtr[0]	= GDT_ENTRIES * sizeof(GDT) - 1;
    *(int *)&gdtr[2]	= (int)pSysGdt;

/* 
 * We assume that there are no memory mapped IO addresses
 * above the "memTop" if INCLUDE_PCI is not defined.
 * Thus we set the "limit" to get the General Protection Fault
 * when the memory above the "memTop" is accessed.
 */

#ifndef	INCLUDE_PCI
    {
    GDT *pGdt = pSysGdt;
    int limit = (((int)memTop) / 0x1000 - 1);

    for (ix=1; ix < GDT_ENTRIES; ix++)
	{
	pGdt++;
	pGdt->limit00 = limit & 0x0ffff;
	pGdt->limit01 = ((limit & 0xf0000) >> 16) | (pGdt->limit01 & 0xf0);
	}
    }
#endif	/* INCLUDE_PCI */

    /* load the global descriptor table. set the MMU table */

    sysLoadGdt (gdtr);
    pMmu = &sysPhysMemDesc[2];		/* upper memory */
    pMmu->len = (UINT)memTop - (UINT)pMmu->physicalAddr;

    memTopPhys = memTop;		/* set the real memory size */
    
    return (memTop);
    }


/*******************************************************************************
*
* sysMemTop - get the address of the top of VxWorks memory
*
* This routine returns a pointer to the first byte of memory not
* controlled or used by VxWorks.
*
* The user can reserve memory space by defining the macro USER_RESERVED_MEM
* in config.h.  This routine returns the address of the reserved memory
* area.  The value of USER_RESERVED_MEM is in bytes.
*
* RETURNS: The address of the top of VxWorks memory.
*/

char * sysMemTop (void)
    {
    static char * memTop = NULL;

    if (memTop == NULL)
        {
        memTop = sysPhysMemTop () - USER_RESERVED_MEM;

        if ((int)&end < 0x100000)		/* this is for bootrom */
            memTop = (char *)0xa0000;
        }

    return (memTop);
    }


/*******************************************************************************
*
* sysToMonitor - transfer control to the ROM monitor
*
* This routine transfers control to the ROM monitor.  It is usually called
* only by reboot() -- which services ^X -- and by bus errors at interrupt
* level.  However, in some circumstances, the user may wish to introduce a
* new <startType> to enable special boot ROM facilities.
*
* RETURNS: Does not return.
*/

STATUS sysToMonitor
    (
    int startType   /* passed to ROM to tell it how to boot */
    )
    {
    FUNCPTR pEntry;
    int ix;
    int iy;
    int iz;
    char buf[ROM_SIGNATURE_SIZE];
    short *pSrc;
    short *pDst;

    VM_ENABLE (FALSE);			/* disbale MMU */

⌨️ 快捷键说明

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