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

📄 syslib.c

📁 mtx604在vxworks下的bsp源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
* This routine disables interrupts for the on-board LAN chip. ** RETURNS: OK, or ERROR if network support not included.** SEE ALSO: sysLanIntEnable()*/STATUS sysLanIntDisable    (    int intLevel 		/* interrupt level to enable */    )    {    /* disable the ISA IRQ for LAN */    return (intDisable (intLevel));    }/******************************************************************************** sysSpuriousIntHandler - spurious interrupt handler** This is the entry point for spurious interrupts.** NOTE: This routine has no effect.** This routine catches all spurious interrupts.  It does nothing at all.** RETURNS: N/A.** NOMANUAL*/void sysSpuriousIntHandler (void)    {    }/******************************************************************************** sysNvRead - read one byte from NVRAM** This routine reads a single byte from a specified offset in NVRAM.** RETURNS: The byte from the specified NVRAM offset.*/UCHAR sysNvRead    (    ULONG	offset	/* NVRAM offset to read the byte from */    )    {    sysOutByte (NV_RAM_LSB_REG, LSB(offset));    sysOutByte (NV_RAM_MSB_REG, MSB(offset));    return sysInByte (NV_RAM_DAT_REG);    }/******************************************************************************** sysNvWrite - write one byte to NVRAM** This routine writes a single byte to a specified offset in NVRAM.  The* MVME2600 uses a 48T18 device w/fast write times, no wait.** RETURNS: N/A*/void sysNvWrite    (    ULONG	offset,	/* NVRAM offset to write the byte to */    UCHAR	data	/* datum byte */    )    {    sysOutByte (NV_RAM_LSB_REG, LSB(offset));    sysOutByte (NV_RAM_MSB_REG, MSB(offset));    sysOutByte (NV_RAM_DAT_REG, data);    }/********************************************************************************* sysCpuCheck - confirm the CPU type** This routine validates the cpu type.  If the wrong cpu type is discovered* a message is printed using the serial channel in polled mode.** RETURNS: N/A.*/void sysCpuCheck (void)    {    int msgSize;    int msgIx;    SIO_CHAN * pSioChan;        /* serial I/O channel */    /* Check for a valid CPU type;  If one is found, just return */#if	(CPU == PPC603)    if	((CPU_TYPE == CPU_TYPE_603) || (CPU_TYPE == CPU_TYPE_603E) ||         (CPU_TYPE == CPU_TYPE_603P))	{	return;	}#else	/* (CPU == PPC604) */    if	((CPU_TYPE == CPU_TYPE_604) || (CPU_TYPE == CPU_TYPE_604E) ||	 (CPU_TYPE == CPU_TYPE_604R) || (CPU_TYPE == CPU_TYPE_750))	{	return;	}#endif	/* (CPU == PPC604) */    /* Invalid CPU type; print error message and terminate */    msgSize = strlen (sysWrongCpuMsg);    sysSerialHwInit ();    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for (msgIx = 0; msgIx < msgSize; msgIx++)	{	while (sioPollOutput (pSioChan, sysWrongCpuMsg[msgIx]) == EAGAIN);	}    sysToMonitor (BOOT_NO_AUTOBOOT);    }/******************************************************************************** sysDebugMsg - print a debug string to the console in polled mode.** This routine prints a message to the system console in polled mode and* optionally exits to the monitor.** RETURNS: N/A**/void sysDebugMsg    (    char * str,    UINT32  recovery    )    {    int msgSize;    int msgIx;    SIO_CHAN * pSioChan;        /* serial I/O channel */    msgSize = strlen (str);    sysSerialHwInit ();    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for (msgIx = 0; msgIx < msgSize; msgIx++)        {        while (sioPollOutput (pSioChan, str[msgIx]) == EAGAIN);        }    }/******************************************************************************** sysDelay - delay for approximately one millisecond** Delay for approximately one milli-second.** RETURNS: N/A*/void sysDelay (void)    {    sysMsDelay (1);    }/******************************************************************************** sysMsDelay - delay for the specified amount of time (MS)** This routine will delay for the specified amount of time by counting* decrementer ticks.** This routine is not dependent on a particular rollover value for* the decrementer, it should work no matter what the rollover* value is.** A small amount of count may be lost at the rollover point resulting in* the sysMsDelay() causing a slightly longer delay than requested.** This routine will produce incorrect results if the delay time requested* requires a count larger than 0xffffffff to hold the decrementer* elapsed tick count.  For a System Bus Speed of 67 MHZ this amounts to* about 258 seconds.** RETURNS: N/A*/void sysMsDelay    (    UINT        delay                   /* length of time in MS to delay */    )    {    register UINT oldval;               /* decrementer value */    register UINT newval;               /* decrementer value */    register UINT totalDelta;           /* Dec. delta for entire delay period */    register UINT decElapsed;           /* cumulative decrementer ticks */    /*     * Calculate delta of decrementer ticks for desired elapsed time.     */    totalDelta = ((DEC_CLOCK_FREQ / 4) / 1000) * delay;    /*     * Now keep grabbing decrementer value and incrementing "decElapsed" until     * we hit the desired delay value.  Compensate for the fact that we may     * read the decrementer at 0xffffffff before the interrupt service     * routine has a chance to set in the rollover value.     */    decElapsed = 0;    oldval = vxDecGet ();    while (decElapsed < totalDelta)	{	newval = vxDecGet ();	if ( DELTA(oldval,newval) < 1000 )	    decElapsed += DELTA(oldval,newval);  /* no rollover */	else	    if (newval > oldval)		decElapsed += abs((int)oldval);  /* rollover */	oldval = newval;	}    }/******************************************************************************** sysMemProbeTrap - trap handler for vxMemProbe exception** This routine is called from the excConnectCode stub if sysMemProbeSup* generates an exception. By default, sysMemProbeSup returns OK.* This code changes the PC value to "sysProbeExc" (within the sysMemProbeSup* routine), and sysProbeExc sets the return value to ERROR.*/static int sysMemProbeTrap    (    ESFPPC *    pEsf		/* pointer to exception stack frame */    )    {    REG_SET *pRegSet = &pEsf->regSet;    pRegSet->pc = (_RType)sysProbeExc;	/* sysProbeExc forces an ERROR return */    return (0);    }/******************************************************************************** sysPciWriteFlush - flush posted PCI writes from buffer** This routine flushes the posted write buffer in the Raven and the Dec2155x if* it is present.** RETURNS: OK if flush succeeded or ERROR if an error occured.*/STATUS sysPciWriteFlush(void)    {    UINT16   devId;    /*     * Flush Raven posted write buffer by doing a dummy read of one     * of its MPC registers     */    devId = sysIn16 ((UINT16 *)(RAVEN_BASE_ADRS + RAVEN_MPC_DEVID));    return (OK);    }/******************************************************************************** sysMemProbeBus - probe an address on a bus.** This routine probes a specified address to see if it is readable or* writable, as specified by <mode>.  The address will be read or written as* 1, 2, or 4 bytes as specified by <length> (values other than 1, 2, or 4* yield unpredictable results).  If the probe is a VX_READ, the value read will* be copied to the location pointed to by <pVal>.  If the probe is a VX_WRITE,* the value written will be taken from the location pointed to by <pVal>.* In either case, <pVal> should point to a value of 1, 2, or 4 bytes, as* specified by <length>.** This routine probes the specified address with interrupts disabled and* a special handler for Machine Check, Data Access and Alignment exceptions.** RETURNS: OK if probe succeeded or ERROR if an exception occured.*/LOCAL STATUS sysMemProbeBus    (    char   * adrs,	/* address to be probed */    int      mode,	/* VX_READ or VX_WRITE */    int      length,	/* 1, 2 or 4 byte probe */    char   * pVal,	/* address of value to write OR */			/* address of location to place value read */    UINT16   ravenCnfg  /* raven probe configuration */    )    {    int      oldLevel;    FUNCPTR  oldVec1;    FUNCPTR  oldVec2;    STATUS   status;    UINT16   devId;    UINT16   mpcErrEnbl;/* Raven MPC Error Enable reg */    UINT32   ppcHid0;   /* H/W Implementation Dependent reg (PPC60x) */    UINT32   ppcMsr;    /* PPC Machine Status Reg */    /* Probes performed with interrupts disabled */    oldLevel = intLock ();    /* Handle Machine Check Exceptions locally */    oldVec1 = excVecGet ((FUNCPTR *) _EXC_OFF_MACH);    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, FUNCREF(sysMemProbeTrap));     /*     *  Handle Data Access Exceptions locally     *     *  Data Access Exceptions will occur when trying to probe addresses     *  that have not been mapped by the MMU.     */    oldVec2 = excVecGet ((FUNCPTR *) _EXC_OFF_DATA);    excVecSet ((FUNCPTR *) _EXC_OFF_DATA, FUNCREF(sysMemProbeTrap));    /* Enable Abort Machine Check Exception generation by Raven */    mpcErrEnbl = sysIn16 ((UINT16 *)(RAVEN_BASE_ADRS + RAVEN_MPC_MEREN));    sysOut16 ((UINT16 *)(RAVEN_BASE_ADRS + RAVEN_MPC_MEREN),              mpcErrEnbl | ravenCnfg);    /* Enable Machine Check Pin (EMCP) */    ppcHid0 = vxHid0Get();    vxHid0Set(ppcHid0 | _PPC_HID0_EMCP);    /* Enable Machine Check exception */    ppcMsr = vxMsrGet();    vxMsrSet(ppcMsr | _PPC_MSR_ME);    /* do probe */    if (mode == VX_READ)        {        status = sysMemProbeSup (length, adrs, pVal);        EIEIO_SYNC;        }    else        {        status = sysMemProbeSup (length, pVal, adrs);        EIEIO_SYNC;        /*         *  Flush the probe instruction out of the Raven by         *  doing a dummy read of one of its' MPC registers         */         devId = sysIn16 ((UINT16 *)(RAVEN_BASE_ADRS + RAVEN_MPC_DEVID));        }    /* Restore previous MSR value */    vxMsrSet(ppcMsr);    /* Restore previous HID0 value */    vxHid0Set(ppcHid0);    /* Restore previous Raven configuration */    sysOut16 ((UINT16 *)(RAVEN_BASE_ADRS + RAVEN_MPC_MEREN), mpcErrEnbl);    /* restore original vectors and unlock */    excVecSet ((FUNCPTR *) _EXC_OFF_DATA, oldVec2);    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, oldVec1);    intUnlock (oldLevel);    return (status);    }/******************************************************************************** sysProbeErrClr - clear errors associated with probing an address on a bus.** This routine clears the error flags and conditions in the DAR, DSISR, SRR0* and SRR1 PowerPC registers arising from probing addresses as well as the* Raven MERST and PCI_CFG_STATUS registers and V_AMERR registers.** RETURNS: N/A*/void sysProbeErrClr (void)    {    /* Clear Raven MPC MERST Register */    sysOutByte ((ULONG)(RAVEN_BASE_ADRS + RAVEN_MPC_MERST),		RAVEN_MPC_MERST_CLR);    /* Clear Raven's Cnfg Hdr Status Reg */    pciConfigOutWord (sysRavPciBusNo, sysRavPciDevNo, sysRavPciFuncNo,                      PCI_CFG_STATUS, RAVEN_PCI_CFG_STATUS_CLR);    /* Clear PowerPC Data Access Exception Registers */    vxDarSet   (0);    vxDsisrSet (0);    vxSrr0Set  (0);    vxSrr1Set  (0);    }/******************************************************************************** sysPciProbe - probe a PCI bus address** This routine probes an address on the PCI bus.  The PCI bridge (Raven chip)* must have a special setup to enable generation of Master Abort cycles on* write probes and reception of Target Abort cycles on read probes.  The Raven* MPC must be configured to generate Machine Check interrupts on Master Abort* or Target Abort cycles.  The CPU must be configured to enable Machine Check* exceptions.  All probing is done with interrupts disabled.** RETURNS: OK or ERROR if address cannot be probed*/STATUS sysPciProbe    (    char   * adrs,	/* address to be probed */    int      mode,	/* VX_READ or VX_WRITE */    int      length,	/* 1, 2 or 4 byte probe */    char   * pVal	/* address of value to write OR */			/* address of location to place value read */    )    {    STATUS status = ERROR;    /* Perform probe */    status = sysMemProbeBus (adrs, mode, length, pVal, RAVEN_MPC_MEREN_SMAM);    return (status);    }/******************************************************************************** sysBusProbe - probe a bus address based on bus type.** This routine is a function hook into vxMemProbe.  It determines which bus,* PCI or local is being probed based on the address to be probed.* If the PCI bus is being probed, the sysPciProbe() routine is called to do the* special PCI probing. If the local bus is being probed, the routine calls an* architecture-specific probe routine.** RETURNS: ERROR if the probed address does not respond or causes a MMU fault.* Returns OK if the probed address responds.*/STATUS  sysBusProbe    (    char   * adrs,	/* address to be probed */    int      mode,	/* VX_READ or VX_WRITE */    int      length,	/* 1, 2 or 4 byte probe */    char   * pVal	/* address of value to write OR */			/* address of location to place value read */    )    {    STATUS status;    /* Clear any existing errors/exceptions */    sysProbeErrClr ();    /* Handle PCI bus in special manner */

⌨️ 快捷键说明

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