diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-13 17:12:29 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-13 17:12:29 -0400 |
commit | 5481848e27fdd4fc859def9841a0283665531a46 (patch) | |
tree | 990a8df008214d85141a3bd10bd96898e64b0c37 /src/kernel/pmap.c | |
parent | 1e4a254674f668839e5de273916024c16814b045 (diff) | |
download | portland-os-5481848e27fdd4fc859def9841a0283665531a46.tar.gz |
fixed some paging bugs, added fault handlers and new programs
Diffstat (limited to 'src/kernel/pmap.c')
-rw-r--r-- | src/kernel/pmap.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/kernel/pmap.c b/src/kernel/pmap.c index 8634303..37c7261 100644 --- a/src/kernel/pmap.c +++ b/src/kernel/pmap.c @@ -77,8 +77,14 @@ void init_pagemap() { //a smarter algorithm might pick the smallest one available, //and go by bytes (or dwords) instead of bits where possible. void *allocate_kernel_pages(uint32_t n) { +//logsz("trace: allocate_kernel_pages("); +//char nbuf[11]; +//u32_dec(n, nbuf); +//logsz(nbuf); +//logsz(") = 0x"); + uint32_t run = 0; - + for (uint32_t page = KBSS_START >> 12; page < USER_START >> 12; ++page) { if (PAGE_USED(page)) run = 0; @@ -87,6 +93,9 @@ void *allocate_kernel_pages(uint32_t n) { for (uint32_t i = start; i <= page; ++i) SET_PAGE(i); kernel_pages_left -= n; + //u32_hex(start << 12, nbuf); + //logsz(nbuf); + //logch('\n'); return (void *)(start << 12); } } @@ -98,8 +107,14 @@ void *allocate_kernel_pages(uint32_t n) { //a smarter algorithm might pick the smallest one available, //and go by bytes (or dwords) instead of bits where possible. void *allocate_user_pages(uint32_t n) { +//logsz("trace: allocate_user_pages("); +//char nbuf[11]; +//u32_dec(n, nbuf); +//logsz(nbuf); +//logsz(") = 0x"); + uint32_t run = 0; - + for (uint32_t page = USER_START >> 12; page < 1048576; ++page) { if (PAGE_USED(page)) run = 0; @@ -108,6 +123,9 @@ void *allocate_user_pages(uint32_t n) { for (uint32_t i = start; i <= page; ++i) SET_PAGE(i); user_pages_left -= n; + //u32_hex(start << 12, nbuf); + //logsz(nbuf); + //logch('\n'); return (void *)(start << 12); } } @@ -117,6 +135,15 @@ void *allocate_user_pages(uint32_t n) { //in the future, change this to go by bytes or dwords instead of bits. void free_pages(const void *ptr, uint32_t n) { +//logsz("trace: free_pages(0x"); +//char nbuf[11]; +//u32_hex(ptr, nbuf); +//logsz(nbuf); +//logsz(", "); +//u32_dec(n, nbuf); +//logsz(nbuf); +//logsz(")\n"); + uint32_t page = (uint32_t)ptr >> 12; for (uint32_t i = page; i < page + n; ++i) CLEAR_PAGE(i); |