diff options
author | Anton Kling <anton@kling.gg> | 2024-12-09 18:35:54 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-12-09 19:17:57 +0100 |
commit | e7272b29feb855f4678c5c510d331f297351d3a2 (patch) | |
tree | a1961628a7466af9320f14827cb528ac688ddb76 /kernel/ksbrk.c | |
parent | 906923ad3f2ecb2c73d286924e2ac05f8f3ae502 (diff) |
mmu: Make certain allocations physical and virtual mapping linear
Previously it was possible for fragmentation to occur and as a result
certain allocations would have a linear virtual address space but not a
linear physical address space. This is bad since a lot of calls to
kmalloc_align rely upon both being linear, it has now been changed such
that all allocations done by kmalloc_align now guarantee this mapping
holds for both virtual and physical addresses.
It was due to oversight and sheer luck that this had been working for so
long.
Diffstat (limited to 'kernel/ksbrk.c')
-rw-r--r-- | kernel/ksbrk.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/kernel/ksbrk.c b/kernel/ksbrk.c deleted file mode 100644 index 82fc5ed..0000000 --- a/kernel/ksbrk.c +++ /dev/null @@ -1,40 +0,0 @@ -#include <assert.h> -#include <ksbrk.h> -#include <mmu.h> -#include <stddef.h> -#include <typedefs.h> - -/* -extern uintptr_t data_end; -extern PageDirectory *kernel_directory; - -#define HEAP 0x00E00000 -#define PHYS 0x403000 -#define PAGE_SIZE ((uintptr_t)0x1000) -void *ksbrk(size_t s) { - uintptr_t rc = (uintptr_t)align_page((void *)data_end); - data_end += s; - data_end = (uintptr_t)align_page((void *)data_end); - - if (!get_active_pagedirectory()) { - // If there is no active pagedirectory we - // just assume that the memory is - // already mapped. - return (void *)rc; - } - mmu_allocate_shared_kernel_region((void *)rc, (data_end - (uintptr_t)rc)); - assert(((uintptr_t)rc % PAGE_SIZE) == 0); - memset((void *)rc, 0xFF, s); - return (void *)rc; -} - -void *ksbrk_physical(size_t s, void **physical) { - void *r = ksbrk(s); - if (physical) { - // if (0 == get_active_pagedirectory()) - // *physical = (void *)((uintptr_t)r - (0xC0000000 + PHYS) + HEAP); - // else - *physical = (void *)virtual_to_physical(r, 0); - } - return r; -}*/ |