欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

syslib.c

大名鼎鼎的mpc8260的bsp源代码
C
第 1 页 / 共 3 页
字号:
     if (pciConfigLibInit (PCI_MECHANISM_1, PCI_PRIMARY_CAR,
				PCI_PRIMARY_CDR, NULL) != OK)
		    {
		    sysToMonitor (BOOT_NO_AUTOBOOT);
		    }
    SysQspanHwInit((PQSPAN)(0x70000000));
    sysPCISpaceAssign();


    /* Reset serial channels */

    sysSerialHwInit();

#if 0
    /*Reset PCI config*/
    
    sysQspanHwInit();

    /* Reset the CT69000 configure */
    sysCt69kHwInit();
#endif

#if 0	
    HW_NT_Initial(0);
	
    HW_NT_Initial(1);
#endif	
#if 0
    reset_chips();
    I2CInit();	
    HW_Audio_Initial();
#endif	
        
    }


/******************************************************************************
*
* sysPciTrap - trap handler for PCI exception
*
* This routine is called from the excConnectCode stub if the PCI configuration
* access generates an exception. By default, sysIn... returns the value read.
* This code changes the PC to sysPciErr which sets the return value to -1.
*  NOTE:  The QSpan PCI Bridge causes machine check exceptions to
*  occur when a non-present device address is put into the
*  configuration register.  This is why the sysPciTrap routine
*  is essential.
*
* RETURNS: N/A
*/

void sysPciTrap
    (
    ESFPPC *    pEsf			/* pointer to exception stack frame */
    )
    {
    REG_SET *pRegSet = &pEsf->regSet;
    pRegSet->pc = (_RType)sysPciErr;	/* sysPciErr forces a -1 return */
    }


/******************************************************************************
*
* sysPciCfgRead - read longword from PCI configuration space
*
* This does a QSPAN style PCI read.  This function is passed as a pointer 
* during initialization of PCI mechanism 0 in pciConfigLibInit.  This 
* function has the machine check handler support included in.
*
* RETURNS: OK always.
*/

STATUS sysPciCfgRead
    (
    int busNo,
    int deviceNo,
    int funcNo,
    int offset,
    int size, /* 1, 2, or 4 */
    void * pResult
    )
    {
    FUNCPTR     machCheckHandler;
    IMPORT int  pciConfigBdfPack(int bus, int dev, int func);
    int         key;
    STATUS      result = OK;
    UINT32      conAdrVal;
    UINT32      conDataReg;

    /* generate coded value for CON_ADR register */

    conAdrVal = pciConfigBdfPack (busNo, deviceNo, funcNo) | (offset & 0xfc);
    conDataReg = (UINT32)PCI_PRIMARY_CDR + (offset & 0x3);

    /* Use Type 1, if bus is not the local bus */

    if (busNo != PCI_HOST_BUS_NBR)
        conAdrVal |= 0x1; /* do type 1 for other busses */

    /*
     * Connect the PowerPC machine check exception to catch exceptions,
     * Save off the existing handler first.
     * NOTE:  The QSpan PCI Bridge causes machine check exceptions to
     * occur when a non-present device address is put into the
     * configuration register.
     */

    machCheckHandler = excVecGet ((FUNCPTR *) _EXC_OFF_MACH);

    key = intLock ();

    /* Load the CON_ADR (CAR) value first, then read from CON_DATA (CDR) */

    PCI_OUT_LONG (PCI_PRIMARY_CAR, conAdrVal);

    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, (FUNCPTR)sysPciTrap);


    switch (size)
	{
	case 4:
	    /* Note: *pResult comes back as -1 if machine check happened */

	    if ( (*(UINT32 *)pResult = PCI_IN_LONG (conDataReg)) == 0xffffffff)
		result = ERROR;
	    break;

	case 2:

	    if ((*(UINT16 *)pResult = PCI_IN_WORD (conDataReg)) == 0xffff)
		result = ERROR;
	    break;

	case 1:

	    if ((*(UCHAR *)pResult = PCI_IN_BYTE (conDataReg)) == 0xff)
		result = ERROR;
	    break;

	default:

	    result = ERROR;
	    break;
	}

    /* Restore the PowerPC machine check exception */

    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, (FUNCPTR)machCheckHandler);

    intUnlock (key);

    return (result);
    }


/******************************************************************************
*
* sysPciCfgWrite - write longword to PCI configuration space
*
* This does a QSPAN style PCI write.  This function is passed as a pointer
* during initialization of PCI mechanism 0 in pciConfigLibInit.  This 
* function has the machine check handler support included in.
*
* RETURNS: OK always
*/

