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

📄 syslib.c

📁 VxWOrks中bspMCF5200下的Nand Flash TFFS的驱动程序。
💻 C
📖 第 1 页 / 共 2 页
字号:
** NOMANUAL*/LOCAL void sysDmaInit (void)    {    /* disable DMA */    *M5272_DMA_DMR(SIM_BASE) = 0;    }/******************************************************************************** sysTimerInit - initialize the timer subsystem** RETURNS: N/A** NOMANUAL*/LOCAL void sysTimerInit (void)    {    /* Clear CLK0-CLK3 to stop timers. */    *MCF_TIMER_DTMR(0) = 0x00;    *MCF_TIMER_DTMR(1) = 0x00;    *MCF_TIMER_DTMR(2) = 0x00;    *MCF_TIMER_DTMR(3) = 0x00;#ifdef INCLUDE_COLDFIRE_SYS_CLK    /* setup sysClk - uses timer 0 */    sysClkTimer.tmr = MCF_TIMER_DTMR( 0);    sysClkTimer.ter = MCF_TIMER_DTER( 0);    sysClkTimer.tcn = MCF_TIMER_DTCN( 0);    sysClkTimer.tcr = MCF_TIMER_DTCR( 0);    sysClkTimer.trr = MCF_TIMER_DTRR( 0);    sysClkTimer.imr = MCF_INTC0_IMRL;    sysClkTimer.imrSize = sizeof(*MCF_INTC0_IMRL);			    sysClkTimer.imrMask = MCF_INTC0_IMRL_INT_MASK19;				#endif#ifdef INCLUDE_COLDFIRE_AUX_CLK    /* setup auxClk - uses timer 1 */    auxClkTimer.tmr = MCF_TIMER_DTMR(1);    auxClkTimer.ter = MCF_TIMER_DTER(1);    auxClkTimer.tcn = MCF_TIMER_DTCN(1);    auxClkTimer.tcr = MCF_TIMER_DTCR(1);    auxClkTimer.trr = MCF_TIMER_DTRR(1);    auxClkTimer.imr = MCF_INTC0_IMRL;    auxClkTimer.imrSize = sizeof(*MCF_INTC0_IMRL);    auxClkTimer.imrMask = MCF_INTC0_IMRL_INT_MASK20;#endif    }/******************************************************************************** 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.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/char * sysPhysMemTop (void)    {    static char * memTop = NULL;    if (memTop == NULL)	{#ifdef LOCAL_MEM_AUTOSIZE#       error "Memory autosizing is not supported with this BSP"#else	/* size is given by LOCAL_MEM_SIZE */	memTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /*LOCAL_MEM_AUTOSIZE*/	}    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;	}    return memTop;    }/******************************************************************************** sysToMonitor - transfer control to the ROM monitor** This routine transfers control to the ROM monitor.  Normally, it is called* only by reboot()--which services ^X--and bus errors at interrupt level.* However, in some circumstances, the user may wish to introduce a* <startType> to enable special boot ROM facilities.** RETURNS: Does not return.*/STATUS sysToMonitor    (    int startType	/* parameter passed to ROM to tell it how to boot */    )    {    FUNCPTR pRom = (FUNCPTR) (ROM_WARM_ADRS);    sysClearCache();    /* go to ROM */    (*pRom) (startType);	/* jump to romInit.s */    return (OK);	/* in case we ever continue from the 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.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet    (    int procNum			/* processor number */    )    {    sysProcNum = procNum;    }/******************************************************************************** sysBusTas - test and set a location across the bus** NOTE: This routine has no effect, since there is no external bus.** RETURNS: FALSE, since there is no external bus.** SEE ALSO: vxTas()*/BOOL sysBusTas    (    char *adrs		/* address to be tested and set */    )    {    int oldLevel;    oldLevel = intLock ();    if (*(volatile char *) adrs == 0)	{	*(volatile char *) adrs = 1;	intUnlock (oldLevel);	return (TRUE);	}    intUnlock (oldLevel);    return (FALSE);    }/******************************************************************************* sysBusIntAck - acknowledge a bus interrupt.** RETURNS: N/A** NOMANUAL*/int sysBusIntAck    (    int intLevel    )    {    return (0);    }#ifdef INCLUDE_END/******************************************************************************* sysCpuSpeed - returns the CPU speed, in hertz.** RETURNS: CPU speed** NOMANUAL*/unsigned long sysCpuSpeed(void)    {    return(MASTER_CLOCK);    }/******************************************************************************* intEnable - enable the ethernet interrupts** RETURNS: OK** NOMANUAL*/int intEnable    (    int intNum    )    {    int intmask;    if ((intNum > 64) & (intNum < 192))        intNum -= 64;    else         return ERROR;            if (intNum <  0x00000020)	{	intmask = ~ (0x1 <<intNum);	        *MCF_INTC0_IMRL =  (*MCF_INTC0_IMRL) &intmask;	}    else   if (intNum <  0x00000040)    	{    		intmask = ~ (0x1 <<( intNum-0x20));   		*MCF_INTC0_IMRH =  (*MCF_INTC0_IMRH) &intmask;    	         	}   else   if (intNum <  0x00000060)   	{   		intmask = ~ ((0x1 <<( intNum-0x40))|MCF_INTC1_IMRL_MASKALL);   		*MCF_INTC1_IMRL =  (*MCF_INTC1_IMRL) &intmask;   	}   else   if (intNum <  0x00000080)   	{   		intmask = ~ (0x1 <<( intNum-0x60));   		*MCF_INTC1_IMRH =  (*MCF_INTC1_IMRH) &intmask;   	         	}    return(OK);    }/******************************************************************************* intDisable - disable the ethernet interrupts** RETURNS: OK** NOMANUAL*/int intDisable    (    int intNum    )      {    if ((intNum > 64) & (intNum < 192))    intNum-=64;    if (intNum <  0x00000020)	{	      *MCF_INTC0_IMRL =  (*MCF_INTC0_IMRL) | (0x1 << intNum);	}    else   if (intNum <  0x00000040)    	{    	      *MCF_INTC0_IMRH = ( *MCF_INTC0_IMRH ) | (0x1 << ( intNum - 0x20));    	}   else   if (intNum <  0x00000060)   	{   		*MCF_INTC1_IMRL =  (*MCF_INTC1_IMRL) | (0x1 <<( intNum-0x40));   	}   else   if (intNum <  0x00000080)   	{   	      *MCF_INTC1_IMRH = ( *MCF_INTC1_IMRH ) | (0x1 << ( intNum - 0x60));   	}    return(OK);    }/******************************************************************************* sysFecEnetEnable - enable the ethernet controller** RETURNS: OK** NOMANUAL*/STATUS sysFecEnetEnable    (    UINT32 motCpmAddr    )    {    /* Nothing special to do */    return(OK);    }/******************************************************************************* sysFecEnetDisable - disable the ethernet controller** RETURNS: OK** NOMANUAL*/STATUS sysFecEnetDisable    (    UINT32 motCpmAddr    )    {    /* Nothing special to do */    return(OK);    }/******************************************************************************* sysFecEnetAddrGet - return an ethernet address for the board** RETURNS: OK** NOMANUAL*/STATUS sysFecEnetAddrGet    (    UINT32 motCpmAddr,    UCHAR * enetAddr    )    {#ifndef ETHERNET_ADR_SET    memcpy(enetAddr, motFecEnetAddr, 6);   #else    int index;    char enetAddrTemp[6];    STATUS return_status;    return_status = sysEnetAddrGet( 0, (UINT8 *)enetAddrTemp);    /* swap bytes */    for ( index = 0; index < 6; index++)         {         enetAddr[index] = enetAddrTemp[5 - index];         }#endif    return (OK);    }#endif	/* INCLUDE_END */#ifdef ETHERNET_ADR_SET/********************************************************************************* sysEnetAddrGet - get the hardware Ethernet address** This routine determines the unique Ethernet address for the CPU board and* copies it to <addr>, such that the low-order byte is `addr[0]' and the* high-order byte is `addr[5]'.  The memory area pointed to by <addr> is* six bytes.** RETURNS: OK, or ERROR if the Ethernet address cannot be returned.*/STATUS sysEnetAddrGet    (    int		unit,    UINT8 *	addr    )    {    char    bytes[7];    if (unit != 0)        return (ERROR);    /* read the variable address bytes */    sysNvRamGet (bytes, 6, ENET_NVRAM_OFFSET);    /* if the network address is not initialized, return ERROR */    if (   (bytes[0] == -1) && (bytes[1] == -1)        && (bytes[2] == -1) && (bytes[3] == -1)        && (bytes[4] == -1) && (bytes[5] == -1))        {        return (ERROR);        }    addr[5] = ((ENET_DEFAULT & 0x0000ff00) >> 8);   /* High order */    addr[4] = ((ENET_DEFAULT & 0x00ff0000) >> 16);    addr[3] = ((ENET_DEFAULT & 0xff000000) >> 24);    addr[2] = bytes[3];    addr[1] = bytes[4];    addr[0] = bytes[5];                 /* Low order */    return (OK);    }/******************************************************************************** sysEnetAddrSet - set the Ethernet address for this board** This routine sets the variable portion of the Ethernet address, the first* three bytes contain a fixed manufacturer's code, while the last 3 bytes are* set locally, to generate a unique Ethernet address on the local network.** RETURN: OK, always.** NOMANUAL*/STATUS sysEnetAddrSet    (    char byte5,                 /* Ethernet address high order byte */    char byte4,    char byte3,    char byte2,    char byte1,    char byte0                  /* Ethernet address low order byte */    )    {    char	bytes[6];    /* Save six bytes in NVRAM */    bytes[0] = byte5; bytes[1] = byte4; bytes[2] = byte3;    bytes[3] = byte2; bytes[4] = byte1; bytes[5] = byte0;    sysNvRamSet (bytes, 6, ENET_NVRAM_OFFSET);    return (OK);    }#endif /* ETHERNET_ADR_SET */

⌨️ 快捷键说明

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