📄 sysalib.s
字号:
/* sysALib.s - Wind River SBC405GP system-dependent assembly routines *//* Copyright 1984-2001 Wind River Systems, Inc. *//*modification history--------------------01d,11jul02,pch SPR 77845: fix name collision with PCI drivers01c,07dec01,kab Fixed decl to keep diab happy01b,22nov01,g_h Add assembler abstractions (FUNC_EXPORT, FUNC_BEGIN, etc.)01a,08may01.g_h created from Walnut version 01f*//*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 "sysLib.h"#include "config.h"#include "asm.h"#include "regs.h" /* defines */#define CNTRL_DCR_BASE 0x0b0#define strap (CNTRL_DCR_BASE+0x4) /* strap register */ /* globals */ FUNC_EXPORT(_sysInit) /* start of system code */ FUNC_EXPORT(sysInit) /* start of system code */ FUNC_EXPORT(sysPciInByte) FUNC_EXPORT(sysPciOutByte) FUNC_EXPORT(sysPciInWord) FUNC_EXPORT(sysPciOutWord) FUNC_EXPORT(sysPciInLong) FUNC_EXPORT(sysPciOutLong) FUNC_EXPORT(sysInByte) FUNC_EXPORT(sysOutByte) FUNC_EXPORT(sysInWord) FUNC_EXPORT(sysOutWord) FUNC_EXPORT(sysInLong) FUNC_EXPORT(sysOutLong) FUNC_EXPORT(sysPlbInByte) FUNC_EXPORT(sysPlbOutByte) FUNC_EXPORT(sysPlbInWord) FUNC_EXPORT(sysPlbOutWord) FUNC_EXPORT(sysPlbInLong) FUNC_EXPORT(sysPlbOutLong) FUNC_EXPORT(sysSpin) /* 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)FUNC_BEGIN(sysInit)#ifdef INCLUDE_VWARE_LAUNCH lis r5,HI(sysPrivateVwareParams) ori r5,r5,LO(sysPrivateVwareParams) stw r4,0(r5) stw r3,4(r5)#endif /* INCLUDE_VWARE_LAUNCH */ /* Repeat initialization done in romInit.s except SDRAM and EBC */ /* * Initalize registers that need to be set to zero. */ addi r4,r0,0x0000 mtmsr r4 /* disable all interrupts */ isync mtspr ICCR,r4 /* turn off I-cache */ mtspr DCCR,r4 /* turn off D-cache */ mtspr DCWR,r4 /* all memory regions write-back */ mtspr ESR, r4 /* clear error status */ mtspr TCR, r4 /* disable all timers */ mtspr PIT, r4 /* clear the PIT timer */ mtdcr UIC_ER, r4 /* disable ints at the UIC */ mtspr XER, r4 /* clear integer exception reg */ mtdcr DMA_CR0, r4 /* stop DMA channels */ mtdcr DMA_CR1, r4 mtdcr DMA_CR2, r4 mtdcr DMA_CR3, r4 /* * Initalize registers that need to be cleared with 0xFFFFFFFF */ addis r4,r0,0xffff ori r4,r4,0xffff mtspr TSR, r4 /* clear timer status */ mtspr DBSR, r4 /* clear debug status reg */ mtdcr UIC_SR, r4 /* clear all pending UIC ints */ mtdcr DMA_SR, r4 /* clear DMA status reg */ /* * Set storage guarded attribute * Unguarded: 0x00000000 - 0x7FFFFFFF SDRAM * Guarded: 0x80000000 - 0xF7FFFFFF PCI Memory, I/O, config, * 405GP internal peripherals, * SBC405GP external peripherals * Unguarded: 0xF8000000 - 0xFFFFFFFF Bootrom */ addi r4,r0,0x0000 ori r4,r4,0xfffe mtspr SGR,r4 /* * Invalidate the entire instruction cache. This can be done * with a single iccci instruction in the 405 processor core. */ iccci r0, r0 /* * Invalidate the entire data cache. * The 405 processor core in the 405GP has 128 congruence classes. * Each cache line in the 405 processor is 32 bytes. */ li r3, 0 /* clear r3 */ li r4, _DCACHE_LINE_NUM_405GP /* load number of cache lines */ mtctr r4rom405Dcci: dccci r0, r3 addi r3, r3, _CACHE_ALIGN_SIZE /* bump to next line */ bdnz rom405Dcci /* go to invalidate */ /* * Clear the CPU reservation bit */ li r0, 0 lwarx r3, r0, r0 stwcx. r3, r0, r0 /* * Initialize the stack pointer */ lis sp, HIADJ(_sysInit) addi sp, sp, LO(_sysInit)#if FALSE /* SDA not supported */ /* initialize r2 and r13 according to EABI standard */ lis r2, HIADJ(_SDA2_BASE_) addi r2, r2, LO(_SDA2_BASE_) lis r13, HIADJ(_SDA_BASE_) addi r13, r13, LO(_SDA_BASE_)#endif mfmsr r3 /* read msr */ INT_MASK(r3, r3) /* mask ee bit and ce bit */ mtmsr r3 /* DISABLE INTERRUPT */ addi sp, sp, -FRAMEBASESZ /* car frame stack */ li r3, BOOT_WARM_AUTOBOOT /* set start type arg = WARM_BOOT */ bl FUNC(usrInit)FUNC_END(sysInit)FUNC_END(_sysInit)/***************************************************************************** sysPciInByte - reads a byte from PCI Config Space.** This function reads a byte from a specified PCI Config Space address.** SYNOPSIS* \ss* UCHAR sysPciInByte* (* ULONG address* )* \se** SEE ALSO: sysPciInWord(), sysPciInLong(), sysPciOutByte(), sysPciOutWord(), * sysPciOutLong()** RETURNS: byte from address.*/FUNC_BEGIN(sysPciInByte)FUNC_LABEL(sysInByte) sync lbz r3, 0(r3) sync bclr 20,0FUNC_END(sysPciInByte)/***************************************************************************** sysPciInWord - reads a word (16-bit big-endian) from PCI Config Space.** This function reads a word from a specified PCI Config Space (little-endian)* address. It uses the load halfword byte-reversed instruction.** SYNOPSIS* \ss* USHORT sysPciInWord* (* ULONG address* )* \se** SEE ALSO: sysPciInByte(), sysPciInLong(), sysPciOutByte(), sysPciOutWord(), * sysPciOutLong()** RETURNS: word (16-bit big-endian) from address.*/FUNC_BEGIN(sysPciInWord)FUNC_LABEL(sysInWord) sync lis r0,0 lhbrx r4, r0, r3 sync mr r3, r4 bclr 20,0FUNC_END(sysPciInWord)/***************************************************************************** sysPciInLong - reads a long (32-bit big-endian) from PCI Config Space.** This function reads a long from a specified PCI Config Space (little-endian)* address. It uses the load word byte-reversed instruction.** SYNOPSIS* \ss* ULONG sysPciInLong* (* ULONG address* )* \se** SEE ALSO: sysPciInByte(), sysPciInWord(), sysPciOutByte(), sysPciOutWord(), * sysPciOutLong()** RETURNS: long (32-bit big-endian) from address.*/FUNC_BEGIN(sysPciInLong)FUNC_LABEL(sysInLong) sync lis r0,0 lwbrx r4, r0, r3 sync mr r3, r4 bclr 20,0FUNC_END(sysPciInLong)/***************************************************************************** sysPciOutByte - writes a byte to PCI Config Space.** This function writes a byte to a specified PCI Config Space address.** SYNOPSIS* \ss* void sysPciOutByte* (* ULONG address* UCHAR data* )* \se** SEE ALSO: sysPciInByte(), sysPciInWord(), sysPciInLong(), sysPciOutWord(), * sysPciOutLong()** RETURNS: N/A*/FUNC_BEGIN(sysPciOutByte)FUNC_LABEL(sysOutByte) sync stb r4,0(r3) sync bclr 20,0FUNC_END(sysPciOutByte)/***************************************************************************** sysPciOutWord - writes a word (16-bit big-endian) to PCI Config Space.** This function writes a word to a specified PCI Config Space (little-endian)* address. It uses the store halfword byte-reversed instruction.** SYNOPSIS* \ss* void sysPciOutWord* (* ULONG address* USHORT data* )* \se** SEE ALSO: sysPciInByte(), sysPciInWord(), sysPciInLong(), sysPciOutByte(), * sysPciOutLong()** RETURNS: N/A*/FUNC_BEGIN(sysPciOutWord)FUNC_LABEL(sysOutWord) sync lis r0,0 sthbrx r4, r0, r3 sync bclr 20,0FUNC_END(sysPciOutWord)/***************************************************************************** sysPciOutLong - writes a long (32-bit big-endian) to PCI Config Space.** This function writes a long to a specified PCI Config Space (little-endian)* address. It uses the store word byte-reversed instruction.** SYNOPSIS* \ss* void sysPciOutLong* (* ULONG address* ULONG data* )* \se** SEE ALSO: sysPciInByte(), sysPciInWord(), sysPciInLong(), sysPciOutWord(), * sysPciOutByte()** RETURNS: N/A*/FUNC_BEGIN(sysPciOutLong)FUNC_LABEL(sysOutLong) sync lis r0,0 stwbrx r4, r0, r3 sync bclr 20,0FUNC_END(sysPciOutLong)/***************************************************************************** sysPlbInByte - reads a byte from an io address.** This function reads a 8 bit byte from a specified IO address.** SYNOPSIS* \ss* UCHAR sysPlbInByte* (* ULONG address* )* \se** SEE ALSO: sysPlbInWord(), sysPlbInLong(), sysPlbOutByte(), sysPlbOutWord(), * sysPlbOutLong()** RETURNS: byte from address.*/FUNC_BEGIN(sysPlbInByte) sync lbz r3, 0(r3) sync bclr 20,0FUNC_END(sysPlbInByte)/***************************************************************************** sysPlbInWord - reads a half word (16-bit) from an IO address.** This function reads a 16 bit half word from a specified IO address.** SYNOPSIS* \ss* USHORT sysPlbInWord* (* ULONG address* )* \se** SEE ALSO: sysPlbInByte(), sysPlbInLong(), sysPlbOutByte(), sysPlbOutWord(), * sysPlbOutLong()** RETURNS: half word (16-bit) from address.*/FUNC_BEGIN(sysPlbInWord) lhzx r3,r0,r3 /* Read word from an address */ sync /* Sync I/O operation */ bclr 20,0 /* Return to caller */FUNC_END(sysPlbInWord)/***************************************************************************** sysPlbInLong - reads a word (32-bit) from an IO address.** This function reads a 32 bit word from a specified IO address.** SYNOPSIS* \ss* ULONG sysPlbInLong* (* ULONG address* )* \se** SEE ALSO: sysPlbInByte(), sysPlbInWord(), sysPlbOutByte(), sysPlbOutWord(), * sysPlbOutLong()** RETURNS: word (32-bit) from address.*/FUNC_BEGIN(sysPlbInLong) lwzx r3,r0,r3 /* Read word from an address */ sync /* Sync I/O operation */ bclr 20,0 /* Return to caller */FUNC_END(sysPlbInLong)/***************************************************************************** sysPlbOutByte - writes a byte to an IO address.** This function writes a 8 bit byte to a specified IO address.** SYNOPSIS* \ss* void sysPlbOutByte* (* ULONG address* UCHAR data* )* \se** SEE ALSO: sysPlbInByte(), sysPlbInWord(), sysPlbInLong(), sysPlbOutWord(), * sysPlbOutLong()** RETURNS: N/A*/FUNC_BEGIN(sysPlbOutByte) sync stb r4,0(r3) sync bclr 20,0FUNC_END(sysPlbOutByte)/***************************************************************************** sysPlbOutWord - writes a half word (16-bit) to an IO address.** This function writes a 16 bit half word to a specified IO address.** SYNOPSIS* \ss* void sysPlbOutWord* (* ULONG address* USHORT data* )* \se** SEE ALSO: sysPlbInByte(), sysPlbInWord(), sysPlbInLong(), sysPlbOutByte(), * sysPlbOutLong()** RETURNS: N/A*/FUNC_BEGIN(sysPlbOutWord) sthx r4,r0,r3 /* Write a word to an address */ sync /* Sync I/O operation */ bclr 20,0 /* Return to caller */FUNC_END(sysPlbOutWord)/***************************************************************************** sysPlbOutLong - writes a word (32-bit) to an IO address.** This function writes a 32 bit word to a specified IO address.** SYNOPSIS* \ss* void sysPlbOutLong* (* ULONG address* ULONG data* )* \se** SEE ALSO: sysPlbInByte(), sysPlbInWord(), sysPlbInLong(), sysPlbOutWord(), * sysPlbOutByte()** RETURNS: N/A*/FUNC_BEGIN(sysPlbOutLong) stwx r4,r0,r3 /* Write a word to an address */ sync /* Sync I/O operation */ bclr 20,0 /* Return to caller */FUNC_END(sysPlbOutLong)/***************************************************************************** sysSpin - performs a branch hang, used for debug purposes.** This function performs a branch hang, used for debug purposes.** SYNOPSIS* \ss* void sysSpin* (* void* )* \se** RETURNS: N/A*/FUNC_BEGIN(sysSpin) b sysSpinFUNC_END(sysSpin)/* * Include other .s files for chip specific DCR functions */#include "405gpDcr.s"#include "uicDcr.s"#include "sdramDcr.s"#include "ebcDcr.s"#include "dmaDcr.s"#if defined(EMAC_CACHE_FLUSH) || defined(EMAC_CACHE_INVALIDATE)#include "405cache.s"#endif /* defined(EMAC_CACHE_FLUSH) || defined(EMAC_CACHE_INVALIDATE) */#include "sysDcr.s"#ifdef INCLUDE_VWARE_LAUNCH#include "sysPpcAVware.s"#endif /* INCLUDE_VWARE_LAUNCH */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -