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

📄 syslib.c

📁 VxWorks下 MV2400的BSP源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* return TAS test result */    if (state)        {	return (FALSE);	}    else        {        return (TRUE);        }    }/******************************************************************************** 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.** 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) ||         (CPU_TYPE == CPU_TYPE_MAX))	{	return;	}#endif	/* (CPU == PPC604) */    /* Invalid CPU type; print error message and terminate */    msgSize = strlen (wrongCpuMsg);    sysSerialHwInit ();    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for (msgIx = 0; msgIx < msgSize; msgIx++)    	{    	while (sioPollOutput (pSioChan, wrongCpuMsg[msgIx]) == EAGAIN);    	}    sysToMonitor (BOOT_NO_AUTOBOOT);    }#if defined(INCLUDE_PMC_SPAN) && !defined(INCLUDE_PCI_AUTOCONF)/******************************************************************************** sysPmcSpanConfig - configure the PMC Span (DEC21150 PCI-to-PCI Bridge)** This routine configures the DEC21150 PCI-to-PCI Bridge on the PMC Span.** RETURNS: OK or ERROR if pciConfigLib has not been initialized.*/STATUS sysPmcSpanConfig    (    int         pciBusNo,       /* PCI bus number */    int         pciDevNo,       /* PCI device number */    int         pciFuncNo,      /* PCI function number */    PMC_SPAN *  pmcSpan         /* pointer to PMC Span config array */    )    {    STATUS      result = OK;    FAST        i;    /* Write all parameters in pcmSpan in the order given */    for (i = 0; i < NUM_PMC_SPAN_PARMS && result == OK; ++i)        {        switch (pmcSpan[i].parmSize)            {            case 1:                result = pciConfigOutByte (pciBusNo, pciDevNo, pciFuncNo,                                           pmcSpan[i].parmOffset,                                           pmcSpan[i].parmValue);                break;            case 2:                result = pciConfigOutWord (pciBusNo, pciDevNo, pciFuncNo,                                           pmcSpan[i].parmOffset,                                           pmcSpan[i].parmValue);                break;            case 4:                result = pciConfigOutLong (pciBusNo, pciDevNo, pciFuncNo,                                           pmcSpan[i].parmOffset,                                           pmcSpan[i].parmValue);                break;            }        }    return (result);    }#endif /* INCLUDE_PMC_SPAN *//******************************************************************************** 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);    }/******************************************************************************** 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.*/static 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   hawkCnfg   /* Hawk probe configuration */    )    {    int      oldLevel;    FUNCPTR  oldVec1;    FUNCPTR  oldVec2;    STATUS   status;    UINT16   devId;    UINT16   mpcErrEnbl;/* Hawk 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 Hawk */    mpcErrEnbl = sysIn16 ((UINT16 *)(HAWK_PHB_BASE_ADRS + HAWK_MPC_MEREN));    sysOut16 ((UINT16 *)(HAWK_PHB_BASE_ADRS + HAWK_MPC_MEREN),              mpcErrEnbl | hawkCnfg);    /* 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 Hawk by         *  doing a dummy read of one of its' MPC registers         */         devId = sysIn16 ((UINT16 *)(HAWK_PHB_BASE_ADRS + HAWK_MPC_DEVID));        }    /* Disable Machine Check Exceptions */    vxMsrSet(ppcMsr);    /* Disable Machine Check Pin (EMCP) */    vxHid0Set(ppcHid0);    /* Restore previous Hawk configuration */    sysOut16 ((UINT16 *)(HAWK_PHB_BASE_ADRS + HAWK_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* Hawk MERST and PCI_CFG_STATUS registers and the Universe PCI_CSR and* V_AMERR registers.** RETURNS: N/A*/void sysProbeErrClr (void)    {    UINT32  pciCsr;    /* Get current status */    sysPciRead32 ((UINT32)(UNIVERSE_PCI_CSR), &pciCsr);    /* Clear PCI_CSR */    sysPciWrite32 ((UINT32)(UNIVERSE_PCI_CSR), pciCsr);    /* Clear any VME address error */    sysPciWrite32 ((UINT32)UNIVERSE_V_AMERR, V_AMERR_V_STAT);    /* Force write due to Write-Posting and get updated status */    sysPciRead32 ((UINT32)(UNIVERSE_PCI_CSR), &pciCsr);    /* Clear Hawk MPC MERST Register */    sysOutByte ((ULONG)(HAWK_PHB_BASE_ADRS + HAWK_MPC_MERST),		HAWK_MPC_MERST_CLR);    /* Clear Hawk's Cnfg Hdr Status Reg */    pciConfigOutWord (hawkPciBusNo, hawkPciDevNo, hawkPciFuncNo, PCI_CFG_STATUS,                      HAWK_PCI_CFG_STATUS_CLR);    /* Clear PowerPC Data Access Exception Registers */    vxDarSet   (0);    vxDsisrSet (0);    vxSrr0Set  (0);    vxSrr1Set  (0);    }/******************************************************************************** sysVmeProbe - probe a VME bus address** This routine probes an address on the VME bus.  The PCI bridge (Hawk 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 Hawk* 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.  In addition, if the probe is a write, the Universe must be* configured to disable Posted Writes.  All probing is done with interrupts* disabled.** NOTE: This routine assumes that the Universe Local Control registers are* dedicated to these VME address spaces:** .CS*   LSI0 - LM/SIG (mailbox)*   LSI1 - A32*   LSI2 - A24*   LSI3 - A16* .CE** RETURNS: OK or ERROR if address cannot be probed*/STATUS sysVmeProbe    (    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;    UINT32 lsiCtlReg;	/* adress of Local Control register in Universe */    UINT32 pciSlv1Ctl;	/* Universe PCI Slave Image Control reg */    /* Determine which Control register controls this address */    if ((VME_A32_REG_SPACE != 0) && ((UINT32)adrs >= VME_A32_REG_BASE) &&        ((UINT32)adrs <= (VME_A32_REG_BASE + VME_A32_REG_SPACE)))        lsiCtlReg = (UINT32)(UNIVERSE_LSI0_CTL);    else if ((VME_A32_MSTR_SIZE != 0) && ((UINT32)adrs >= VME_A32_MSTR_LOCAL) &&             ((UINT32)adrs <= (VME_A32_MSTR_LOCAL + VME_A32_MSTR_SIZE)))        lsiCtlReg = (UINT32)(UNIVERSE_LSI1_CTL);    else if ((VME_A24_MSTR_SIZE != 0) && ((UINT32)adrs >= VME_A24_MSTR_LOCAL) &&             ((UINT32)adrs <= (VME_A24_MSTR_LOCAL + VME_A24_MSTR_SIZE)))        lsiCtlReg = (UINT32)(UNIVERSE_LSI2_CTL);    else if ((VME_A16_MSTR_SIZE != 0) && ((UINT32)adrs >= VME_A16_MSTR_LOCAL) &&             ((UINT32)adrs <= (VME_A16_MSTR_LOCAL + VME_A16_MSTR_SIZE)))        lsiCtlReg = (UINT32)(UNIVERSE_LSI3_CTL);    else        return (ERROR);    /* If write probe, disable Posted Writes in Universe */    if (mode == VX_WRITE)        {        sysPciRead32 (lsiCtlReg, &pciSlv1Ctl);        sysPciWrite32 (lsiCtlReg, (pciSlv1Ctl & ~LSI_CTL_WP));        }    /* Perform probe */    status = sysMemProbeBus (adrs, mode, length, pVal, HAWK_MPC_MEREN_RTAM);    /* Restore Posted Writes by Universe if previously enabled */    if ((mode == VX_WRITE) && (pciSlv1Ctl & LSI_CTL_WP))        {        sysPciWrite32 (lsiCtlReg, pciSlv1Ctl);        }    return (status);    }/******************************************************************************** sysPciProbe - probe a PCI bus address** This routine probes an address on the PCI bus.  The PCI bridge (Hawk 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 Hawk* MPC must be configured to generate Machine Check interrup

⌨️ 快捷键说明

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