mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
This vmm package exports ReservedZeroedFrame which can be used to setup a lazy physical page allocation scheme. This is implemented by mapping ReservedZeroedFrame to each page in a virtual memory region using the following flag combination: FlagPresent | FlagCopyOnWrite. This has the effect that all reads from the virtual address region target the contents of ReservedZeroedFrame (always returning zero). On the other hand, writes to the virtual address region trigger a page fault which is resolved as follows: - a new physical frame is allocated and the contents of ReservedZeroedFrame are copied to it (effectively clearing the new frame). - the page entry for the virtual address that caused the fault is updated to point to the new frame and its flags are changed to: FlagPresent | FlagRW - execution control is returned back to the code that caused the fault