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

📄 syslib_5100.c

📁 sysLib.c - generic PPC system-dependent library 5100BSP重要文件
💻 C
📖 第 1 页 / 共 5 页
字号:
    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* MVME5100 uses a 48T37 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_7400) || (CPU_TYPE == CPU_TYPE_7410))        {        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);    }/******************************************************************************** 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 (sysHawkPciBusNo, sysHawkPciDevNo, sysHawkPciFuncNo,                       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 - Universe Register Access Image (for 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_RAI_MSTR_SIZE != 0) && ((UINT32)adrs >= VME_RAI_MSTR_BUS) &&        ((UINT32)adrs <= (VME_RAI_MSTR_BUS + VME_RAI_MSTR_SIZE)))        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 */    pciSlv1Ctl = sysPciInLong (lsiCtlReg);    if (mode == VX_WRITE)        {        sysPciOutLong (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))        {        sysPciOutLong (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 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, HAWK_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,* VME, PCI or local is being probed based on the address to be probed.* If the VME bus is being probed, the sysVmeProbe() routine is called to do* the special VME probing.  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 returns ERROR which indicates that the default local* bus probe in vxMemProbe() should be used.** RETURNS: ERROR if local bus is being probed, OK if VME or PCI bus.*/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 VME bus in special manner */    if (IS_VME_ADDRESS(adrs))        status = sysVmeProbe (adrs, mode, length, pVal);    /* Handle PCI bus in special manner */    else if (IS_PCI_ADDRESS(adrs))        status = sysPciProbe (adrs, mode, length, pVal);    /* Handle local bus in architecture-specific manner */    else        status = vxMemArchProbe (adrs, mode, length, pVal);    /* Clear any errors/exceptions before exiting */    sysProbeErrClr ();    return (status);    }/******************************************************************************** sysUsDelay - delay at least the specified amount of time (in microseconds)** This routine will delay for at least the specified amount of time using the* lower 32 bit "word" of the Time Base register as the timer.  The accuracy of* the delay increases as the requested delay increases due to a certain

⌨️ 快捷键说明

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