aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmake_cdrom.sh1
-rw-r--r--menu_cdrom.lst1
-rw-r--r--src/kernel/core/paging.c16
-rw-r--r--src/kernel/user/process.c2
4 files changed, 12 insertions, 8 deletions
diff --git a/make_cdrom.sh b/make_cdrom.sh
index 7f9f9e9..cccca8e 100755
--- a/make_cdrom.sh
+++ b/make_cdrom.sh
@@ -9,6 +9,7 @@ fi
cp menu_cdrom.lst cdrom/boot/grub/menu.lst
cp src/kernel/kernel.bin cdrom; strip cdrom/kernel.bin
+cp src/apps/init/init.bin cdrom; strip cdrom/init.bin
genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -input-charset ascii \
diff --git a/menu_cdrom.lst b/menu_cdrom.lst
index 829cbdf..b6fd297 100644
--- a/menu_cdrom.lst
+++ b/menu_cdrom.lst
@@ -2,3 +2,4 @@ timeout 10
title Macroscope
kernel /kernel.bin
+module /init.bin
diff --git a/src/kernel/core/paging.c b/src/kernel/core/paging.c
index 69fb98f..0b46be1 100644
--- a/src/kernel/core/paging.c
+++ b/src/kernel/core/paging.c
@@ -7,8 +7,8 @@
#include <thread.h>
#include <malloc.h>
-#define PAGE_OF_ADDR(x) (((size_t)x >> PAGE_SHIFT) % N_PAGES_IN_PT)
-#define PT_OF_ADDR(x) ((size_t)x >> (PAGE_SHIFT + PT_SHIFT))
+#define PAGE_OF_ADDR(x) (((size_t)(x) >> PAGE_SHIFT) % N_PAGES_IN_PT)
+#define PT_OF_ADDR(x) ((size_t)(x) >> (PAGE_SHIFT + PT_SHIFT))
typedef struct page_table {
uint32_t page[1024];
@@ -197,14 +197,16 @@ uint32_t pd_get_frame(void* vaddr) {
}
bool pd_map_page(void* vaddr, uint32_t frame_id, bool rw) {
- uint32_t pt = PT_OF_ADDR(vaddr);
- uint32_t page = PAGE_OF_ADDR(vaddr);
+ const uint32_t pt = PT_OF_ADDR(vaddr);
+ const uint32_t page = PAGE_OF_ADDR(vaddr);
ASSERT((size_t)vaddr < PD_MIRROR_ADDR);
- pagedir_t *pdd = ((size_t)vaddr >= K_HIGHHALF_ADDR || current_thread == 0
- ? &kernel_pd_d : current_thread->current_pd_d);
- pagetable_t *pd = ((size_t)vaddr >= K_HIGHHALF_ADDR ? &kernel_pd : current_pd);
+ bool on_kernel_pd = (size_t)vaddr >= K_HIGHHALF_ADDR || current_thread == 0;
+
+ pagedir_t *pdd = (on_kernel_pd ? &kernel_pd_d : current_thread->current_pd_d);
+ pagetable_t *pd = (on_kernel_pd ? &kernel_pd : current_pd);
+
mutex_lock(&pdd->mutex);
if (!(pd->page[pt] & PTE_PRESENT)) {
diff --git a/src/kernel/user/process.c b/src/kernel/user/process.c
index 72042d9..fc608a7 100644
--- a/src/kernel/user/process.c
+++ b/src/kernel/user/process.c
@@ -220,7 +220,7 @@ bool mchmap(process_t *proc, void* addr, int mode) {
// change mode on already mapped pages
pagedir_t *save_pd = get_current_pagedir();
switch_pagedir(proc->pd);
- for (void* it = r->addr; it < r->addr + r->size; r += PAGE_SIZE) {
+ for (void* it = r->addr; it < r->addr + r->size; it += PAGE_SIZE) {
uint32_t ent = pd_get_entry(it);
uint32_t frame = pd_get_frame(it);