📄 sysalib.s
字号:
/* Copyright 1984-2004 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01m,30jul04,dtr adding func sysTimeBaseLGet. Modify instruction parity handler to reboot if errata#30 hit.01l,22jul04,dtr Add sysL1CsrSet routine.01k,05jun04,dtr Enabling branch prediction and L1 parity error handler.01j,20nov03,dtr Work on issue.01i,22oct03,dtr Removing compiler warning.01h,02oct03,dtr Ensure contiguous cache flush.01g,17sep03,dtr Remove LCRR update and removing PCI CAM entry.Set LAWBAR4 to cover max flash of 16MB.01f,04sep03,dtr Adding in stack frame pointer init.01e,02sep03,dtr Adding sysPCGet function to query if rom resident image.01d,04aug03,dtr Fix vision vxworks image.01c,29jul03,dtr Removing magic numbers.01b,07jul03,mil Added VISION_VXWORKS for no bootrom and local bus access window with bootrom.01a,03oct02,dtr Created.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h"#include "config.h"#include "sysLib.h"#include "sysL2Cache.h"#include "arch/ppc/mmuE500Lib.h" FUNC_EXPORT(sysInit) FUNC_EXPORT(_sysInit) FUNC_EXPORT(vxL2CTLSet) FUNC_EXPORT(vxL2CTLGet) FUNC_EXPORT(sysCacheFlush) FUNC_IMPORT(usrInit) FUNC_EXPORT(sysInWord) FUNC_EXPORT(sysOutWord) FUNC_EXPORT(sysInLong) FUNC_EXPORT(sysOutLong) FUNC_EXPORT(sysInByte) 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) FUNC_EXPORT(sysPCGet) /* get the value of the PC register */ FUNC_EXPORT(sysL1Csr1Set) FUNC_EXPORT(sysTimeBaseLGet) FUNC_EXPORT(sysIParityHandler) FUNC_EXPORT(sysIvor1Set) FUNC_EXPORT(disableBranchPrediction) FUNC_EXPORT(jumpIParity) FUNC_EXPORT(getCurSp) _WRS_TEXT_SEG_START DATA_IMPORT(inFullVxWorksImage) DATA_IMPORT(instrParityCount) #define CACHE_ALIGN_SHIFT 5 /* Cache line size == 2**5 */ FUNC_LABEL(_sysInit) FUNC_BEGIN(sysInit) xor p0,p0,p0 mtspr TCR,p0 xor r6, r6, r6 msync isync mtspr L1CSR0, r6 /* Disable the Data cache */ li r6, 0x0002 msync isync mtspr L1CSR0, r6 /* Invalidate the Data cache */ li r6, 0x0000 msync isync mtspr L1CSR1, r6 /* Disable the Instrunction cache */ li r6, 0x0002 msync isync mtspr L1CSR1, r6 /* Invalidate the Instruction cache */ isync li r6, 0x0000 msync isync mtspr L1CSR1, r6 /* Enable the Instruction cache*/#if defined(INCLUDE_CACHE_SUPPORT) && defined(USER_I_CACHE_ENABLE) isync li r7, 0x0001 msync isync mtspr L1CSR1, r7 /* enable the instruction cache */#endif /* INCLUDE_CACHE_SUPPORT && USER_I_CACHE_ENABLE */ msync isync#ifdef INCLUDE_BRANCH_PREDICTION li r6, _PPC_BUCSR_FI mtspr 1013,r6 li r6, _PPC_BUCSR_E mtspr 1013,r6#endif lis r6, HIADJ(inFullVxWorksImage) addi r6, r6,LO(inFullVxWorksImage) li r7, TRUE stw r7, 0(r6) /* initialize the stack pointer */ lis sp, HIADJ(RAM_LOW_ADRS) addi sp, sp, LO(RAM_LOW_ADRS) addi sp, sp, -FRAMEBASESZ /* get frame stack */ li r3, BOOT_WARM_AUTOBOOT /* set the default boot code */ b usrInitFUNC_END(sysInit) .balign 32/******************************************************************************** vxL2CTLSet - Set the value of the L@ cache control register** This routine returns the value written.** SYNOPSIS* \ss* UINT32 sysL2CTLSet* (* UINT32 value,* UINT32 *addr* )* \se** RETURNS: This routine returns the value in the L2CTL reg.*/ FUNC_BEGIN(vxL2CTLSet) mbar 0 isync stw p0,0(p1) lwz p0,0(p1) mbar 0 isync blrFUNC_END(vxL2CTLSet) .balign 32/******************************************************************************** vxL2CTLGet - Get the value of the L2 cache control register** SYNOPSIS* \ss* UINT32 sysL2CTLGet* (* UINT32 *addr* )* \se** RETURNS: This routine returns the value in the L2CTL reg.*/FUNC_BEGIN(vxL2CTLGet) mbar 0 isync lwz p1,0x0(p0) addi p0,p1,0x0 mbar 0 isync blrFUNC_END(vxL2CTLGet)/******************************************************************************* disableBranchPrediction - disables branch prediction ** SYNOPSIS* \ss* void disableBranchPrediction* (* void* )* \se** RETURNS: NONE*/FUNC_BEGIN(disableBranchPrediction) mfspr p0, 1013 andi. p1, p0,LO(~_PPC_BUCSR_E) isync mtspr 1013,p1 isync li p0, _PPC_BUCSR_FI mtspr 1013,p0 isync blrFUNC_END(disableBranchPrediction)/**************************************************** * sysCacheFlush just flushes cache - assume int lock * p0 - cache line num * p1 - buffer origin * p2 - cache align size */ FUNC_BEGIN(sysCacheFlush) /* * p3 contains the count of cache lines to be fetched & flushed. * Convert to a count of pages covered, and fetch a word from * each page to ensure that all addresses involved are in * the TLB so that reloads do not disrupt the flush loop. * A simple shift without round-up is sufficient because * the p3 value is always a multiple of the shift count. */ srwi p3, p0, MMU_RPN_SHIFT - CACHE_ALIGN_SHIFT mtspr CTR, p3 addi p6,p1,0 li p5,MMU_PAGE_SIZE subf p3,p5,p1 /* * There might be a page boundary between here and the end of * the function, so make sure both pages are in the I-TLB. */ b cacheL2DisableLoadItlbcacheL2DisableLoadDtlb: add p3,p3,p5 lbzu p4,0(p3) bdnz cacheL2DisableLoadDtlb mtctr p0 /* Load counter with number of cache lines */ subf p1, p2, p1 /* buffer points to text - cache line size */l2DisableFlush: add p1, p2, p1 /* + cache line size */ lbzu p3, 0x0(p1) /* flush the data cache block */ bdnz l2DisableFlush /* loop till cache ctr is zero */ sync isync mtctr p0 /* Load counter with number of cache lines */ addi p1, p6, 0 subf p1, p2, p1 /* buffer points to text - cache line size */l2DisableClear: add p1, p2, p1 /* point to next cache line */ dcbf 0,p1 /* flush newly-loaded line */ bdnz l2DisableClear /* repeat for all sets and ways */ sync isync blrcacheL2DisableLoadItlb: b cacheL2DisableLoadDtlbFUNC_END(sysCacheFlush)/******************************************************************************* 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 p0,r0,p0 /* Read byte from I/O space */ bclr 20,0 /* Return to caller */FUNC_END(sysInByte) /******************************************************************************** sysOutByte - writes a byte to an io address.** This function writes a byte to a specified io address.** RETURNS: N/A* VOID sysOutByte* (* UCHAR * pAddr, /@ Virtual I/O addr to write to @/* UCHAR data /@ data to be written @/* )*/FUNC_BEGIN(sysOutByte) stbx p1,r0,p0 /* Write a byte to PCI space */ eieio /* Sync I/O operation */ sync bclr 20,0 /* Return to caller */FUNC_END(sysOutByte) /******************************************************************************* 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 p0,r0,p0 /* Read and swap */ bclr 20,0 /* Return to caller */FUNC_END(sysInWord)/******************************************************************************* sysOutWord - writes a word to an address swapping the bytes.** This function writes a swapped word to a specified * address.** RETURNS: N/A* VOID sysOutWord* (* ULONG address, /@ Virtual addr to write to @/* UINT16 data /@ Data to be written @/* )*/FUNC_BEGIN(sysOutWord) sthbrx p1,r0,p0 /* Write with swap to address */ eieio /* Sync I/O operation */ sync bclr 20,0 /* Return to caller */FUNC_END(sysOutWord)/******************************************************************************* 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 p0,r0,p0 /* Read and swap from address */ bclr 20,0 /* Return to caller */FUNC_END(sysInLong)/******************************************************************************** sysOutLong - write a swapped long to address.** This routine will store a 32-bit data item (input as big-endian)* into an address in little-endian mode.** RETURNS: N/A* VOID sysOutLong
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -