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

📄 syslib.c

📁 vxworks mv2100 vxworks BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
void	sysCpuCheck (void);char *  sysPhysMemTop (void);void sysDec21x40UpdateLoadStr (void);UCHAR	sysNvRead(ULONG);void	sysNvWrite(ULONG,UCHAR);void	sysBusTasClear (volatile char *);#if defined(INCLUDE_PMC_SPAN) && !defined(INCLUDE_PCI_AUTOCONF)STATUS  sysPmcSpanConfig (int, int, int, PMC_SPAN *);#endif /* INCLUDE_PMC_SPAN & !INCLUDE_PCI_AUTOCONF */STATUS  sysBusProbe (char *, int, int, char *);IMPORT UINT sysHid1Get(void);LOCAL	BOOL sysVmeVownTas(char *);LOCAL	BOOL sysVmeRmwTas(char *);void	sysDebugMsg(char * str, UINT32  recovery);STATUS	sysAtuInit();			/* initialize Kahlua ATU */UINT 	sysGetBusSpd(void);     	/* system bus speed (in megahertz) */UINT	sysGetBusSpdHertz(void);	/* system bus speed (in hertz) */UINT	sysGetMpuSpd(void);     	/* processor speed (in megahertz) */UINT	sysGetMpuSpdHertz(void);	/* processor speed (in hertz) */UINT	sysGetPciSpd(void);     	/* pci bus speed (in megahertz) */UINT	sysGetPciSpdHertz(void);	/* pci bus speed (in hertz) *//* externals */IMPORT UCHAR  sysInByte (ULONG);IMPORT void   sysOutByte (ULONG, UCHAR);IMPORT USHORT sysInWord (ULONG);IMPORT void   sysOutWord (ULONG, USHORT);IMPORT ULONG  sysInLong (ULONG);IMPORT void   sysOutLong (ULONG, ULONG);IMPORT UINT32 sysPciInLong (UINT32);IMPORT void   sysPciOutLong (UINT32, UINT32);IMPORT UINT32 sysPciConfigInLong (UINT32 *);IMPORT void   sysPciConfigOutLong (UINT32 *, UINT32);IMPORT UINT16 sysPciConfigInWord (UINT16 *);IMPORT void   sysPciConfigOutWord (UINT16 *, UINT16);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[];IMPORT UINT32 sysMemParamConfig();/* BSP DRIVERS */#include "pci/pciConfigLib.c"#ifdef INCLUDE_NETWORK#include "./sysEnd.c"#endif /* INCLUDE_NETWORK */#include "sysSerial.c"#include "mem/byteNvRam.c"#include "sysMotVpd.c"#include "timer/ppcDecTimer.c"		/* PPC603 has on chip timers */#ifdef INCLUDE_SHOW_ROUTINES#include "pci/pciConfigShow.c"          /* display of PCI config space */#include "sysMotVpdShow.c"#endif#ifdef INCLUDE_SCSI#   include "sysScsi.c"			/* sysScsiInit routine */#endif /* INCLUDE_SCSI */#include "universe.c"#include "kahluaEpic.c"#ifdef INCLUDE_AUX_CLK#    include "kahluaAuxClk.c"#endif#ifdef INCLUDE_PCI_AUTOCONF#  include "pci/pciAutoConfigLib.c"#  include "./sysBusPci.c"#endif/* 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)    {    int    cpu;    char cpuStr[80];    /* Determine CPU type and build display string */    cpu = CPU_TYPE;    switch (cpu)        {	case CPU_TYPE_603EK:	    sprintf(cpuStr, "8240");	    break;        default:            sprintf (cpuStr, "60%d", cpu);            break;        }    sprintf (sysModelStr, "Motorola MVME2100 - MPC %s", 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);    }/********************************************************************************* sysDecDelay - decrementer delay** This function's purpose is delay for the specified number* micro-seconds.** RETURNS: none*/void sysDecDelay    (    UINT usDelay    )    {    UINT  oneUsDelta;    UINT  valueCurrent, valuePrevious, valueDelta;    /* if no delay count, exit */    if (!usDelay)         return;    /*     * calculate delta of decrementer ticks for 1ms of elapsed time,     * the bus clock (in megahertz) is used for 603/604 versions, the     * decrementer counts down once every for bus clocks for the     * 603/604 versions, and once every RTC tick for the 601, the RTC     * tick for 601 is the period of 1ns     */    oneUsDelta = ((DEC_CLOCK_FREQ / 4) / 1000000);    /*     * snapshot current decrementer count, this count is used     * as the starting point     *     * check for rollover, the decrementer counts down from     * the maximum count (0xffffffff) to zero     *     * calculate delta of the decrementer counts and divide     * down by the one MS divider, exit if count has been     * met or exceeded     */    for (valuePrevious = vxDecGet();;)         {        valueCurrent = vxDecGet();        valueDelta = 0;        if (valueCurrent > valuePrevious)             {            valueDelta = (0xFFFFFFFF - valueCurrent) + valuePrevious;            }         else             {            if (valueCurrent < valuePrevious)                 {                valueDelta = valuePrevious - valueCurrent;                }            }        if ((valueDelta / oneUsDelta) >= usDelay)             break;        }    }/******************************************************************************** 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 */    /* Initialize the VPD information */    (void) sysVpdInit ();    /*     *	Validate CPU type     */    sysCpuCheck();    /*     *  Initialize PCI driver library.     */    if (pciConfigLibInit (PCI_MECHANISM_1, PCI_MSTR_PRIMARY_CAR, 	PCI_MSTR_PRIMARY_CDR, 0) != OK)        {        sysToMonitor (BOOT_NO_AUTOBOOT);        }#ifdef INCLUDE_PCI_AUTOCONF    /* Auto-Configure the PCI busses/devices. */    /*     * 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++;	/* Remember that PCI is configured */	}#endif#ifdef INCLUDE_NETWORK    sysDec21x40UpdateLoadStr ();#endif /* INCLUDE_NETWORK */    /*     * Do the necessary setup for the UNIVERSE chip.     *      * In all cases we need to get the Base Address for the UNIVERSE     * registers in PCI space.     * If PCI autoconfiguration is not enabled, then we need to manually     * configure the UNIVERSE chip.     */    if (pciFindDevice ((PCI_ID_UNIVERSE & 0xFFFF),                        (PCI_ID_UNIVERSE >> 16) & 0xFFFF, 0,                        &pciBusNo, &pciDevNo, &pciFuncNo) != ERROR)        {        pciToVmeDev = UNIVERSE_II;#if !defined(INCLUDE_PCI_AUTOCONF)        (void)pciDevConfig (pciBusNo, pciDevNo, pciFuncNo,                            NULL,                            PCI_MEM_UNIVERSE_ADRS,                            (PCI_CMD_MASTER_ENABLE | PCI_CMD_MEM_ENABLE));#endif /* !defined(INCLUDE_PCI_AUTOCONF) */	/* get the base address for the Universe registers */	(void)pciConfigInLong(pciBusNo, pciDevNo, pciFuncNo,			PCI_CFG_BASE_ADDRESS_0,			&univBaseAdrs);	if (univBaseAdrs & PCI_BAR_SPACE_IO)	    {	    univBaseAdrs = (ISA_MSTR_IO_LOCAL + (univBaseAdrs & 			    PCI_IOBASE_MASK));	    }	else	    {	    univBaseAdrs = (PCI_MSTR_MEMIO_LOCAL + (univBaseAdrs & 			    PCI_MEMBASE_MASK));	    }        }#if defined(INCLUDE_NETWORK) && !defined(INCLUDE_PCI_AUTOCONF)    /*  Initialize the Standard PCI Header of the LANCE device if present */    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));            }        else            {            sysToMonitor (BOOT_NO_AUTOBOOT);            }#endif /* INCLUDE_NETWORK & !INCLUDE_PCI_AUTOCONF */     /* initialize the address translation unit (ATU) */     sysAtuInit();    /* Initialize the EPIC. */    sysEpicInit();#if defined(INCLUDE_PMC_SPAN) && !defined(INCLUDE_PCI_AUTOCONF)    /*     * Initialize and configure PMC Span (bridge) to secondary PCI bus.     */    if  (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 & !INCLUDE_PCI_AUTOCONF */    /*     *  The LANCE 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 */    /* 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 ();    /* Upon completion, clear the Board Fail LED */    *(UINT8 *)MV2100_SYS_STAT_REG2 &= ~MV2100_BD_FAIL;    }/********************************************************************************* 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)    {#ifdef LOCAL_MEM_AUTOSIZE    sramConfigReg MemControlReg;#endif    static char * sysPhysMemSize = NULL;	/* ptr to top of mem + 1 */    if (sysPhysMemSize == NULL)	{#ifdef LOCAL_MEM_AUTOSIZE	/*	 * Do dynamic memory sizing.	 *	 * Since the memory controller interface has already been set to	 * control all memory, just read and interpret its DRAM Attributes	 * Register.	 */        sysPhysMemSize = (char *)sysMemParamConfig(&MemControlReg);        /* Adjust initial DRAM size to actual physical memory. */        sysPhysMemDesc[1].len = (ULONG)sysPhysMemSize -			        (ULONG)sysPhysMemDesc[1].physicalAddr;#else /* not LOCAL_MEM_AUTOSIZE */	/* Don't do auto-sizing, use defined constants. */	sysPhysMemSize = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */	}    return sysPhysMemSize;    }/*******************************************************************************

⌨️ 快捷键说明

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