📄 syslib.c
字号:
spllMulFactor = (*PLPRCR(immrVal) & 0x000f0000) >> 16;
spllFreq = spllMulFactor * cfg->sysXtalFreq;
cfg->sysCpuFreq = spllMulFactor * cfg->sysXtalFreq;
cfg->sysDecFreq = cfg->sysXtalFreq / 4;
cfg->sysBrgClkFreq = spllFreq / ( 1 << (2 * BRGCLK_DIV_FACTOR));
*PLPRCR(immrVal) = (*PLPRCR(immrVal) & ~PLPRCR_CSR); /* disable check stop reset */
/* if set by PlanetCore */
/* reset the port A */
*PAPAR(immrVal) = 0x0000;
*PADIR(immrVal) = 0x0000;
*PAODR(immrVal) = 0x0000;
/* reset the port B */
*PBPAR(immrVal) = 0x0000000;
*PBDIR(immrVal) = 0x0000000;
*PBODR(immrVal) = 0x0000000;
/* reset the port C */
*PCPAR(immrVal) = 0x0000;
*PCDIR(immrVal) = 0x0000;
*PCSO(immrVal) = 0x0000;
*SICR(immrVal) = 0x0; /* initialize SI/NMSI connections */
/* Initialize interrupts */
ppc860IntrInit(IV_LEVEL4); /* default vector level */
sysSerialHwInit();
/* make sure Ethernet is disabled */
/* Add by Jin */
#ifdef INCLUDE_SCC_HDLC
sysSccEnetDisable (0);
sysSccEnetIntDisable (0);
sysSccEnetDisable (1);
sysSccEnetIntDisable (1);
#endif /* INCLUDE_SCC_HDLC */
#ifdef INCLUDE_CPM
sysCpmEnetDisable (0);
sysCpmEnetIntDisable (0);
#endif /* INCLUDE_CPM */
#ifdef INCLUDE_MOT_FEC
/* make sure the FEC is disabled */
sysFecEnetDisable (immrVal);
#endif /* INCLUDE_MOT_FEC */
#ifdef FORCE_DEFAULT_BOOT_LINE
strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);
#endif
/* strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);
bootlineinflash = (char *)BOOT_LINE_ADRS_IN_FLASH;
strncpy(tempStr, bootlineinflash, BOOT_LINE_SIZE);
if(strncmp(tempStr,BOOT_DEV_NAME,3))
{
strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);
}
else
{
strncpy(sysBootLine,bootlineinflash,strlen(bootlineinflash)+1);
}
*/
change_bootline();
/*
* The power management mode is initialized here. Reduced power mode
* is activated only when the kernel is iddle (cf vxPowerDown).
* Power management mode is selected via vxPowerModeSet().
* DEFAULT_POWER_MGT_MODE is defined in config.h.
*/
vxPowerModeSet (DEFAULT_POWER_MGT_MODE);
}
/******************************************************************************
*
* 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();
* SCCR(immrVal) &= ~SCCR_TBS;
* TBK(immrVal) = 0x55ccaa33;
* TBSCRK(immrVal) = 0x55ccaa33;
/* un-freeze the Time Base clock */
* TBSCR(immrVal) = TBSCR_TBE ;
configured = TRUE;
}
}
/*******************************************************************************
*
* 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. Upon initial call, the MMU table is also
* updated based on the information provided by PlanetCore.
*
* RETURNS: The address of the top of physical memory.
*
* SEE ALSO: sysMemTop()
*/
char * sysPhysMemTop (void)
{
EPCFG *cfg = getEpCfg();
static char *physTop = NULL;
if (physTop == NULL)
{
/* Adjust initial DRAM size to actual physical memory. */
sysPhysMemDesc[0].len = (ULONG)cfg->sysMemSize;
physTop = (char *)((ULONG)sysPhysMemDesc[0].physicalAddr + cfg->sysMemSize);
}
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 */
)
{
int immrVal = vxImmrGet();
int *temp;
int intLevel = intLock();
*PLPRCR(immrVal) = (*PLPRCR(immrVal) | PLPRCR_CSR); /* enable check stop reset */
vxMsrSet(0x30); /* only enable address/data translation */
/* turn off RI, ME and EE */
/* Force a machine check which will in turn cause a checkstop and reset */
temp =(int *)(immrVal + 0x34); /* offset into internal register at reserved area */
*temp = 0;
intUnlock(intLevel);
return (OK); /* in case we ever continue from ROM monitor */
}
/****************************************************************************/
/* */
/* Function : sysBoardType( void ) */
/* */
/* Purpose. : Determines the type of board */
/* */
/* Returns. : Board Type */
/* Notes... : None */
/****************************************************************************/
int sysBoardType (void)
{
if ((strncmp("EP852", sysBoardTypeStr, 5)) == 0)
return (EP852);
else
return (RPX_UNKWN);
}
/****************************************************************************/
/* */
/* Function : sysBoardRevision( void ) */
/* */
/* Purpose. : Determines the revision of board */
/* */
/* Returns. : Board Revision */
/* Notes... : None */
/****************************************************************************/
int sysBoardRevision (void)
{
if ((strncmp("1.0", sysBoardRevStr, 3)) == 0)
return (EP_REV_10);
else if ((strncmp("1.1", sysBoardRevStr, 3)) == 0)
return (EP_REV_11);
else if ((strncmp("1.2", sysBoardRevStr, 3)) == 0)
return (EP_REV_12);
else if ((strncmp("1.3", sysBoardRevStr, 3)) == 0)
return (EP_REV_13);
else if ((strncmp("1.4", sysBoardRevStr, 3)) == 0)
return (EP_REV_14);
else if ((strncmp("1.5", sysBoardRevStr, 3)) == 0)
return (EP_REV_15);
else
return (RPX_REV_UNKWN);
}
/****************************************************************************/
/* */
/* Function : sysCpuType( void ) */
/* */
/* Purpose. : Determines the type of processor on the board */
/* */
/* Returns. : CPU Type */
/* Notes... : None */
/****************************************************************************/
int sysCpuType (void)
{
if ((strncmp("852", sysCpuTypeStr, 3)) == 0)
return (PROC_852);
else if ((strncmp("8xx", sysCpuTypeStr, 3)) == 0)
return (PROC_8xx);
else
return (PROC_UNK);
}
/****************************************************************************/
/* */
/* Function : sysCpuVariant( void ) */
/* */
/* Purpose. : Determines the type of processor variant on the board */
/* */
/* Returns. : CPU Variant */
/* Notes... : None */
/****************************************************************************/
int sysCpuVariant (void)
{
if ((strncmp("T", sysCpuVariantStr, 1)) == 0)
return (PVAR_T);
else
return (PVAR_NONE);
}
/****************************************************************************/
/* */
/* Function : sysSerPort( void ) */
/* */
/* Purpose. : Determines the serial port on the board used for the */
/* monitor port */
/* Returns. : SMC Port */
/* Notes... : None */
/****************************************************************************/
int sysSerPort (void)
{
if ((strncmp("SMC1", sysSerPortStr, 4)) == 0)
return (SMC1);
else if ((strncmp("SMC2", sysSerPortStr, 4)) == 0)
return (SMC2);
}
#ifdef BSP_DEBUG
/***************************************************************************
* Show board configuration structure.
***************************************************************************/
int sysShowCfg (void)
{
EPCFG *cfg = getEpCfg();
printf ("sysBoardType : %s (%X)\n",sysBoardTypeStr, cfg->sysBoard);
printf ("sysBoardRev : %s (%X)\n",sysBoardRevStr, cfg->sysBoardRev);
printf ("sysCpuType : %s (%X)\n",sysCpuTypeStr, cfg->sysCpuType);
printf ("sysCpuVariant : %s (%X)\n",sysCpuVariantStr, cfg->sysCpuVar);
printf ("sysSerPort : %s (%X)\n",sysSerPortStr, cfg->sysSerPort);
printf ("sysIpAddr : %s\n",sysIpAddr);
printf ("sysXtalFreq (Hz) : %d\n",cfg->sysXtalFreq);
printf ("sysCpuFreq (Hz) : %d\n",cfg->sysCpuFreq);
printf ("sysDecFreq (Hz) : %d\n",cfg->sysDecFreq);
printf ("sysBrgClkFreq (Hz) : %d\n",cfg->sysBrgClkFreq);
printf ("sysConsoleBaud : %d\n",cfg->sysConsoleBaud);
printf ("sysMemSize (bytes) : %d\n",cfg->sysMemSize);
printf ("sysNvRamSize (bytes): %d\n",cfg->sysNvRamSize);
return OK;
}
#endif
/******************************************************************************
*
* 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.
*
*
* 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
* memory address.
*
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysBusToLocalAdrs()
*/
STATUS sysLocalToBusAdrs
(
int adrsSpace, /* bus address space where busAdrs resides */
char * localAdrs, /* local address to convert */
char ** pBusAdrs /* where to return bus address */
)
{
return (ERROR);
}
/******************************************************************************
*
* sysBusToLocalAdrs - convert a bus address to a local address
*
* This routine gets the local address that accesses a specified VMEbus
* physical memory address.
*
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysLocalToBusAdrs()
*/
STATUS sysBusToLocalAdrs
(
int adrsSpace, /* bus address space where busAdrs resides */
char * busAdrs, /* bus address to convert */
char ** pLocalAdrs /* where to return local address */
)
{
return (ERROR);
}
/******************************************************************************
*
* sysBusTas - test and set a location across the bus
*
* This routine does an atomic test-and-set operation across the backplane.
*
*
* RETURNS: FALSE, always.
*
* SEE ALSO: vxTas()
*/
BOOL sysBusTas
(
char * adrs /* address to be tested-and-set */
)
{
return (FALSE);
}
/******************************************************************************
*
* sysBusClearTas - test and clear
*
* This routine is a null function.
*
* RETURNS: N/A
*/
void sysBusClearTas
(
volatile char * address /* address to be tested-and-cleared */
)
{
}
/***********************************************************************
*
* sysCpmReset - issues a CPM reset command
*
* This routine issues a CPM reset command
*
* RETURNS: N/A
*
*/
void sysCpmReset
(
void
)
{
/* Get the location of the IMMR register. */
int immrVal = vxImmrGet ();
/* Wait for any previous commands to finish */
while (*CPCR(immrVal) & CPM_CR_FLG)
{}
*CPCR(immrVal) = CPM_CR_RESET | CPM_CR_FLG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -