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

📄 syslib.c

📁 MPC8360MDS VXWORKS BSP
💻 C
📖 第 1 页 / 共 3 页
字号:
    intLock();    cacheDisable(INSTRUCTION_CACHE);    cacheDisable(DATA_CACHE);#ifdef INCLUDE_AUX_CLK    sysAuxClkDisable();#endif    vxMsrSet (0);    (*pRom) (startType);	/* jump to bootrom entry point */    return (OK);	/* in case we ever continue from ROM monitor */    }/******************************************************************************** sysHwInit2 - additional system configuration and initialization** This routine connects system interrupts and does any additional* configuration necessary.** RETURNS: NA*/void sysHwInit2 (void)    {    if (!configured)	{#ifdef  INCLUDE_VXBUS	vxbDevInit();#endif /* INCLUDE_VXBUS */	/* initialize serial interrupts */	*BCSR1 &= ~0x01;#ifndef DRV_SIO_NS16550	sysSerialHwInit2();#endif#ifdef INCLUDE_SIO_UTILS    sysSerialConnectAll();#endif	configured = TRUE;#ifdef INCLUDE_PCI#ifdef INCLUDE_FEI_END	sysPciConfigEnable (PCI_1_BUS);	sys557PciInit();#endif#ifdef INCLUDE_GEI8254X_END    sysPciConfigEnable (PCI_1_BUS);#ifdef INCLUDE_PCI_AUTOCONF    pciConfigForeachFunc (0, FALSE, (PCI_FOREACH_FUNC) sys8254xDeviceCheck, (void *)&sysPci1SysNum);#else#ifdef INCLUDE_GEI8254X_END_PCI1    sys8254xDeviceCheck(0,0x13,0,(void *)&sysPci1SysNum);#endif /*INCLUDE_GEI8254X_END_PCI1 */#endif /* INCLUDE_PCI_AUTOCONF */#ifdef  INCLUDE_SECONDARY_PCI    sysPciConfigEnable (PCI_2_BUS);#ifdef INCLUDE_PCI_AUTOCONF    pciConfigForeachFunc (0, FALSE, (PCI_FOREACH_FUNC) sys8254xDeviceCheck, (void *)&sysPci2SysNum);#else#ifdef INCLUDE_GEI8254X_END_PCI2    sys8254xDeviceCheck(0,0x13,0,(void *)&sysPci2SysNum);#endif /* INCLUDE_GEI8254X_END_PCI2 */#endif /* INCLUDE_PCI_AUTOCONF */#endif /*  INCLUDE_SECONDARY_PCI */#endif /* INCLUDE_GEI8254X_END */#endif /* INCLUDE_PCI */#ifdef  INCLUDE_VXBUS    taskSpawn("devConnect",0,0,10000,vxbDevConnect,0,0,0,0,0,0,0,0,0,0);#endif /* INCLUDE_VXBUS */	}    }/******************************************************************************** sysUsDelay - delay at least the specified amount of time (in microseconds)** This routine will delay for at least the specified amount of time using the* lower 32 bit "word" of the Time Base register as the timer.  The accuracy of* the delay increases as the requested delay increases due to a certain amount* of overhead.  As an example, a requested delay of 10 microseconds is* accurate within approximately twenty percent, and a requested delay of 100* microseconds is accurate within approximately two percent.** NOTE:  This routine will not relinquish the CPU; it is meant to perform a* busy loop delay.  The minimum delay that this routine will provide is* approximately 10 microseconds.  The maximum delay is approximately the* size of UINT32; however, there is no roll-over compensation for the total* delay time, so it is necessary to back off two times the system tick rate* from the maximum.** RETURNS: N/A*/void sysUsDelay    (    int      delay        /* length of time in microsec to delay */    )    {    volatile int loop;    volatile UINT32 decValue;    for(loop=0;loop<(delay * (coreFreq / 4000000));loop++)		decValue = vxDecGet();    }/*********************************************************************** sysMsDelay - Uses the decrementer to calculate time elapsed** void sysMsDelay*   (*   UINT        delay              * length of time in MS to delay **   )** RETURNS : NONE**/void sysMsDelay    (    uint32_t        delay                   /* length of time in MS to delay */    )    {    register UINT oldval;               /* decrementer value */    register UINT newval;               /* decrementer value */    register UINT totalDelta;           /* Dec. delta for entire delay period */    register UINT decElapsed;           /* cumulative decrementer ticks */    /*     * Calculate delta of decrementer ticks for desired elapsed time.     */    totalDelta = (sysBaudClkFreq() / 1000) * delay;    /*     * Now keep grabbing decrementer value and incrementing "decElapsed" until     * we hit the desired delay value.  Compensate for the fact that we may     * read the decrementer at 0xffffffff before the interrupt service     * routine has a chance to set in the rollover value.     */    decElapsed = 0;    oldval = vxDecGet ();    while (decElapsed < totalDelta)        {        newval = vxDecGet ();        if ( DELTA(oldval,newval) < 1000 )            decElapsed += DELTA(oldval,newval);  /* no rollover */        else            if (newval > oldval)                decElapsed += abs((int)oldval);  /* rollover */        oldval = newval;        }    }/*********************************************************************** sysDelay - Fixed 1ms delay. Just calls sysMsDelay** sysDelay(void)** RETURNS : NONE**/void sysDelay (void)    {    sysMsDelay (1);    }/******************************************************************************** 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 (sysProcNum);    }/******************************************************************************** sysProcNumSet - set the processor number** This routine sets the processor number for the CPU board.  Processor numbers* should be unique on a single backplane.** Not applicable for the busless 8260Ads.** RETURNS: NA** SEE ALSO: sysProcNumGet()**/void sysProcNumSet    (    int 	procNum			/* processor number */    )    {    sysProcNum = procNum;    }/******************************************************************************** sysLocalToBusAdrs - convert a local address to a bus address** This routine gets the VMEbus address that accesses a specified local* memory address.** Not applicable for the 8260Ads** RETURNS: ERROR, always.** SEE ALSO: sysBusToLocalAdrs()*/STATUS sysLocalToBusAdrs    (    int 	adrsSpace,	/* bus address space where busAdrs resides */    char *	localAdrs,	/* local address to convert */    char **	pBusAdrs	/* where to return bus address */    )    {    return (ERROR);    }/******************************************************************************** sysBusToLocalAdrs - convert a bus address to a local address** This routine gets the local address that accesses a specified VMEbus* physical memory address.** Not applicable for the 8260Ads** RETURNS: ERROR, always.** SEE ALSO: sysLocalToBusAdrs()*/STATUS sysBusToLocalAdrs    (     int  	adrsSpace, 	/* bus address space where busAdrs resides */     char *	busAdrs,   	/* bus address to convert */     char **	pLocalAdrs 	/* where to return local address */    )    {    return (ERROR);    }/******************************************************************************** sysBusTas - test and set a location across the bus** This routine does an atomic test-and-set operation across the backplane.** Not applicable for the 8260Ads.** RETURNS: FALSE, always.** SEE ALSO: vxTas()*/BOOL sysBusTas    (     char *	adrs		/* address to be tested-and-set */    )    {    return (FALSE);    }/******************************************************************************** sysBusClearTas - test and clear** This routine is a null function.** RETURNS: NA*/void sysBusClearTas    (     volatile char * address	/* address to be tested-and-cleared */    )    {    }/**************************************************************************** sysFlashLED - flash one of the signal lamps** This routine will flash the indicated signal lamp for about 1/4 second** RETURNS: None*/void sysFlashLED    (    int LED	/* bitmap of LED to flash */    )    {    sysControlLED(LED, BCSR0_LED_ON);    taskDelay(15);    sysControlLED(LED, BCSR0_LED_OFF);    }/**************************************************************************** sysControlLED - control one of the signal lamps** This routine will turn the indicated signal lamp on or off as* requested** RETURNS: None*/void sysControlLED    (    int LED, 	/* bitmap of LED to control */    BOOL on	/* if TRUE turn LED OFF; otherwise, turn LED ON */    )    {    CACHE_PIPE_FLUSH();        }#ifdef INCLUDE_PCI 	/* board level PCI routines *//******************************************************************************** sysPciConfigEnable -  enable PCI 1 or PCI 2 bus configuration** This function enables PCI 1 or PCI 2 bus configuration*  * RETURNS: N/A*/void sysPciConfigEnable     (    int pciHost    )    {    int level;    level = intLock ();    if (pciHost == PCI_2_BUS)        {        sysPciConfAddr = PCI2_CFG_ADR_REG;   /* PCI Configuration Address */        sysPciConfData = PCI2_CFG_DATA_REG;  /* PCI Configuration Data */        }    else /* default is for PCI 1 host */        {        sysPciConfAddr = PCI_CFG_ADR_REG;   /* PCI Configuration Address */        sysPciConfData = PCI_CFG_DATA_REG;  /* PCI Configuration Data */        }    WRS_ASM("sync;eieio");    intUnlock (level);    }/********************************************************************************* sysPciSpecialCycle - generate a special cycle with a message** This routine generates a special cycle with a message.** NOMANUAL** RETURNS: OK*/STATUS sysPciSpecialCycle    (    int		busNo,    UINT32	message    )    {    int deviceNo	= 0x0000001f;    int funcNo		= 0x00000007;    PCI_OUT_LONG (sysPciConfAddr,                  pciConfigBdfPack (busNo, deviceNo, funcNo) |                  0x80000000);    PCI_OUT_LONG (sysPciConfData, message);    return (OK);    }/********************************************************************************* sysPciConfigRead - read from the PCI configuration space** This routine reads either a byte, word or a long word specified by* the argument <width>, from the PCI configuration space* This routine works around a problem in the hardware which hangs* PCI bus if device no 12 is accessed from the PCI configuration space.** NOMANUAL** RETURNS: OK, or ERROR if this library is not initialized*/STATUS sysPciConfigRead    (    int	busNo,    /* bus number */    int	deviceNo, /* device number */    int	funcNo,	  /* function number */    int	offset,	  /* offset into the configuration space */    int width,	  /* width to be read */    void * pData /* data read from the offset */    )    {    UINT8  retValByte = 0;    UINT16 retValWord = 0;    UINT32 retValLong = 0;    STATUS retStat = ERROR;    if ((busNo == 0) && (deviceNo == 12))        return (ERROR);    switch (width)        {        case 1:	/* byte */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);            retValByte = PCI_IN_BYTE (sysPciConfData + (offset & 0x3));            *((UINT8 *)pData) = retValByte;	    retStat = OK;            break;        case 2: /* word */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    retValWord = PCI_IN_WORD (sysPciConfData + (offset & 0x2));            *((UINT16 *)pData) = retValWord;	    retStat = OK;	    break;        case 4: /* long */	    PCI_OUT_LONG (sysPciConfAddr,		          pciConfigBdfPack (busNo, deviceNo, funcNo) |		          (offset & 0xfc) | 0x80000000);	    retValLong = PCI_IN_LONG (sysPciConfData);            *((UINT32 *)pData) = retValLong;	    retStat = OK;            break;        default:            retStat = ERROR;            break;        }    return (retStat);    }/********************************************************************************* sysPciConfigWrite - write to the PCI configuration space** This routine writes either a byte, word or a long word specified by* the argument <width>, to the PCI configuration space* This routine works around a problem in the hardware which hangs* PCI bus if device no 12 is accessed from the PCI configuration space.** NOMANUAL** RETURNS: OK, or ERROR if this library is not initialized*/STATUS sysPciConfigWrite    (    int	busNo,    /* bus number */    int	deviceNo, /* device number */    int	funcNo,	  /* function number */    int	offset,	  /* offset into the configuration space */    int width,	  /* width to write */    ULONG data	  /* data to write */    )    {    if ((busNo == 0) && (deviceNo == 12))        return (ERROR);    switch (width)        {        case 1:	/* byte */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    PCI_OUT_BYTE ((sysPciConfData + (offset & 0x3)), data);            break;        case 2: /* word */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    PCI_OUT_WORD ((sysPciConfData + (offset & 0x2)), data);	    break;        case 4: /* long */	    PCI_OUT_LONG (sysPciConfAddr,		          pciConfigBdfPack (busNo, deviceNo, funcNo) |		          (offset & 0xfc) | 0x80000000);	    PCI_OUT_LONG (sysPciConfData, data);            break;        default:            return (ERROR);        }    return (OK);    }#endif /* INCLUDE_PCI *//*********************************************************************** sysLedReset -** sysLedReset(void)** RETURNS : NONE**/void sysLedInit(void){    volatile UINT8 *ptr = BCSR0 ;    int key = intLock();    /* turn off both LEDs */    *BCSR7 = 0x33 ;    *ptr |= 0x06 ;    intUnlock(key) ;}

⌨️ 快捷键说明

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