aboutsummaryrefslogtreecommitdiff
path: root/common/vmem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-10-26 12:42:01 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-10-26 12:42:01 +0300
commit5c335752c4fb7e472d68b2b2731c3674a10cbd97 (patch)
tree9339ea883b640c177e699a98aae9601a04310258 /common/vmem.c
parent7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 (diff)
downloadkmi-5c335752c4fb7e472d68b2b2731c3674a10cbd97.tar.gz
kmi-5c335752c4fb7e472d68b2b2731c3674a10cbd97.zip
Identified issue with vmem implementation
+ Sensible mappings should help, discard what I wrote in the previous commit. Nothing works unless I get vmem up and running properly.
Diffstat (limited to 'common/vmem.c')
-rw-r--r--common/vmem.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/common/vmem.c b/common/vmem.c
index c874e3d..87d5b3b 100644
--- a/common/vmem.c
+++ b/common/vmem.c
@@ -90,15 +90,19 @@ void init_vmem(struct vm_branch_t *branch, vm_t tmp_pte)
map_vmem(branch, first_block, (vm_t)root_region, VM_W | VM_R | VM_V, MM_O0);
memset(root_region, 0, __o_size(MM_O0));
+ /* apparently I'm overwriting some memory here which is fucking up
+ * things elsewhere, specifically some PTE. Really should come up with
+ * some sensible address mappings, as everything is at the moment sort
+ * of hither and tither. */
root_region->max_blocks = (__o_size(MM_O0) - sizeof(struct mm_block_region_t))
/ sizeof(struct mm_block_t);
- root_region->first = (struct mm_block_t *)sizeof(struct mm_block_t);
+ root_region->first = (struct mm_block_t *)((vm_t)root_region + sizeof(struct mm_block_t));
root_block = root_region->first;
root_block->start = __o_size(MM_O0);
/* TODO: add in UMEM_TOP or something */
root_block->end = -1;
- root_block->status = USED;
+ root_block->status = FREE;
}
@@ -185,10 +189,13 @@ vm_t map_vregion(struct vm_branch_t *branch, pm_t base, vm_t start, size_t size,
if(node->status == FREE && node->end >= start + size){
gobble_block(branch, node, start, start + size);
- break;
+ goto found;
}
}
+ return 0;
+
+found:
for(; size >= __o_size(MM_O0); size -= __o_size(MM_O0)){
map_vmem(branch, start, base, flags, MM_O0);
start += __o_size(MM_O0);