powermac-rom/NanoKernel
Elliot Nunn a323be3c8b Reverse some VM functions (Daniel)
VeryPopularFunction (now GetPARPageInfo) takes a page number in the PAR
and returns a bunch of info on it. The flags of the PTE are copied into
cr5-cr7 of the condition register so that VMCalls can easily make
decisions off of them. I had already figured out the bit flags of the
PTEs Mac OS 9 uses when I reversed PagingFunc1. The definitions are in
the end of the 'Area Definitions.txt' file I sent you a while ago.

If you see a  ' bltl cr5, VMDoSomethingWithTLB' (now RemovePageFromTLB)
followed by a ' bltl cr5, major_0x09b40' (now RemovePTEFromHTAB), you
know that the function is manipulating pages directly. RemovePageFromTLB
clears a page from the TLB if it follows a VeryPopularFunction call.
RemovePTEFromHTAB takes a page that is resident in the HTAB and removes
its HTAB entry. cr5_lt is bit 20 (mask 0x800), which my notes tell me is
set when the PTE is in the HTAB. Altogether, the sequence translates to
'if the page is in the HTAB, flush it from the TLB and delete its HTAB
entry'. VMExchangePages uses this (twice) to make sure there are no race
conditions when it is swapping the data in the pages.

I still don't have proof, but I am very very strongly convinced that
KDP.FlatPageListPointer is always equal to the PAR's PageMapArrayPtr.

On an unrelated note, KCMapPage seems to always panic when called on an
area where the PageMapArrayPtr is 2d. I have absolutely no idea why this
happens, but it is bad news for MPMapper because the threshold for
2-dimensionality is around 1 MB. I would have to make 512 separate
CreateArea calls to map all the memory without the NK panicking. I will
have to look into this.
2018-02-18 11:17:23 +08:00
..
InnerMakeFile Initial commit 2018-02-18 01:24:10 +08:00
MakeFile Initial commit 2018-02-18 01:24:10 +08:00
NanoKernel.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKAdditions.s Initial commit 2018-02-18 01:24:10 +08:00
NKAddressSpaceMPCalls.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKBuiltinInit.s Initial commit 2018-02-18 01:24:10 +08:00
NKCacheCalls.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKConsoleLog.s Use new _AssertAndRelease macro 2018-02-18 01:24:19 +08:00
NKEquates.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKIndex.s Initial commit 2018-02-18 01:24:10 +08:00
NKInit.s Start to reverse the legacy VM subsystem 2018-02-18 01:24:21 +08:00
NKInterrupts.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKMacros.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKMPCalls.s Reverse some VM functions (Daniel) 2018-02-18 11:17:23 +08:00
NKPaging.s Initial commit 2018-02-18 01:24:10 +08:00
NKPoolAllocator.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKPowerCalls.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKPrimaryIntHandlers.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKProcFlagsTbl.s Initial commit 2018-02-18 01:24:10 +08:00
NKProcInfoTbl.s Initial commit 2018-02-18 01:24:10 +08:00
NKReplacementInit.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKRTASCalls.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKScheduler.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKScreenConsole.s Initial commit 2018-02-18 01:24:10 +08:00
NKSleep.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKSync.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKTasks.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKThud.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKTimers.s Reverse userspace sync primitives 2018-02-18 01:24:20 +08:00
NKTranslation.s Initial commit 2018-02-18 01:24:10 +08:00
NKVMCalls.s Reverse some VM functions (Daniel) 2018-02-18 11:17:23 +08:00