📄 syslib.c
字号:
char * sysPhysMemTop ( void ) { static char * physTop = NULL; if (physTop == NULL) { physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE); } 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 by 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 */ ) { FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4); /* Warm reboot */#ifdef INCLUDE_MOTFCCEND /* */ /* Get the physical location of the IMMR register */ /* */ int immrVal = vxImmrGet ();#endif /* INCLUDE_MOTFCCEND */ intLock (); cacheDisable (INSTRUCTION_CACHE); cacheDisable (DATA_CACHE);#ifdef INCLUDE_AUX_CLK sysAuxClkDisable ();#endif /* INCLUDE_AUX_CLK */#ifdef INCLUDE_MOTSCCEND sysSccEnetDisable (0); /* disable the ethernet device */ sysSccEnetIntDisable (0); /* disable the ethernet device interrupt */#endif /* INCLUDE_MOTSCCEND */#ifdef INCLUDE_MOTFCCEND /* disable the FCC */ sysFccEnetDisable (immrVal, 2);#endif /* INCLUDE_MOTFCCEND */ sysSerialReset (); /* reset the serial device */ vxMsrSet (0); (*pRom) (startType); /* jump to bootrom entry point */ return( OK ); /* in case we continue from ROM monitor */ }/************************************************************************* sysHwInit2 - initialize additional system hardware** This routine connects system interrupt vectors and configures any * required features not configured by sysHwInit().** RETURNS: N/A*/void sysHwInit2 ( void ) { static BOOL configured = FALSE ; if (!configured) {#if defined(INCLUDE_AUXCLK) || defined(INCLUDE_AUXCLK) /* * initialize and start auxiliary clock support */ sysAuxClkEnable ();#endif /* INCLUDE_AUXCLK */ /* * initialize serial interrupts */ sysSerialHwInit2 (); /* * Indicate we have been through this procedure for reentrancy. */ configured = TRUE ; } }/************************************************************************* 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. It also maps local resources onto* the VMEbus.** 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); }/************************************************************************* sysBaudClkFreq - returns the frequency of the BRG clock** This routine returns the frequency of the BRG clock** NOTE: 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** RETURNS: Frequence in HZ**/int sysBaudClkFreq ( void ) { UINT32 cpmFreq = sysCpmFreqGet (); if (cpmFreq == ERROR) return ERROR; else return cpmFreq*2/16; }/************************************************************************* 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 modChar; swValue = BSCR_USER_SWITCH; modChar = 0; /* skip obvious equalities */ if ( swValue == 0x00 || swValue == 0xFF ) return swValue; if (swValue & 0x80) modChar += 0x01; if (swValue & 0x40) modChar += 0x02; if (swValue & 0x20) modChar += 0x04; if (swValue & 0x10) modChar += 0x08; if (swValue & 0x08) modChar += 0x10; if (swValue & 0x04) modChar += 0x20; if (swValue & 0x02) modChar += 0x40; if (swValue & 0x01) modChar += 0x80; return modChar; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -