From 7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 25 Oct 2021 19:40:53 +0300 Subject: Some minor changes to virtual memory handling + Should start to think about how virtual memory should be handled efficiently, I'm sort of flailing around and not actually doing anything beneficial. The mapping system I've so far implemented _works_, but it's not good and I'm not happy with it. I might come back and fix/improve it, but I think I'll go ahead and do other things for a while, might give me a better overhead view of what the virtual memory system should do. + TODO: should probably document the memory layout I'm going with at the moment. --- common/mem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'common/mem.c') diff --git a/common/mem.c b/common/mem.c index 48bd776..cff11b7 100644 --- a/common/mem.c +++ b/common/mem.c @@ -9,19 +9,19 @@ size_t __mm_sizes[10]; size_t __mm_page_shift; size_t __mm_max_order; -void init_mem(size_t max_order, size_t widths[10], size_t page_shift) +void init_mem(size_t max_order, size_t bits[10], size_t page_shift) { __mm_max_order = max_order; __mm_page_shift = page_shift; __mm_shifts[0] = 0; - __mm_widths[0] = 1 << widths[0]; + __mm_widths[0] = 1 << bits[0]; __mm_sizes[0] = 1 << __mm_page_shift; - for(size_t i = 0; i <= __mm_max_order; ++i){ - __mm_widths[i] = 1 << widths[i]; - __mm_shifts[i] = __mm_shifts[i - 1] + __mm_widths[i - 1]; - __mm_sizes[i] = 1 << __mm_shifts[i] << __mm_page_shift; + for(size_t i = 1; i <= __mm_max_order; ++i){ + __mm_widths[i] = 1 << bits[i]; + __mm_shifts[i] = __mm_shifts[i - 1] + bits[i - 1]; + __mm_sizes[i] = 1UL << __mm_shifts[i] << __mm_page_shift; } } -- cgit v1.3