📄 syslib.c
字号:
#if defined(SYS_SM_ANCHOR_POLL_LIST) && defined(INCLUDE_DEC2155X)
LOCAL SYS_SM_ANCHOR_POLLING_LIST sysSmAnchorPollList[] =
{
SYS_SM_ANCHOR_POLL_LIST
{ 0xffffffff, 0xffffffff } /* Required entry: marks end of list */
};
#endif
LOCAL int sysSmUtilTasValue = 0; /* special soft tas value */
/* last 5 nibbles are board specific, initialized in sysHwInit */
unsigned char lnEnetAddr [6] = { 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00 };
unsigned char clearWd [1] = { 0x00 };
/* locals */
LOCAL char sysModelStr[80];
LOCAL char wrongCpuMsg[] = WRONG_CPU_MSG;
/* forward declarations */
void sysSpuriousIntHandler(void);
void sysCpuCheck (void);
char * sysPhysMemTop (void);
void sysBusTasClear (volatile char *);
STATUS sysBusProbe (char *, int, int, char *);
IMPORT UINT sysHid1Get(void);
void sysFpSet(ULONG tmp);
void sysDebugMsg(char * str, UINT32 recovery);
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) */
void led12(unsigned short );
void led11(unsigned short );
void flashled(unsigned short ,unsigned short );
void sysPciInsertLong (UINT32, UINT32, UINT32);
void sysPciInsertWord (UINT32, UINT16, UINT16);
void sysPciInsertByte (UINT32, UINT8, UINT8);
void sysPciOutLongConfirm (UINT32, UINT32);
void sysPciOutWordConfirm (UINT32, UINT16);
void sysPciOutByteConfirm (UINT32, UINT8);
void sysDelay (void);
/* add by zoutl for test 2003-3-28 9:42 */
void testConfigReg(void);
void AddMyexcHandler( void );
/* add by zoutl for test 2003-3-28 9:42 */
#ifdef INCLUDE_PCI9030
void pci9030Init(void);
#endif
#ifdef INCLUDE_SM_NET
LOCAL STATUS sysPciConfig21554InLong (int, int, int, int, UINT32 *);
LOCAL int sysPciConfigPack21554 ( int, int, int, int);
LOCAL void sysSmParamsCompute (void);
int sysSmArg2Compute (void);
# if (SM_OFF_BOARD == TRUE)
# ifdef SYS_SM_ANCHOR_POLL_LIST
LOCAL UINT sysSmAnchorCandidate ( UINT, UINT, UINT);
# endif
LOCAL STATUS sysSmAnchorFind ( int, char **);
LOCAL char *sysSmAnchorPoll (void);
char * sysSmAnchorAdrs (); /* Anchor address (dynamic) */
# endif
#endif /* INCLUDE_SM_NET */
/* 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 UINT8 sysPciConfigInByte (UINT8 * dataPtr);
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 sysInLongRev ( UINT32);
IMPORT void sysOutLongRev (UINT32, UINT32);
IMPORT UINT16 sysInWordRev (UINT32);
IMPORT void sysOutWordRev (UINT32, UINT16);
/* BSP DRIVERS */
#include "pci/pciConfigLib.c"
#include "sysSerial.c"
#include "mem/nullNvRam.c"
#include "timer/ppcDecTimer.c" /* PPC603 has on chip timers */
/* add by zoutl for NVRam & double boot 2003-4-21 19:01 */
/* delete by wanggeng 20050729
#include "../../Modules/DoubleBoot/xpbConI2c.c"
#include "../../Modules/DoubleBoot/xpbConEeprom.c"
#include "../../Modules/DoubleBoot/BootRomDrv.c"
*/
#ifdef INCLUDE_NETWORK
# include "sysNet.c"
# ifdef INCLUDE_END
# ifdef INCLUDE_RTL_81X9_END
# include "sysRtl81x9End.c"
# include "rtl81x9.c"
# endif /* INCLUDE_RTL_81X9_END */ /*INCLUDE_RTL_81X9_END is added by mashuyu*/
# ifdef INCLUDE_RTL_CP_END
# include "rtlcpp.c"
# include "sysRtlcpEnd.c"
# include "rtl8139Config.c"
# endif
# endif /* INCLUDE_END */
#endif /* INCLUDE_NETWORK */
#ifdef INCLUDE_SHOW_ROUTINES
#include "pci/pciConfigShow.c" /* display of PCI config space */
#endif
#ifdef INCLUDE_SCSI
# include "sysScsi.c" /* sysScsiInit routine */
#endif /* INCLUDE_SCSI */
#ifdef INCLUDE_TFFS
# include "i28f640.c"
# include "p755-sysTffs.c"
# include "trueFFS.c" /* tffs routine */
#endif /* INCLUDE_TFFS */
#include "mpc8240Epic.c"
#ifdef INCLUDE_AUXCLK
# include "mpc8240AuxClk.c"
#endif
/* add by zoutl for test BSP 2003-5-30 14:31 */
#ifdef BSP_TEST
# include "./test/mpc8240AuxClk1.c"
# include "./test/NetTest.c"
#endif
#if 0
# include "pci/pciAutoConfigLib.c"
#else
# include "./pci/pciAutoConfigLib.c"
#endif
# include "./sysBusPci.c"
#include "i2o.c"
#include "i2c.c"
#include "flash.c"
#include "pciAddrAlloc.c"
/* delete by wanggeng 20050729
#include "BspCpusApi.c"
*/
/*#include "rtc.c"*/
/*#include "dma.c"*/
/*#include "testfile.c"*/
/* defines for sysBusTas() and sysBusTasClear() */
#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, "ZTE CDMA LPB %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 four 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)
{
/* Validate CPU type */
sysCpuCheck();
/*12.30 for 64bit opt*/
#if(1)
sysFpSet(0);
#endif
/* 写EUMB寄存器 Added by xdg*/
/* 参数中前者是需要写到PCI配置地址寄存器的值,后者是需要写到PCI配置数据寄存器的值*/
sysPciConfigOutLong ( (UINT32*)(CNFG_PCI_HOST_BRDG+MPC8240_CFG_EUMBBAR), \
(UINT32)MPC8240_EUMB_BASE );
sysPciConfigOutLong ( (UINT32*)(CNFG_PCI_HOST_BRDG+0xD0), \
(UINT32)0x85080000 );
sysPciConfigOutLong ( (UINT32*)(CNFG_PCI_HOST_BRDG+0xD8), \
(UINT32)0x0000000B );
/*
* 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 ();
/* add by zoutl 2003-5-24 10:32 */
#ifdef BOOT_DEBUG_MSG
sysDebugMsg("sysPhysMemTop succeed!\n\r",0);
#endif
/* Initialize PCI driver library. */
if (pciConfigLibInit (PCI_MECHANISM_1, PCI_MSTR_PRIMARY_CAR,
PCI_MSTR_PRIMARY_CDR, 0) != OK)
{
sysToMonitor (BOOT_NO_AUTOBOOT);
}
/* 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 )
{pci1200=1;
}
if(1)
{
/* in ROM boot phase, OK to continue and configure PCI busses.*/
sysPciAutoConfig ();
PCI_AUTOCONFIG_FLAG++; /* Remember that PCI is configured */
}
/* add by zoutl 2003-5-24 10:32 */
#ifdef BOOT_DEBUG_MSG
sysDebugMsg("sysPciAutoConfig succeed!\n\r",0);
#endif
/* Initialize the EPIC. */
sysEpicInit();
/* add by zoutl 2003-5-24 10:32 */
#ifdef BOOT_DEBUG_MSG
sysDebugMsg("sysEpicInit succeed!\n\r",0);
#endif
/* set pointer to bus probing hook */
_func_vxMemProbeHook = (FUNCPTR)sysBusProbe;
/* Initialize COM1 and COM2 serial channels */
/*pciConfigOutLong (0, 21, 0, 0x18, 0x88000000); */
sysSerialHwInit();
/* add by zoutl 2003-5-24 10:32 */
#ifdef BOOT_DEBUG_MSG
sysDebugMsg("sysSerialHwInit succeed!\n\r",0);
#endif
#ifdef INCLUDE_NETWORK
/* Initialize the network */
sysNetHwInit();
/* add by zoutl 2003-5-24 10:32 */
#ifdef BOOT_DEBUG_MSG
sysDebugMsg("sysNetHwInit succeed!\n\r",0);
#endif
#endif
/*#ifdef INCLUDE_PCI9030
pci9030Init();
#endif*/
}
/*******************************************************************************
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -