📄 mpc6xx_lo.s
字号:
stfd f23,o_f23(r31)
stfd f24,o_f24(r31)
stfd f25,o_f25(r31)
stfd f26,o_f26(r31)
stfd f27,o_f27(r31)
stfd f28,o_f28(r31)
stfd f29,o_f29(r31)
stfd f30,o_f30(r31)
stfd f31,o_f31(r31)
mtmsr r4 # MSR[FP]=0
sync
# Store all segment registers
mfsr r10,sr0
mfsr r11,sr1
mfsr r12,sr2
mfsr r13,sr3
mfsr r14,sr4
mfsr r15,sr5
mfsr r16,sr6
mfsr r17,sr7
mfsr r18,sr8
mfsr r19,sr9
mfsr r20,sr10
mfsr r21,sr11
mfsr r22,sr12
mfsr r23,sr13
mfsr r24,sr14
mfsr r25,sr15
stw r10,o_sr0(r31) # store sr0
stw r11,o_sr1(r31) # store sr1
stw r12,o_sr2(r31) # store sr2
stw r13,o_sr3(r31) # store sr3
stw r14,o_sr4(r31) # store sr4
stw r15,o_sr5(r31) # store sr5
stw r16,o_sr6(r31) # store sr6
stw r17,o_sr7(r31) # store sr7
stw r18,o_sr8(r31) # store sr8
stw r19,o_sr9(r31) # store sr9
stw r20,o_sr10(r31) # store sr10
stw r21,o_sr11(r31) # store sr11
stw r22,o_sr12(r31) # store sr12
stw r23,o_sr13(r31) # store sr13
stw r24,o_sr14(r31) # store sr14
stw r25,o_sr15(r31) # store sr15
#
# Store the Special Purpose Registers
#
tbloop:
mftb r14,269 # TBU
mftb r13,268 # TBL
mftb r15,269 # TBU
cmpw r15,r14
bne tbloop
mfspr r15,spr_pvr
stw r13,o_tbl(r31)
stw r14,o_tbu(r31)
stw r15,o_pvr(r31)
sync
mfspr r10,spr_ibat0u
mfspr r11,spr_ibat0l
mfspr r12,spr_ibat1u
mfspr r13,spr_ibat1l
mfspr r14,spr_ibat2u
mfspr r15,spr_ibat2l
mfspr r16,spr_ibat3u
mfspr r17,spr_ibat3l
stw r10,o_ibat0u(r31)
stw r11,o_ibat0l(r31)
stw r12,o_ibat1u(r31)
stw r13,o_ibat1l(r31)
stw r14,o_ibat2u(r31)
stw r15,o_ibat2l(r31)
stw r16,o_ibat3u(r31)
stw r17,o_ibat3l(r31)
sync
mfspr r10,spr_dbat0u
mfspr r11,spr_dbat0l
mfspr r12,spr_dbat1u
mfspr r13,spr_dbat1l
mfspr r14,spr_dbat2u
mfspr r15,spr_dbat2l
mfspr r16,spr_dbat3u
mfspr r17,spr_dbat3l
stw r10,o_dbat0u(r31)
stw r11,o_dbat0l(r31)
stw r12,o_dbat1u(r31)
stw r13,o_dbat1l(r31)
stw r14,o_dbat2u(r31)
stw r15,o_dbat2l(r31)
stw r16,o_dbat3u(r31)
stw r17,o_dbat3l(r31)
sync
mfspr r10,spr_sdr1
mfspr r11,spr_dar
mfspr r12,spr_dsisr
mfspr r13,spr_dec
mfspr r14,spr_srr1
mfspr r15,spr_sprg0
mfspr r16,spr_sprg1
mfspr r17,spr_sprg2
mfspr r18,spr_sprg3
stw r10,o_sdr1(r31)
stw r11,o_dar(r31)
stw r12,o_dsisr(r31)
stw r13,o_dec(r31)
stw r14,o_srr1(r31)
# stw r15,o_sprg0(r31)
# stw r16,o_sprg1(r31)
stw r17,o_sprg2(r31)
stw r18,o_sprg3(r31)
sync
#
# Processor specific registers
#
mfspr r3,spr_pvr
rlwinm r3,r3,16,16,31
cmpli cr0,0,r3,PVR_602
bc 12,2,save_spr_602 # beq
cmpli cr0,0,r3,PVR_603
bc 12,2,save_spr_603 # beq
cmpli cr0,0,r3,PVR_603E
bc 12,2,save_spr_603E # beq
cmpli cr0,0,r3,PVR_603EV
bc 12,2,save_spr_603EV # beq
cmpli cr0,0,r3,PVR_604
bc 12,2,save_spr_604 # beq
cmpli cr0,0,r3,PVR_604E
bc 12,2,save_spr_604E # beq
cmpli cr0,0,r3,PVR_MACH5
bc 12,2,save_spr_MACH5 # beq
cmpli cr0,0,r3,PVR_750
bc 12,2,save_spr_750 # beq
b save_spr_done
#
# NOTE: In the mpc60x.h, the processor specific registers
# are stored in a C union. Therefore, the offsets for each
# of the various registers are probably different. Ie.
# the MPC603 and MPC603E both have DMISS, but the actual offset
# for storing DMISS is not the same.
#
# Bottom line, do not share code here unless the processor's
# union is the same/identical in mpc60x.h
#
save_spr_602:
b save_spr_done
save_spr_603:
mfspr r10,spr_603_hid0
mfspr r11,spr_603_dmiss
mfspr r12,spr_603_dcmp
mfspr r13,spr_603_hash1
mfspr r14,spr_603_hash2
mfspr r15,spr_603_imiss
mfspr r16,spr_603_icmp
mfspr r17,spr_603_rpa
mfspr r18,spr_603_iabr
# mfspr r19,spr_603_ear
stw r10,o_603_hid0(r31)
stw r11,o_603_dmiss(r31)
stw r12,o_603_dcmp(r31)
stw r13,o_603_hash1(r31)
stw r14,o_603_hash2(r31)
stw r15,o_603_imiss(r31)
stw r16,o_603_icmp(r31)
stw r17,o_603_rpa(r31)
stw r18,o_603_iabr(r31)
# stw r19,o_603_ear(r31)
mtspr spr_603_iabr,r0 # disable
b save_spr_done
save_spr_603E:
save_spr_603EV:
mfspr r10,spr_603e_hid0
mfspr r11,spr_603e_hid1
mfspr r12,spr_603e_dmiss
mfspr r13,spr_603e_dcmp
mfspr r14,spr_603e_hash1
mfspr r15,spr_603e_hash2
mfspr r16,spr_603e_imiss
mfspr r17,spr_603e_icmp
mfspr r18,spr_603e_rpa
mfspr r19,spr_603e_iabr
# mfspr r20,spr_603e_ear
stw r10,o_603e_hid0(r31)
stw r11,o_603e_hid1(r31)
stw r12,o_603e_dmiss(r31)
stw r13,o_603e_dcmp(r31)
stw r14,o_603e_hash1(r31)
stw r15,o_603e_hash2(r31)
stw r16,o_603e_imiss(r31)
stw r17,o_603e_icmp(r31)
stw r18,o_603e_rpa(r31)
stw r19,o_603e_iabr(r31)
# stw r20,o_603e_ear(r31)
mtspr spr_603e_iabr,r0 # disable
b save_spr_done
save_spr_604:
mfspr r10,spr_604_hid0
mfspr r11,spr_604_pmc1
mfspr r12,spr_604_pmc2
mfspr r13,spr_604_mmcr0
mfspr r14,spr_604_sda
mfspr r15,spr_604_sia
mfspr r16,spr_604_iabr
mfspr r17,spr_604_dabr
# mfspr r18,spr_604_ear
mfspr r19,spr_604_pir
stw r10,o_604_hid0(r31)
stw r11,o_604_pmc1(r31)
stw r12,o_604_pmc2(r31)
stw r13,o_604_mmcr0(r31)
stw r14,o_604_sda(r31)
stw r15,o_604_sia(r31)
stw r16,o_604_iabr(r31)
stw r17,o_604_dabr(r31)
# stw r18,o_604_ear(r31)
stw r19,o_604_pir(r31)
mtspr spr_604_iabr,r0 # disable
b save_spr_done
save_spr_604E:
save_spr_MACH5:
mfspr r10,spr_604e_hid0
mfspr r11,spr_604e_hid1
mfspr r12,spr_604e_pmc1
mfspr r13,spr_604e_pmc2
mfspr r14,spr_604e_pmc3
mfspr r15,spr_604e_pmc4
mfspr r16,spr_604e_mmcr0
mfspr r17,spr_604e_mmcr1
mfspr r18,spr_604e_sda
mfspr r19,spr_604e_sia
mfspr r20,spr_604e_iabr
mfspr r21,spr_604e_dabr
# mfspr r22,spr_604e_ear
mfspr r23,spr_604e_pir
stw r10,o_604e_hid0(r31)
stw r11,o_604e_hid1(r31)
stw r12,o_604e_pmc1(r31)
stw r13,o_604e_pmc2(r31)
stw r14,o_604e_pmc3(r31)
stw r15,o_604e_pmc4(r31)
stw r16,o_604e_mmcr0(r31)
stw r17,o_604e_mmcr1(r31)
stw r18,o_604e_sda(r31)
stw r19,o_604e_sia(r31)
stw r20,o_604e_iabr(r31)
stw r21,o_604e_dabr(r31)
# stw r22,o_604e_ear(r31)
stw r23,o_604e_pir(r31)
mtspr spr_604e_iabr,r0 # disable
b save_spr_done
save_spr_750:
# mfspr r5,spr_750_upmc1
# mfspr r6,spr_750_upmc2
# mfspr r7,spr_750_upmc3
# mfspr r8,spr_750_upmc4
# mfspr r9,spr_750_usia
# mfspr r10,spr_750_ummcr0
# mfspr r11,spr_750_ummcr1
# mfspr r12,spr_750_hid0
# mfspr r13,spr_750_hid1
# mfspr r14,spr_750_pmc1
# mfspr r15,spr_750_pmc2
# mfspr r16,spr_750_pmc3
# mfspr r17,spr_750_pmc4
# mfspr r18,spr_750_mmcr0
# mfspr r19,spr_750_mmcr1
# mfspr r20,spr_750_sia
# mfspr r21,spr_750_thrm1
# mfspr r22,spr_750_thrm2
# mfspr r23,spr_750_thrm3
# mfspr r24,spr_750_ictc
# mfspr r25,spr_750_l2cr
# mfspr r26,spr_750_iabr
# mfspr r27,spr_750_dabr
# mfspr r28,spr_750_ear
stw r5,o_750_upmc1(r31)
stw r6,o_750_upmc2(r31)
stw r7,o_750_upmc3(r31)
stw r8,o_750_upmc4(r31)
stw r9,o_750_usia(r31)
stw r10,o_750_ummcr0(r31)
stw r11,o_750_ummcr1(r31)
stw r12,o_750_hid0(r31)
stw r13,o_750_hid1(r31)
stw r14,o_750_pmc1(r31)
stw r15,o_750_pmc2(r31)
stw r16,o_750_pmc3(r31)
stw r17,o_750_pmc4(r31)
stw r18,o_750_mmcr0(r31)
stw r19,o_750_mmcr1(r31)
stw r20,o_750_sia(r31)
# stw r21,o_750_thrm1(r31)
# stw r22,o_750_thrm2(r31)
# stw r23,o_750_thrm3(r31)
stw r24,o_750_ictc(r31)
stw r25,o_750_l2cr(r31)
stw r26,o_750_iabr(r31)
stw r27,o_750_dabr(r31)
# stw r28,o_750_ear(r31)
mtspr spr_750_iabr,r0 # disable
b save_spr_done
save_spr_done:
sync
isync
#
# Context save complete! Change to monitor stack and make
# memory coherent. Because the caches use physical addresses
# (versus logical addresses) for tags, no issues with coherency
# between a possible virtual environment and the simple environment
# that the debugger executes in.
#
addis r1,r0,(__SP_INIT-20)@h
ori r1,r1,(__SP_INIT-20)@l
bl cpu_cache_flush
bl mpc10x_l2_flush
# Invoke the C exception handler.
#
# int cpu_handler (ADDRESS exception);
#
mfspr r3,spr_sprg1 # the address in LR indicates exception
bl cpu_handler
# Code to determine if we go back to monitor or user code
# r3 == 1 if to go back to monitor, 0 for RFI
cmpi cr0,0,r3,0x0001
beq cr0,backtomonitor
# restore state and execute rfi.
# Point r3 to the user register data structure
addis r3,r0,(context)@h
ori r3,r3,(context)@l
b asm_switch_context
# The RFI is performed in asm_switch_context
backtomonitor:
b mainloop
######################################################################
#
# This routine is called from a system call to save the context and
# return to the dBUG prompt. This routine is used in conjuction with
# asm_exception_body() and cpu_handler() to avoid rewriting/copying
# the context save code. It passes exception #0xFF00 to cpu_handler(),
# which will then dump out to the dBUG prompt.
#
# Prior to invoking this routine, the caller must have ensured that
# the entry conditions for asm_exception_body have already been met,
# with the exception that LR is set here to indicate bogus exception.
#
asm_sc_exit_to_dbug:
addi r31,0,-1
mtspr spr_lr,r31
b asm_exception_body
######################################################################
#
# This routine accepts a pointer to the data structure containing
# the user register set, and restores its context.
# Call from C:
#
# void asm_switch_context(&context);
#
asm_switch_context:
# Point r31 to the user register data structure
addi r31,r3,0 # arg in r3
#
# Processor specific registers
#
mfspr r3,spr_pvr
rlwinm r3,r3,16,16,31
cmpli cr0,0,r3,PVR_602
bc 12,2,restore_spr_602 # beq
cmpli cr0,0,r3,PVR_603
bc 12,2,restore_spr_603 # beq
cmpli cr0,0,r3,PVR_603E
bc 12,2,restore_spr_603E # beq
cmpli cr0,0,r3,PVR_603EV
bc 12,2,restore_spr_603EV # beq
cmpli cr0,0,r3,PVR_604
bc 12,2,restore_spr_604 # beq
cmpli cr0,0,r3,PVR_604E
bc 12,2,restore_spr_604E # beq
cmpli cr0,0,r3,PVR_MACH5
bc 12,2,restore_spr_MACH5 # beq
cmpli cr0,0,r3,PVR_750
bc 12,2,restore_spr_750 # beq
b restore_spr_done
restore_spr_602:
b restore_spr_done
restore_spr_603:
# lwz r10,o_603_hid0(r31)
# lwz r11,o_603_dmiss(r31)
# lwz r12,o_603_dcmp(r31)
# lwz r13,o_603_hash1(r31)
# lwz r14,o_603_hash2(r31)
# lwz r15,o_603_imiss(r31)
# lwz r16,o_603_icmp(r31)
# lwz r17,o_603_rpa(r31)
lwz r18,o_603_iabr(r31)
# lwz r19,o_603_ear(r31)
# mtspr spr_603_hid0,r10
# mtspr spr_603_dmiss,r11
# mtspr spr_603_dcmp,r12
# mtspr spr_603_hash1,r13
# mtspr spr_603_hash2,r14
# mtspr spr_603_imiss,r15
# mtspr spr_603_icmp,r16
# mtspr spr_603_rpa,r17
mtspr spr_603_iabr,r18
# mtspr spr_603_ear,r19
b restore_spr_done
restore_spr_603E:
restore_spr_603EV:
# lwz r10,o_603e_hid0(r31)
# lwz r11,o_603e_hid1(r31)
# lwz r12,o_603e_dmiss(r31)
# lwz r13,o_603e_dcmp(r31)
# lwz r14,o_603e_hash1(r31)
# lwz r15,o_603e_hash2(r31)
# lwz r16,o_603e_imiss(r31)
# lwz r17,o_603e_icmp(r31)
# lwz r18,o_603e_rpa(r31)
lwz r19,o_603e_iabr(r31)
# lwz r20,o_603e_ear(r31)
# mtspr spr_603e_hid0,r10
# mtspr spr_603e_hid1,r11
# mtspr spr_603e_dmiss,r12
# mtspr spr_603e_dcmp,r13
# mtspr spr_603e_hash1,r14
# mtspr spr_603e_hash2,r15
# mtspr spr_603e_imiss,r16
# mtspr spr_603e_icmp,r17
# mtspr spr_603e_rpa,r18
mtspr spr_603e_iabr,r19
# mtspr spr_603e_ear,r20
b restore_spr_done
restore_spr_604:
# lwz r10,o_604_hid0(r31)
# lwz r11,o_604_pmc1(r31)
# lwz r12,o_604_pmc2(r31)
# lwz r13,o_604_mmcr0(r31)
# lwz r14,o_604_sda(r31)
# lwz r15,o_604_sia(r31)
lwz r16,o_604_iabr(r31)
lwz r17,o_604_dabr(r31)
# lwz r18,o_604_ear(r31)
# lwz r19,o_604_pir(r31)
# mtspr spr_604_hid0,r10
# mtspr spr_604_pmc1,r11
# mtspr spr_604_pmc2,r12
# mtspr spr_604_mmcr0,r13
# mtspr spr_604_sda,r14
# mtspr spr_604_sia,r15
mtspr spr_604_iabr,r16
mtspr spr_604_dabr,r17
# mtspr spr_604_ear,r18
# mtspr spr_604_pir,r19
b restore_spr_done
restore_spr_604E:
restore_spr_MACH5:
# lwz r10,o_604e_hid0(r31)
# lwz r11,o_604e_hid1(r31)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -