This commit is contained in:
Elliot Nunn 2018-07-15 17:34:52 +08:00
parent 7b62fa404d
commit f106b59fda
10 changed files with 43 additions and 119 deletions

View File

@ -2,83 +2,6 @@
; Data structures internal to the NanoKernel
;_______________________________________________________________________
;_______________________________________________________________________
; INFORECORD PAGE
;
; Lives at 5fffe000 on most (all?) PowerPC Macs. The public-ish part
; is the InfoRecord, which lives in the upper 64 bytes. This contains
; logical pointers, sizes and versions for the data structures that
; are shared between the NanoKernel and userspace. See
; PPCInfoRecordsPriv.s for the contents of these structures.
;
;_______________________________________________________________________
IRP record 0xdc0,INCR
SystemInfo ds.l 80 ; dc0:f00 ; other NK versions keep their structures elsewhere,
HWInfo ds.l 48 ; f00:fc0 ; so always use InfoRecord to find them from userspace
InfoRecord ds.l 16 ; fc0:1000 ; the public part
endr
; Some InfoRecord fields are obliquely referenced from PPCInfoRecordsPriv.h
; (e.g. nkSystemInfoPtr = 0x5FFFEFF0)
InfoRecBlkEntry
InfoRecBlk record 64,DECR
ProcInfo ds InfoRecBlkEntry
SysInfo ds InfoRecBlkEntry
DiagInfo ds InfoRecBlkEntry
NKInfo ds InfoRecBlkEntry
ProcInfo2 ds InfoRecBlkEntry
Unknown5 ds InfoRecBlkEntry
Unknown6 ds InfoRecBlkEntry
Unknown7 ds InfoRecBlkEntry
endr
InfoRecBlk record 0,INCR
UnknownPtr ds.l 1 ; 00
UnknownVer ds.l 1 ; 04
UnknownLen ds.l 1 ; 06
NKProcessorStatePtr ds.l 1 ; 08
NKProcessorStateVer ds.w 1 ; 0c
NKProcessorStateLen ds.w 1 ; 0e
NKHWInfoPtr ds.l 1 ; 10
NKHWInfoVer ds.w 1 ; 14
NKHWInfoLen ds.w 1 ; 16
NKProcessorInfoPtr ds.l 1 ; 18
NKProcessorInfoVer ds.w 1 ; 1c
NKProcessorInfoLen ds.w 1 ; 1e
NKNanoKernelInfoPtr ds.l 1 ; 20
NKNanoKernelInfoVer ds.w 1 ; 24
NKNanoKernelInfoLen ds.w 1 ; 26
NKDiagInfoPtr ds.l 1 ; 28
NKDiagInfoVer ds.w 1 ; 2c
NKDiagInfoLen ds.w 1 ; 2e
NKSystemInfoPtr ds.l 1 ; 30
NKSystemInfoVer ds.w 1 ; 34
NKSystemInfoLen ds.w 1 ; 36
NKProcessorInfoPtr2 ds.l 1 ; 38
NKProcessorInfoVer2 ds.w 1 ; 3c
NKProcessorInfoLen2 ds.w 1 ; 3e
Size equ *
endr
;_______________________________________________________________________
; PRIMARY SYSTEM AREA
;
@ -722,8 +645,7 @@ SysInfo ds NKSystemInfo ; cc0:d80
DiagInfo ds NKDiagInfo ; d80:e80
NKInfo ds NKNanoKernelInfo; e80:f80 ; see NKNanoKernelInfo in PPCInfoRecordsPriv
ProcInfo ds NKProcessorInfo ; f80:fc0
InfoRecBlk ds InfoRecBlk ; fc0:1000 ; was main copy in NKv1, now vestigial?
InfoRecBlk
endr

View File

@ -241,7 +241,7 @@ RunSystemContext
addi r8, r1, KDP.VecBaseSystem ; System VecTable
mtsprg 3, r8
bcl BO_IF, bitFlagEmu, Panic ; System Context already running!
bcl BO_IF, bitFlagEmu, SystemCrash ; System Context already running!
; Fallthru (new CB in r9, old CB in r6)

View File

@ -9,6 +9,7 @@ rED set r8 ; Emulator Data Page
########################################################################
b *+0x1234
li r0, 0 ; Zero lots of fields
########################################################################

View File

