Move the FrameList logic out of the physical memory allocator into its
own module. This allows `FrameList` to be shared between the physical
memory allocator and the slab allocator.
Create a new submodule within `memory`, `allocators` which contains all
memory allocators. Also split out the `Frame` struct from the `pg_alloc`
module, allowing it to be used by other modules.
Currently, when a kernel stack overflow occures, the exception handler
blindly attempts to write the current context to the stack. If the SP
isn't valid this causes another fault, and so on - locking up the
system.
This commit re-arranges the stack layout, performs SP validation before
usage and switches to an emergency stack when SP isn't valid. This
allows the handler to run and panic gracefully.
Fixes: #98
Having the ability to use the `FrameAlloctor`, simulating via the heap
is a very useful pattern when testing libkernel code. Make the test
fixture public for other modules to use.
Implement a `shrink_to` function for a VMA. This shrinks the VMA's
region to the specified region, while recalculating file offsets and
size if the VMA is file-backed.
The `expand` function adds bytes size into the region; the check `size
>= self.size` isn't needed since this is an expanding function, not a
resizing one. To emphasise that, rename the function to `expand_by`.
Also include a bunch of unit tests to ensure that expansion by regions
with differing sizes works correctly.
Determine whether the program break needs extending with aligned logic,
but always return the requested, non-aligned, address.
Use `brk_addr` in unit tests instead.