diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-25 19:40:53 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-25 19:44:11 +0300 |
| commit | 7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 (patch) | |
| tree | 51ded3e49cb467915a6e2b0e570b5d9973515553 /common/mem.c | |
| parent | 59a374b0eed4313d1a67e2cdb673a295e79a6494 (diff) | |
| download | kmi-7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81.tar.gz kmi-7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81.zip | |
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.
Diffstat (limited to 'common/mem.c')
| -rw-r--r-- | common/mem.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; } } |
