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

📄 syslib.c

📁 ads826x bsp 重要代码:sysLib.c - Motorola ads 8260 board system-dependent library
💻 C
📖 第 1 页 / 共 4 页
字号:
                            {FREQ_66_MHZ, 6, 5, FREQ_166_MHZ, FREQ_200_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 6, 6, FREQ_166_MHZ, FREQ_233_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 6, 7, FREQ_166_MHZ, FREQ_266_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 0, FREQ_166_MHZ, FREQ_300_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 1, FREQ_200_MHZ, FREQ_133_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 2, FREQ_200_MHZ, FREQ_166_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 3, FREQ_200_MHZ, FREQ_200_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 4, FREQ_200_MHZ, FREQ_233_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 5, FREQ_200_MHZ, FREQ_266_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 6, FREQ_200_MHZ, FREQ_300_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 7, 7, FREQ_233_MHZ, FREQ_133_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 8, 0, FREQ_233_MHZ, FREQ_166_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 8, 1, FREQ_233_MHZ, FREQ_200_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 8, 2, FREQ_233_MHZ, FREQ_233_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 8, 3, FREQ_233_MHZ, FREQ_266_MHZ, CPU_TYPE_8266},                            {FREQ_66_MHZ, 8, 4, FREQ_233_MHZ, FREQ_300_MHZ, CPU_TYPE_8266},                            {END_OF_TABLE,0,0,0,0,0}                         };/* static locals */LOCAL UINT32 *immrAddress = (UINT32 *) IMMR_ADDRESS_RESET_VALUE;#ifdef INCLUDE_PCI#ifdef PCI_BRIDGE_READ_ERRATA_WORKAROUND/* Partial Fix for Errata on read access to PCI bridge registers *//* Uses IDMA2 to access instead of direct read.  */ UINT8   pciBridgeRegisterReadByte(int);UINT16  pciBridgeRegisterReadWord(int);UINT32  pciBridgeRegisterReadLong(int);#undef  PCI_IN_BYTE#undef  PCI_IN_WORD#undef  PCI_IN_LONG#define PCI_IN_BYTE(x) pciBridgeRegisterReadByte(x)#define PCI_IN_WORD(x) pciBridgeRegisterReadWord(x)#define PCI_IN_LONG(x) pciBridgeRegisterReadLong(x)#endif  /* PCI_BRIDGE_READ_ERRATA_WORKAROUND */ULONG sysPciConfAddr = PCI_CFG_ADR_REG;          /* PCI Configuration Address */ULONG sysPciConfData = PCI_CFG_DATA_REG;          /* PCI Configuration Data */#include "pci/pciIntLib.c"           /* PCI int support */#include "pci/pciConfigLib.c"        /* pci configuration library *//* use show routine */#ifdef INCLUDE_SHOW_ROUTINES#include "pci/pciConfigShow.c"       /* pci configuration show routines */#endif/* use pci auto config */#include "pci/pciAutoConfigLib.c"    /* automatic PCI configuration */#include "sysBusPci.c"               /* pciAutoConfig BSP support file */#include "mot82xxPci.c"#endif /* INCLUDE_PCI */UINT32 vxImmrGet();#include "sysSerial.c"#include "intrCtl/m8260IntrCtl.c"#include "timer/m8260Timer.c"#include "sio/m8260Sio.c"#include "mem/nullNvRam.c"#include "mem/m8260Flash.c"#ifdef  INCLUDE_MOTFCCEND/* set the following array to a unique Ethernet hardware address */ /* last 5 nibbles are board specific, initialized in sysHwInit */ unsigned char sysFccEnetAddr [6] = {0x08, 0x00, 0x3e, 0x33, 0x02, 0x01}; STATUS sysFccEnetAddrGet (int unit, UCHAR * address);STATUS sysFccEnetEnable (UINT32 immrVal, UINT8 fccNum);STATUS sysFccMiiBitWr (UINT32 immrVal, UINT8 fccNum, INT32 bitVal);STATUS sysFccMiiBitRd (UINT32 immrVal, UINT8 fccNum, INT8 * bitVal);STATUS sysMiiOptRegsHandle (PHY_INFO * pPhyInfo); #endif  /* INCLUDE_MOTFCCEND */ /* locals */STATUS sysFccEnetDisable (UINT32 immrVal, UINT8 fccNum);void sysControlLED ( int LED, int on);/* defines */#define ZERO    0#define SYS_MODEL       "Motorola MPC8260 ADS"#define SYS_MODEL_HIP4  "Motorola MPC82xx ADS - HIP4"/* needed to enable timer base */#ifdef INCLUDE_PCI#define      M8260_DPPC_MASK	0x0C000000 /* bits 4 and 5 */#define      M8260_DPPC_VALUE	0x0C000000 /* bits (4,5) should be (1,0) */#else#define      M8260_DPPC_MASK	0x0C000000 /* bits 4 and 5 */#define      M8260_DPPC_VALUE	0x08000000 /* bits (4,5) should be (1,0) */#endif /*INCLUDE_PCI */#define DELTA(a,b)                 (abs((int)a - (int)b))#include "drv/sio/m8260Sio.h"#ifdef  INCLUDE_MOTFCCEND#   include "sysMotFccEnd.c"#endif /* INCLUDE_MOTFCCEND */#ifdef INCLUDE_FEI_END#   include "sysFei82557End.c"#endif /* INCLUDE_FEI_END */#ifdef PCI_BRIDGE_READ_ERRATA_WORKAROUNDUCHAR	sysInByte(ULONG port){return(pciBridgeRegisterReadByte(port));}USHORT	sysInWord(ULONG port){return(pciBridgeRegisterReadWord(port));}ULONG	sysInLong(ULONG port){return(pciBridgeRegisterReadLong(port));}#endif /*PCI_BRIDGE_READ_ERRATA_WORKAROUND *//******************************************************************************** sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.** RETURNS: A pointer to the string.*/char * sysModel (void)    {    UINT device;    if (((device = vxPvrGet()) & HIP4_MASK) == HIP4_ID)        return(SYS_MODEL_HIP4);    return (SYS_MODEL);    }/******************************************************************************** sysBspRev - return the bsp version with the revision eg 1.0/<x>** This function returns a pointer to a bsp version with the revision.* for eg. 1.0/<x>. BSP_REV defined in config.h is concatanated to* BSP_VERSION and returned.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev (void)    {    return (BSP_VERSION BSP_REV);    } /******************************************************************************  *  * sysCpmFreqGet - Determines the CPM Operating Frequency  *  * From page 9-2 Rev. 0  MPC8260  PowerQUICC II User's Manual  *  * RETURNS: CPM clock frequency for the current MOD_CK and MOD_CK_H settings    */UINT32 sysCpmFreqGet    (     void    )    {    UINT  n;    UINT  device;    UINT32 modck_H = MOD_CK_H;    UINT32 modck13 = MOD_CK;    UINT32 oscFreq = OSCILLATOR_FREQ;    UINT16 cpuType = CPU_TYPE_8260;    if (((device = vxPvrGet()) & HIP4_MASK) == HIP4_ID)	{	modck_H = MOD_CK_H_8266;	modck13 = MOD_CK_8266;        cpuType = CPU_TYPE_8266;	}    for (n=0; modckH_modck13[n].coreFreq != END_OF_TABLE ;n++)        {        if ((modckH_modck13[n].modck_h == modck_H) &&            (modckH_modck13[n].modck13 == modck13) &&	    (modckH_modck13[n].cpuType == cpuType))            {            if (modckH_modck13[n].inputFreq == oscFreq)                return  modckH_modck13[n].cpmFreq;	    }        }    return ERROR;    }/******************************************************************************** sysBaudClkFreq - Obtains frequency of the BRG_CLK in HZ** From page 9-5 in Rev. 0 MPC8260 PowerQUICC II User's Manual**     baud clock = 2*cpm_freq/2^2*(DFBRG+1) where DFBRG = 01*                = 2*cpm_freq/16** RETURNS: frequency of the BRG_CLK in HZ*/int sysBaudClkFreq    (     void    )    {    UINT32 cpmFreq = sysCpmFreqGet();    if (cpmFreq == ERROR)        return ERROR;    else        return cpmFreq*2/16;    }/****************************************************************************** * * sysHwMemInit - initialize and configure system memory. * * This routine is called before sysHwInit(). It performs memory auto-sizing * and updates the system's physical regions table, `sysPhysRgnTbl'. It may * include the code to do runtime configuration of extra memory controllers. * * NOTE: This routine should not be called directly by the user application.  It * cannot be used to initialize interrupt vectors. * * RETURNS: N/A */void sysHwMemInit (void)    {    /* Call sysPhysMemTop() to do memory autosizing if available */    sysPhysMemTop ();    }/******************************************************************************** sysHwInit - initialize the system hardware** This routine initializes various feature of the MPC8260 ADS board. It sets up* the control registers, initializes various devices if they are present.** NOTE: This routine should not be called directly by the user.** RETURNS: NA*/void sysHwInit (void)    {    int	immrVal = vxImmrGet();    /* set the BRGCLK division factor */    * M8260_SCCR(immrVal) = BRGCLK_DIV_FACTOR;    /* set DPPC in SIUMCR to 10 so that timer is enabled (TBEN) */	    * M8260_SIUMCR(immrVal) &= ~M8260_DPPC_MASK;  /* clear the dppc */    * M8260_SIUMCR(immrVal) |= M8260_DPPC_VALUE;  /* or in the desired value */    /* reset the Communications Processor */    *M8260_CPCR(immrVal) = 0x80010000;    CACHE_PIPE_FLUSH();    /* Get the Baud Rate Generator Clock  frequency */    baudRateGenClk = sysBaudClkFreq();#ifdef INCLUDE_PCI#ifdef PCI_BRIDGE_READ_ERRATA_WORKAROUND    /* Setup to do IDMA for PCI Bridge reads */    pciBridgeIdmaInit();#endif / *PCI_BRIDGE_READ_ERRATA_WORKAROUND */        /* config pci */    if (pciConfigLibInit (PCI_MECHANISM_0,(ULONG) sysPciConfigRead,                              (ULONG) sysPciConfigWrite,(ULONG) sysPciSpecialCycle) != OK)        {        sysToMonitor (BOOT_NO_AUTOBOOT);  /* BAIL */        }    /*  Initialize PCI interrupt library. */    if ((pciIntLibInit ()) != OK)        {        sysToMonitor (BOOT_NO_AUTOBOOT);        }    if ( *((char*)PCI_AUTO_CONFIG_ADRS)==FALSE )         {	mot82xxBridgeInit();        if (PCI_CFG_TYPE == PCI_CFG_AUTO)            sysPciAutoConfig();            *((char*)PCI_AUTO_CONFIG_ADRS)=TRUE;	}        #endif /* INCLUDE_PCI */         /* Reset serial channels */    sysSerialHwInit();    /* Initialize interrupts */    m8260IntrInit();    /* handle the LXT970 properly */#ifdef INCLUDE_MOTFCCEND    miiPhyOptFuncSet ((FUNCPTR) sysMiiOptRegsHandle);#endif  /* INCLUDE_MOTFCCEND */    /*     * The power management mode is initialized here. Reduced power mode     * is activated only when the kernel is iddle (cf vxPowerDown).     * Power management mode is selected via vxPowerModeSet().     * DEFAULT_POWER_MGT_MODE is defined in config.h.     */    vxPowerModeSet (DEFAULT_POWER_MGT_MODE);    }/********************************************************************************* 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)    {    LOCAL char * physTop = NULL;    if (physTop == NULL)	{	physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);	}    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)    {    LOCAL 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_TEXT_ADRS + 8);	/* Warm reboot */    intLock();

⌨️ 快捷键说明

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