📄 syslib.c
字号:
*
* sysClkRateAdjust - calculates proper decrementer frequency for a cpu frequency
*
* This routine calculates proper decrementer frequency for a cpu frequency
*
* RETURNS: Speed in Hz
*
*/
void sysClkRateAdjust
(
int *sysDecClkFrequency
)
{
*sysDecClkFrequency = sysInputFreqGet() / DEC_ADJUSTMENT;
return;
}
/*******************************************************************************
*
* sysInputFreqGet - determines the Input Oscillator clock frequency
*
* This routine determines the Input Oscillator clock frequency
*
* NOTE: From page 9-2 in Rev0 of 8260 book
*
* RETURNS: Input frequency in HZ
*
*/
UINT32 sysInputFreqGet
(
void
)
{
#ifdef HARDCODED_FREQ_PARMS
return INPUT_FREQUENCY;
#else
UINT8 *pModck_H = (UINT8 *)HRDW_CONFIG_BYTE4;
*pModck_H &= MODCK_H_MASK; /* Mask the uper 4 bit */
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 */
}
/*******************************************************************************
*
* sysCpmFreqGet - determines the CPM operating frequency
*
* This routine determines the CPM operating frequency
*
* NOTE: From page 9-2 in Rev0 of 8260 book
*
* RETURNS: CPM frequency in HZ
*
*/
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 */
}
/*******************************************************************************
*
* sysCoreFreqGet - determines the Core operating frequency
*
* This routine determines the Core operating frequency
*
* NOTE: From page 9-2 in Rev0 of 8260 book
*
* RETURNS: Core frequency in HZ
*
*/
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 */
}
/*******************************************************************************
*
* sysModckHGet - determines the value of MODCK_H reset configuration value
*
* This routine determines the value of MODCK_H reset configuration value
*
* NOTE: From page 9-2 in Rev0 of 8260 book
*
* RETURNS: MODCK_H value
*
*/
UINT8 sysModckHGet
(
void
)
{
UINT8 *pModck_H = (UINT8 *)HRDW_CONFIG_BYTE4;
*pModck_H &= MODCK_H_MASK; /* Mask the uper 4 bit */
return *pModck_H;
}
/*******************************************************************************
*
* sysModck13Get - determines the value of MODCK[1-3] reset configuration value
*
* This routine determines the value of MODCK[1-3] reset configuration value
*
* NOTE: From 'Clock Configuration Modes' 8260 Manual
* User Dip Switch 6,7, and 8 must match Config Switch 6,7, 8
*
* RETURNS: MODCK[1-3] value
*
*/
UINT8 sysModck13Get
(
void
)
{
return sysUserSwitchGet() & 0x07; /* lower 3 bits are modck[1-3] */
}
/*******************************************************************************
*
* sysChipRev - determines revision of Chip installed
*
* This routine determines revision of Chip installed
*
* RETURNS: Chip revision
*
*/
UINT32 sysChipRev(void)
{
UINT32 ImmrRegAddr = vxImmrGet();
UINT32 ImmrValue;
ImmrRegAddr += 0x101A8;
ImmrValue = *(UINT32 *)ImmrRegAddr;
ImmrValue &= MASKNUM_MASK;
return (ImmrValue);
}
/*******************************************************************************
*
* 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 ( *M8260_CPCR( immrVal ) & M8260_CPCR_FLG )
{}
*M8260_CPCR( immrVal ) = M8260_CPCR_RESET | M8260_CPCR_FLG;
/* See if the command has been accepted. */
while ( *M8260_CPCR( immrVal ) & M8260_CPCR_FLG )
{}
return;
}
/*******************************************************************************
*
* sysUserSwitchGet - returns the value of the User Dip Switch
*
* This routine returns the value of the User Dip Switch
*
* NOTE: Reverse bits so S1 is MSB S8 is LSB
*
* RETURNS: Unsigned 8 bit value
*
*/
UINT8 sysUserSwitchGet
(
void
)
{
/* UINT8 swvalue;*/
UINT8 mod_char = 0;
return mod_char;
}
/*******************************************************************************
*
* chipInfoCheck - returns the value of the User Dip Switch
*
*
*/
STATUS chipInfoCheck(void)
{
UINT32 ImmrRegAddr = vxImmrGet();
UINT32 ImmrValue;
UINT32 temp32;
/*chip version*/
ImmrRegAddr += 0x101A8;
ImmrValue = *(UINT32 *)ImmrRegAddr;
printf("IMMR = 0x%x.\n",ImmrValue);
ImmrValue &= MASKNUM_MASK;
if(ImmrValue <= 0x24)
{
printf("MPC8260 is Hip3 chip.\n");
if(ImmrValue == 0x11) printf("Ver A.1.\n");
}
else
{
printf("MPC8260 is Hip4 chip.\n");
if(ImmrValue == 0x60) printf("Ver A.0.\n");
else if(ImmrValue == 0x62) printf("Ver B.1.\n");
}
/*BUS/CPU/CPM speed */
temp32 = sysInputFreqGet();
if(temp32 != ERROR) printf("Sys Input Freq = %dHz.\n",temp32);
temp32 = sysCoreFreqGet();
if(temp32 != ERROR) printf("Sys core Freq = %dHz.\n",temp32);
temp32 = sysCpmFreqGet();
if(temp32 != ERROR) printf("Sys cpm Freq = %dHz.\n",temp32);
return (OK);
}
/*******************************************************************************
*
* ledRunDisplay - display system operation OK
* author:yuecode.
*/
STATUS ledErrDisplay(void)
{
int immrVal = vxImmrGet() ;
*M8260_IOP_PAPAR( immrVal ) &= ~(PA7 | PA8); /*general i/o*/
*M8260_IOP_PADIR( immrVal ) |= ( PA8|PA7);
* M8260_IOP_PADAT(immrVal) &= ~PA8;
* M8260_IOP_PADAT(immrVal) |= PA7;
return OK;
}
/*******************************************************************************
*
* ledRunDisplay - display system operation OK
* author:yuecode.
*/
STATUS ledRunDisplay(void)
{
int immrVal = vxImmrGet() ;
*M8260_IOP_PAPAR( immrVal ) &= ~(PA7 | PA8); /*general i/o*/
*M8260_IOP_PADIR( immrVal ) |= ( PA7|PA8);
* M8260_IOP_PADAT(immrVal) &= ~PA7;
* M8260_IOP_PADAT(immrVal) |= PA8;
return OK;
}
/*******************************************************************************
*
* sysEnetAddrSet - sets the 6 byte ethernet address used by the ethernet device.
*
* This routine sets the 6 byte ethernet address used by the ethernet device.
*
* RETURNS: N/A
*/
void sysEnetAddrSet
(
int unit ,
unsigned char byte5,
unsigned char byte4,
unsigned char byte3,
unsigned char byte2,
unsigned char byte1,
unsigned char byte0
)
{
char *tmp;
glbEnetAddr[0] = byte5;
glbEnetAddr[1] = byte4;
glbEnetAddr[2] = byte3;
glbEnetAddr[3] = byte2;
glbEnetAddr[4] = byte1;
glbEnetAddr[5] = byte0;
tmp = glbEnetAddr;
}
/*******************************************************************************
*
* sysEnetAddrGet - gets the 6 byte ethernet address used by the ethernet device.
*
* This routine gets the 6 byte ethernet address used by the ethernet device.
*
* RETURNS: OK
*/
STATUS sysEnetAddrGet
(
int unit , /* not used */
UINT8 * addr /* Location address is returned in */
)
{
int n;
for ( n=0; n < MAC_ADRS_LEN ;n++) *(addr+n) = (char)glbEnetAddr[n];
return( OK ) ;
}
VOID Task_Delay (VOID)
{int i;
for(i=0;i<100000000;i++);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -