Struct riscy::memory::PagedMemory
source · pub struct PagedMemory { /* private fields */ }
Expand description
PagedMemory
is the implementation of the
Memory
interfaced used by the riscy
binary.
Whenever an address is first accessed, it will allocate a 4KiB page containing that address.
The pages are stored in a
BTreeMap
which making finding the correct page fast and efficient. Each page is represented by contiguous
block of memory.
The full 32-bit address space of a RISC-V machine is 4GiB in size. Using on-demand pages like this means that the host system usually only allocates a bit more memory than it actually uses.
Once a page is allocated, it is never de-allocated.
When reading from uninitilized memory, PagedMemory
will return a value of 0x00
for that byte.
This is unrealistic in physical memory, where you get whatever junk the operating system or
the hardware had left over. However, getting zeroed-out memory makes it easier to debug
when there is a problem.
Implementations§
source§impl PagedMemory
impl PagedMemory
sourcepub fn new() -> PagedMemory
pub fn new() -> PagedMemory
Create a new PagedMemory
with no allocated pages.