@ -23,7 +23,7 @@ IntExternal0
stw r3, 0(r3)
mtmsr r2
mtsrr0 r4
mrsrr1 r5
mtsrr1 r5
lwz r4, EWA.r4(r1)
lwz r5, EWA.r5(r1)
@ -93,11 +93,11 @@ IntExternal1
lbz r0, -0x6000(r2)
mtmsr r2
mtsrr0 r4
mrsrr1 r5
mtsrr1 r5
lwz r4, EWA.r4(r1)
lwz r5, EWA.r5(r1)
lwz r3, KDP.PA_NanoKernelCode ; Loop that number up in the table
lwz r3, KDP.PA_NanoKernelCode(r1) ; Loop that number up in the table
rlwimi r3, r0, 0, 0x0000003F
lbz r2, IntLookupTable-NKTop(r3)
mfcr r0
@ -151,7 +151,7 @@ IntExternal2
lwz r3, 0x2C(r2)
mtmsr r0
mtsrr0 r4
mrsrr1 r5
mtsrr1 r5
lwz r4, EWA.r4(r1)
lwz r5, EWA.r5(r1)

View File

@ -148,20 +148,20 @@ VMInit_BigLoop
andi. r3, r8, 0xc00
cmpwi r3, 0xc00
bne VMInit_0x110
bnel cr1, VMPanic
bnel cr1, SystemCrash
rlwinm r15, r8, 22, 0, 29
addi r3, r1, KDP.PARPerSegmentPLEPtrs
rlwimi r3, r5, 2, 28, 29
stw r15, 0x0000(r3)
slwi r3, r5, 16
cmpw r3, r4
bnel VMPanic
bnel SystemCrash
VMInit_0xa8
lwz r16, 0x0000(r15)
addi r7, r7, -0x01
andi. r3, r16, 0x01
beql VMPanic
beql SystemCrash
andi. r3, r16, 0x800
beq VMInit_0x100
lwz r14, KDP.HTABORG(r1)
@ -169,15 +169,15 @@ VMInit_0xa8
lwzux r8, r14, r3
lwz r9, 0x0004(r14)
andis. r3, r8, 0x8000
beql VMPanic
beql SystemCrash
andi. r3, r9, 0x03
cmpwi r3, 0x00
beql VMPanic
beql SystemCrash
rlwinm r3, r16, 17, 22, 31
rlwimi r3, r8, 10, 16, 21
rlwimi r3, r8, 21, 12, 15
cmpw r3, r4
bnel VMPanic
bnel SystemCrash
; bl RemovePageFromTLB
bl RemovePTEFromHTAB
@ -196,7 +196,7 @@ VMInit_0x110
lwz r7, KDP.TotalPhysicalPages(r1)
cmpw r4, r7
bnel VMPanic
bnel SystemCrash
lwz r5, KDP.PARPageListPtr(r1)
lwz r4, KDP.VMLogicalPages(r1)
andi. r7, r5, 0xfff
@ -271,7 +271,7 @@ VMInit_0x1ec
VMInit_0x218
lwz r16, 0x0000(r15)
andi. r7, r16, 0x01
beql VMPanic
beql SystemCrash
ori r16, r16, 0x404
stw r16, 0x0000(r15)
addi r5, r5, -0x400
@ -714,7 +714,7 @@ VMMarkResident ; OUTSIDE REFERER
bl GetPARPageInfo
bge cr4, VMReturnMinus1
bso cr7, VMReturnMinus1
bltl cr5, VMPanic
bltl cr5, SystemCrash
rlwimi r16, r5, 12, 0, 19
ori r16, r16, 0x01
stw r16, 0x0000(r15)
@ -947,7 +947,7 @@ GetPARPageInfo_0x10
rlwinm r8, r16, 23, 9, 28;convert page# into an index
rlwinm r9, r16, 0, 0, 19;get unshifted page#
bgelr cr5 ;return if PTE is not in HTAB
bns cr7, VMPanic;panic if the PTE is in the HTAB but isn't mapped to a real page
bns cr7, SystemCrash;panic if the PTE is in the HTAB but isn't mapped to a real page
lwzux r8, r14, r8 ;get first word of PTE from HTAB
lwz r9, 0x0004(r14);get second word of PTE from HTAB
mtcrf 0x80, r8
@ -955,7 +955,7 @@ GetPARPageInfo_0x10
rlwimi r16, r9, 27, 28, 28
mtcrf 0x07, r16
bltlr ;return if PTE is valid
bl VMPanic;panic if PTE isn't valid but is in the HTAB
bl SystemCrash;panic if PTE isn't valid but is in the HTAB
GetPARPageInfo_0x40 ;some kind of little-used code path for when VMMaxVirtualPages is invalid? ROM overlay?
lis r9, 4
@ -1132,7 +1132,7 @@ VMLastExportedFunc_0xd7
mflr r6
slwi r27, r4, 12
bl PopulateHTAB
bnel VMPanic
bnel SystemCrash
mr r27, r7
mr r29, r8
mr r30, r9

