You might want to take a look at
the big picture.
For example I use
the same allocator for both the kernel heap and userspace, the only difference is the callback. From userspace, it calls mmap (through libc with a syscall), and when used in the kernel, it calls a function to map into kernelspace (direct function call).
indigo286 wrote:
On an unrelated note, is there any reason the kernel heap should be virtually continuous?
No, kernel heap does not need to be contiguous. Mine is, but only because my kernel never frees memory. Being a microkernel, it does not store lists that could change (device lists, process list, open file lists etc.), so all it needs is allocated on boot, hence kernel memory never gets fragmented and remains contiguous. But it could be fragmented, there's no constraint that would require contiguous kernel heap.
indigo286 wrote:
What could go wrong if my virtual allocator got the chunk it needed, and simply returned the address of the chunk in my mapping of physical ram?
For example that chunk isn't page aligned or not multiple of page size.
Cheers,
bzt