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

📄 syslib.c

📁 Vxworks下BSP源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#error CPU not supported#endif /* (CPU == ARMARCH4) */#else /*(_BYTE_ORDER == _LITTLE_ENDIAN)*/#if   (CPU == ARMARCH4)    return    "AT91Arm9 - ARM920T (ARM) Big Endian";#elif (CPU == ARMARCH4_T)    return    "AT91Arm9 - ARM920T (Thumb) Big Endian";#else#error CPU not supported#endif /* (CPU == ARMARCH4) */#endif /*(_BYTE_ORDER == _LITTLE_ENDIAN)*/    }/******************************************************************************** sysBspRev - return the bsp version with the revision eg 1.1/<x>** This function returns a pointer to a bsp version with the revision.* for eg. 1.1/<x>. BSP_REV is concatenated to BSP_VERSION to form the* BSP identification string.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev (void)    {    return (BSP_VERSION BSP_REV);    }/******************************************************************************** sysHwInit - initialize the CPU board hardware** This routine initializes various features of the hardware.* Normally, it is called from usrInit() in usrConfig.c.** NOTE: This routine should not be called directly by the user.** RETURNS: N/A*/void sysHwInit (void)    {	/*	excVectInst();*/ 	    /* install the IRQ/SVC interrupt stack splitting routine */    _func_armIntStackSplit = sysIntStackSplit;#if 0    sysLcdInit(); /* initialize the LCD panel */    sysLcdWriteString("   WindRiver    ", 1, 1);#if (_BYTE_ORDER == _LITTLE_ENDIAN)#if   (CPU == ARMARCH4)    sysLcdWriteString("   SBC ARM7     ", 2, 1);#else  /* ARMARCH4 */    sysLcdWriteString("   SBC ARM7 (t) ", 2, 1);#endif  /* ARMARCH4 */#else /* (_BYTE_ORDER == _LITTLE_ENDIAN) */#if   (CPU == ARMARCH4)    sysLcdWriteString("  SBC ARM7 (BE) ", 2, 1);#else  /* ARMARCH4 */    sysLcdWriteString("  SBC ARM7 (tBE)", 2, 1);#endif  /* ARMARCH4 */#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */    sysLedInit(); /* initialize the LED */#endif#ifdef  FORCE_DEFAULT_BOOT_LINE    strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);#elif defined INCLUDE_VWARE_LAUNCH    sysVwareBuildBootLine((char*)&sysAt91cMacAddr);#endif /* FORCE_DEFAULT_BOOT_LINE */   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** NOMANUAL** Note: this is called from sysClkConnect() in the timer driver.*/void sysHwInit2 (void)    {    /* initialize the interrupt library and interrupt driver */    intLibInit (AT91C_INTNUMLEVELS, AT91C_INTNUMLEVELS, INT_MODE);    at91cIntDevInit();    /* connect sys clock interrupt and auxiliary clock interrupt *//*Add to serial int*//*   (void)intConnect (INUM_TO_IVEC (INT_VEC_SYSIRQ), sysClkInt, 0);*/	/*sys interrupt *//*    (void)intConnect (INUM_TO_IVEC (INT_VEC_TIMER1), sysAuxClkInt, 0);*//*it is my define*/    /* connect serial interrupt */	sysSerialHwInit2();#ifdef INCLUDE_USB    /* Low level init for usb */    sysUsbPciInit();#endif/*myDelay();*/    }/******************************************************************************** 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 no 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 */    )    {    FUNCPTR     pRom;    UINT32 *    p = (UINT32 *)ROM_TEXT_ADRS;#ifdef INCLUDE_AT91C_END    END_OBJ *   pEnd;#endif#ifdef INCLUDE_CACHE_SUPPORT/*/    sngks32cCacheDisable();*/#endif /* INCLUDE_CACHE_SUPPORT */    /*     * Examine ROM - if it's a VxWorks boot ROM, jump to the warm boot entry     * point; otherwise jump to the start of the ROM.     * 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).     */#if (_BYTE_ORDER == _LITTLE_ENDIAN)    if (p[0] == 0xE3A00002 && p[2] == 0x79706F43)        pRom = (FUNCPTR)(ROM_TEXT_ADRS + 4);    /* warm boot address */    else        pRom = (FUNCPTR)ROM_TEXT_ADRS;        /* start of ROM */#else /* (_BYTE_ORDER == _LITTLE_ENDIAN) */    if (p[0] == 0xE3A00002 && p[2] == 0x436F7079)        pRom = (FUNCPTR)(ROM_TEXT_ADRS + 4);    /* warm boot address */    else        pRom = (FUNCPTR)ROM_TEXT_ADRS;        /* start of ROM */#endif /* (_BYTE_ORDER == _LITTLE_ENDIAN) */#ifdef INCLUDE_AT91C_END    /*     * Reset Ethernet controller to prevent it doing anything     * before jumping to the bootrom.     */    pEnd = endFindByName ("atm", 0);    if (pEnd != NULL)        pEnd->pFuncTable->stop(pEnd->devObject.pDevice);#endif /* INCLUDE_AT91C_END */    (*pRom)(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;    }#ifdef INCLUDE_FLASH/* default procedures assume static ram with no special r/w routines */#ifndef NV_RAM_WR_ENBL#   define NV_RAM_WR_ENBL    /* no write enable procedure */#endif /*NV_RAM_WR_ENBL*/#ifndef NV_RAM_WR_DSBL#   define NV_RAM_WR_DSBL    /* no write disable procedure */#endif /*NV_RAM_WR_DSBL*/#ifndef NV_RAM_READ#   define NV_RAM_READ(x) \    (*(UCHAR *)((int)NV_RAM_ADRS + ((x) * NV_RAM_INTRVL)))#endif /*NV_RAM_READ*/#ifndef NV_RAM_WRITE#   define NV_RAM_WRITE(x,y) \    (*(UCHAR *)((int)NV_RAM_ADRS + ((x) * NV_RAM_INTRVL)) = (y))#endif /*NV_RAM_WRITE*/    /******************************************************************************** sysNvRamGet - get the contents of non-volatile RAM** This routine copies the contents of non-volatile memory into a specified* string.  The string is terminated with an EOS.** RETURNS: OK, or ERROR if access is outside the non-volatile RAM range.** SEE ALSO: sysNvRamSet()*/STATUS sysNvRamGet    (    char *string,    /* where to copy non-volatile RAM    */    int   strLen,      /* maximum number of bytes to copy   */    int   offset       /* byte offset into non-volatile RAM */    )    {    STATUS retVal;    offset += NV_BOOT_OFFSET;   /* boot line begins at <offset> = 0 */    if ((offset < 0)     || (strLen < 0)     || ((offset + strLen) > NV_RAM_SIZE))        return (ERROR);    retVal = sysFlashGet (string, strLen, offset);    string [strLen] = EOS;    return (OK);    }/******************************************************************************** sysNvRamSet - write to non-volatile RAM** This routine copies a specified string into non-volatile RAM.** RETURNS: OK, or ERROR if access is outside the non-volatile RAM range.** SEE ALSO: sysNvRamGet()*/STATUS sysNvRamSet    (    char *string,     /* string to be copied into non-volatile RAM */    int strLen,       /* maximum number of bytes to copy           */    int offset        /* byte offset into non-volatile RAM         */    )    {    offset += NV_BOOT_OFFSET;   /* boot line begins at <offset> = 0 */    if ((offset < 0)     || (strLen < 0)     || ((offset + strLen) > NV_RAM_SIZE))        return ERROR;    NV_RAM_WR_ENBL;    return (sysFlashSet (string, strLen, offset));    }/******************************************************************************** sysFlashBoardDelay - create a delay** This routine is used by flashMem.c to produce specified delays. It* appears that the Flash driver cannot use taskDelay() at certain* points.** RETURNS: N/A*/void sysFlashBoardDelay (void)    {    return;    }#endif /* INCLUDE_FLASH */#ifdef DEBUG/******************************************************************************** sysDebug - print message using polled serial driver** Use the polled driver to print debug messages.  Useful before the full* hardware initialization is complete (but only after sysHwInit).** RETURNS: N/A.** NOMANUAL*/void sysDebug    (    char *str    )    {    int msgSize;    int msgIx;    LOCAL SIO_CHAN * pSioChan;        /* serial I/O channel */    LOCAL BOOL beenHere = FALSE;    msgSize = strlen (str);    if (!beenHere)        {        sysSerialHwInit ();        pSioChan = sysSerialChanGet (0);        sioIoctl (pSioChan, SIO_BAUD_SET, (void *)CONSOLE_BAUD_RATE);        sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);        beenHere = TRUE;	}    for (msgIx = 0; msgIx < msgSize; msgIx++)        {        while (sioPollOutput (pSioChan, str[msgIx]) == EAGAIN)            /* do nothing */;        }    }#endif /* DEBUG */#if 0void excVectInst(void){	int i;	armInitExceptionModes();	 for (i = 0; i < SYS_EXC_NUM; ++i)	{		*(UINT32 *)(sysExcTbl[i].vector) = (UINT32)0xe59ff0f4;  /* jump to next 0xfc */       	*(UINT32 *)(sysExcTbl[i].vector + 0xfc) = (UINT32)(sysExcTbl[i].func);	}    _func_armIrqHandler = excIntHandle;/*系统汇编程序里??调用check函数获取中断

⌨️ 快捷键说明

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