summaryrefslogtreecommitdiff
path: root/src/kernel/pmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/pmap.c')
-rw-r--r--src/kernel/pmap.c31
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);