1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

4 Commits

Author SHA1 Message Date
Achilleas Anagnostopoulos
1fc9d20ed2 Reserve and protect zereod frame when initializing vmm
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
2017-06-22 19:17:19 +01:00
Achilleas Anagnostopoulos
dbdf686d27 Provide helper for setting the active frame allocator
This allows us to remove the allocFn argument from the vmm functions
which causes the compiler's escape analysis to sometimes incorectly flag
it as escaping to the heap.
2017-06-18 09:49:47 +01:00
Achilleas Anagnostopoulos
c0a9e07e83 Remove mem.PageOrder
Since the goal is to bootstrap the runtime's slab-like allocator the kernel
should only deal with managing allocations at a single page level.
2017-06-18 09:14:53 +01:00
Achilleas Anagnostopoulos
8e38ff969d Implement API for mapping virtual addresses to physical frames
The API provides the Map() and MapTemporary() functions that establish
virtual -> physical address mappings using the currently active page
directory table.

Mapped pages can be unmapped using the Unmap() function. When unmapping
virtual addresses, the page tables leading to them will not be
automatically released even if they are empty. This will be addressed by
a future commit.
2017-06-06 11:02:48 +01:00