📄 sysalib.s
字号:
/* sysALib.s - Motorola ads827x system-dependent assembly routines *//* Copyright 1984-2003 Wind River Systems, Inc. */ .data .globl copyright_wind_river .long copyright_wind_river/*modification history--------------------01h,07oct03,dee add reference to romSdramInit() to force linking with resident images01g,01oct03,dee add common routines for bootrom and vxWorks01f,24jan03,dtr Adding PCI Errata workaround. Also enabled machine check pin.01e,24jun02,dtr Adding PCI support.01d,08may01,pch Add assembler abstractions (FUNC_EXPORT, FUNC_BEGIN, etc.)01c,15jul99,ms_ make compliant with our coding standards01b,27apr99,ms_ add cache/mmu initialization01a,07jan99,ms_ written from mtx603 sysALib.s*//*DESCRIPTIONThis module contains system-dependent routines written in assemblylanguage.This module must be the first specified in the \f3ld\f1 command used tobuild the system. The sysInit() routine is the system start-up code.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h"#include "cacheLib.h"#include "arch/ppc/cachePpcLib.h"#include "config.h"#include "regs.h" #include "sysLib.h" /* globals */ FUNC_EXPORT(_sysInit) /* start of system code */ FUNC_EXPORT(sysMsrGet) /* get the value of the MSR register */#ifdef PCI_BRIDGE_READ_ERRATA_WORKAROUND FUNC_EXPORT(sysWord) FUNC_EXPORT(sysByte) FUNC_EXPORT(sysLong)#else FUNC_EXPORT(sysInWord) FUNC_EXPORT(sysInByte) FUNC_EXPORT(sysInLong)#endif /* PCI_BRIDGE_READ_ERRATA_WORKAROUND */ FUNC_EXPORT(sysOutLong) FUNC_EXPORT(sysOutWord) FUNC_EXPORT(sysOutByte) 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_EXPORT(sysPCGet) /* get the value of the PC register */ 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. This code does the following:** .CS* sets the MSR to all 0 which, among other things:* disables external interrupts* disables machine check interrupts* selects exception prefix 0x000n_nnnn* disables instruction and data address translation* clears the SPRGs* clears the segment registers* places an rfi instruction at the decrementer exception vector* initializes the stack pointer* disables instruction and data translations in the MMU* initializes the BAT registers* invalidates all entries in instruction and data TLBs* clear HID0 , among other things:* disables instruction and data caches* invalidates instruction and data caches* sets up the stack* .CE** At the end it 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.** NOTE: This routine should not be called by the user.** RETURNS: N/A** sysInit (void) /@ THIS IS NOT A CALLABLE ROUTINE @/**/FUNC_BEGIN(_sysInit) /* * Initialize all necessary core registers before continuing * * 1. Clear MSR to disable all exceptions, no mmu, no fpu etc * 2. Clear out the SPRGs * 3. Clear out the Segment Registers * 4. Clear Instruction BAT registers * 5. Clear Data BAT registers * 6. Initialize FPU registers * */ /* initialize the stack pointer */ lis sp, HIADJ(RAM_LOW_ADRS) addi sp, sp, LO(RAM_LOW_ADRS) addi sp, sp, -FRAMEBASESZ /* get frame stack */ bl sysClearMSR bl sysClearSPRGs bl sysClearSRs bl sysClearIBATs bl sysClearDBATs bl sysClearFPRegs /* return from decrementer exceptions */ li r0, 0 bl loadrfi /* link reg now had address of rfi */ rfiloadrfi: mflr r4 /* r4 now had address of rfi instruction */ lwz r4, 0(r4) /* r4 now has opcode of rfi instruction */ stw r4, 0x900(r0) /* rfi instruction now in decr exception vec */ /* invalidate entries within both TLBs */ li r4, 32 mtctr r4 /* CTR = 32 */ li r3, 0 /* r3 = 0 */ isync /* context sync req'd before tlbie */sysALoop: tlbie r3 addi r3,r3,0x1000 /* increment bits 15-19 */ bdnz sysALoop /* decrement CTR, branch if CTR != 0 */ sync /* sync instr req'd after tlbie */ /* clear HID0 */ li r3, 0 sync isync mtspr HID0, r3 /* * Invalidate both caches by setting and then clearing the cache * invalidate bits */ mfspr r3, HID0 lis r3, HIADJ(_PPC_HID0_ICFI | _PPC_HID0_DCFI | _PPC_HID0_PAR | _PPC_HID0_EMCP) /* set bits */ ori r3, r3, LO(_PPC_HID0_ICFI | _PPC_HID0_DCFI | _PPC_HID0_PAR | _PPC_HID0_EMCP) /* set bits */ sync isync mtspr HID0, r3 /* clear HID0, which clears cache invalidate bits */ li r3, 0 sync isync mtspr HID0, r3 li r3, BOOT_WARM_AUTOBOOT /* set the default boot code */ /* jump to usrInit */ b usrInit /* never returns - starts up kernel */FUNC_END(_sysInit)/****************************************************************************** sysMsrGet - Get the value of the MSR (Machine State Register)** This routine returns the value of the MSR.** RETURNS: the Machine State Register (MSR) value.** UINT32 sysMsrGet (void)**/FUNC_BEGIN(sysMsrGet) mfmsr retval0 /* put msr value into EABI return register */ blr /* Return to caller */FUNC_END(sysMsrGet)#ifndef PCI_BRIDGE_READ_ERRATA_WORKAROUND /****************************************************************************** sysInByte - reads a byte from an io address.** This function reads a byte from a specified io address.** RETURNS: byte from address.** UCHAR sysInByte* (* UCHAR * pAddr /@ Virtual I/O addr to read from @/* )**/FUNC_BEGIN(sysInByte) eieio /* Sync I/O operation */ sync lbzx retval0,r0,p0 /* Read byte from I/O space */ blr /* Return to caller */FUNC_END(sysInByte)/****************************************************************************** sysInWord - reads a word from an address, swapping the bytes.** This function reads a swapped word from a specified* address.** RETURNS:* Returns swapped 16 bit data from the specified address.* USHORT sysInWord* (* ULONG address, /@ addr to read from @/* )*/FUNC_BEGIN(sysInWord) eieio /* Sync I/O operation */ sync lhbrx retval0,r0,p0 /* Read and swap */ blr /* Return to caller */FUNC_END(sysInWord)/****************************************************************************** sysInLong - reads a long from an address.** This function reads a long from a specified PCI Config Space* (little-endian)* address.** RETURNS:* Returns 32 bit data from the specified register. Note that for PCI systems* if no target responds, the data returned to the CPU will be 0xffffffff.** ULONG sysInLong* (* ULONG address, /@ Virtual addr to read from @/* )*/FUNC_BEGIN(sysInLong) eieio /* Sync I/O operation */ sync lwbrx retval0,r0,p0 /* Read and swap from address */ blr /* Return to caller */FUNC_END(sysInLong)#else/****************************************************************************** sysByte - reads a byte from an io address.** This function reads a byte from a specified io address.** RETURNS: byte from address.** UCHAR sysByte* (* UCHAR * pAddr /@ Virtual I/O addr to read from @/* )**/FUNC_BEGIN(sysByte) lbzx retval0,r0,p0 /* Read byte from I/O space */ blr /* Return to caller */FUNC_END(sysByte)/****************************************************************************** sysWord - reads a word from an address, swapping the bytes.** This function reads a swapped word from a specified* address.** RETURNS:* Returns swapped 16 bit data from the specified address.** USHORT sysWord* (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -