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

📄 syslib.c

📁 VxWorks下 MV2400的BSP源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* externals */IMPORT UCHAR  sysInByte (ULONG);IMPORT void   sysOutByte (ULONG, UCHAR);IMPORT UINT16 sysIn16 (UINT16 *);IMPORT void   sysOut16 (UINT16 *, UINT16);IMPORT UINT32 sysIn32 (UINT32 *);IMPORT void   sysOut32 (UINT32 *, UINT32);IMPORT void   sysPciRead32 (UINT32, UINT32 *);IMPORT void   sysPciWrite32 (UINT32, UINT32);IMPORT void   sysClkIntCIO (void);IMPORT STATUS sysMemProbeSup (int length, char * src, char * dest);IMPORT int    sysProbeExc();IMPORT VOIDFUNCPTR      smUtilTasClearRtn;IMPORT void   sysBusRmwEnable(UINT, UINT, UINT, char *);IMPORT void   sysBusRmwDisable(void);IMPORT UINT32 sysTimeBaseLGet (void);IMPORT UCHAR  sysProductStr[];/* BSP DRIVERS */#include "pci/pciConfigLib.c"#ifdef INCLUDE_NETWORK#   include "./sysNet.c"#   ifdef INCLUDE_END#      include "./sysDec21x40End.c"#   endif /* INCLUDE_END */#endif /* INCLUDE_NETWORK */#include "sysSerial.c"#include "mem/byteNvRam.c"#include "sysMotVpd.c"#include "timer/ppcDecTimer.c"		/* PPC603 & 604 have on chip timers */#ifdef INCLUDE_SHOW_ROUTINES#include "pci/pciConfigShow.c"          /* display of PCI config space */#include "sysMotVpdShow.c"#include "hawkSmcShow.c"#endif#ifdef INCLUDE_PCI_AUTOCONF#  include "pci/pciAutoConfigLib.c"#  include "./sysBusPci.c"#endif#include "sysCache.c"#include "universe.c"#include "hawkPhb.c"#ifdef INCLUDE_MPIC#  include "hawkMpic.c"#else#  include "sl82565IntrCtl.c"#endif /* INCLUDE_MPIC */#ifdef INCLUDE_HAWK_AUXCLK#  include "hawkAuxClk.c"#endif  /* INCLUDE_HAWK_AUXCLK *//* defines for sysBusTas() and sysBusTasClear() */#define VMEBUS_OWNER	(*UNIVERSE_MAST_CTL & LONGSWAP(MAST_CTL_VOWN_ACK))#define CPU_CLOCKS_PER_LOOP	10#define LOCK_TIMEOUT		10#define UNLOCK_TIMEOUT		10000/******************************************************************************** sysModel - return the model name of the CPU board** This routine returns the model name of the CPU board.  The returned string* depends on the board model and CPU version being used.** RETURNS: A pointer to the string.*/char * sysModel (void)    {    UINT cpu;    char cpuStr[80];    /* Determine CPU type and build display string */    cpu = CPU_TYPE;    switch (cpu)        {        case CPU_TYPE_604E:            sprintf(cpuStr, "604e");            break;        case CPU_TYPE_604R:            sprintf(cpuStr, "604r");            break;        case CPU_TYPE_603P:            sprintf(cpuStr, "603p");            break;        case CPU_TYPE_603E:            sprintf(cpuStr, "603e");            break;        case CPU_TYPE_750:            sprintf(cpuStr, "750");            break;        default:            sprintf (cpuStr, "60%d", cpu);            break;        }    sprintf (sysModelStr, "Motorola %s - MPC %s", sysProductStr, cpuStr);    return (sysModelStr);    }/********************************************************************************* sysBspRev - return the BSP version and revision number** This routine returns a pointer to a BSP version and revision number, for* example, 1.1/0. BSP_REV is concatenated to BSP_VERSION and returned.** RETURNS: A pointer to the BSP version/revision string.*/char * sysBspRev (void)    {    return (BSP_VERSION BSP_REV);    }/******************************************************************************** sysHwInit - initialize the system hardware** This routine initializes various features of the CPU board.  It is called* by usrInit() in usrConfig.c.  This routine sets up the control registers* and initializes various devices if they are present.** NOTE: This routine should not be called directly by the user application.  It* cannot be used to initialize interrupt vectors.** RETURNS: N/A*/void sysHwInit (void)    {    int         pciBusNo;       /* PCI bus number */    int         pciDevNo;       /* PCI device number */    int         pciFuncNo;      /* PCI function number */    /* Do the Hawk PCI-Host Bridge phase 1 init */    (void) hawkPhbInit ();    /* Initialize the VPD information */    (void) sysVpdInit ();    /* Do the Hawk PCI-Host Bridge phase 2 init */    (void) hawkPhbInit2 ();    /*     *	Validate CPU type     */    sysCpuCheck();    /*     *  Initialize PCI driver library.     */    if (pciConfigLibInit (PCI_MECHANISM_1, PCI_PRIMARY_CAR, PCI_PRIMARY_CDR, 0)        != OK)        {        sysToMonitor (BOOT_NO_AUTOBOOT);        }#ifdef INCLUDE_PCI_AUTOCONF    /*     * Test to determine if we need to configure the PCI busses with     * sysPciAutoConfig().  If we are coming up from a ROM-based image     * then we need to reconfigure.  If we have been booted from a ROM     * image then we don't need to reconfigure since the bootrom will     * already have reconfigured the PCI busses.  We must avoid     * configuring the PCI busses twice on startup.     */    if ( !PCI_AUTOCONFIG_DONE )        {        /* in ROM boot phase, OK to continue and configure PCI busses. */        sysPciAutoConfig ();        PCI_AUTOCONFIG_FLAG = TRUE;     /* Remember that PCI is configured */        }#else /* !INCLUDE_PCI_AUTOCONF */    /* Initialize the Standard PCI Header of the VME device if present */     if (pciFindDevice ((PCI_ID_UNIVERSE & 0xFFFF),                        (PCI_ID_UNIVERSE >> 16) & 0xFFFF, 0,                        &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                            NULL,                            PCI_MEM_UNIVERSE_ADRS,                            (PCI_CMD_MASTER_ENABLE | PCI_CMD_MEM_ENABLE));        /* configure the interrupt line register */        pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo,                          PCI_CFG_DEV_INT_LINE, UNIV_INT_VEC);        }#   ifdef INCLUDE_NETWORK    /*     *  Initialize the Standard PCI Header of the LANCE device if present     */     if ((sysProdConfigGet(PCO_ENET1_CONN) == TRUE) )        {        if ((pciFindDevice ((PCI_ID_PRI_LAN & 0xFFFF),                            (PCI_ID_PRI_LAN >> 16) & 0xFFFF, 0,                            &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR))            {            (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                                PCI_IO_LN_ADRS,                                NULL,                                (PCI_CMD_MASTER_ENABLE | PCI_CMD_IO_ENABLE));            /* configure the interrupt line register */            pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo,                              PCI_CFG_DEV_INT_LINE, LN_INT_VEC);            }        else            {            sysToMonitor (BOOT_NO_AUTOBOOT);            }        }#   endif /* INCLUDE_NETWORK */#   ifdef INCLUDE_PMC_SPAN    /*     * Initialize and configure PMC Span (bridge) to secondary PCI bus.     */    if ((sysProdConfigGet(PCO_PCI0EXP_CONN) == TRUE) &&        (pciFindDevice ((PCI_ID_BR_DEC21150 & 0xFFFF),                        (PCI_ID_BR_DEC21150 >> 16) & 0xFFFF, 0,                        &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR))        {        (void)sysPmcSpanConfig (pciBusNo, pciDevNo, pciFuncNo, sysPmcSpanParm);        }#   endif  /* INCLUDE_PMC_SPAN */#endif /* INCLUDE_PCI_AUTOCONF */    /* Get the base address for the Universe registers if present */    if (pciFindDevice ((PCI_ID_UNIVERSE & 0xFFFF),                        (PCI_ID_UNIVERSE >> 16) & 0xFFFF, 0,                        &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        pciConfigInLong(pciBusNo, pciDevNo, pciFuncNo,                        PCI_CFG_BASE_ADDRESS_0,                         &univBaseAdrs);        if (univBaseAdrs & PCI_BAR_SPACE_IO)            {            univBaseAdrs = (univBaseAdrs & PCI_IOBASE_MASK) - PCI_MSTR_IO_BUS                            + PCI_MSTR_IO_LOCAL;            }        else            {            univBaseAdrs = (univBaseAdrs & PCI_MEMBASE_MASK) - PCI_MSTR_MEM_BUS                            + PCI_MSTR_MEM_LOCAL;            }        /*         *  Initialize the non-PCI Config Space registers of the         *  Universe which doesn't have a true device driver.         */        sysUniverseInit();         }    /*     *  The Hawk powers up with the correct PCI Header values.     *  So, no initialization of the PCI Header is performed.     */     /*     *  The IBC powers up with most of the PCI Header values     *  being correct.  So, only registers that do not power-up     *  in the correct state are modified here.     */    if (pciFindDevice ((PCI_ID_IBC & 0xFFFF), (PCI_ID_IBC >> 16) & 0xFFFF, 0,                       &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {	/*	 * Enable Guaranteed Access Timing (default), the Arbiter Timeout	 * Timer, and  Bus Lock (locks PCI Bus when PCI LOCK# signal asserted)	 */        pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IBC_ARB_CTL,			  (ARB_CTL_GAT |			   ARB_CTL_TIMEOUT_TIMER |			   ARB_CTL_BUS_LOCK));        }    /*     *  Initialize the extended portion of the Hawk's PCI Header.     *	The non-PCI Config Space registers have already been     *	initialized in the initial startup code.     */    if (pciFindDevice ((PCI_ID_HAWK & 0xFFFF), (PCI_ID_HAWK >> 16) & 0xFFFF,                       0, &hawkPciBusNo, &hawkPciDevNo,                       &hawkPciFuncNo) != ERROR)        {        (void)hawkInitPhbExt (hawkPciBusNo, hawkPciDevNo, hawkPciFuncNo);        }#ifndef INCLUDE_MPIC    /* Initialize the extended portion of the IBC's PCI Header.  */    if (pciFindDevice ((PCI_ID_IBC & 0xFFFF), (PCI_ID_IBC >> 16) & 0xFFFF, 0,                       &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        (void)sysPciExtIbcInit(pciBusNo, pciDevNo, pciFuncNo);        }#endif /* INCLUDE_MPIC */    /*     *  Initialize the non-PCI Config Space registers of the     *  IBC which doesn't have a true device driver.     */    sysIbcInit();    /*     *  Reset the MPIC.     */    sysPciWrite32( MPIC_ADDR(MPIC_GLOBAL_CONFIG_REG), RESET_CNTRLR ); #ifdef INCLUDE_MPIC    /*     *  Initialize the non-PCI Config Space registers of the     *  Hawk Mpic.     */    sysMpicInit();#endif /* INCLUDE_MPIC */#ifdef  INCLUDE_VME_DMA    /*  Initialize the VMEbus DMA driver */    sysVmeDmaInit();#endif  /* INCLUDE_VME_DMA */    /* set shared memory TAS Clear routine pointer */    smUtilTasClearRtn = (VOIDFUNCPTR)sysBusTasClear;    /* set pointer to bus probing hook */    _func_vxMemProbeHook = (FUNCPTR)sysBusProbe;    /* Initialize COM1 and COM2 serial channels */    sysSerialHwInit();#ifdef INCLUDE_NETWORK    sysNetHwInit();#endif    /* Disable the watchdog timer */    sysNvWrite ((ULONG)WD_TIMER, 0);    /*     * If mmu tables are used, this is where we would dynamically     * update the entry describing main memory, using sysPhysMemTop().     * We must call sysPhysMemTop () at sysHwInit() time to do     * the memory autosizing if available.     */    sysPhysMemTop ();    /* clear Hawk error conditions */    hawkErrClr ();    /* Upon completion, clear BFL (Board Fail) LED */    *(UINT8 *)z8536_PORTA_DATA &= ~z8536_PORTA_BRDFAIL;    }/********************************************************************************* 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 * sysPhysMemSize = NULL;	/* ptr to top of mem + 1 */#ifdef LOCAL_MEM_AUTOSIZE    UINT32        dramIndex;    int           i, j;    static UINT32 dramSize[] =	{	0x00000000,			/*   0MB */	0x02000000,			/*  32MB (4Mx16) */	0x04000000,			/*  64MB (8Mx8) */	0x04000000,			/*  64MB (8Mx16) */	0x08000000,			/* 128MB (16Mx4) */	0x08000000,			/* 128MB (16Mx8) */	0x08000000,			/* 128MB (16Mx16) */	0x10000000,			/* 256MB (32Mx4) */	0x10000000,			/* 256MB (32Mx8) */	0x20000000,			/* 512MB (64Mx4 */	0x00000000,			/*   0MB reserved */	0x00000000,			/*   0MB reserved */	0x00000000,			/*   0MB reserved */	0x00000000,			/*   0MB reserved */	0x00000000,			/*   0MB reserved */	0x00000000,			/*   0MB reserved */	};    static UINT8 *dramAttr[] =	{	(UINT8 *) HAWK_SMC_SDRAM_ATTR_AD,	(UINT8 *) HAWK_SMC_SDRAM_ATTR_EH,	};#endif /* LOCAL_MEM_AUTOSIZE */    if (sysPhysMemSize == NULL)	{#ifdef LOCAL_MEM_AUTOSIZE	/*

⌨️ 快捷键说明

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