Overview of address space handling:
TODO for each class of pages describe which privilege etc. bits to set
-Use each logical address only once over all processes. That makes it easier
to find the process belonging to an address and, maybe, also the other way
around.
-As the stack is pinned we don't need to handle it in paging code. For
simplicity we can have the stack at the same logical address in each process.
If there are problems with that we give it a logical address resulting from
adding a fixed offset to the stack's *physical* address.
(...)
init_memory():
-Set up the page directory for kernel space. It will only need one entry as
one page table can cover 4 MB.
-Set up the kernel's page table. For simplicity (so that kernel code doesn't
need to change) it should map logical addresses directly to physical ones.
TODO protection and access privileges bits
-Set the paging flag in CR0 to enable paging
setup_page_table():
-TODO code and data address space
-Find a free physical stack page and set up a page for the stack as described
in the overview.
page_fault_handler():
-ASSERT() that the fault address actually belongs to the process using the
pcb's swap_size entry.
-Call page_alloc() to allocate the page and handle diskette reading and writing
page_alloc():
-Swap out a random page to floppy
TODO how to find the diskette sectors?
-Find the sectors we need to swap in using the pcb's fault_addr and swap_loc
entries.
-Swap in the requested page from floppy
page_swap_in():
page_swap_out():