STATUS sysPciCfgWrite
    (
    int busNo,
    int deviceNo,
    int funcNo,
    int offset,
    int size,
    UINT32 data
    )
    {
    FUNCPTR     machCheckHandler;
    IMPORT int  pciConfigBdfPack(int bus, int dev, int func);
    int         key;
    STATUS      result = OK;
    UINT32      conAdrVal;
    UINT32      conDataReg;

    conAdrVal = pciConfigBdfPack (busNo, deviceNo, funcNo) | (offset & 0xfc);
    conDataReg = PCI_PRIMARY_CDR + (offset & 0x3);

    if (busNo != 0)
        conAdrVal |= 0x1; /* do type 1 for other bus */

    /*
     * Connect the PowerPC machine check exception to catch exceptions,
     * Save off the existing handler first.
     * NOTE:  The QSpan PCI Bridge causes machine check exceptions to
     * occur when a non-present device address is put into the
     * configuration register.
     */

    key = intLock ();

    machCheckHandler = excVecGet ((FUNCPTR *) _EXC_OFF_MACH);

    PCI_OUT_LONG (PCI_PRIMARY_CAR, conAdrVal);

    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, (FUNCPTR)sysPciTrap);

    switch (size)
	{
	case 4:
	    PCI_OUT_LONG (conDataReg, (UINT32)data);
	    break;

	case 2:
	    PCI_OUT_WORD (conDataReg, (UINT16)data);
	    break;

	case 1:
	    PCI_OUT_BYTE (conDataReg, (UINT8)data);
	    break;

	default:
	    result = ERROR;
	    break;
	}

    /* Restore the PowerPC machine check exception */

    excVecSet ((FUNCPTR *) _EXC_OFF_MACH, (FUNCPTR)machCheckHandler);

    intUnlock (key);

    return (result);
    }

/*******************************************************************************
*
* 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.
*
* RETURNS: The address of the top of physical memory.
*
* SEE ALSO: sysMemTop()
*/

char * sysPhysMemTop (void)
    {
    static char * physTop = NULL;

    if (physTop == NULL)
	{
	physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);
	}

    return (physTop) ;
    }

/*******************************************************************************
*
* sysMemTop - get the address of the top of VxWorks memory
*
* This routine returns a pointer to the first byte of memory not
* controlled or used by VxWorks.
*
* The user can reserve memory space by defining the macro USER_RESERVED_MEM
* in config.h.  This routine returns the address of the reserved memory
* area.  The value of USER_RESERVED_MEM is in bytes.
*
* RETURNS: The address of the top of VxWorks memory.
*/

char * sysMemTop (void)
    {
    static char * memTop = NULL;

    if (memTop == NULL)
	{
	memTop = sysPhysMemTop () - USER_RESERVED_MEM;
	}

    return memTop;
    }


/******************************************************************************
*
* sysToMonitor - transfer control to the ROM monitor
*
* This routine transfers control to the ROM monitor.  Normally, it is called
* only by reboot()--which services ^X--and bus errors at interrupt level.
* However, in some circumstances, the user may wish to introduce a
* <startType> to enable special boot ROM facilities.
*
* RETURNS: Does not return.
*/

STATUS sysToMonitor
    (
     int startType	/* parameter passed to ROM to tell it how to boot */
    )
    {
    FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4);	/* Warm reboot */

    *CIMR(vxImmrGet()) = 0;     /* disable all cpm interupts */
    
    sysCpmEnetDisable (0);	/* disable the ethernet device */

#ifdef INCLUDE_MOT_FEC

    /* disable the FEC */

    sysFecEnetDisable (vxImmrGet ());

#endif /* INCLUDE_MOT_FEC */
 
    sysSerialReset();		/* reset the serail device */

    (*pRom) (startType);	/* jump to bootrom entry point */

    return (OK);	/* in case we ever continue from ROM monitor */
    }

/******************************************************************************
*
* sysHwInit2 - additional system configuration and initialization
*
* This routine connects system interrupts and does any additional
* configuration necessary.
*
* RETURNS: N/A
*/

void sysHwInit2 (void)
    {
    static BOOL configured = FALSE;
    int		immrVal;

    if (!configured)
	{

	immrVal = vxImmrGet();

	/* initialize serial interrupts */

	sysSerialHwInit2();

#if 0
    PrepareUInt();
 #endif   
	* SCCR(immrVal) &= ~SCCR_TBS;

	/* un-freeze the Time Base clock */

	* TBSCR(immrVal) = TBSCR_TBE ;

	configured = TRUE;
	}
    }

/******************************************************************************
*
* sysProcNumGet - get the processor number
*
* This routine returns the processor number for the CPU board, which is
* set with sysProcNumSet().
* 
* RETURNS: The processor number for the CPU board.
*
* SEE ALSO: sysProcNumSet()
*/

int sysProcNumGet (void)
    {
    return (sysProcNum);
    }

/******************************************************************************
*
* sysProcNumSet - set the processor number
*
* This routine sets the processor number for the CPU board.  Processor numbers
* should be unique on a single backplane.
*
* Not applicable for the busless 860Ads.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*
*/

void sysProcNumSet
    (
    int 	procNum			/* processor number */
    )
    {
    sysProcNum = procNum;
    }

/******************************************************************************
*
* sysLocalToBusAdrs - convert a local address to a bus address
*
* This routine gets the VMEbus address that accesses a specified local

⌨️ 快捷键说明

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