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

📄 syslib.c

📁 WINDRIVER SBC7410 BSP
💻 C
📖 第 1 页 / 共 3 页
字号:
* However, in some circumstances, the user may wish to introduce a* <startType> to enable special boot ROM facilities.** The entry point for a warm boot is defined by the macro ROM_WARM_ADRS* in config.h.  We do an absolute jump to this address to enter the* ROM code.** RETURNS: Does not return.*/STATUS sysToMonitor    (    int startType    /* parameter passed to ROM to tell it how to boot */    )    {    FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4); /* Warm reboot */    intLock ();         /* disable interrupts */    cacheDisable (INSTRUCTION_CACHE);       /* Disable the Instruction Cache */    cacheDisable (DATA_CACHE);      /* Disable the Data Cache */    vxMsrSet (0);       /* Clear the MSR */    sysLedSetAll(LED_ON);    (*pRom) (startType);    /* jump to romInit.s */    return(OK);        /* in case we 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(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.** For bus systems, it is assumes that processor 0 is the bus master and* exports its memory to the bus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet    (    int procNum         /* processor number */    )    {    sysProcNum = procNum;    if ( procNum == 0 )        {#ifdef INCLUDE_PCI        /* TODO - Enable/Initialize the interface as bus slave */#endif        }    }/********************************************************************************* sysCpuCheck - confirm the CPU type** This routine validates the cpu type.  If the wrong cpu type is discovered* a message is printed using the serial channel in polled mode.** RETURNS: N/A.*/void sysCpuCheck (void)    {    int        msgSize;    int        msgIx;    SIO_CHAN * pSioChan;        /* serial I/O channel */    int        cpuType;    cpuType = CPU_TYPE;    /* Check for a valid CPU type;  If one is found, just return */    if ( (cpuType == CPU_TYPE_750) || (cpuType == CPU_TYPE_755) || (cpuType == CPU_TYPE_7400) || (cpuType == CPU_TYPE_7410) )        {        return;        }    /* Invalid CPU type; print error message and terminate */    msgSize = strlen (wrongCpuMsg);    sysSerialHwInit ();    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for ( msgIx = 0; msgIx < msgSize; msgIx++ )        {        while ( sioPollOutput (pSioChan, wrongCpuMsg[msgIx]) == EAGAIN );        }    sysToMonitor (BOOT_NO_AUTOBOOT);    }#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 *//********************************************************************************* sysMsDelay - delay for x msecs.** RETURNS: N/A.** NOMANUAL*/#define DELTA(a,b)              (abs((int)a - (int)b))void sysMsDelay    (    int delay            /* length of time in MS to delay */    )    {    register UINT32 oldval;      /* decrementer value */    register UINT32 newval;      /* decrementer value */    register UINT32 totalDelta;  /* Dec. delta for entire delay period */    register UINT32 decElapsed;  /* cumulative decrementer ticks */    /* Calculate delta of decrementer ticks for desired elapsed time. */    totalDelta = ((SYS_CPU_FREQ / 4) / 1000) * (UINT32) delay;    /*     * Now keep grabbing decrementer value and incrementing "decElapsed"     * we hit the desired delay value.  Compensate for the fact that we     * 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;        }    }/********************************************************************************* sysGt64260Init - initialize GT64260.** RETURNS: N/A.** NOMANUAL*/void sysGt64260Init(void)    {    UINT32 temp ;    /* GT64260 specific initialization */    /* Enable cfg and i/o sync barrier cmds */    GT64260_REG_RD(CPU_CFG, &temp);    temp &= ~0x30000000 ;    temp |= 0x00002000 ; /* turn on pipeline */    while ( 1 )        {        GT64260_REG_WR(CPU_CFG,temp);        GT64260_REG_RD(CPU_CFG, &temp);        if ( !(temp&0x30000000) )            if ( temp&0x00002000 )                break;        }    /* Make sure intarb bit is set in master control */    GT64260_REG_RD(CPU_MASTER_CTRL, &temp);    temp |= 0x100 ;    GT64260_REG_WR(CPU_MASTER_CTRL, temp);    /* Disable watchdog */    GT64260_REG_RD(WDC, &temp);    if ( temp & 0x80000000 )        {        /* watchdog is enabled */        temp &= ~0x03000000 ;        temp |=  0x01000000 ;        GT64260_REG_WR(WDC, temp);        temp &= ~0x03000000 ;        temp |=  0x02000000 ;        GT64260_REG_WR(WDC, temp);        }    /* Stop timer/counters */    GT64260_REG_WR(TMR0_3_CTRL, 0) ;    GT64260_REG_WR(TMR4_7_CTRL, 0) ;    /* Abort DMA activity */    GT64260_REG_WR(DMA_CH0_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH1_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH2_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH3_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH4_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH5_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH6_CTRL_L, (1<<20));      GT64260_REG_WR(DMA_CH7_CTRL_L, (1<<20));      /* Abort Ethernet port activity */    GT64260_REG_RD(ETH0_SDCMR, &temp);    if ( temp & 0x00000080 )        {        temp |= 0x00008000 ;        GT64260_REG_WR(ETH0_SDCMR, temp);        }    GT64260_REG_RD(ETH1_SDCMR, &temp);    if ( temp & 0x00000080 )        {        temp |= 0x00008000 ;        GT64260_REG_WR(ETH1_SDCMR, temp);        }    GT64260_REG_RD(ETH2_SDCMR, &temp);    if ( temp & 0x00000080 )        {        temp |= 0x00008000 ;        GT64260_REG_WR(ETH2_SDCMR, temp);        }    /* Abort MPSC activity */    GT64260_REG_RD(MPSC0_CH0R2, &temp);    temp |= (1<<23) ;       /* Set abort reception bit */    temp &= ~(1<<31);   /* Reset enter hunt bit for safety */    GT64260_REG_WR(MPSC0_CH0R2, temp) ;    GT64260_REG_RD(MPSC1_CH1R2, &temp);    temp |= (1<<23) ;       /* Set abort reception bit */    temp &= ~(1<<31);   /* Reset enter hunt bit for safety */    GT64260_REG_WR(MPSC1_CH1R2, temp) ;    /* Abort SDMA activity */    GT64260_REG_WR(SDCM0, (1<<15));    GT64260_REG_WR(SDCM1, (1<<15));    }/********************************************************************************* sysDramSize - return size of memory.** RETURNS: N/A.** NOMANUAL*/int sysDramSize(void)    {    return(LOCAL_MEM_SIZE);    }/********************************************************************************* sysUsDelay - delay for x microseconds.** RETURNS: N/A.** NOMANUAL*/void sysUsDelay    (    int delay    )    {    register UINT32 oldval;      /* decrementer value */    register UINT32 newval;      /* decrementer value */    register UINT32 totalDelta;  /* Dec. delta for entire delay period */    register UINT32 decElapsed;  /* cumulative decrementer ticks */    /* Calculate delta of decrementer ticks for desired elapsed time. */    totalDelta = ((SYS_CPU_FREQ / 4) / 1000000) * (UINT32)delay;    /*     * Now keep grabbing decrementer value and incrementing "decElapsed"     * we hit the desired delay value.  Compensate for the fact that we     * 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;        }    }

⌨️ 快捷键说明

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