View File

@ -152,7 +152,7 @@ PopulateHTAB ; LogicalAddress r28 // Success cr0.eq
rlwimi r31, r28, 30, 31, 31
beq @return_daddy_flag
bltlr cr7
bl Panic
bl SystemCrash
########################################################################
; Helpful code that jumps back to roughly where it started
@ -280,10 +280,10 @@ PopulateHTAB ; LogicalAddress r28 // Success cr0.eq
andi. r30, r28, 0x800
rlwinm r30, r28, (32-9), 0x007FFFF8
xor r30, r30, r29
beq Panic
beq SystemCrash
andi. r30, r30, 0xffff
xori r28, r28, 0x800
bne Panic
bne SystemCrash
rlwimi r28, r31, 0, 0, 19 ; r28 = EA of victim of overflow
rlwimi r28, r31, 29, 27, 27
rlwimi r28, r31, 27, 28, 28

View File

@ -22,7 +22,7 @@ InitVectorTables
; System/Alternate Context tables
_kaddr r23, rNK, Panic
_kaddr r23, rNK, SystemCrash
addi r8, r1, KDP.VecBaseSystem
li r22, 3 * VecTable.Size
@vectab_initnext_segment
@ -38,7 +38,7 @@ rAlt set r8
addi rAlt, r1, KDP.VecBaseAlternate
_kaddr r23, rNK, Panic
_kaddr r23, rNK, SystemCrash
stw r23, VecTable.SystemResetVector(rSys)
stw r23, VecTable.SystemResetVector(rAlt)

View File

@ -320,7 +320,7 @@ KCallSystemCrash
stmw r14, EWA.r14(r1)
bl Panic
bl SystemCrash
########################################################################

View File

@ -1,25 +1,25 @@
SystemCrash
mfsprg0 r1
mfsprg r1, 0
stw r0, KDP.ThudSavedR0(r1)
mfspr r0, sprg1
mfsprg r0, 1
stw r0, KDP.ThudSavedR1(r1)
stmw r2, KDP.ThudSavedR2(r1)
mfspr r0, cr
mfcr r0
stw r0, KDP.ThudSavedCR(r1)
mfspr r0, mq
stw r0, KDP.ThudSavedMQ(r1)
mfspr r0, xer
mfxer r0
stw r0, KDP.ThudSavedXER(r1)
mfspr r0, sprg2
mfsprg r0, 2
stw r0, KDP.ThudSavedSPRG2(r1)
mfspr r0, ctr
mfctr r0
stw r0, KDP.ThudSavedCTR(r1)
mfspr r0, pvr
@ -43,13 +43,13 @@ SystemCrash
stw r0, KDP.ThudSavedHID0(r1)
mfspr r0, sdr1
stw r0, KDP.ThudSavedSDR(r1)
stw r0, KDP.ThudSavedSDR1(r1)
mfspr r0, srr0
mfsrr0 r0
stw r0, KDP.ThudSavedSRR0(r1)
mfspr r0, srr1
stw r0, KDP.ThudSavedSRR(r1)
mfspr r0, msr
mfsrr1 r0
stw r0, KDP.ThudSavedSRR1(r1)
mfmsr r0
stw r0, KDP.ThudSavedMSR(r1)
mfsr r0, 0
@ -85,8 +85,8 @@ SystemCrash
mfsr r0, 15
stw r0, KDP.ThudSavedSR15(r1)
mfspr r0, msr
ori r0, r0, 0x2000
mfmsr r0
_bset r0, r0, bitMsrFP
mtmsr r0
stfd f0, KDP.ThudSavedF0(r1)
stfd f1, KDP.ThudSavedF1(r1)
@ -137,9 +137,9 @@ SystemCrash
bne @nonzero
@retryrtc ; Save RTC in "Mac/Smurf shared message mem"
mfrtcu r2
mfrtcl r3
mfrtcu r0
mfspr r2, rtcu
mfspr r3, rtcl
mfspr r0, rtcu
xor. r0, r0, r2
bne @retryrtc
lwz r1, KDP.SharedMemoryAddr(r1)

View File

@ -9,6 +9,8 @@
include 'NKEquates.s'
include 'NKMacros.s'
csect NanoKernel[PR]
org 0
; I want these to be visibly wrong for the time being
FDP_TableBase
FDP_003C
@ -28,5 +30,4 @@ NKTop
include 'NKFloatingPt.s'
include 'NKSoftInt.s'
include 'NKLegacyVM.s'
NKBtm