📄 syslib.c
字号:
int sysBus = VME_BUS; /* legacy */
int sysCpu = CPU; /* system CPU type (MC680x0) */
char *sysBootLine = BOOT_LINE_ADRS; /* address of boot line */
char *sysExcMsg = EXC_MSG_ADRS; /* catastrophic message area */
int sysProcNum = 0; /* processor number of this CPU */
int sysFlags; /* boot flags */
char sysBootHost [BOOT_FIELD_LEN]; /* name of host from which we booted */
char sysBootFile [BOOT_FIELD_LEN]; /* name of file from which we booted */
UINT sysVectorIRQ0 = INT_VEC_IRQ0;
UINT sysStrayIntCount = 0; /* Stray interrupt count */
#ifdef INCLUDE_ATA_686 /* ATA Hard Disk Driver */
ATA_RESOURCE ataResources[ATA_MAX_CTRLS]; /* ataDrv.h */
/*
* The first member in the ATA_TYPE struct has a dual purpose.
* 1) If cylinders == 0, the device location is not probed at startup.
* 2) If cylinders |= 0, the device location is probed, and if a device
* is found, the driver will fill in the first 3 member of the struct
* with number of cylinders, number of heads, and sectors per track.
*
* The last 2 members of the struct are static and should not be changed.
*
* The ATA_TYPE struct has the following layout:
* int cylinders;
* int heads;
* int sectorsTrack;
* int bytesSector;
* int precomp;
*
* NOTE: If configType == ATA_GEO_FORCE, the user must fill in
* values for cylinders, heads, and sectorsTrack.
*/
ATA_TYPE ataTypes [ATA_MAX_CTRLS][ATA_MAX_DRIVES] =
{
{
{ATA_DEV0_STATE, 0, 0, 512, 0xff}, /* ctrl 0, drive 0 */
{ATA_DEV1_STATE, 0, 0, 512, 0xff}, /* ctrl 0, drive 1 */
},
{
{ATA_DEV2_STATE, 0, 0, 512, 0xff}, /* ctrl 1, drive 0 */
{ATA_DEV3_STATE, 0, 0, 512, 0xff}, /* ctrl 1, drive 1 */
}
};
#endif /* INCLUDE_ATA_686 */
#ifdef INCLUDE_LPT_686
LPT_RESOURCE lptResources [N_LPT_CHANNELS] =
{
{LPT0_BASE_ADRS, INT_NUM_LPT0, LPT0_INT_LVL,
TRUE, 10000, 10000, 1, 1, 0
},
{LPT1_BASE_ADRS, INT_NUM_LPT1, LPT1_INT_LVL,
TRUE, 10000, 10000, 1, 1, 0
},
{LPT2_BASE_ADRS, INT_NUM_LPT2, LPT2_INT_LVL,
TRUE, 10000, 10000, 1, 1, 0
}
};
#endif /* INCLUDE_LPT_686 */
/* static locals */
LOCAL char sysModelStr [80] = SYS_MODEL; /* Sandpoint Model string */
LOCAL char sysInfoStr [200]; /* Sandpoint INFO string */
LOCAL char wrongCpuMsg [] = WRONG_CPU_MSG;
/* static locals which define the PREP or CHRP mapping */
LOCAL ULONG sysPciConfAddr; /* PCI Configuration Address */
LOCAL ULONG sysPciConfData; /* PCI Configuration Data */
LOCAL ULONG sysPciMstrIsaIoLocal; /* CPU's PCI ISA IO Address */
LOCAL ULONG sysPciMstrCfgAdrs; /* CPU's PCI Config Address */
LOCAL ULONG sysPciMstrIoLocal; /* CPU's PCI IO Address */
LOCAL ULONG sysPciMstrIackLocal; /* CPU's PCI IACK Address */
LOCAL ULONG sysPciMstrIsaMemLocal; /* CPU's PCI ISA MEMORY Address */
LOCAL ULONG sysPciMstrMemIoLocal; /* CPU's PCI Memory Address */
LOCAL ULONG sysPciSlvMemLocal; /* PCI view of system memory */
LOCAL ULONG sysPciMstrMemIoBus; /* PCI view of PCI */
/* forward declarations */
void ledRun(void);
extern STATUS ataDevIdentify
(
int ctrl,
int dev
);
char * sysPhysMemTop (void); /* Top of physical memory */
char * sysInfo (void);
void sysMemMapDetect (void); /* detect PREP or CHRP map */
void sysCpuCheck (void); /* detect CPU type */
void sysDelay (void); /* delay 1 millisecond */
void sysMsDelay (UINT delay); /* delay N millisecond(s) */
ULONG sys107RegRead (ULONG regNum);
void sys107RegWrite (ULONG regNum, ULONG regVal);
STATUS sysIntEnablePIC (int intNum); /* Enable i8259 or EPIC */
ULONG sysEUMBBARRead (ULONG regNum);
void sysEUMBBARWrite (ULONG regNum, ULONG regVal);
#if defined INCLUDE_PCI
STATUS sysPciSpecialCycle (int busNo, UINT32 message);
STATUS sysPciConfigRead (int busNo, int deviceNo, int funcNo,
int offset, int width, void * pData);
STATUS sysPciConfigWrite (int busNo, int deviceNo, int funcNo,
int offset, int width, ULONG data);
STATUS vt82c686PciConfigRead (int busNo, int deviceNo, int funcNo,
int offset, int width, void * pData);
STATUS vt82c686PciConfigWrite (int busNo, int deviceNo, int funcNo,
int offset, int width, ULONG data);
#endif /* INCLUDE_PCI */
#ifdef INCLUDE_MMU /* add a sysPhysMemDesc entry */
STATUS sysMmuMapAdd (void *address, UINT len,
UINT initialStateMask, UINT initialState);
#endif /* INCLUDE_MMU */
#ifdef INCLUDE_NVRAM /* NVRAM init and access routines */
void sysNvramHwInit (void);
UCHAR sysNvRead (ULONG);
void sysNvWrite (ULONG, UCHAR);
#if defined(INCLUDE_SYS_UPDATE_FLASH) /* reprogram the bootrom */
STATUS sysUpdateFlash (char * filename);
#endif /* INCLUDE_SYS_UPDATE_FLASH */
#endif /* INCLUDE_NVRAM */
#if defined(INCLUDE_NETWORK) && defined(INCLUDE_END) /* network */
#if defined(INCLUDE_DC_END)
STATUS sysDec21x40PciInit (void);
#endif /* INCLUDE_DC_END */
#if defined(INCLUDE_FEI_END)
void sys557PciInit (void);
#endif /* INCLUDE_FEI_END */
#if defined(INCLUDE_LN_97X_END)
STATUS sysLan97xPciInit (void);
#endif /* INCLUDE_LN_97X_END */
#if defined(INCLUDE_EL_3C90X_END)
STATUS sysEl3c90xPciInit (void);
#endif /* INCLUDE_LN_97X_END */
#endif /* INCLUDE_NETWORK && INCLUDE_END */
/* external imports */
IMPORT VOID sysOutWord (ULONG address, UINT16 data); /* sysALib.s */
IMPORT VOID sysOutLong (ULONG address, ULONG data); /* sysALib.s */
IMPORT USHORT sysInWord (ULONG address); /* sysALib.s */
IMPORT ULONG sysInLong (ULONG address); /* sysALib.s */
IMPORT VOID sysOutByte (ULONG, UCHAR); /* sysALib.s */
IMPORT UCHAR sysInByte (ULONG); /* sysALib.s */
IMPORT STATUS sysMemProbeSup (int length, char * src, char * dest);
IMPORT VOIDFUNCPTR _pSysL2CacheInvFunc;
IMPORT VOIDFUNCPTR _pSysL2CacheEnable;
IMPORT VOIDFUNCPTR _pSysL2CacheDisable;
IMPORT VOIDFUNCPTR _pSysL2CacheFlush;
IMPORT BOOL snoopEnable;
IMPORT ULONG sysPVRReadSys(void);
IMPORT VOIDFUNCPTR _pSysL3CacheFlushDisableFunc;
IMPORT VOIDFUNCPTR _pSysL3CacheInvalEnableFunc;
/*
* mmuPpcBatInitMPC74x5 initializes the standard 4 (0-3) I/D BAT's &
* the additional 4 (4-7) I/D BAT's present on the MPC74[45]5.
*/
IMPORT void mmuPpcBatInitMPC74x5 (UINT32 *pSysBatDesc);
/*
* mmuPpcBatInitMPC7x5 initializes the standard 4 (0-3) I/D BAT's &
* the additional 4 (4-7) I/D BAT's present on the MPC7[45]5.
*/
IMPORT void mmuPpcBatInitMPC7x5 (UINT32 *pSysBatDesc);
/* _pSysBatInitFunc needs to be set to either of the above 2 depending
on which processor it is running to make use of the additional BAT's
on the MPC 7455/755.
If this is not set or is set to NULL then the standard mmuPpcBatInit
fn. would be called which would initialize the (0-3) I/D BAT's
*/
IMPORT FUNCPTR _pSysBatInitFunc;
#if defined INCLUDE_ATA_686 /* ATA / EIDE driver */
IMPORT ATA_CTRL ataCtrl []; /* for sysAta.c */
IMPORT VOIDFUNCPTR _func_sysAtaInit;
#endif
/* By default this is set to NULL in the mmu Library and in that case
the standard BAT init func. to initialize the 4 I/D BAT's is called.
If the standard & Extra BAT's need to be initialized then set this
to the ones supplied by the mmuLib or else implement your own fn. and
supply it here.
*/
/* BSP DRIVERS */
#include "vme/nullVme.c" /* No VME bus on the Sandpoint */
#include "vt82c686PciIbc.c"
#include "sysEpic.c"
#ifdef INCLUDE_DUART
# include "sysDuart.c" /* 8245 Duart driver */
# include "ns16550Sio.c" /* NS Uart driver */
#endif /* INCLUDE_DUART */
#include "vt82c686.c" /* superIO support */
#ifndef SP8240
#include "sysCacheLockLib.c" /* Cache Lock/unlock library */
#endif
/*
* Note: local copies of pciConfigLig.c and pciAutoConfigLib.c are
* provided to work around a board problem with device IDSEL=12 causing
* a freeze-up when probed
*
*/
#if defined (INCLUDE_PCI)
# include "pci/pciIntLib.c" /* PCI int support */
# include "pci/pciConfigLib.c"
# ifdef INCLUDE_SHOW_ROUTINES
# include "pci/pciConfigShow.c" /* PCI config space display */
# endif /* INCLUDE_SHOW_ROUTINES */
# ifdef INCLUDE_PCI_AUTOCONF /* Sandpoint uses autoconfig */
# include "pci/pciAutoConfigLib.c" /* automatic PCI configuration */
# include "sysBusPci.c" /* pciAutoConfig BSP support file */
# endif /* INCLUDE_PCI_AUTOCONF */
#endif /* INCLUDE_PCI */
#if defined (INCLUDE_NVRAM)
# include "mem/byteNvRam.c" /* byte nvram routines */
#endif
#ifdef INCLUDE_SYSCLK
#include "timer/ppcDecTimer.c"
#endif /* INCLUDE_SYSCLK */
#ifdef INCLUDE_AUXCLK
#include "i8254AuxClk.c" /* i8254 (on via) support */
#endif
#if defined(INCLUDE_SERIAL)
#include "sysSerial.c" /* BSP i8250 sio/serial setup */
#endif
#ifdef INCLUDE_ATA_686
#include "sysAta.c" /* sysAtaInit() routine */
#include "atadrv.c"
#include "usrAta.c"
#include "ataShow.c"
#endif /* INCLUDE_ATA_686 */
#ifdef INCLUDE_FDC
#include "./isaDma.c"
#include "./fdcDrv.c"
#endif /* INCLUDE_FDC */
#ifdef INCLUDE_NETWORK
# include "./sysNet.c" /* network setup */
# ifdef INCLUDE_END
# ifdef INCLUDE_DC_END
# include "sysDec21x40End.c"
# endif /* INCLUDE_DC_END */
# ifdef INCLUDE_FEI_END
# include "sysFei82557End.c"
# endif /* INCLUDE_FEI_END */
# ifdef INCLUDE_LN_97X_END
# include "sysLn97xEnd.c"
# endif /* INCLUDE_LN_97X_END */
# ifdef INCLUDE_EL_3C90X_END
# include "sysEl3c90xEnd.c"
# endif /* INCLUDE_EL_3C90X_END */
# endif /* INCLUDE_END */
#endif /* INCLUDE_NETWORK */
#ifdef INCLUDE_FLASH
# include "mem/flashMem.c" /* 29F040 is supported */
#endif /* INCLUDE_FLASH */
#if defined(INCLUDE_WINDML)
#include "sysWindML.c"
#endif /* INCLUDE_WINDML */
/*******************************************************************************
*
* 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 Sandpoint - MPC8240"
*
* RETURNS: A pointer to the string.
*/
char * sysModel (void)
{
ULONG regVal;
ULONG procVer;
sprintf (sysModelStr, "Motorola %s", SYS_MODEL);
/* The CPU type is indicated in the Processor Version Register (PVR) */
regVal = sysPVRReadSys();
procVer = regVal & 0xffff;
regVal = regVal >>16;
switch (regVal)
{
case CPU_TYPE_603:
strcat (sysModelStr, "- MPC603");
break;
case CPU_TYPE_603E:
strcat (sysModelStr, "- MPC603E");
break;
case CPU_TYPE_603P:
strcat (sysModelStr, "- MPC603P");
break;
case CPU_TYPE_604:
strcat (sysModelStr, "- MPC604");
break;
case CPU_TYPE_604E:
strcat (sysModelStr, "- MPC604E");
break;
case CPU_TYPE_604R:
strcat (sysModelStr, "- MPC604R");
break;
case CPU_TYPE_750:
if ( procVer == CPU_TYPE_745 )
strcat (sysModelStr, "- MPC745");
else
if ( procVer == CPU_TYPE_755 )
strcat (sysModelStr, "- MPC755");
else
if ( procVer == CPU_VER_750 )
strcat (sysModelStr, "- MPC750");
else
if ( procVer == CPU_VER_740 )
strcat (sysModelStr, "- MPC740");
else
strcat (sysModelStr, "- MPC7xx");
break;
/* strcat (sysModelStr, "- MPC740/750");
break;*/
case CPU_TYPE_8240:
strcat(sysModelStr, "- MPC8240");
break;
case CPU_TYPE_8245:
#if defined(SP8241)
strcat(sysModelStr, "- MPC8241");
#elif defined(SP8245)
strcat(sysModelStr, "- MPC8245");
#else
strcat(sysModelStr, "- MPC8245/MPC8241");
#endif
break;
case CPU_TYPE_7400:
strcat(sysModelStr, "- MPC7400");
break;
case CPU_TYPE_7410:
strcat(sysModelStr, "- MPC7410");
break;
case CPU_TYPE_7450:
#if defined(SP7441)
strcat(sysModelStr, "- MPC7441");
#else
strcat(sysModelStr, "- MPC7450");
#endif
break;
case CPU_TYPE_7455:
#if defined(SP7445)
strcat(sysModelStr, "- MPC7445");
#else
strcat(sysModelStr, "- MPC7455");
#endif
break;
default:
break;
} /* switch */
return (sysModelStr);
}
#if defined (INCLUDE_ALTIVEC)
/*******************************************************************************
*
* sysAltivecProbe - Check if the CPU has ALTIVEC unit.
*
* This routine returns OK it the CPU has an ALTIVEC unit in it.
* Presently it checks for 7400
* RETURNS: OK - for 7400 Processor type
* ERROR - otherwise.
*/
int sysAltivecProbe (void)
{
ULONG regVal;
int altivecUnitPresent = ERROR;
/* The CPU type is indicated in the Processor Version Register (PVR) */
regVal = CPU_TYPE;
switch (regVal)
{
case CPU_TYPE_7400:
case CPU_TYPE_7410:
case CPU_TYPE_7450:
case CPU_TYPE_7455:
altivecUnitPresent = OK;
break;
default:
break;
} /* switch */
return (altivecUnitPresent);
}
#endif /* INCLUDE_ALTIVEC */
/*******************************************************************************
*
* sysInfo - return some information on the CPU board configuration
*
* This routine returns a string containing the L2 backside cache size,
* if enabled, the PCI map selected, and whether NVRAM is selected.
* The string may contain line feeds. For example,
*
* 512KB L2 backside cache enabled
* PCI Memory Map B
* NVRAM enabled
*
* RETURNS: A pointer to the string.
*/
char * sysInfo (void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -