So memory has to be assigned as virtual to maintain computability with 68K stuff, even though it really is physical memory and will still perform like physical memory?
Short answer: Basically yes.
Long answer: It works like this: Some memory is physically mapped, just like on old Exec.
OTOH, some of the physical memory is set aside to serve as pages for the virtual memory
system (This page pool is not mapped, so it's invisible to the CPU). Currently, this means that
these pages are just mapped somewhere in the address space to provide memory for virtual
addresses. As there's currently no pager, they remain there until unmapped.
Once we have a pager, this will move pages in and out of memory to disk, remapping existing
pages. That's why right now, you're limited to the physical memory you have (the virtual
memory is just a "reordering" of the current memory layout).
The point about 68k is as follows: The PPC can mark memory as executable. Only memory
with this attribute can hold code. So what we do is, we set aside some area of addresses
which have this attribute. PPC code is always allocated from this virtual region (and backed
up with memory from the page pool just like any virtual memory). So just by looking at the
address (actually, it's a bit more complicated, but boils down to this) we can determine if an
address holds PPC code or not.
This mechanism is used by all sort of "untyped" calls, for example Hooks. If you want to use a
hook in OS4, you just set h_Entry to the code you want to be called (68k or PPC), and use
utility.library/CallHookPkt. CallHookPkt determines if the code is PPC or not, and either
directly calls the function, or emulates it. The same works for interrupt handlers; you can
actually set a 68k function as interrupt handler. The code that determines the type is actually
quite fast, in the best case, it's just a table lookup, making this a viable solution.
The whole idea was to be able to make Hooks available where you just set the h_Entry
pointer, without the need to go through specific emulator traps. I didn't like the idea of having
to go through an emulator trap every time a PPC function is called (after all, 68k is to be
considered legacy). Plus, you don't need to change your source code, then.
|