📄 sysaspeed.s
字号:
/* sysASpeed.s - Motorola system-dependent assembly routines *//* Copyright 2000-2001 Wind River Systems, Inc. *//*modification history--------------------01b,01nov01,mil Use of macros for directives and function header updates.01a,24oct01,mil Written (mcp750/sysASpeed.s) to fix boot hanging during Falcon init (SPR 71148).*//*DESCRIPTIONThis module contains system-dependent routines written in assemblylanguage. The routines herein are likely called before the memorycontroller is initialized, thus need to be in assembly with theexception of sysGetMpuSpd(). However, since it is also calledfrom romInit.s and needed to be in the uncompressed portion ofthe bootrom, it is also included.Furthermore, the Falcon init code needs some volatile registers bepreserved when these routines return (see romInit.s). Thus r9-r19are used for computation when stack is not used.This module must be listed in the \f3ld\f1 command used to build thecompressed bootrom image (likely by means of BOOT_EXTRA in the BSPmakefile.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "config.h"#include "regs.h" #include "asm.h"#include "mcpx750.h" /* globals */ FUNC_EXPORT(sysGetBusSpd) FUNC_EXPORT(sysGetDramSpd) FUNC_EXPORT(sysGetMpuSpd) /* externals */ FUNC_IMPORT(vxHid1Get)#ifdef INCLUDE_I2C FUNC_IMPORT(getDIMMdramspeed)#endif /* INCLUDE_I2C */ .text .balign 4tableArthur: .long 0 .long 75 .long 70 .long 10 .long 20 .long 65 .long 25 .long 45 .long 30 .long 55 .long 40 .long 50 .long 15 .long 60 .long 35 .long 0 _WRS_TEXT_SEG_START/***************************************************************************** sysGetBusSpd - get the speed of the 60x processor bus** SYNOPSIS* \ss* UINT sysGetBusSpd* (* void* )* \se** INCLUDE FILES: mcpx750.h** RETURNS: The bus speed (in MHz).** This routine returns the speed (in MHz) of the 60x system bus.**/FUNC_BEGIN(sysGetBusSpd) lis r9, HI(SYS_REG_CCR_) /* SYS_REG_CCR */ ori r9, r9, LO(SYS_REG_CCR_) lwz r11, 0(r9) rlwinm r9, r11, 0, 8, 11 /* & 0x00f0_0000 */ lis r11, HI(SYS_REG_CCR_CPU_CLK_60) cmpw 0, r9, r11 bc 12, 2, busSpd60 /* beq */ lis r11, HI(SYS_REG_CCR_CPU_CLK_50) cmpw 0, r9, r11 bc 12, 2, busSpd50 /* beq */busSpd66:busSpdDefault: li r3, 67 /* speed = 67 */ blr /* return */busSpd60: li r3, 60 /* speed = 60 */ blr /* return */busSpd50: li r3, 50 /* speed = 50 */ blr /* return */FUNC_END(sysGetBusSpd)/***************************************************************************** sysGetDramSpd - get the speed of DRAM on the MPC60x processor** SYNOPSIS* \ss* UINT sysGetDramSpd* (* void* )* \se** INCLUDE FILES: mcpx750.h** RETURNS: DRAM speed encoded for the Falcon's General Control Register.** This routine returns the speed of DRAM on the MPC60x system.**/FUNC_BEGIN(sysGetDramSpd)#ifdef INCLUDE_I2C /* WARNING: INCLUDE_I2C should not be defined for bootrom code. /* This function requires stack usage when INCLUDE_I2C is defined. * mcpx750 romInit.s calls this function before the memory * controller (falcon/hawk) is initialized. Therefore stack * usage or call to C functions may cause the board to hang * during boot. This is rewritten in assembly from C to prevent * stack usage when INCLUDE_I2C is not defined (SPR 71148). * The I2C portion of this code is for reference only. */ stwu r1, -16(r1) /* alloc stack */ mflr r0 stw r0, 20(r1) /* save LR on stack */ bl getDIMMdramspeed /* warning: C code */ cmpwi 0, r3, 60 bc 12, 2, dramSpd60ns /* beq */ cmpwi 0, r3, 50 bc 12, 2, dramSpd50ns /* beq */dramSpd70ns:dramSpdDefault: li r3, SYS_REG_GCR_DRAM_70ns b dramSpdAlldramSpd60ns: li r3, SYS_REG_GCR_DRAM_60ns b dramSpdAlldramSpd50ns: li r3, SYS_REG_GCR_DRAM_50ns b dramSpdAlldramSpdAll: lwz r0, 20(r1) /* retrieve LR */ mtlr r0 la r1, 16(r1) /* dealloc stack */ blr /* return */#else /* INCLUDE_I2C */ lis r9, HI(SYS_REG_MCR_) /* SYS_REG_MCR */ ori r9, r9, LO(SYS_REG_MCR_) lwz r11, 0(r9) rlwinm r9, r11, 0, 6, 7 /* & 0x0300_0000 */ lis r11, HI(SYS_REG_MCR_DRAM_60ns) cmpw 0, r9, r11 bc 12, 2, dramSpd60ns /* beq */ lis r11, HI(SYS_REG_MCR_DRAM_50ns) cmpw 0, r9, r11 bc 12, 2, dramSpd50ns /* beq */dramSpd70ns:dramSpdDefault: li r3, SYS_REG_GCR_DRAM_70ns blr /* return */dramSpd60ns: li r3, SYS_REG_GCR_DRAM_60ns blr /* return */dramSpd50ns: li r3, SYS_REG_GCR_DRAM_50ns blr /* return */#endif /* INCLUDE_I2C */FUNC_END(sysGetDramSpd)/***************************************************************************** sysGetMpuSpd - get the speed of the MPC750 processor.** SYNOPSIS* \ss* UINT sysGetMpuSpd* (* void* )* \se** INCLUDE FILES: mcpx750.h** RETURNS: The approximate CPU speed (in MHz).** This routine returns the speed (in MHz) of the 60x processor.** Note: This speed returned is an approximation based on the* accuracy of the value returned by sysGetBusSpd().* For a 267MHz Arthur system, running with a bus clock* of 67 MHz, the actual speed returned is 268MHz.** This function is dependent upon proper bus speed being* returned via call to sysGetBusSpd(). In addition to this* dependency, the function will only work for CPUs whose* speed is dependent upon the bus speed and the value in* the PLL bits of the HID1 register. CPUs which HAVE this* property are 602, Arthur, 604ev and 604r. CPUs which* do NOT HAVE this property (and for which this function* will NOT work) are: 601, 603, 603e, 603p, and 604.**/FUNC_BEGIN(sysGetMpuSpd) stwu r1, -32(r1) /* alloc stack */ mflr r0 stw r28, 16(r1) stw r29, 20(r1) stw r30, 24(r1) stw r31, 28(r1) stw r0, 36(r1) /* save LR backchain */ lis r29, tableArthur@ha /* load table addr */ la r29, tableArthur@l(r29) bl vxHid1Get /* get HID1 */ rlwinm r3, r3, 6, 26, 29 /* HID1 >> 28 */ lwzx r28, r29, r3 /* tableArthur[HID1>>28] */ bl sysGetBusSpd /* get sysGetBusSpd() */ mullw r3, r3, r28 /* times table value */ lis r0, 0xcccc ori r0, r0, 0xcccd mulhwu r3, r3, r0 srwi r3, r3, 3 /* then divide by 10 */ lwz r0, 36(r1) /* restore LR */ mtlr r0 lwz r28, 16(r1) lwz r29, 20(r1) lwz r30, 24(r1) lwz r31, 28(r1) la r1, 32(r1) /* dealloc stack */ blr /* return */FUNC_END(sysGetMpuSpd)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -