Lots of work on Address Spaces

This commit is contained in:
Elliot Nunn 2018-04-23 23:22:55 +08:00
parent b725df3cf7
commit 6c199998f0
16 changed files with 5365 additions and 4470 deletions

View File

@ -90,9 +90,21 @@ ContextBlock record 0,INCR
Flags ds.l 1 ; 000 ; (SPAC) copied from kdp by CreateTask
Enables ds.l 1 ; 004
org 0x40
SavedFlags ds.l 1 ; 040 ; from before exception
org 0x44
SavedEnables ds.l 1 ; 044 ; from before exception
org 0x4c
ExceptionHandler ds.l 1 ; 04c
org 0x5c
LA_EmulatorKernelTrapTable ds.l 1
org 0x74
SRR0 ds.l 1 ; 074
org 0x84
LA_EmulatorEntry ds.l 1 ; 084 ; Entry pt of emulator; set by NK Init.s

View File

@ -127,16 +127,16 @@ kFlag5 equ 5
kFlag6 equ 6
kFlag7 equ 7
kFlag8 equ 8
kFlag9 equ 9
kFlagTakesAllExceptions equ 9
kFlag10 equ 10
kFlag11 equ 11
kFlag12 equ 12 ; set for idle1, idle2
kFlag13 equ 13
kFlag14 equ 14 ; set for blue, idle1
kFlagNotDebuggable equ 14 ; set for blue, idle1
kFlagBlue equ 15
kFlag16 equ 16
kFlag17 equ 17
kFlag18 equ 18
kFlagPageFaulted equ 18
kFlag19 equ 19
kFlag20 equ 20
kFlagPerfMon equ 21 ; set by MPMarkPMFTask, means perf monitor
@ -175,7 +175,7 @@ CodeFaultCtr ds.l 1 ; 0e0 ; these two only climb when VM is on
DataFaultCtr ds.l 1 ; 0e4
PreemptCtr ds.l 1 ; 0e8
SomeLabelField ds.l 1 ; 0ec
YellowVecTblPtr ds.l 1 ; 0f0
VecBase ds.l 1 ; 0f0
ExceptionHandlerID ds.l 1 ; 0f4 ; a queue
ErrToReturnIfIDie ds.l 1 ; 0f8
ds.l 1 ; 0fc
@ -447,7 +447,8 @@ kSignature equ 'SPAC'
ID ds.l 1 ; 00
Signature ds.l 1 ; 04
ds.l 1 ; 08
Flags ds.l 1 ; 08
kFlag30 equ 30
TaskCount ds.l 1 ; 0c ; incremented by CreateTask
RsrvList ds.l 4 ; 10:20 ; LLL
AreaList ds.l 4 ; 20:30 ; LLL
@ -561,6 +562,9 @@ kIDClass equ 11
kFirstID equ 0x000b0001
kSignature equ 'AREA'
kPLEFlagIsInHTAB equ 20 ; bits 0-19 = HTAB offset if set, else physical page
kPLEFlagHasPhysPage equ 31
;_______________________
; Fields
;_______________________
@ -594,7 +598,7 @@ LLL ds.l 4 ; 54:64 ; member of address space
ds.l 1 ; 64
PageSize ds.l 1 ; 68 ; always 4k, the size of a PPC page
AddressSpacePtr ds.l 1 ; 6c
ContigPTETemplate ds.l 1 ; 70 ; in contig areas, acts as PTE template for every page
ContigPTETemplate ds.l 1 ; 70 ; in contig areas, acts as PTE template for every page (whole Area is same page)
PagedPTETemplate ds.l 1 ; 74 ; when paged area is created this fills PageMapArray
AlignmentMask ds.l 1 ; 78 ; bit mask that LogicalBase is aligned to
DefaultAlignmentMask ds.l 1 ; 7c ; always 0xFFFFF000 (page alignment)
@ -607,6 +611,9 @@ FenceLLL ds.l 4 ; 90:a0 ; function unknown, id is 'fenc'
Size equ *
endr
; Page List Entry bits:

View File

@ -159,11 +159,11 @@ Pending68kInt ds.w 1 ; -43c ; used when Sch interrupts blue task (-1 means "no
_43a ds.w 1 ; -43a
DecClockRateHzCopy ds.l 1 ; -438 ; copied by Init.s
OtherTimerQueuePtr ds.l 1 ; -434 ; unsigned timer queue in the pool, set by InitTMRQs
FreePageCount ds.l 1 ; -430 ; zeroed by InitFreeList
FreePageCount ds.l 1 ; -430 ; zeroed by InitFreePageList
UnheldFreePageCount ds.l 1 ; -42c
ExternalHandlerID ds.l 1 ; -428 ; notification for PIH to bump
SystemAddressSpaceID ds.l 1 ; -424
_420 ds.l 1 ; -420
AgerID ds.l 1 ; -420
blueProcessPtr ds.l 1 ; -41c ; physical ptr to first type-1 struct created
ThermalHandlerID ds.l 1 ; -418 ; is a Note struct
PMFHandlerID ds.l 1 ; -414 ; also a Note struct
@ -173,7 +173,7 @@ _408 ds.l 1 ; -408
_404 ds.l 1 ; -404
_400 ds.l 1 ; -400
OtherSystemAddrSpcPtr ds.l 1 ; -3fc
OtherSystemAddrSpcPtr2 ds.l 1 ; -3f8 ; copied from the one above by InitFreeList
OtherSystemAddrSpcPtr2 ds.l 1 ; -3f8 ; copied from the one above by InitFreePageList
ZeroedByInitFreeList3 ds.l 1 ; -3f4
_3f0 ds.l 1 ; -3f0
_3ec ds.l 1 ; -3ec
@ -580,9 +580,9 @@ NCBCacheLA3 ds.l 1 ; 358
NCBCachePA3 ds.l 1 ; 35c
NCBPointerCacheEnd
YellowVecBase ds.l 48 ; 360:420 ; used to ignore illegal AltiVec insns by Init.s
OrangeVecBase ds.l 48 ; 420:4e0
RedVecBase ds.l 48 ; 4e0:5a0
VecBaseSystem ds.l 48 ; 360:420 ; when 68k emulator is running, *or* any MTask
VecBaseAlternate ds.l 48 ; 420:4e0 ; native PowerPC in blue task
VecBaseTranslation ds.l 48 ; 4e0:5a0 ; "FDP" instruction emulation
OldKDP ds.l 1 ; 5a0 ; gotten from the old SPRG0
OtherFreeThing ds.l 1 ; 5a4
TopOfFreePages ds.l 1 ; 5a8 ; gotten from the old SPRG0
@ -634,10 +634,10 @@ PageAttributeInit ds.l 1 ; 688 ; defaults for page table entries (see ConfigInf
ds.l 1 ; 69c
PTEGMask ds.l 1 ; 6a0
HTABORG ds.l 1 ; 6a4
PrimaryAddrRangePages ds.l 1 ; 6a8 ; set at init and changed by VMInit
VMLogicalPages ds.l 1 ; 6a8 ; set at init and changed by VMInit
TotalPhysicalPages ds.l 1 ; 6ac ; does not take into acct maximum MacOS memory
FlatPageListPtr ds.l 1 ; 6b0
VMMaxVirtualPages ds.l 1 ; 6b4 ; size of main contiguous segment?
FlatPageListPtr ds.l 1 ; 6b0 ; VM puts this in system heap
VMMaxVirtualPages ds.l 1 ; 6b4 ; always 5fffe000, even with VM on
CpuSpecificBytes
CpuSpecificByte1 ds.b 1 ; 6b8 ; seems to contain flags (set from PVR & tbl by Init.s)
CpuSpecificByte2 ds.b 1 ; 6b9 ; probably not flags (set in same way)

View File

@ -17,7 +17,7 @@ NKFiles =
{NKDir}NKMPCalls.s ¶
{NKDir}NKSync.s ¶
{NKDir}NKTasks.s ¶
{NKDir}NKAddressSpaceMPCalls.s カ
{NKDir}NKAddressSpaces.s ¶
{NKDir}NKPoolAllocator.s ¶
{NKDir}NKTimers.s ¶
{NKDir}NKScheduler.s ¶

View File

@ -16,7 +16,7 @@ NKDebug
beq @already_physical
li r9, 0
bl V2P ; takes page EA in r8, r9=0, returns page PA in r17
bl SpaceL2PUsingBATs ; LogicalPage *r8, MPAddressSpace *r9 // PhysicalPage *r17
beq @fail
rlwimi r8, r17, 0, 0, 19
@already_physical

File diff suppressed because it is too large Load Diff

4801
NanoKernel/NKAddressSpaces.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -198,13 +198,13 @@ FinishInitBuiltin
llabel r8, IgnoreSoftwareInt
add r8, r8, r9
stw r8, KDP.YellowVecBase + VecTable.ProgramIntVector(r1)
stw r8, KDP.VecBaseSystem + VecTable.ProgramIntVector(r1)
llabel r8, HandlePerfMonitorInt
add r8, r8, r9
stw r8, KDP.YellowVecBase + VecTable.PerfMonitorVector(r1)
stw r8, KDP.VecBaseSystem + VecTable.PerfMonitorVector(r1)
addi r8, r1, KDP.YellowVecBase
addi r8, r1, KDP.VecBaseSystem
mtsprg 3, r8
@ -366,21 +366,21 @@ InitHighLevel
; Fill with Panics: Yellow, Orange, Red (KDP)
; Violet, Blue (PSA)
; Fill the old-style KDP vector tables, and also two new PSA ones,
; with panics
llabel r23, panic
add r23, r23, r25
addi r8, r1, KDP.YellowVecBase
addi r8, r1, KDP.VecBaseSystem
li r22, VecTable.Size
bl wordfill
addi r8, r1, KDP.OrangeVecBase
addi r8, r1, KDP.VecBaseAlternate
li r22, VecTable.Size
bl wordfill
addi r8, r1, KDP.RedVecBase
addi r8, r1, KDP.VecBaseTranslation
li r22, VecTable.Size
bl wordfill
@ -405,12 +405,13 @@ InitHighLevel
; Activate Yellow and fill Yellow and Orange (KDP)
; Populate System and Alternate Context vector tables.
; Activate System Context vector table (will enter 68k emu soon).
addi r9, r1, KDP.YellowVecBase
addi r9, r1, KDP.VecBaseSystem
mtsprg 3, r9
addi r8, r1, KDP.OrangeVecBase
addi r8, r1, KDP.VecBaseAlternate
llabel r23, panic
add r23, r23, r25
@ -432,14 +433,15 @@ InitHighLevel
stw r23, VecTable.ISIVector(r9)
stw r23, VecTable.ISIVector(r8)
; Difference: Yellow seems more likely to reach PIH
llabel r23, IntExternalYellow
; Here is the difference between the System and Alternate
; vector tables
llabel r23, IntExternalSystem
add r23, r23, r25
stw r23, VecTable.ExternalIntVector(r9) ; yellow
stw r23, VecTable.ExternalIntVector(r9)
llabel r23, IntExternalOrange
llabel r23, IntExternalAlternate
add r23, r23, r25
stw r23, VecTable.ExternalIntVector(r8) ; orange
stw r23, VecTable.ExternalIntVector(r8)
llabel r23, IntAlignment
add r23, r23, r25
@ -490,9 +492,9 @@ InitHighLevel
; Fill Red (KDP), used while were emulating some instructions
; Fill the Translation vector table
addi r8, r1, KDP.RedVecBase
addi r8, r1, KDP.VecBaseTranslation
llabel r23, panic
add r23, r23, r25
@ -502,7 +504,7 @@ InitHighLevel
add r23, r23, r25
stw r23, VecTable.MachineCheckVector(r8)
llabel r23, IntDSIOtherOther
llabel r23, IntDSITranslation
add r23, r23, r25
stw r23, VecTable.DSIVector(r8)
@ -1026,7 +1028,7 @@ SetProcessorFlags
; Initialize the kernel queues. They are called:
;
; - PHYS (free list, in KDP, by InitFreeList)
; - PHYS (free list, in KDP, by InitFreePageList)
; - DLYQ (in KDP, by me)
; - DBUG (in KDP, by me)
; - PAGQ (in KDP, has ID, by me)
@ -1037,7 +1039,7 @@ SetProcessorFlags
; Free list in hardcoded KDP location
; ARG KernelData *r1
; CLOB r8, r9
bl InitFreeList
bl InitFreePageList
; Delay queue in hardcoded KDP location
@ -1132,7 +1134,7 @@ SetProcessorFlags
li r8, 2
stb r8, Task.State(r31)
lisori r8, 0x30028 ; (Z>>Task.kFlag14) | (Z>>Task.kFlagBlue) | (Z>>Task.kFlag26) | (Z>>Task.kFlag28)
lisori r8, 0x30028 ; (Z>>Task.kFlagNotDebuggable) | (Z>>Task.kFlagBlue) | (Z>>Task.kFlag26) | (Z>>Task.kFlag28)
stw r8, Task.Flags(r31)
li r8, 200
@ -1226,7 +1228,7 @@ SetProcessorFlags
stw r8, Task.Name(r31)
lisori r8, 0xA0040 ; (Z>>Task.kFlag12) | (Z>>Task.kFlag14) | (Z>>Task.kFlag25)
lisori r8, 0xA0040 ; (Z>>Task.kFlag12) | (Z>>Task.kFlagNotDebuggable) | (Z>>Task.kFlag25)
stw r8, Task.Flags(r31)
; For the scheduler
@ -1626,7 +1628,7 @@ PrimeFreeListFromBanks
@loop
lwz r8, 0(r29)
rlwinm r8, r8, 0, 0, 19 ; physical base of page
bl free_list_add_page
bl FreePageListPush ; PhysicalPage *r8
subi r17, r17, 1
subi r29, r29, 4
@ -1661,7 +1663,7 @@ PrimeFreeListFromSystemHeap
@stupidloop
rlwinm r8, r18, 0, 0, 19
bl free_list_add_page
bl FreePageListPush ; PhysicalPage *r8
addi r17, r17, -0x01
addi r18, r18, 0x1000
cmpwi r17, 0x00
@ -1685,7 +1687,7 @@ DonePrimingFreeList
_log 'VMLogicalPages: '
lwz r8, 0x06a8(r1) ; kdp.phys_pages
lwz r8, KDP.VMLogicalPages(r1)
mr r8, r8
bl Printw
@ -1764,7 +1766,7 @@ ReconcileMemory
; The above, divided by 4096
srwi r19, r19, 12
stw r19, KDP.PrimaryAddrRangePages(r1)
stw r19, KDP.VMLogicalPages(r1)
addi r29, r1, KDP.FlatPageListSegPtrs - 4
addi r19, r1, KDP.SegMaps - 8
@ -1794,7 +1796,7 @@ ReconcileMemory
; Number of pages in that last segment
sth r22, 0x0002(r8)
lwz r17, KDP.PrimaryAddrRangePages(r1)
lwz r17, KDP.VMLogicalPages(r1)
lwz r18, KDP.TotalPhysicalPages(r1)
stw r17, KDP.TotalPhysicalPages(r1)
@ -1815,7 +1817,7 @@ ReconcileMemory
@loop
mr r8, r31
bl free_list_add_page
bl FreePageListPush ; PhysicalPage *r8
addi r31, r31, 4096
subi r18, r18, 1
cmpwi r18, 0
@ -1827,7 +1829,7 @@ ReconcileMemory
; Create Areas (an abstract NKv2 structure) from the Trampoline's PageMap
bl convert_pmdts_to_areas
bl CreateAreasFromPageMap
@ -1870,7 +1872,7 @@ finish_old_world
addi r29, r1, 0x5e8
bl PagingFunc2
bl PagingFlushTLB
bl convert_pmdts_to_areas
bl CreateAreasFromPageMap
bl ProbePerfMonitor
lwz r27, 0x0630(r1)
lwz r27, 0x0094(r27)
@ -1931,7 +1933,7 @@ setup_0x11f0
_log 'Nanokernel replaced. Returning to boot process^n'
addi r9, r1, KDP.OrangeVecBase
addi r9, r1, KDP.VecBaseAlternate
mtsprg 3, r9
; r1 = kdp
@ -1954,7 +1956,7 @@ CancelReplacement
lwz r8, KDP.OldKDP(r1)
mtsprg 0, r8
addi r9, r8, KDP.OrangeVecBase
addi r9, r8, KDP.VecBaseAlternate
mtsprg 3, r9

File diff suppressed because it is too large Load Diff

View File

@ -299,7 +299,7 @@ MPCall_0 ; OUTSIDE REFERER
; Fail if this page is outside of the PAR
rlwinm. r4, r3, 20, 12, 31
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
beq ReturnMPCallOOM
cmplw r4, r9
bge ReturnMPCallOOM
@ -1408,9 +1408,11 @@ KCStopScheduling ; OUTSIDE REFERER
lbz r17, 0x0019(r31)
cmpwi r17, 0x00
beq KCStopScheduling_0x94
lwz r17, 0x0064(r31)
oris r17, r17, 0x80
stw r17, 0x0064(r31)
lwz r17, Task.Flags(r31)
_bset r17, r17, Task.kFlag8
stw r17, Task.Flags(r31)
mr r8, r31
bl SchTaskUnrdy
li r17, 0x00
@ -1494,7 +1496,7 @@ NKxprintf ; OUTSIDE REFERER
mr r8, r3
beq NKxprintf_0x1c
li r9, 0x00
bl V2P
bl SpaceL2PUsingBATs ; LogicalPage *r8, MPAddressSpace *r9 // PhysicalPage *r17
beq NKxprintf_0x24
rlwimi r8, r17, 0, 0, 19
@ -1969,13 +1971,13 @@ MPCall_115_0x94
crmove 30, 2
beq MPCall_115_0xd0
li r9, 0x00
bl MPCall_95_0x45c
bl SpaceL2PIgnoringBATs ; LogicalPage *r8, MPAddressSpace *r9 // PhysicalPage *r17
beq ReleaseAndReturnMPCallOOM
add r8, r4, r5
li r9, 0x00
addi r8, r8, -0x01
mr r30, r8
bl MPCall_95_0x45c
bl SpaceL2PIgnoringBATs ; LogicalPage *r8, MPAddressSpace *r9 // PhysicalPage *r17
beq ReleaseAndReturnMPCallOOM
MPCall_115_0xd0
@ -1997,7 +1999,7 @@ MPCall_115_0xe0
beq MPCall_115_0x11c
mr r27, r16
li r9, 0x00
bl MPCall_95_0x45c
bl SpaceL2PIgnoringBATs ; LogicalPage *r8, MPAddressSpace *r9 // PhysicalPage *r17
beq ReleaseAndReturnMPCallOOM
mr r26, r17

View File

@ -76,7 +76,7 @@ PagingFunc1 ; OUTSIDE REFERER
@_fc
mr r8, r27
bl MPCall_95_0x1e4
bl SpaceGetPagePLE ; LogicalPage *r8, Area *r31 // PLE *r30, notfound cr0.eq
lwz r28, 0x0000(r30)
mr r26, r30
mr r8, r27
@ -380,7 +380,7 @@ PagingFunc1 ; OUTSIDE REFERER
mr r8, r28
bgt @_600
bgt Local_Panic
bl MPCall_95_0x1e4
bl SpaceGetPagePLE ; LogicalPage *r8, Area *r31 // PLE *r30, notfound cr0.eq
mr r26, r30
beql @_88

View File

@ -1272,7 +1272,7 @@ major_0x142dc_0x184
rlwimi r11, r27, 24, 29, 29
beq+ major_0x142dc_0x1bc
lwz r10, 0x00fc(r6)
rlwinm r27, r27, 0, 9, 7
_bclr r27, r27, Task.kFlag8
stw r27, 0x0064(r31)
major_0x142dc_0x1bc
@ -1332,7 +1332,7 @@ _SchPreempt
stw r6, Task.ContextBlockPtr(r31)
mfsprg r8, 3
stw r16, Task.Flags(r31)
stw r8, Task.YellowVecTblPtr(r31)
stw r8, Task.VecBase(r31)
; Spam its context block
@ -1432,7 +1432,7 @@ _SchPreempt
lwz r11, 0x00a4(r6)
lwz r8, 0x00f0(r30)
rlwimi r11, r27, 24, 29, 29
rlwinm r27, r27, 0, 9, 7
_bclr r27, r27, Task.kFlag8
mtsprg 3, r8
stw r27, Task.Flags(r30)
@ -1478,9 +1478,9 @@ _SchPreempt
lwz r6, KDP.PA_ECB(r1)
addi r26, r1, KDP.YellowVecBase
addi r26, r1, KDP.VecBaseSystem
mtsprg 3, r26
stw r26, Task.YellowVecTblPtr(r30)
stw r26, Task.VecBase(r30)
stw r6, EWA.PA_ContextBlock(r19)
stw r6, Task.ContextBlockPtr(r30)
@ -2042,7 +2042,7 @@ NewCpuEntryPoint
stw r7, EWA.Flags(r14)
stw r28, EWA.Enables(r14)
lwz r8, Task.YellowVecTblPtr(r31)
lwz r8, Task.VecBase(r31)
mtsprg 3, r8
lwz r10, ContextBlock.CodePtr(r6)

View File

@ -11,10 +11,12 @@ Local_Panic set *
; ARG ProcessID r3
; RET OSStatus r3, TaskID r10
; kMPCreateTaskSuspendedMask is ignored?
DeclareMPCall 7, MPCall_7
MPCall_7 ; OUTSIDE REFERER
rlwinm. r8, r5, 0, 31, 28
rlwinm. r8, r5, 0, ~0x00000006 ; kMPCreateTaskValidOptionsMask minus kMPCreateTaskSuspendedMask
bne ReturnMPCallOOM
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
@ -65,14 +67,14 @@ MPCall_7 ; OUTSIDE REFERER
lwz r16, Task.Flags(r28)
rlwinm. r8, r5, 0, 30, 30
rlwinm. r8, r5, 0, kMPCreateTaskTakesAllExceptionsMask
beq @noflag
oris r16, r16, 0x40 ; Task.kFlag9
_bset r16, r16, Task.kFlagTakesAllExceptions
@noflag
rlwinm. r8, r5, 0, 29, 29
rlwinm. r8, r5, 0, kMPCreateTaskNotDebuggableMask
beq @noflag2
oris r16, r16, 0x02 ; Task.kFlag14
_bset r16, r16, Task.kFlagNotDebuggable
@noflag2
stw r16, Task.Flags(r28)
@ -226,8 +228,8 @@ CreateTask
lwz r16, PSA.UserModeMSR(r1)
stw r16, Task.ContextBlock + ContextBlock.MSR(r28)
addi r16, r1, KDP.YellowVecBase
stw r16, Task.YellowVecTblPtr(r28)
addi r16, r1, KDP.VecBaseSystem
stw r16, Task.VecBase(r28)
li r16, 0
lwz r17, Task.NotificationPtr(r28)
@ -790,7 +792,7 @@ ThrowTaskToDebugger ; OUTSIDE REFERER
MPCall_58_0x114
mtcr r29
mr r28, r8
bc BO_IF, Task.kFlag14, MPCall_58_0x13c
bc BO_IF, Task.kFlagNotDebuggable, MPCall_58_0x13c
bc BO_IF, Task.kFlag20, MPCall_58_0x13c
lwz r8, PSA._8e8(r1)

View File

@ -285,7 +285,7 @@ FDP_023c
FDP_024c
li r8, 18
b major_0x02980
b DataLikeException
FDP_0254 ; stswi
@ -2122,10 +2122,10 @@ ProbePerfMonitor ; OUTSIDE REFERER
; Temporarily disable program interrupts (leave old handler in r20)
lwz r21, KDP.PA_NanoKernelCode(r1)
lwz r20, KDP.YellowVecBase + VecTable.ProgramIntVector(r1)
lwz r20, KDP.VecBaseSystem + VecTable.ProgramIntVector(r1)
llabel r18, IgnoreSoftwareInt
add r21, r18, r21
stw r21, KDP.YellowVecBase + VecTable.ProgramIntVector(r1)
stw r21, KDP.VecBaseSystem + VecTable.ProgramIntVector(r1)
@ -2189,7 +2189,7 @@ ProbePerfMonitor ; OUTSIDE REFERER
; Restore program interrupts
stw r20, KDP.YellowVecBase + VecTable.ProgramIntVector(r1)
stw r20, KDP.VecBaseSystem + VecTable.ProgramIntVector(r1)
; Test r23 and save
@ -2351,7 +2351,7 @@ FDP_1354
stw r9, 0x0ea0(r6)
lwz r6, -0x0014(r1)
lwz r7, -0x0010(r1)
b major_0x02980_0x134
b CodeLikeException
@ -3142,7 +3142,7 @@ FDP_1c40 ; OUTSIDE REFERER
; r6 = saved at *(ewa + 0x18)
; sprg1 = saved at *(ewa + 4)
; rN (0,7,8,9,10,11,12,13, not r1) = saved at *(*(ewa - 0x14) + 0x104 + 8*N)
bl int_prepare
bl LoadInterruptRegisters
; r0 = 0
; r1 = *(ewa - 4)
; r6 = kdp

View File

@ -93,7 +93,7 @@ VMDispatchTableEnd
@noalt
lwzx r8, r8, r7
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
add r8, r8, r7
mtlr r8
bltlr
@ -203,7 +203,7 @@ VMFinalInit ; OUTSIDE REFERER
@loop
srwi r4, r31, 12
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
bl GetPARPageInfo
bge cr4, @skip
bltl cr5, RemovePageFromTLB
@ -239,7 +239,7 @@ VMInit ; OUTSIDE REFERER
cmpw r7, r8
bne VMReturn1
stw r4, KDP.PrimaryAddrRangePages(r1) ; resize PAR
stw r4, KDP.VMLogicalPages(r1) ; resize PAR
stw r5, KDP.FlatPageListPtr(r1) ; where did NK find this???
@ -311,7 +311,7 @@ VMInit_0x110
cmpw r4, r7
bnel Local_Panic
lwz r5, KDP.FlatPageListPtr(r1)
lwz r4, KDP.PrimaryAddrRangePages(r1)
lwz r4, KDP.VMLogicalPages(r1)
andi. r7, r5, 0xfff
li r3, 0x02
@ -354,7 +354,7 @@ VMInit_0x110
li r3, 0x06
bne VMInit_Fail
stw r4, KDP.PrimaryAddrRangePages(r1)
stw r4, KDP.VMLogicalPages(r1)
lwz r8, -0x0020(r1)
slwi r7, r4, 12
stw r7, 0x0dc8(r8)
@ -380,7 +380,7 @@ VMInit_0x1ec
lwz r15, KDP.FlatPageListPtr(r1)
srwi r7, r5, 10
add r15, r15, r7
lwz r5, KDP.PrimaryAddrRangePages(r1)
lwz r5, KDP.VMLogicalPages(r1)
VMInit_0x218
lwz r16, 0x0000(r15)
@ -411,7 +411,7 @@ VMInit_0x250
sth r9, 0x0002(r3)
sth r9, 0x000a(r3)
lwz r6, 0x05e8(r1)
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
lwz r15, KDP.FlatPageListPtr(r1)
VMInit_0x288
@ -451,7 +451,7 @@ VMInit_0x29c
lwz r16, KDP.FlatPageListPtr(r1)
stw r16, Area.PageMapArrayPtr(r8)
lwz r16, KDP.PrimaryAddrRangePages(r1)
lwz r16, KDP.VMLogicalPages(r1)
slwi r16, r16, 12
stw r16, Area.Length(r8)
subi r16, r16, 1
@ -475,7 +475,7 @@ VMInit_0x29c
VMInit_Fail
lwz r7, KDP.TotalPhysicalPages(r1)
lwz r8, KDP.FlatPageListSegPtrs + 0(r1)
stw r7, KDP.PrimaryAddrRangePages(r1)
stw r7, KDP.VMLogicalPages(r1)
stw r8, KDP.FlatPageListPtr(r1)
b VMReturn
@ -498,7 +498,7 @@ VMExchangePages ; OUTSIDE REFERER
mr r6, r15
mr r4, r5
mr r5, r16
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
bl GetPARPageInfo
bge cr4, VMReturnMinus1
bgt cr5, VMReturnMinus1
@ -548,7 +548,7 @@ VMGetPhysicalPage ; OUTSIDE REFERER
VMGetPhysicalPage_0x28
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
VMGetPhysicalPage_0x30
bl GetPARPageInfo
@ -578,8 +578,8 @@ getPTEntryGivenPage ; OUTSIDE REFERER
beq getPTEntryGivenPage_0x3c
bns cr7, getPTEntryGivenPage_0x3c
bge cr5, getPTEntryGivenPage_0x3c
bl MPCall_95_0x2e0
bl MPCall_95_0x334
bl InvalPTE ; page *r8, PTE r16/r17, PTE *r18, PLE *r30 // PLEflags cr5-7
bl SetPTE ; PTE r16/r17, PTE *r18
lwz r3, 0x0000(r30)
rlwimi r3, r17, 0, 0, 19
@ -591,7 +591,7 @@ getPTEntryGivenPage_0x3c
getPTEntryGivenPage_0x48
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
getPTEntryGivenPage_0x50
bl GetPARPageInfo
@ -654,8 +654,8 @@ major_0x08d88_0x74
major_0x08d88_0x8c
mr r8, r29
bl MPCall_95_0x1e4
bl MPCall_95_0x2b0
bl SpaceGetPagePLE ; LogicalPage *r8, Area *r31 // PLE *r30, notfound cr0.eq
bl GetPTEFromPLE ; PLE *r30 // PTE r16/r17, PTE *r18, PTEflags cr0, PLEflags cr5-7
mtlr r27
crclr cr0_lt
crclr cr0_eq
@ -708,7 +708,7 @@ VMIsResident ; OUTSIDE REFERER
VMIsResident_0x28
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
VMIsResident_0x30
bl GetPARPageInfo
@ -1136,8 +1136,8 @@ VMMarkBacking ; OUTSIDE REFERER
beq major_0x08d88_0xa8
bns cr7, VMMarkBacking_0x30
bge cr5, VMMarkBacking_0x30
bl MPCall_95_0x2e0
bl MPCall_95_0x348
bl InvalPTE ; page *r8, PTE r16/r17, PTE *r18, PLE *r30 // PLEflags cr5-7
bl DeletePTE ; PTE *r18, PLE *r30
VMMarkBacking_0x30
lwz r18, 0x0000(r30)
@ -1152,7 +1152,7 @@ VMMarkBacking_0x30
VMMarkBacking_0x50
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
VMMarkBacking_0x58
bl GetPARPageInfo
@ -1255,7 +1255,7 @@ VMMarkResident ; OUTSIDE REFERER
VMMarkResident_0x50
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
VMMarkResident_0x58
bl GetPARPageInfo
@ -1313,8 +1313,8 @@ setPTEntryGivenPage ; OUTSIDE REFERER
beq major_0x08d88_0xa8
bns cr7, setPTEntryGivenPage_0x34
bge cr5, setPTEntryGivenPage_0x34
bl MPCall_95_0x2e0
bl MPCall_95_0x348
bl InvalPTE ; page *r8, PTE r16/r17, PTE *r18, PLE *r30 // PLEflags cr5-7
bl DeletePTE ; PTE *r18, PLE *r30
setPTEntryGivenPage_0x34
lwz r18, 0x0000(r30)
@ -1331,7 +1331,7 @@ setPTEntryGivenPage_0x34
setPTEntryGivenPage_0x5c
; r6 = ewa
bl SchRestoreStartingAtR14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
setPTEntryGivenPage_0x64
mr r6, r4
@ -1401,7 +1401,7 @@ VMAllocateMemory ; OUTSIDE REFERER
or r7, r4, r6
rlwinm. r7, r7, 0, 0, 11
ble cr6, VMReturnMinus1
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
bne cr7, VMReturnMinus1
mr r7, r4
bne VMReturnMinus1
@ -1423,7 +1423,7 @@ VMAllocateMemory ; OUTSIDE REFERER
b VMAllocateMemory_0xc0
VMAllocateMemory_0x6c
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
addi r5, r5, -0x01
VMAllocateMemory_0x74
@ -1431,7 +1431,7 @@ VMAllocateMemory_0x74
bl GetPARPageInfo
bltl cr5, RemovePageFromTLB
bltl cr5, RemovePTEFromHTAB
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
subf r8, r4, r9
cmplw cr7, r5, r8
and. r8, r16, r6
@ -1498,7 +1498,7 @@ VMAllocateMemory_0x164
lwz r7, KDP.TotalPhysicalPages(r1)
subf r7, r5, r7
stw r7, KDP.TotalPhysicalPages(r1)
stw r7, KDP.PrimaryAddrRangePages(r1)
stw r7, KDP.VMLogicalPages(r1)
lwz r5, -0x0020(r1)
slwi r8, r7, 12
stw r8, 0x0dc4(r5)
@ -1564,7 +1564,7 @@ VMAllocateMemory_0x1a4
ori r8, r8, 0xc0
stw r8, 0x0008(r31)
mr r8, r31
bl createarea
bl CreateArea
cmpwi r9, 0x00
bne Local_Panic
mr r31, r8
@ -1575,7 +1575,7 @@ VMAllocateMemory_0x1a4
lwz r16, 0x0024(r8)
cmpwi r16, 0x00
bne Local_Panic
lwz r16, KDP.PrimaryAddrRangePages(r1)
lwz r16, KDP.VMLogicalPages(r1)
lwz r17, 0x002c(r8)
slwi r16, r16, 12
cmpw r17, r16
@ -1876,7 +1876,7 @@ VMLastExportedFunc_0xd7
mr r31, r5
mr r28, r16
mr r26, r14
lwz r9, KDP.PrimaryAddrRangePages(r1)
lwz r9, KDP.VMLogicalPages(r1)
bl GetPARPageInfo
mtlr r6
b RemovePageFromTLB

View File

@ -34,7 +34,7 @@ NKTop
align 5
include 'NKTasks.s'
align 5
include 'NKAddressSpaceMPCalls.s'
include 'NKAddressSpaces.s'
align 5
include 'NKPoolAllocator.s'