syslib.c
来自「wrSbc8255的vxWorks BSP驱动源码」· C语言 代码 · 共 873 行 · 第 1/2 页
C
873 行
* which indicates the top of memory.** Normally, the user specifies the amount of physical memory with the* macro LOCAL_MEM_SIZE in config.h. BSPs that support run-time* memory sizing do so only if the macro LOCAL_MEM_AUTOSIZE is defined.* If not defined, then LOCAL_MEM_SIZE is assumed to be, and must be, the* true size of physical memory.** NOTE: Do no adjust LOCAL_MEM_SIZE to reserve memory for application* use. See sysMemTop() for more information on reserving memory.** RETURNS: The address of the top of physical memory.** SEE ALSO: sysMemTop()*/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) {#ifdef 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 ) { return INPUT_FREQUENCY; }/************************************************************************* 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 ) { return CPM_FREQUENCY; }/************************************************************************* 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 ) { return CORE_FREQUENCY; }/************************************************************************* 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 + =
减小字号Ctrl + -
显示快捷键?