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

📄 syslib.c

📁 vxworks的BSP开发配置文件
💻 C
📖 第 1 页 / 共 3 页
字号:
* sysHwInit2 - additional system configuration and initialisation** This routine connects system interrupts and does any additional* configuration necessary.** RETURNS: N/A** NOMANUAL*/void sysHwInit2 (void)    {    /* initialise the interrupt library and interrupt driver */    DEBUG_LED(8);    intLibInit (IXM1200_INT_NUM_LEVELS, IXM1200_INT_NUM_VECTORS, INT_MODE);    ixm1200IntDevInit();    DEBUG_LED(9);    /* connect sys clock interrupt and auxiliary clock interrupt */    intConnect (INUM_TO_IVEC (SYS_TIMER_INT_LVL), sysClkInt, 0);    intConnect (INUM_TO_IVEC (AUX_TIMER_INT_LVL), sysAuxClkInt, 0);    /* Fix B0 PCI problem */#if defined(INCLUDE_PCI) && defined(INCLUDE_HPC)    if (sysCpuRev == 1)        sysPciFix();#endif    /*     * Initialize HPC driver     * Note that this must occur before sysSerialHwInit2 if HPC serial     * ports are being used.     */#ifdef INCLUDE_HPC    if (!(sysStartType & BOOT_DONT_INIT_HPC)) {        IXM1200_PCI_REG_WRITE(IXM1200_DBELL_PCI_MASK, 0);        IXM1200_PCI_REG_WRITE(IXM1200_DBELL_SA_MASK,  0);        intConnect((void*)INT_VEC_DFH, pciInt, INT_VEC_DFH);        hpcSysInit(0);        intEnable(INT_VEC_DFH);    } else {        intConnect((void*)INT_VEC_DFH, pciInt, INT_VEC_DFH);        hpcSysInit(1);        intEnable(INT_VEC_DFH);    }#endif#if defined (INCLUDE_SERIAL)    /* connect serial interrupt */    sysSerialHwInit2();#endif#if defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL)    /* These need to be set up for the case of a bootROM image     * where the standard libraries do not set these values, but     * the ethernet controller (dec21x4x) needs them.     */    cacheDmaFuncs.virtToPhysRtn = (FUNCPTR) sysVirtToPhys;    cacheDmaFuncs.physToVirtRtn = (FUNCPTR) sysPhysToVirt;#endif    /* Initialize other drivers here */#if defined (INCLUDE_PCI)    if (sysPciIsCentralFunc()) {        intConnect((void*)INT_VEC_PIL, pciInt, INT_VEC_PIL);        intEnable(INT_VEC_PIL);    }#endif    /* DEBUG_LED(0xA); */    sysLedsReadWrite(0x0,0xA); /* Set LED to A */    return;    }/********************************************************************************* 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 memory.** Normally, the user specifies the amount of physical memory with the* macro LOCAL_MEM_SIZE in config.h.  BSPs that support run-time* memory sizing do so only if the macro LOCAL_MEM_AUTOSIZE is defined.* If not defined, then LOCAL_MEM_SIZE is assumed to be, and must be, the* true size of physical memory.** NOTE: Do not adjust LOCAL_MEM_SIZE to reserve memory for application* use.  See sysMemTop() for more information on reserving memory.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/char * sysPhysMemTop (void)    {    static char * physTop = NULL;    if (physTop == NULL)        {#ifdef LOCAL_MEM_AUTOSIZE	/* If auto-sizing is possible, this would be the spot.  */#	error   "Dynamic memory sizing not supported"#else	/* Don't do autosizing, if size is given */	physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */	}    return physTop;    }/********************************************************************************* 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;	}    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 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 */    )    {    UINT32 *    p = (UINT32 *)ROM_TEXT_ADRS;#if defined(INCLUDE_FEI82557END) || defined(INCLUDE_DEC21X40END)    END_OBJ * pEnd;#endif    DEBUG_LED(4);#if defined(INCLUDE_SERIAL)    sysSerialReset ();	/* put serial devices into quiet state */#endif    /* Reset microengines and macs */    IXM1200_PCI_REG_WRITE(IXM1200_RESET, RESET_MICROENGINE | RESET_EXTERNAL);#if defined(INCLUDE_DEC21X40END)    /*     * If the Ethernet driver were left alone, the controller chip might     * alter memory, so we stop the controller before jumping to the bootrom.     */        if( (pEnd = endFindByName ("dc", 0)) )            pEnd->pFuncTable->stop(pEnd->devObject.pDevice);#endif /* INCLUDE_DEC21X40END */#if defined(INCLUDE_FEI82557END)    /*     * If the Ethernet driver were left alone, the controller chip might     * alter memory, so we stop the controller before jumping to the bootrom.     */        if( (pEnd = endFindByName ("fei", 0)) )            pEnd->pFuncTable->stop(pEnd->devObject.pDevice);#endif /* INCLUDE_FEI82557END */    /*     * Examine ROM - if it's a VxWorks boot ROM, jump to the warm boot     * entry point; otherwise hang (we don't attempt to remap the machine     * to find the Primary Boot Loader).     * A VxWorks boot ROM begins     *    MOV   R0,#BOOT_COLD     *    B     ...     *    DCB   "Copyright"     * We check the first and third words only. This could be tightened up     * if required (see romInit.s).     *     * Note that the MMU must stay on.     */    /*     * Note that only p[2] is possibly swapped because it is byte data and     * not longword data.     */    if (p[0] != 0xE3A00002 || p[2] != SWAP32PCI(0x79706F43))	{	while (TRUE)	    /* do nothing */ ;	}    /* Don't clobber registers when we reboot */    startType |= BOOT_DONT_INIT_HPC | BOOT_DONT_INIT_PCI;    /* Actually jump to ROM, first we have to turn off the MMU */    /* transition routine address */    sysToRomInit(startType);			/* jump to bootrom */    return OK;		/* in case we ever continue from ROM monitor */    }/****************************************************************************** sysProcNumGet - get the processor number** This routine returns the processor number for the CPU board, which is* set with sysProcNumSet().** RETURNS: The processor number for the CPU board.** SEE ALSO: sysProcNumSet()*/int sysProcNumGet (void)    {    return 0;    }/****************************************************************************** sysProcNumSet - set the processor number** Set the processor number for the CPU board.  Processor numbers should be* unique on a single backplane.** NOTE* By convention, only processor 0 should dual-port its memory.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet    (    int procNum		/* processor number */    )    {    sysProcNum = procNum;    }/******************************************************************************** sysLedsReadWrite - read/write the state of the LEDs on the IXM1200 board** This routine can be used to read and write the state of the debug LEDs* on the IXM1200 board. The current state is ANDed and EORed with the* supplied parameters. Bits 0..3 control the LEDs. The current state appears* as a  hexadecimal digit on the LED.** RETURNS: previous state of LEDs.*/int sysLedsReadWrite    (    int and,    int eor    )    {    static UINT8 current = 0;    int oldLevel, previous;    oldLevel = intLock ();	 /* no interrupts during read-modify-write */    /*     * Read current state, remove old bit and insert new one.     * Note the extra '^', necessary because a 1 => OFF, 0 => ON     */    previous = current;    current = ((current & and) ^ eor) & 0xF;    IXM1200_REG_WRITE(IXM1200_LED_ADDR, current);    intUnlock (oldLevel);    return previous;    }/********************************************************************************* sysMmuMapAdd - Add entries to sysPhysMemDesc** This routine adds mapping entries to sysPhysMemDesc.** Add the entry {addr, addr, len, mask, state} to sysPhysMemDesc.** RETURNS:*   OK or ERROR*/STATUS sysMmuMapAdd    (    void *addr,      /* Virtual and physical address of region */    UINT len,        /* Length of region */    UINT mask,       /* Initial State mask */    UINT state       /* Initial State */    ){    if (sysPhysMemDescNumEnt < sysPhysMemDescNumEntMax) {        sysPhysMemDesc[sysPhysMemDescNumEnt].virtualAddr = addr;        sysPhysMemDesc[sysPhysMemDescNumEnt].physicalAddr = addr;        sysPhysMemDesc[sysPhysMemDescNumEnt].len = ROUND_UP(len, PAGE_SIZE);        sysPhysMemDesc[sysPhysMemDescNumEnt].initialStateMask = mask;        sysPhysMemDesc[sysPhysMemDescNumEnt].initialState = state;        sysPhysMemDescNumEnt++;        return OK;    } else {        return ERROR;    }}/********************************************************************************* sysMemVirtSize - get sizes of virtual memory regions** This routine returns sizes of virtual memory regions.** SYS_ALL is the actual amount of memory mapped to virtual address* zero from the SDRAM. Some amount of the top end of this may be* reserved by users, so the amount actually available to VxWorks* is given by SYS. The size SDRAM which is available to the HW and* not used by VxWorks (mapped with virt addr == phys addr) is given* by SDRAM.** RETURNS: N/A*/void sysMemVirtSize    (    unsigned int* sys,       /* Size of memory mapped at zero for VxWorks */    unsigned int* sys_all,   /* Size of memory mapped at zero and usable by VxWorks */    unsigned int* sdram,     /* Size of memory mapped at C0000000 and usable by HW */    unsigned int* sram,      /* Size of sram */    unsigned int* flash      /* Size of Flash */    ){    /* Size of memory mapped at zero for VxWorks */    *sys_all = LOCAL_MEM_SIZE;    /* Size of memory mapped at zero and usable by VxWorks */    *sys = LOCAL_MEM_SIZE - USER_RESERVED_MEM;    /* Size of memory mapped at C0000000 and usable by HW */    *sdram = RESERVED_LOW_MEM;    /* Size of sram */    *sram = SRAM_SIZE;    /* Size of Flash */    *flash = (ROM_BASE_ADRS + ROM_SIZE_TOTAL - ROM_VIRT_OFFSET);}

⌨️ 快捷键说明

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