📄 sysalib.s
字号:
/* sysALib.s - PPMC74xx system-dependent assembly routines *//* Copyright 1984-2001 Wind River Systems, Inc. *//*modification history--------------------01g,06jan03,dee remove vWARE hooks01f,04feb02,g_h Move sysL2crPut() & sysL2crGet() to sysACache.s01e,07dec01,kab Fixed decl to keep diab happy01d,23oct01,g_h Remove DIAB dependences.01c,23may01,g_h Protected Vision-specific hooks w/ INCLUDE_VWARE_LAUNCH01b,25aug97,dat code review comments from thierrym01a,08jul97,dat written (from mv2603/sysALib.s,ver 01h)*//*DESCRIPTIONThis module contains the entry code, sysInit(), for VxWorks images that startrunning from RAM, such as 'vxWorks'. These images are loaded into memoryby some external program (e.g., a boot ROM) and then started.The routine sysInit() must come first in the text segment. Its job is to performthe minimal setup needed to call the generic Croutine usrInit() with parameter BOOT_COLD.The routine sysInit() typically masks interrupts in the processor, sets theinitial stack pointer (to STACK_ADRS which is defined in configAll.h), then jumps to usrInit.Most other hardware and device initialization is performed later bysysHwInit().*/#define _ASMLANGUAGE /* Must be first *//* includes */#include "vxWorks.h"#include "sysLib.h"#include "config.h"#include "regs.h" #include "asm.h"#include "wrSbc7410.h"/* defines */ /* globals */ FUNC_EXPORT(_sysInit) /* start of system code */ FUNC_EXPORT(sysInByte) FUNC_EXPORT(sysOutByte) FUNC_EXPORT(sysInWord) FUNC_EXPORT(sysOutWord) FUNC_EXPORT(sysInLong) FUNC_EXPORT(sysOutLong) FUNC_EXPORT(sysMemProbeSup) FUNC_EXPORT(sysProbeExc) FUNC_EXPORT(sysClearBATsInvalidateTLBs) FUNC_EXPORT(sysInvalidateTLBs) FUNC_EXPORT(sysMinimumBATsInit) FUNC_EXPORT(sysPciRead32) FUNC_EXPORT(sysPciWrite32) FUNC_EXPORT(sysPciInByte) FUNC_EXPORT(sysPciOutByte) FUNC_EXPORT(sysPciInWord) FUNC_EXPORT(sysPciOutWord) FUNC_EXPORT(sysPciInLong) FUNC_EXPORT(sysPciOutLong)/* externals */ FUNC_IMPORT(usrInit) _WRS_TEXT_SEG_START/***************************************************************************** sysInit - start after boot** This is the system start-up entry point for VxWorks in RAM, the* first code executed after booting. It disables interrupts, sets up* the stack, and jumps to the C routine usrInit() in usrConfig.c.** The initial stack is set to grow down from the address of sysInit(). This* stack is used only by usrInit() and is never used again. Memory for the* stack must be accounted for when determining the system load address.** SYNOPSIS* \ss* sysInit* (* void /@ THIS IS NOT A CALLABLE ROUTINE @/* )* \se** NOTE: This routine should not be called by the user.** RETURNS: N/A*/FUNC_BEGIN(_sysInit) /* disable external interrupts (by zeroing out msr) */ xor r5,r5,r5 isync mtmsr r5 isync /* Zero-out registers: r0 & SPRGs */ xor r0,r0,r0 isync mtspr SPRG0,r0 mtspr SPRG1,r0 mtspr SPRG2,r0 mtspr SPRG3,r0 /* Turn on FP (temporarily) */ xor r3, r3, r3 sync ori r3, r3, _PPC_MSR_FP sync mtmsr r3 isync /* Init the floating point control/status register */ mtfsfi 7,0x0 mtfsfi 6,0x0 mtfsfi 5,0x0 mtfsfi 4,0x0 mtfsfi 3,0x0 mtfsfi 2,0x0 mtfsfi 1,0x0 mtfsfi 0,0x0 isync /* Initialize the floating point data registers to a known state */ mfspr r3,8 lfs f0,0(r3) lfs f1,0(r3) lfs f2,0(r3) lfs f3,0(r3) lfs f4,0(r3) lfs f5,0(r3) lfs f6,0(r3) lfs f7,0(r3) lfs f8,0(r3) lfs f9,0(r3) lfs f10,0(r3) lfs f11,0(r3) lfs f12,0(r3) lfs f13,0(r3) lfs f14,0(r3) lfs f15,0(r3) lfs f16,0(r3) lfs f17,0(r3) lfs f18,0(r3) lfs f19,0(r3) lfs f20,0(r3) lfs f21,0(r3) lfs f22,0(r3) lfs f23,0(r3) lfs f24,0(r3) lfs f25,0(r3) lfs f26,0(r3) lfs f27,0(r3) lfs f28,0(r3) lfs f29,0(r3) lfs f30,0(r3) lfs f31,0(r3) sync /* Turn off FP (by clearing MSR) */ xor r4,r4,r4 isync mtmsr r4 isync /* Init the Segment registers */ xor r3, r3, r3 isync mtsr 0,r3 mtsr 1,r3 mtsr 2,r3 mtsr 3,r3 mtsr 4,r3 mtsr 5,r3 mtsr 6,r3 mtsr 7,r3 mtsr 8,r3 mtsr 9,r3 mtsr 10,r3 mtsr 11,r3 mtsr 12,r3 mtsr 13,r3 mtsr 14,r3 mtsr 15,r3 isync /* Turn off data and instruction cache enable bits */ xor r4,r4,r4 ori r4, r4,(_PPC_HID0_ICE | _PPC_HID0_DCE) mfspr r3, HID0 andc r3,r3,r4 sync mtspr HID0, r3 isync /* Turn on FP, machine check ME, and recoverable interrupt RI */ xor r4,r4,r4 ori r4,r4,(_PPC_MSR_FP | _PPC_MSR_ME | _PPC_MSR_RI) sync mtmsr r4 isync /* fake a Decrementer Exception Handler (i.e. rfi @ 0x900) */ xor r0,r0,r0 /* clear r0 */ lis r3,HI(0x4C000064) ori r3,r3,LO(0x4C000064) /* load rfi (0x4c000064) to */ stw r3,0x900(r0) /* store rfi at 0x00000900 */ bl sysClearBATs /* invalidate the MPU's data/instruction caches */ mfspr r4,HID0 mr r3,r4 /* for manual clear of xCFI bits */ ori r3, r3,(_PPC_HID0_ICFI | _PPC_HID0_DCFI) sync mtspr HID0, r3 mtspr HID0, r4 isync bl sysMinimumBATsInit bl sysInvalidateTLBs /* initialize Small Data Area (SDA) start address */#if FALSE /* XXX TPR NO SDA for now */ lis r2, HI(_SDA2_BASE_) ori r2, r2, LO(_SDA2_BASE_) lis r13, HI(_SDA_BASE_) ori r13, r13, LO(_SDA_BASE_)#endif /* initialize the stack pointer */ lis sp, HI(RAM_LOW_ADRS) /* NOTE: sp = r1 */ ori sp, sp, LO(RAM_LOW_ADRS) sync isync addi sp, sp, -FRAMEBASESZ /* get frame stack */ xor r3,r3,r3 isync li r3, BOOT_WARM_AUTOBOOT isync b usrInit /* never returns - starts up kernel */ /* (jumps to usrConfig.c ) */FUNC_END(_sysInit)/***************************************************************************** sysClearBATsInvalidateTLBs - clear the BAT's register and invalidate the TLB's** This routine will clear the BAT's register & invalidate the TLB's register. ** SYNOPSIS* \ss* void sysClearBATsInvalidateTLBs* (* void* )* \se** SEE ALSO: sysClearBATs(), sysInvalidateTLBs(), sysMinimumBATsInit()** RETURNS: N/A*/FUNC_BEGIN(sysClearBATsInvalidateTLBs) mfmsr r3 xor r4,r4,r4 ori r4,r4,0x30 andc r3,r3,r4 sync mtmsr r3 isync mflr r4 bl sysClearBATs bl sysInvalidateTLBs mtlr r4 blrFUNC_END(sysClearBATsInvalidateTLBs)/***************************************************************************** sysClearBATs - clear all the BAT's register** This routine will zero the BAT's register.** SYNOPSIS* \ss* void sysClearBATs* (* void* )* \se** SEE ALSO: sysClearBATsInvalidateTLBs(), sysInvalidateTLBs(), sysMinimumBATsInit()** RETURNS: N/A*/FUNC_BEGIN(sysClearBATs) /* zero out the BAT registers */ xor r3,r3,r3 isync mtspr IBAT0U,r3 /* clear all upper BATS first */ mtspr IBAT1U,r3 mtspr IBAT2U,r3 mtspr IBAT3U,r3 mtspr DBAT0U,r3 mtspr DBAT1U,r3 mtspr DBAT2U,r3 mtspr DBAT3U,r3 mtspr IBAT0L,r3 /* then clear lower BATS */ mtspr IBAT1L,r3 mtspr IBAT2L,r3 mtspr IBAT3L,r3 mtspr DBAT0L,r3 mtspr DBAT1L,r3 mtspr DBAT2L,r3 mtspr DBAT3L,r3 isync mfspr r3,287 # read PVR srwi r3,r3,12 andi. r3,r3,0xff cmpwi r3,0x83 beq is7x5 blris7x5: xor r3,r3,r3 mtspr IBAT4U,r3 mtspr IBAT5U,r3 mtspr IBAT6U,r3 mtspr IBAT7U,r3 mtspr DBAT4U,r3 mtspr DBAT5U,r3 mtspr DBAT6U,r3 mtspr DBAT7U,r3 mtspr IBAT4L,r3 mtspr IBAT5L,r3 mtspr IBAT6L,r3 mtspr IBAT7L,r3 mtspr DBAT4L,r3 mtspr DBAT5L,r3 mtspr DBAT6L,r3 mtspr DBAT7L,r3 isync sync blrFUNC_END(sysClearBATs)/***************************************************************************** sysInvalidateTLBs - invalidate all the BAT's register** This routine will invalidate the BAT's register.** SYNOPSIS* \ss* void sysInvalidateTLBs* (* void* )* \se** SEE ALSO: sysClearBATs(), sysClearBATsInvalidateTLBs(), sysMinimumBATsInit()** RETURNS: N/A*/FUNC_BEGIN(sysInvalidateTLBs) isync /* invalidate entries within both TLBs */ li r3,128 mtctr r3 /* CTR = 32 */ xor r3,r3,r3 /* r3 = 0 */ isync /* context sync req'd before tlbie */tlbloop: tlbie r3 addi r3,r3,0x1000 /* increment bits 15-19 */ bdnz tlbloop /* decrement CTR, branch if CTR != 0 */ sync /* sync instr req'd after tlbie */ isync /* context sync req'd before tlbie */ blrFUNC_END(sysInvalidateTLBs)/***************************************************************************** sysMinimumBATsInit - initialize the minimum BAT's register** This routine will initialize the minimum BAT's register.** SYNOPSIS* \ss* void sysMinimumBATsInit* (* void* )* \se** NOTE: When the MMU is disabled, the processor is said to be in Real Addressing * Mode. In this mode, all memory accesses are governed by a default set of * bit values for the WIMG attribute bits. For data accesses, the default * WIMG = 0011 and for instruction fetches default WIMG=0001. In both cases, * the guarded (G) bit is set and the cache-inhibit (I) bit is clear. In * other words, in real addressing mode, the entire address space of the * processor is cacheable ("NOT cache-inhibited") and guarded -- independent * of whether the caches are enabled or not.** The guarded attribute merely prevents out-of-order and speculative * *loads*. More details are avalible in section 5.2.1.5 of the PowerPC * programming environments manual for a more complete explanation of the * guarded attribute. While guarded is a necessary condition for those * memory spaces in which devices reside, it is not a sufficient condition. * Memory accesses to devices must be both guarded and cache inhibited. * Physically disabling the data cache does not provide this second, * equally necessary, condition.** Above, I used the term "NOT cache-inhibited" to draw attention to an * important distinction between cache-inhibited memory accesses and * cacheable memory accesses that are made while the cache itself is * disabled. A naive interpretation of "cacheability" holds that these two * concepts are equivalent -- they are not. To prevent out-of-order * *stores* to devices, we must mark the memory addresses at which those * devices reside as cache inhibited. The only way to do this is to enable * the MMU. So it holds that in order to enforce in-order loads AND stores, * we must enable the MMU and mark the appropriate memory regions as CI & G.** SEE ALSO: sysClearBATs(), sysInvalidateTLBs(), sysClearBATsInvalidateTLBs()** RETURNS: N/A*/FUNC_BEGIN(sysMinimumBATsInit)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -