📄 syslib.c
字号:
/******************************************************************************
*
* 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 */
)
{
#if 0
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);
#endif
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 ;
if ( ! configured )
{
#if defined(INCLUDE_AUX_CLK) || defined(INCLUDE_AUXCLK)
/*
* initialize and start auxiliary clock support
*/
sysAuxClkEnable();
#endif /* INCLUDE_AUX_CLK */
/*
* initialize serial interrupts
*/
sysSerialHwInit2() ;
/*
* Indicate we have been through this procedure for reentrancy.
*/
configured = TRUE ;
#ifdef INCLUDE_NETWORK
sysNetHwInit2 ();
#endif /* INCLUDE_NETWORK */
}
}
/****************************************************************************/
/* */
/* Function : sysBoardType( void ) */
/* */
/* Purpose. : Determines the type of board */
/* */
/* Returns. : Board Type */
/* Notes... : None */
/****************************************************************************/
int sysBoardType (void)
{
return (RPX_UNKWN);
}
/****************************************************************************/
/* */
/* Function : sysBoardRevision( void ) */
/* */
/* Purpose. : Determines the revision of board */
/* */
/* Returns. : Board Revision */
/* Notes... : None */
/****************************************************************************/
int sysBoardRevision (void)
{
return (RPX_REV_UNKWN);
}
/******************************************************************************
*
* 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;
}
/*******************************************************************************
*
* vxImmrSet - Set the IMMR to a specific value
*
* This routine sets the IMMR to a specific value
*
* RETURNS: N/A
*/
void vxImmrSet (UINT32 value)
{
immrAddress = value;
return;
}
/*******************************************************************************
*
* vxImmrGet - return the current IMMR value
*
* This routine returns the current IMMR value
*
* RETURNS: current IMMR value
*
*/
UINT32 vxImmrGet (void)
{
return (immrAddress);
}
/****************************************************************************
*
* Function : sysModck13Get()
*
* Purpose. : Determines the value of MODCK[1-3] reset configuration value
*
* Returns. : MODCK[1-3] value
* Notes... : - from 'Clock Configuration Modes' 8260 Manual
*/
UINT8 sysModck13Get(void)
{
return (*BCSR3 >> 5) & 0x07; /* lower 3 bits are modck[1-3] */
}
/****************************************************************************
*
* Function : sysBaudClkFreq()
*
* Purpose. : Returns the frequency of the BRG clock
*
* Returns. : Frequence in HZ
*
* Notes... : From page 9-5 in Rev0 of 8260 book
*
* baud clock = 2*cpm_freq/2^2*(DFBRG+1) where DFBRG = 01
* = 2*cpm_freq/16
*/
int sysBaudClkFreq(void)
{
UINT32 cpmFreq, sccrDfbrg;
/* Get the physical location of the IMMR register */
UINT32 immrVal = vxImmrGet() ;
sccrDfbrg = (UINT32) *M8260_SCCR(immrVal);
sccrDfbrg &= (~M8260_SCCR_RES_MSK);
if((cpmFreq = sysCpmFreqGet()) == ERROR)
return ERROR;
switch(sccrDfbrg){
case M8260_SCCR_DFBRG_4:
return cpmFreq*2/4;
case M8260_SCCR_DFBRG_16:
return cpmFreq*2/16;
case M8260_SCCR_DFBRG_64:
return cpmFreq*2/64;
case M8260_SCCR_DFBRG_128:
return cpmFreq*2/256 /* 128 */;
default:
return cpmFreq*2/16;
}
}
/****************************************************************************
*
* Function : sysClkRateAdjust()
*
* Purpose. : Calculates proper decrementer frequency for a cpu frequency
*
* Returns. : speed in Hz
* Notes... : None
*/
void sysClkRateAdjust
(
int *sysDecClkFrequency
)
{
*sysDecClkFrequency = sysInputFreqGet() / DEC_ADJUSTMENT;
return;
}
/****************************************************************************
*
* Function : sysInputFreqGet()
*
* Purpose. : Determines the Input Oscillator Clock Frequency
*
* Returns. : speed in Hz
* Notes... : From page 9-2 in Rev0 of 8260 book
*/
UINT32 sysInputFreqGet
(
void
)
{
#ifdef HARDCODED_FREQ_PARMS
return INPUT_FREQUENCY;
#else
UINT8 *pModck_H = (UINT8 *)HRDW_CONFIG_BYTE4;
switch( *pModck_H )
{
case 1: case 2: case 3: case 4:
return FREQ_33MHZ;
case 5: case 6: case 7: case 8:
return FREQ_66MHZ;
default:
return ERROR;
}
#endif /* HARDCODED_FREQ_PARMS */
}
/****************************************************************************
*
* Function : sysCpmFreqGet()
*
* Purpose. : Determines the CPM Operating Frequency
*
* Returns. : speed in Hz
* Notes... : From page 9-2 in Rev0 of 8260 book
*/
UINT32 sysCpmFreqGet
(
void
)
{
#ifdef HARDCODED_FREQ_PARMS
return CPM_FREQUENCY;
#else
UINT n;
UINT32 modck_H = sysModckHGet();
UINT32 modck13 = sysModck13Get();
for (n=0; modckH_modck13[n].coreFreq != END_OF_TABLE ;n++)
{
if ((modckH_modck13[n].modck_h == modck_H) &&
(modckH_modck13[n].modck13 == modck13))
{
return modckH_modck13[n].cpmFreq;
}
}
return ERROR;
#endif /* HARDCODED_FREQ_PARMS */
}
/****************************************************************************
*
* Function : sysCoreFreqGet()
*
* Purpose. : Determines the Core Operating Frequency
*
* Returns. : speed in Hz
* Notes... :From page 9-2 in Rev0 of 8260 book
*/
UINT32 sysCoreFreqGet
(
void
)
{
#ifdef HARDCODED_FREQ_PARMS
return CORE_FREQUENCY;
#else
UINT n;
UINT32 modck_H = sysModckHGet();
UINT32 modck13 = sysModck13Get();
for (n=0; modckH_modck13[n].coreFreq != END_OF_TABLE ;n++)
{
if ((modckH_modck13[n].modck_h == modck_H) &&
(modckH_modck13[n].modck13 == modck13))
{
return modckH_modck13[n].coreFreq;
}
}
return ERROR;
#endif /* HARDCODED_FREQ_PARMS */
}
/****************************************************************************
*
* Function : sysModckHGet()
*
* Purpose. : Determines the value of MODCK_H reset configuration value
*
* Returns. : MODCK_H value
* Notes... : From page 9-2 in Rev0 of 8260 book
*/
UINT8 sysModckHGet
(
void
)
{
UINT8 *pModck_H = (UINT8 *)HRDW_CONFIG_BYTE4;
return *pModck_H;
}
/****************************************************************************
*
* Function : sysChipRev()
*
* Purpose. : Determines Revision of Chip installed
*
* Returns. : speed in Hz
* Notes... : None
*/
UINT32 sysChipRev(void)
{
UINT32 ImmrRegAddr = vxImmrGet();
UINT32 ImmrValue;
ImmrRegAddr += 0x101A8;
ImmrValue = *(UINT32 *)ImmrRegAddr;
ImmrValue &= MASKNUM_MASK;
return (ImmrValue);
}
/****************************************************************************
*
* Function : sysCpmReset( )
*
* Purpose. : Issues a CPM Reset Command
*
* Returns. : OK
*
* Notes... : None
*
*/
void sysCpmReset
(
void
)
{
/* Get the location of the IMMR register. */
int immrVal = vxImmrGet();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -