powermac-rom/NanoKernel/MRInterrupts.s

102 lines
3.2 KiB
ArmAsm
Raw Permalink Normal View History

2018-07-28 06:20:23 +00:00
; AUTO-GENERATED SYMBOL LIST
; IMPORTS:
; NKExceptions
; Exception
; MRException
; NKMemory
; GetPhysical
; PutPTE
; NKSystemCrash
; SystemCrash
; EXPORTS:
; MRDataStorageInt (=> NKReset)
; MRMachineCheckInt (=> NKReset)
2018-07-28 05:37:20 +00:00
2018-07-24 04:56:38 +00:00
; Special MR registers to investigate: r19 (inst addr), r26 (error)
2018-07-28 05:37:20 +00:00
########################################################################
2018-07-24 04:56:38 +00:00
MRDataStorageInt ; Consult DSISR and the page table to decide what to do
mfdsisr r31 ; Check DSISR for simple HTAB miss
andis. r28, r31, 0xC030 ; (bits 0/1/10/11)
mfsprg r1, 1
mfdar r27
bne @possible_htab_miss
andis. r28, r31, 0x0800 ; Illegal data access (else crash!)
2018-07-28 06:20:23 +00:00
addi r29, r1, KDP.CurDBAT0
bnel GetPhysical ; Get LBAT or lower PTE
2018-07-24 04:56:38 +00:00
li r28, 0x43 ; Filter Writethru and Protection bits
and r28, r31, r28
cmpwi cr7, r28, 0x43
beql SystemCrash ; Not illegal data access => Crash
mfsprg r28, 2
mtlr r28
bne cr7, @access_exception ; Any filtered bit unset => Exception
mfsrr0 r28 ; Writethru and Protection bits set => ROM write nop
addi r28, r28, 4
lwz r26, KDP.NKInfo.QuietWriteCount(r1)
2018-07-24 04:56:38 +00:00
mtsrr0 r28
addi r26, r26, 1
stw r26, KDP.NKInfo.QuietWriteCount(r1)
2018-07-24 04:56:38 +00:00
@return
extrwi r26, r25, 8, 22 ; Signal to some MemRetry code?
rfi
@access_exception
andi. r28, r31, 3
li r8, ecDataSupAccessViolation
2018-07-27 08:41:59 +00:00
beq MRException
2018-07-24 04:56:38 +00:00
cmpwi r28, 3
li r8, ecDataWriteViolation
2018-07-27 08:41:59 +00:00
beq MRException ; Nobody allowed to write => Exception
2018-07-24 04:56:38 +00:00
li r8, ecDataSupWriteViolation
2018-07-27 08:41:59 +00:00
b MRException ; Supervisor allowed to write => Exception
2018-07-24 04:56:38 +00:00
@possible_htab_miss
andis. r28, r31, 0x8010 ; Check for DataAccess Interrupt or ec[io]wx
bne MRHardwareFault ; Either of those => big trouble
bl PutPTE ; HTAB miss => fill HTAB
mfsprg r28, 2 ; (restore lr)
2018-07-24 04:59:11 +00:00
mtlr r28
2018-07-24 04:56:38 +00:00
beq @return ; HTAB success => RFI
li r8, ecDataPageFault
2018-07-27 08:41:59 +00:00
blt MRException ; Fault => Exception
2018-07-24 04:56:38 +00:00
li r8, ecDataInvalidAddress
2018-07-27 08:41:59 +00:00
b MRException ; Bad address => Exception
2018-07-24 04:56:38 +00:00
MRMachineCheckInt ; Always gives HW fault
mfsprg r1, 1
lwz r27, KDP.HtabLastEA(r1)
subf r28, r19, r27 ; Delete last HTAB entry if suspicious
2018-07-28 06:20:23 +00:00
cmpwi r28, -16 ; (i.e. within 16b of MemRetried EA)
2018-07-24 04:56:38 +00:00
blt @no_htab_del
cmpwi r28, 16
bgt @no_htab_del
lwz r28, KDP.NKInfo.HashTableDeleteCount(r1)
lwz r29, KDP.ApproxCurrentPTEG(r1)
addi r28, r28, 1
stw r28, KDP.NKInfo.HashTableDeleteCount(r1)
li r28, 0
stw r28, 0(r29)
sync
tlbie r27
sync
@no_htab_del
MRHardwareFault ; Can come from a DSI or a Machine Check
cmplw r10, r19
li r8, ecDataHardwareFault
2018-07-27 08:41:59 +00:00
bne MRException
2018-07-24 04:56:38 +00:00
mtsprg 3, r24
lmw r14, KDP.r14(r1)
li r8, ecInstHardwareFault
b Exception