Setting Up Memory Management
Posted: Thu Aug 24, 2017 5:36 pm
I am working on setting up a memory manager as the next step of my kernel.
I have already obtained a memory map from GRUB that shows which regions are available, reserved, their addresses, and how long they are. My next step would be to set up a page frame allocator for physical memory, but I have a few issues I feel I need to address first. Here is my general thought process:
1. Reserve some space for the kernel's data structures and memory usage. Reserve the remaining portion for user space.
2. Write some kind of malloc() function for the Kernel to use in its data structures (probably using some kind of watermark allocator, without any kind of paging/virtual address space--just using physical addresses and managing memory blocks).
3. Set up paging for the the user space memory and build a memory manager for that from there, including a physical memory manager (page frame allocation), page table, page directory, and enabling paging.
Is this a correct approach?
I am wondering whether the kernel needs to use paging too when allocating its data structures. And if so, and all memory should be under paging (kernel or userspace), how do I set up the data structures that are used in writing a page frame allocator in the first place? If I need a AVL Tree or Linked List for a physical memory manager, don't I need a malloc function for those in the first place?
I have already obtained a memory map from GRUB that shows which regions are available, reserved, their addresses, and how long they are. My next step would be to set up a page frame allocator for physical memory, but I have a few issues I feel I need to address first. Here is my general thought process:
1. Reserve some space for the kernel's data structures and memory usage. Reserve the remaining portion for user space.
2. Write some kind of malloc() function for the Kernel to use in its data structures (probably using some kind of watermark allocator, without any kind of paging/virtual address space--just using physical addresses and managing memory blocks).
3. Set up paging for the the user space memory and build a memory manager for that from there, including a physical memory manager (page frame allocation), page table, page directory, and enabling paging.
Is this a correct approach?
I am wondering whether the kernel needs to use paging too when allocating its data structures. And if so, and all memory should be under paging (kernel or userspace), how do I set up the data structures that are used in writing a page frame allocator in the first place? If I need a AVL Tree or Linked List for a physical memory manager, don't I need a malloc function for those in the first place?