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

📄 syslib.c

📁 VxWorkS下 MV2604的BSP源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
LOCAL char wrongCpuMsg[] = WRONG_CPU_MSG; LOCAL UINT tableArthur[] = 	/* PLL multiplier times ten */    {    00,  75,  70,  10,  20,  65,  25,  45,    30,  55,  40,  50,  15,  60,  35,  00    };/* forward declarations */void	sysSpuriousIntHandler(void);void	sysCpuCheck (void);char *  sysPhysMemTop (void);STATUS	sysPciExtRavenInit (int, int, int);UCHAR	sysNvRead(ULONG);void	sysNvWrite(ULONG,UCHAR);int	sysGetBusSpd (void);void	sysBusTasClear (volatile char *);void    sysRavenErrClr (void);STATUS  sysPmcSpanConfig (int, int, int, PMC_SPAN *);STATUS  sysBusProbe (char *, int, int, char *);void	sysDebugMsg (char * str);IMPORT UINT sysHid1Get(void);LOCAL	BOOL sysVmeVownTas(char *);LOCAL	BOOL sysVmeRmwTas(char *);/* 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);/* BSP DRIVERS */#include "pci/pciConfigLib.c"#include "./sysEnd.c"#include "sysSerial.c"#include "mem/byteNvRam.c"#include "timer/ppcDecTimer.c"		/* PPC603 & 604 have on chip timers */#include "sysScsi.c"                    /* sysScsiInit routine */#include "sysCache.c"#include "universe.c"#ifdef INCLUDE_MPIC#  include "ravenMpic.c"#else#  include "sl82565IntrCtl.c"#endif /* INCLUDE_MPIC */#ifndef MV2300#  include "timer/ppcZ8536Timer.c"#  include "fdcDrv.c"	/* include floppy disk driver */#  include "isaDma.c"   /* include DMA driver */#endif#ifdef INCLUDE_RAVEN_AUXCLK#  include "ravenAuxClk.c"#endif  /* INCLUDE_RAVEN_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, for example,* "Motorola MVME2600 - MPC 604e".** RETURNS: A pointer to the string.*/char * sysModel (void)    {    char   base_type;    char * pBrdType;    int    cpu;    /* Determine board type */    base_type = *MV2600_BMSR;    switch (base_type)        {        case MV2600_BMSR_2300:                pBrdType = "MVME2300";                break;        case MV2600_BMSR_2300_SC:            if (((*MV2600_CCR) & MV2600_CCR_ID_MSK) == MV2600_CCR_2300)			    pBrdType = "MV2300SC";            else			    pBrdType = "MVME2600";            break;        case MV2600_BMSR_SG712:        case MV2600_BMSR_SG761:#ifdef MV2700                pBrdType = "MVME2700";#else                pBrdType = "MVME2600";#endif                break;        case MV2600_BMSR_FG712:        case MV2600_BMSR_FG761:                pBrdType = "MVME3600";                break;        default:                pBrdType = "Unknown";                break;        }    /* Determine CPU type and build display string */    cpu = CPU_TYPE;    switch (cpu)	{	case CPU_TYPE_604E:	    sprintf (sysModelStr, "Motorola %s - MPC 604e", pBrdType);	    break;        case CPU_TYPE_604R:            sprintf (sysModelStr, "Motorola %s - MPC 604r", pBrdType);            break;	case CPU_TYPE_603P:	    sprintf (sysModelStr, "Motorola %s - MPC 603p", pBrdType);	    break;	case CPU_TYPE_603E:	    sprintf (sysModelStr, "Motorola %s - MPC 603e", pBrdType);	    break;        case CPU_TYPE_750:	    sprintf (sysModelStr, "Motorola %s - MPC 750", pBrdType);	    break;	default:	    sprintf (sysModelStr, "Motorola %s - MPC 60%d", pBrdType, cpu);	    break;	}    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 */    /*     *	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);        }    /*     *  Due to a bug in the Universe I, the vme chip needs to be     *  the first PCI device probed and configured.     *     *  Initialize the Standard PCI Header of the VME device if present     */    if ((DEVICE_PRESENT(MV2600_BMFR_VMEP) == TRUE) &&        (pciFindDevice ((PCI_ID_UNIVERSE & 0xFFFF),                        (PCI_ID_UNIVERSE >> 16) & 0xFFFF, 0,                        &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR))        {        UCHAR pciRev;        pciConfigInByte (pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_REVISION,                 &pciRev);        if (pciRev == 0)            {            pciToVmeDev = UNIVERSE_I;            /*	     *  Due to a bug in the Universe I, it is necessary to disable the	     *  PCI Slave Image 0 before accessing other PCI devices.  Refer to	     *  Universe Device Errata #11 and the MVME2600 Series Single Board	     *  Computer Programmer's Reference Guide, Chapter 4, "Universe	     *  Chip Problems after a PCI Reset".             */            sysUniverseReset ();            }        else            {            pciToVmeDev = UNIVERSE_II;            }        (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                            0,                            PCI_MEM_UNIVERSE_ADRS,                            (PCI_CMD_MASTER_ENABLE | PCI_CMD_MEM_ENABLE));        }    /*     *  The Raven 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));        }#ifdef INCLUDE_FD    /*     * IBC initialization for floppy disk driver support, modify the     * ISA-to-PCI address decoder register to map ISA addresses 0x100000     * to 0x1000000 to appear on the PCI Bus.     */    if (pciFindDevice ((PCI_ID_IBC & 0xFFFF), (PCI_ID_IBC >> 16) & 0xFFFF, 0,                       &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo, 0x48, 0xf1 );        }#endif #ifdef INCLUDE_NETWORK    /*     *  Initialize the Standard PCI Header of the Ethernet device if present     */    if ((DEVICE_PRESENT(MV2600_BMFR_LANP) == TRUE))        sysDec21x40UpdateLoadStr ();#endif /* INCLUDE_NETWORK */ #ifdef INCLUDE_SCSI    /*     *  Initialize the Standard PCI Header of the SCSI device if present     */    if ((DEVICE_PRESENT(MV2600_BMFR_SCIP) == TRUE) &&        (pciFindDevice ((PCI_ID_SCSI & 0xFFFF), (PCI_ID_SCSI >> 16) & 0xFFFF,                        0, &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR))        {        (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                            PCI_IO_SCSI_ADRS, 0,                            (PCI_CMD_MASTER_ENABLE | PCI_CMD_IO_ENABLE));        }#endif /* INCLUDE_SCSI */ #ifdef  INCLUDE_SECONDARY_SCSI    /*     *  Initialize the Standard PCI Header of the Secondary SCSI device     *  (SYM53C825A) if present.     */     if (pciFindDevice (PCI_ID_NCR825 & 0xFFFF, (PCI_ID_NCR825 >> 16) & 0xFFFF,                        1, &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                            PCI_IO_SCSI_ADRS2, 0,                            (PCI_CMD_MASTER_ENABLE | PCI_CMD_IO_ENABLE));        }#endif  /* INCLUDE_SECONDARY_SCSI */    /*     *  Initialize the extended portion of the Raven's PCI Header.     *	The non-PCI Config Space registers have already been     *	initialized in the initial startup code.     */    if (pciFindDevice ((PCI_ID_RAVEN & 0xFFFF), (PCI_ID_RAVEN >> 16) & 0xFFFF,                       0, &ravPciBusNo, &ravPciDevNo, &ravPciFuncNo) != ERROR)        {        (void)sysPciExtRavenInit(ravPciBusNo, ravPciDevNo, ravPciFuncNo);        }#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     *  Raven Mpic.     */    sysMpicInit();#endif /* INCLUDE_MPIC */#ifdef INCLUDE_PMC_SPAN    /*     * Initialize and configure PMC Span (bridge) to secondary PCI bus.     */    if ((DEVICE_PRESENT(MV2600_BMFR_BRGP) == 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 */    /*     *  The LANCE has a real driver associated with it, so     *  no additional initialization is done here.  It's done     *  at kernel init time.     */    /*     *  The SCSI has a real driver associated with it, so     *  no additional initialization is done here.  It's done     *  at kernel init time.     */    /*     *  Initialize the non-PCI Config Space registers of the     *  Universe which doesn't have a true device driver.     */    sysUniverseInit(); #ifdef  INCLUDE_VME_DMA    /*  Initialize the VMEbus DMA driver */    sysVmeDmaInit();#endif  /* INCLUDE_VME_DMA */ #ifdef  INCLUDE_SECONDARY_ENET    /*     *  The dec21040 (Secondary Ethernet) has a real driver     *  associated with it, so     *  no additional initialization is done here.  For now,     *  the application must create, configure, and establish     *  a route for the device.     */#endif  /* INCLUDE_SECONDARY_ENET */#ifdef  INCLUDE_SECONDARY_SCSI    /*     *  The Secondary SCSI (SYM53C825A on the mezzanine) has a     *  real driver associated with it, so no additional     *  initialization is done here.  To access it, use     *  pSysScsiCtrl2 when issuing the appropriate calls.     */#endif  /* INCLUDE_SECONDARY_SCSI */    /* 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();    /* Extract the Ethernet address out of non-volatile RAM.     * The Motorola convention for the Ethernet address is that they only     * save the low 3 bytes in BBRAM.  The high three bytes are the     * manufacturers code, and Motorola software knows its own.     * The Motorola code is 0x08003Exxx.     */    sysNvRamGet ((char *)lnEnetAddr, 6, ((int) BB_ENET - NV_BOOT_OFFSET));    /* 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 Raven error conditions */    sysRavenErrClr ();    /* Upon completion, clear BFL (Board Fail) LED */    *(UINT8 *)z8536_PORTA_DATA &= ~z8536_PORTA_BRDFAIL;    }

⌨️ 快捷键说明

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