📄 a400x.s
字号:
#ifndef LR4001#define LR4001#endif#include <mips.h>#include <pmon.h>/************************************************************** Ulong specialRead(Ulong addr,Ulong cfg)* savecfg = read_target(XT_MEM,M_CFG4001,4);* write_target(XT_MEM,M_CFG4001,cfg,4);* val = read_target(XT_MEM,addr,4);* write_target(XT_MEM,M_CFG4001,savecfg,4);* return(val);*/ .globl specialRead400x .ent specialRead400xspecialRead400x: la t0,1f or t0,K1BASE j t0 1: .set noreorder mfc0 t8,C0_SR nop and t0,t8,~SR_IEC mtc0 t0,C0_SR .set reorder li t4,M_CFG4001 lw t3,(t4) # setup sw a1,(t4) lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder # read lw v0,(a0) .set noreorder;nop;nop;.set reorder # restore sw t3,(t4) lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder .set noreorder mtc0 t8,C0_SR .set reorder j ra .end specialRead400x/************************************************************** specialWrite(Ulong addr,Ulong cfg,Ulong val)* savecfg = read_target(XT_MEM,M_CFG4001,4);* write_target(XT_MEM,M_CFG4001,cfg,4);* write_target(XT_MEM,addr,val,4);* write_target(XT_MEM,M_CFG4001,savecfg,4);*/ .globl specialWrite400x .ent specialWrite400xspecialWrite400x: la t0,1f or t0,K1BASE j t0 1: .set noreorder mfc0 t8,C0_SR nop and t0,t8,~SR_IEC mtc0 t0,C0_SR .set reorder li t4,M_CFG4001 lw t3,(t4) sw a1,(t4) lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder sw a2,(a0) .set noreorder;nop;nop;.set reorder sw t3,(t4) lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder .set noreorder mtc0 t8,C0_SR .set reorder j ra .end specialWrite400x#define LCK_BIT (1<<4)/************************************************************** writeLockedBpt400x(Ulong addr,Ulong vmask)* tag = readCache(set,ICACHETAG,addr);* if (!(tag&LCK_BIT)) {* tag &= ~0xf;* tag |= LCK_BIT;* }* tag |= vmask;* writeCache(set,ICACHERAM,addr,BPT_CODE);* writeCache(set,ICACHETAG,addr,tag);* -- make sure that it is not in set1* writeCache(1,ICACHETAG,addr,0); */ .globl writeLockedBpt400x .ent writeLockedBpt400xwriteLockedBpt400x: # switch to kseg1 so things don't change while # we are in the middle of updating the cache tags etc la t0,1f or t0,K1BASE j t0 1: # make sure that we are not interrupted .set noreorder mfc0 t8,C0_SR nop and t0,t8,~SR_IEC mtc0 t0,C0_SR .set reorder # get the current setting li t4,M_CFG4001 lw t7,(t4) # generate the settings we need and t6,t7,~(CFG_CMODEMASK|CFG_IS1EN|CFG_ICEN|CFG_DSIZEMASK) and t6,~(CFG_WBEN|CFG_PGSZMASK|CFG_ISIZEMASK) or t6,(CFG_ICEN|CFG_DCEN) # tag = readCache(0,ICACHETAG,addr); or t0,t6,CFG_CMODE_ITEST sw t0,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder lw v0,(a0) and t0,v0,LCK_BIT bne t0,zero,1f and v0,~0xf or v0,LCK_BIT 1: or v0,a1 # tag |= vmask # write the tag # writeCache(0,ICACHETAG,addr,tag); or t0,t6,CFG_CMODE_ITEST sw t0,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder sw v0,(a0) .set noreorder;nop;nop;.set reorder # write the bpt instruction # writeCache(0,ICACHERAM,addr,BPT_CODE); or t0,t6,CFG_CMODE_IDATA sw t0,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder li t0,BPT_CODE sw t0,(a0) .set noreorder;nop;nop;.set reorder # handle the irefillsz=8 case and t0,t7,CFG_ISIZEMASK srl t0,CFG_ISIZESHFT bne t0,3,3f # brif irefillsz != 8 # irefillsz=8 # even or odd? and t0,a0,0x10 beq t0,zero,1f # brif even # odd # writeCache(0,ICACHETAG,addr&~0x10,0x10); and t2,a0,~0x10 b 2f 1: # even # writeCache(0,ICACHETAG,addr|0x10,0x10); or t2,a0,0x10 2: # write the tag # writeCache(0,ICACHETAG,addr,tag); or t0,t6,CFG_CMODE_ITEST sw t0,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder li t0,0x10 sw t0,(t2) .set noreorder;nop;nop;.set reorder 3: # make sure that it's not already in set1 # writeCache(1,ICACHETAG,addr,0); or t0,t6,(CFG_CMODE_ITEST|CFG_IS1EN) sw t0,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder sw zero,(a0) .set noreorder;nop;nop;.set reorder # restore sw t7,(t4) # write CFG lw zero,(t4) # wbflush .set noreorder;nop;nop;.set reorder .set noreorder mtc0 t8,C0_SR .set reorder j ra .end writeLockedBpt400x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -