summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/Makefile9
-rw-r--r--src/kernel/config.h8
-rw-r--r--src/kernel/core/kmain.c10
-rw-r--r--src/kernel/core/loader_.asm8
-rw-r--r--src/kernel/core/monitor.c4
-rw-r--r--src/kernel/core/sys.c4
-rw-r--r--src/kernel/ipc/shm.c100
-rw-r--r--src/kernel/ipc/shm.h22
-rw-r--r--src/kernel/lib/stdlib.c39
-rw-r--r--src/kernel/lib/stdlib.h15
-rw-r--r--src/kernel/lib/types.h15
-rw-r--r--src/kernel/link.ld12
-rw-r--r--src/kernel/mem/heap.basic.h2
-rw-r--r--src/kernel/mem/heap.std.c6
-rw-r--r--src/kernel/mem/heap.std.h2
-rw-r--r--src/kernel/mem/mem.c4
-rw-r--r--src/kernel/mem/mem.h4
-rw-r--r--src/kernel/mem/paging.c24
-rw-r--r--src/kernel/task/syscall.c4
-rw-r--r--src/kernel/task/task.c6
20 files changed, 61 insertions, 237 deletions
diff --git a/src/kernel/Makefile b/src/kernel/Makefile
index 5d46325..53cfc31 100644
--- a/src/kernel/Makefile
+++ b/src/kernel/Makefile
@@ -2,14 +2,15 @@ Out = kernel.elf
Obj = core/loader_.o core/kmain.o core/sys.o core/test.o \
core/monitor.o task/timer.o \
task/idt.o task/idt_.o task/task.o task/task_.o task/syscall.o task/sched.o \
- lib/stdlib.o lib/bitset.o lib/mutex.o \
+ lib/bitset.o lib/mutex.o \
mem/mem.o mem/paging.o mem/gdt.o mem/heap.o mem/seg.o \
- ipc/shm.o \
linker/elf.o
-include ../common.make
+ExtObj = $(SrcPath)/common/_common.o
-CFLAGS += -I . -I ./lib -g
+include $(SrcPath)/common.make
+
+CFLAGS += -g -I $(SrcPath)/common/include -I . -I ./lib
LDFLAGS += -T link.ld -Map kernel.map
diff --git a/src/kernel/config.h b/src/kernel/config.h
index 38487dc..f021d9c 100644
--- a/src/kernel/config.h
+++ b/src/kernel/config.h
@@ -1,9 +1,9 @@
#ifndef DEF_CONFIG_H
#define DEF_CONFIG_H
-#define K_OS_NAME "Grapes"
-#define K_OS_VER "0.0.4"
-#define K_OS_CODENAME "Cat in my heart"
+#define K_OS_NAME "T/CE"
+#define K_OS_VER "0.0.1"
+#define K_OS_CODENAME "Nyanyanya"
/* HEAP CODE TO USE :
Two kernel heap implementations are available :
@@ -12,4 +12,6 @@
Comment the following define to use the second version */
// #define K_USE_BASIC_HEAP
+
+
#endif
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 8f14843..86db4ff 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -27,12 +27,12 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) {
uint32_t i;
mem_placementAddr = ((size_t)&end & 0xFFFFF000) + 0x1000;
- mbd->cmdline += 0xE0000000; mbd->mods_addr += 0xE0000000;
+ mbd->cmdline += K_HIGHHALF_ADDR; mbd->mods_addr += K_HIGHHALF_ADDR;
struct module_t *mods = (struct module_t*)mbd->mods_addr;
for (i = 0; i < mbd->mods_count; i++) {
- mods[i].mod_start += 0xE0000000;
- mods[i].mod_end += 0xE0000000;
- mods[i].string += 0xE0000000;
+ mods[i].mod_start += K_HIGHHALF_ADDR;
+ mods[i].mod_end += K_HIGHHALF_ADDR;
+ mods[i].string += K_HIGHHALF_ADDR;
if (mods[i].mod_end > mem_placementAddr)
mem_placementAddr = (mods[i].mod_end & 0xFFFFF000) + 0x1000;
}
@@ -68,7 +68,7 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) {
if (pr == 0) {
monitor_write(" : Error loading\n");
} else {
- monitor_write(" : OK pid:"); monitor_writeDec(pr->pid); monitor_write("\n");
+ monitor_write(" : OK, pid="); monitor_writeDec(pr->pid); monitor_write("\n");
}
}
}
diff --git a/src/kernel/core/loader_.asm b/src/kernel/core/loader_.asm
index 5ee998a..07de52c 100644
--- a/src/kernel/core/loader_.asm
+++ b/src/kernel/core/loader_.asm
@@ -1,3 +1,4 @@
+[EXTERN k_highhalf_addr]
[GLOBAL loader] ; making entry point visible to linker
[EXTERN kmain] ; kmain is defined in kmain.c
[EXTERN tasking_tmpStack] ; a temporary 4k stack used by tasking, and used when setting up kernel stuff
@@ -30,10 +31,9 @@ loader: ;here, we load our false GDT, used for having the kernel in higher half
section .text
higherhalf: ; now we're running in higher half
-
mov esp, tasking_tmpStack+0x8000 ; set up the stack
push eax ; pass Multiboot magic number
- add ebx, 0xE0000000 ; update the MB info structure so that it is in the new seg
+ add ebx, k_highhalf_addr ; update the MB info structure so that it is in the new seg
push ebx ; pass Multiboot info structure
call kmain ; call kernel proper
@@ -51,7 +51,7 @@ trickgdt: ; our false GDT
gdt:
dd 0, 0 ; null GDT entry
- db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x20 ; kernel code segment
- db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x20 ; kernel data segment
+ db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40 ; kernel code segment
+ db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40 ; kernel data segment
gdt_end:
diff --git a/src/kernel/core/monitor.c b/src/kernel/core/monitor.c
index 0d0f5eb..ba2a6df 100644
--- a/src/kernel/core/monitor.c
+++ b/src/kernel/core/monitor.c
@@ -1,8 +1,10 @@
#include "monitor.h"
#include "sys.h"
+#include "mem/mem.h"
+
static int cursor_x = 0, cursor_y = 0;
-static uint16_t *video_memory = (uint16_t*)0xE00B8000;
+static uint16_t *video_memory = (uint16_t*)((size_t)K_HIGHHALF_ADDR + 0xB8000);
static uint8_t attribute = 0x07; // 0 = background = black, 7 = foreground = white
diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c
index 05a7bc5..4c53d58 100644
--- a/src/kernel/core/sys.c
+++ b/src/kernel/core/sys.c
@@ -1,6 +1,8 @@
#include "sys.h"
#include "monitor.h"
+#include "mem/mem.h"
+
/* These four functions are wrappers around ASM operations.
These functions are used when comunicating with the system hardware. */
@@ -27,7 +29,7 @@ uint16_t inw(uint16_t port) {
//////
void stack_trace(size_t bp) {
uint32_t *stack = (uint32_t*)bp, i;
- for (i = 0; i < 5 && stack > 0xE0000000 && stack < (bp + 0x8000); i++) {
+ for (i = 0; i < 5 && stack > K_HIGHHALF_ADDR && stack < (bp + 0x8000); i++) {
monitor_write("| "); monitor_writeHex(stack);
monitor_write("\tnext:"); monitor_writeHex(stack[0]); monitor_write("\t\tret:"); monitor_writeHex(stack[1]);
monitor_write("\n");
diff --git a/src/kernel/ipc/shm.c b/src/kernel/ipc/shm.c
deleted file mode 100644
index 6e48613..0000000
--- a/src/kernel/ipc/shm.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "shm.h"
-#include <mem/mem.h>
-#include <mem/seg.h>
-#include <task/task.h>
-#include <core/sys.h>
-
-static struct segment_map* shmseg_map(struct segment* seg, struct page_directory *pagedir, size_t offset);
-static void shmseg_unmap(struct segment_map*);
-static void shmseg_delete(struct segment *seg);
-static int shmseg_handleFault(struct segment_map *map, size_t addr, int write);
-
-/* Call this function when creating a new shared memory segment.
- Creates the shmseg struct and segment struct, fills them in. */
-struct segment* shmseg_make(size_t len, struct process* owner) {
- struct shmseg *ss = kmalloc(sizeof(struct shmseg));
- struct segment *se = kmalloc(sizeof(struct segment));
- unsigned i;
- se->seg_data = ss;
- se->mappings = 0;
- se->map = shmseg_map;
- se->unmap = shmseg_unmap;
- se->delete = shmseg_delete;
- se->handle_fault = shmseg_handleFault;
- ss->len = len;
- ss->owner = owner;
- ss->frames = kmalloc((len / 0x1000) * sizeof(uint32_t));
- for (i = 0; i < (len / 0x1000); i++) ss->frames[i] = 0;
- return se;
-}
-
-/* For internal use only. Called when the shared memory is mapped somewhere.
- Creates the segment_map struct and fills it up. */
-struct segment_map *shmseg_map(struct segment *seg, struct page_directory *pagedir, size_t offset) {
- struct segment_map *sm = kmalloc(sizeof(struct segment_map));
- sm->start = offset;
- sm->len = ((struct shmseg*)(seg->seg_data))->len;
- return sm;
-}
-
-/* For internal use only. Called when the shared memory is unmapped from somewhere.
- Unmaps all the pages from that place. */
-void shmseg_unmap(struct segment_map *sm) {
- size_t i;
- for (i = 0; i < sm->len; i += 0x1000) {
- struct page *page = pagedir_getPage(sm->pagedir, sm->start + i, 0);
- if (page != 0) page_unmap(page);
- }
-}
-
-/* For internal use only. Called when a page fault occurs.
- Maps a page at that place, possibly requesting a free frame first. */
-int shmseg_handleFault(struct segment_map *sm, size_t addr, int write) {
- struct shmseg *ss = sm->seg->seg_data;
- addr &= 0xFFFFF000;
- struct page *p = pagedir_getPage(sm->pagedir, addr, 1);
- if (p->frame != 0) return 1;
- int frame_idx = (addr - sm->start) / 0x1000;
- if (ss->frames[frame_idx] == 0) {
- ss->frames[frame_idx] = frame_alloc();
- }
- page_map(p, ss->frames[frame_idx], 1, 1);
- return 0;
-}
-
-/* For internal use only. Called when the shared memory is deleted.
- Frees all the frames. */
-void shmseg_delete(struct segment *seg) {
- struct shmseg *ss = seg->seg_data;
- unsigned i;
- for (i = 0; i < (ss->len / 0x1000); i++) {
- if (ss->frames[i] != 0) frame_free(ss->frames[i]);
- }
- kfree(ss->frames);
-}
-
-/* Looks through the mapped segment for a process, looking for a shared memory segment at given offset. */
-struct segment_map* shmseg_getByOff(struct process* pr, size_t offset) {
- struct segment_map* m = pr->pagedir->mappedSegs;
- while (m != 0) {
- if (m->start == offset && m->seg->delete == shmseg_delete) return m;
- m = m->next;
- }
- return 0;
-}
-
-// **** **** SHM syscalls **** ****
-int shm_create(size_t offset, size_t len) {
- if (offset >= 0xE0000000) return -1;
- if (len >= 0x10000000) return -1;
- if (offset+len >= 0xE0000000) return -1;
- seg_map(shmseg_make(len, current_thread->process), current_thread->process->pagedir, offset);
- return 0;
-}
-
-int shm_delete(size_t offset) {
- struct segment_map *s = shmseg_getByOff(current_thread->process, offset);
- if (s == 0) return -1;
- seg_unmap(s);
- return 0;
-}
diff --git a/src/kernel/ipc/shm.h b/src/kernel/ipc/shm.h
deleted file mode 100644
index 5459dbb..0000000
--- a/src/kernel/ipc/shm.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef DEF_SHM_H
-#define DEF_SHM_H
-
-#include <task/task.h>
-
-struct shmseg {
- size_t len;
- uint32_t *frames;
- struct process* owner;
-};
-
-//Shared memory segment stuff
-struct segment* shmseg_make(size_t len, struct process* owner);
- //find a shared memory segment in current address space by its offset
-struct segment_map* shmseg_getByOff(struct process* pr, size_t offset);
-
-//Shared memory syscalls
-int shm_create(size_t offset, size_t len);
-int shm_delete(size_t offset);
-
-#endif
-
diff --git a/src/kernel/lib/stdlib.c b/src/kernel/lib/stdlib.c
deleted file mode 100644
index c5245e7..0000000
--- a/src/kernel/lib/stdlib.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "stdlib.h"
-
-void *memcpy(void *vd, const void *vs, int count) {
- uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
- uint32_t f = count % 4, n = count / 4, i;
- const uint32_t* s = (uint32_t*)src;
- uint32_t* d = (uint32_t*)dest;
- for (i = 0; i < n; i++) {
- d[i] = s[i];
- }
- if (f != 0) {
- for (i = count - f; i < count; i++) {
- dest[i] = src[i];
- }
- }
- return vd;
-}
-
-uint8_t *memset(uint8_t *dest, uint8_t val, int count) {
- int i;
- for (i = 0; i < count; i++) {
- dest[i] = val;
- }
- return dest;
-}
-
-uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) {
- int i;
- for (i = 0; i < count; i++) {
- dest[i] = val;
- }
- return dest;
-}
-
-int strlen(const char *str) {
- int i = 0;
- while (str[i++]);
- return i;
-}
diff --git a/src/kernel/lib/stdlib.h b/src/kernel/lib/stdlib.h
deleted file mode 100644
index 319cf26..0000000
--- a/src/kernel/lib/stdlib.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef DEF_STDLIB_H
-#define DEF_STDLIB_H
-
-#include <types.h>
-
-void *memcpy(void *dest, const void *src, int count);
-uint8_t *memset(uint8_t *dest, uint8_t val, int count);
-uint16_t *memsetw(uint16_t *dest, uint16_t val, int count);
-int strlen(const char *str);
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
-#endif
-
diff --git a/src/kernel/lib/types.h b/src/kernel/lib/types.h
deleted file mode 100644
index b7b19ab..0000000
--- a/src/kernel/lib/types.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef DEF_TYPES_H
-#define DEF_TYPES_H
-
-typedef unsigned long long uint64_t;
-typedef unsigned int uint32_t;
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-typedef long long int64_t;
-typedef int int32_t;
-typedef short int16_t;
-typedef char int8_t;
-
-typedef unsigned int size_t;
-
-#endif
diff --git a/src/kernel/link.ld b/src/kernel/link.ld
index 1ce17cf..fcdb0bb 100644
--- a/src/kernel/link.ld
+++ b/src/kernel/link.ld
@@ -1,27 +1,29 @@
ENTRY (loader)
SECTIONS{
+ k_highhalf_addr = 0xC0000000;
+
. = 0x00100000;
.setup : {
*(.setup)
}
- . += 0xE0000000;
+ . += k_highhalf_addr;
- .text : AT(ADDR(.text) - 0xE0000000) {
+ .text : AT(ADDR(.text) - k_highhalf_addr) {
*(.text)
}
- .rodata ALIGN (0x1000) : AT(ADDR(.rodata) - 0xE0000000) {
+ .rodata ALIGN (0x1000) : AT(ADDR(.rodata) - k_highhalf_addr) {
*(.rodata)
}
- .data ALIGN (0x1000) : AT(ADDR(.data) - 0xE0000000) {
+ .data ALIGN (0x1000) : AT(ADDR(.data) - k_highhalf_addr) {
*(.data)
}
- .bss : AT(ADDR(.bss) - 0xE0000000) {
+ .bss : AT(ADDR(.bss) - k_highhalf_addr) {
sbss = .;
*(COMMON)
*(.bss)
diff --git a/src/kernel/mem/heap.basic.h b/src/kernel/mem/heap.basic.h
index c752750..b52be4e 100644
--- a/src/kernel/mem/heap.basic.h
+++ b/src/kernel/mem/heap.basic.h
@@ -3,7 +3,7 @@
/* This heap implementation is extra-simple and extra-slow. */
-#include "types.h"
+#include <types.h>
#define HH_FREE_MAGIC 0xFEE0FEE0
#define HH_ALLOC_MAGIC 0xA110A110
diff --git a/src/kernel/mem/heap.std.c b/src/kernel/mem/heap.std.c
index 5b2d025..84c11e2 100644
--- a/src/kernel/mem/heap.std.c
+++ b/src/kernel/mem/heap.std.c
@@ -2,7 +2,9 @@
#include "paging.h"
#include <core/sys.h>
-#include <lib/stdlib.h>
+#include <mem/mem.h>
+
+#include <stdlib.h>
#define HEAP_MAGIC 0xBAD0BEEF
#define HEAP_MIN_SIZE 0x4000
@@ -156,7 +158,7 @@ static void heap_contract(struct heap *heap) {
/* Alocate some bytes on the heap. */
void* heap_alloc(struct heap *heap, size_t sz) {
- ASSERT(heap > 0xE0000000);
+ ASSERT(heap > K_HIGHHALF_ADDR);
size_t newsize = sz + sizeof(struct heap_header) + sizeof(struct heap_footer);
uint32_t iterator = 0;
diff --git a/src/kernel/mem/heap.std.h b/src/kernel/mem/heap.std.h
index fa146ae..2018508 100644
--- a/src/kernel/mem/heap.std.h
+++ b/src/kernel/mem/heap.std.h
@@ -6,7 +6,7 @@
The heap algorithm used is based on the one described here :
http://www.jamesmolloy.co.uk/tutorial_html/7.-The%20Heap.html */
-#include "types.h"
+#include <types.h>
struct heap_header {
uint32_t magic;
diff --git a/src/kernel/mem/mem.c b/src/kernel/mem/mem.c
index c6494b7..8d814e4 100644
--- a/src/kernel/mem/mem.c
+++ b/src/kernel/mem/mem.c
@@ -11,6 +11,8 @@
#include "heap.std.h"
#endif
+#include "mem.h"
+
#define FREEPAGESTOKEEP 5
#define KHEAP_IDXSIZE 0x4000 // only used with heap.std.h
@@ -50,7 +52,7 @@ static void get_free_pages() {
mem_placementAddr += 0x1000;
}
freepages[freepagecount].virt = (size_t)kmalloc(0x1000);
- freepages[freepagecount].phys = freepages[freepagecount].virt - 0xE0000000;
+ freepages[freepagecount].phys = freepages[freepagecount].virt - K_HIGHHALF_ADDR;
freepagecount++;
}
}
diff --git a/src/kernel/mem/mem.h b/src/kernel/mem/mem.h
index b372fae..093545e 100644
--- a/src/kernel/mem/mem.h
+++ b/src/kernel/mem/mem.h
@@ -16,5 +16,9 @@ void kheap_init();
extern size_t mem_placementAddr;
extern void end; //Symbol defined by linker : end of kernel code
+extern void k_highhalf_addr; // Symbol defined by linker : high half position of the kerne
+ // Should be at 0xC0000000
+#define K_HIGHHALF_ADDR ((size_t)(&k_highhalf_addr))
+
#endif
diff --git a/src/kernel/mem/paging.c b/src/kernel/mem/paging.c
index 4e5f33a..3e2bffa 100644
--- a/src/kernel/mem/paging.c
+++ b/src/kernel/mem/paging.c
@@ -7,6 +7,8 @@
#include <core/sys.h>
#include <task/task.h>
+#define FIRST_KERNEL_PAGETABLE (K_HIGHHALF_ADDR >> 22)
+
static struct bitset frames;
struct page_directory *kernel_pagedir, *current_pagedir;
@@ -27,7 +29,7 @@ void frame_free(uint32_t id) {
/************************* PAGING INITIALIZATION *****************************/
/* This function creates the kernel page directory. It must be called before the GDT is loaded.
- It maps 0xE0000000+ to the corresponding physical kernel code, but it also maps
+ It maps 0xC0000000+ (k_highhalf_addr) to the corresponding physical kernel code, but it also maps
0x00000000+ to that code because with the false GDT we set up in loader_.asm,
the code will be looked for at the beginning of the memory. Only when the real GDT is loaded
we can de-allocate pages at 0x00000000 ; this is done by paging_cleanup. */
@@ -45,12 +47,12 @@ void paging_init(size_t totalRam) {
kernel_pagedir->tablesPhysical[i] = 0;
}
- for (i = 0xE0000000; i < mem_placementAddr; i += 0x1000) {
+ for (i = K_HIGHHALF_ADDR; i < mem_placementAddr; i += 0x1000) {
page_map(pagedir_getPage(kernel_pagedir, i, 1), frame_alloc(), 0, 0);
}
- for (i = 0; i < (mem_placementAddr - 0xE0000000) / 0x100000; i++) {
- kernel_pagedir->tablesPhysical[i] = kernel_pagedir->tablesPhysical[i + 896];
- kernel_pagedir->tables[i] = kernel_pagedir->tables[i + 896];
+ for (i = 0; i < (mem_placementAddr - K_HIGHHALF_ADDR) / 0x100000; i++) {
+ kernel_pagedir->tablesPhysical[i] = kernel_pagedir->tablesPhysical[i + FIRST_KERNEL_PAGETABLE];
+ kernel_pagedir->tables[i] = kernel_pagedir->tables[i + FIRST_KERNEL_PAGETABLE];
}
monitor_write("{PD: ");
@@ -61,8 +63,8 @@ void paging_init(size_t totalRam) {
/* De-allocates pages at 0x00000000 where kernel code was read from with the GDT from loader_.asm. */
void paging_cleanup() {
- uint32_t i;
- for (i = 0; i < (mem_placementAddr - 0xE0000000) / 0x100000; i++) {
+ size_t i;
+ for (i = 0; i < (mem_placementAddr - K_HIGHHALF_ADDR) / 0x100000; i++) {
kernel_pagedir->tablesPhysical[i] = 0;
kernel_pagedir->tables[i] = 0;
}
@@ -94,7 +96,7 @@ struct page_directory *pagedir_new() {
pd->tables[i] = 0; pd->tablesPhysical[i] = 0;
}
- for (i = 896; i < 1024; i++) {
+ for (i = FIRST_KERNEL_PAGETABLE; i < 1024; i++) {
pd->tables[i] = kernel_pagedir->tables[i];
pd->tablesPhysical[i] = kernel_pagedir->tablesPhysical[i];
}
@@ -108,7 +110,7 @@ void pagedir_delete(struct page_directory *pd) {
//Unmap segments
while (pd->mappedSegs != 0) seg_unmap(pd->mappedSegs);
//Cleanup page tables
- for (i = 0; i < 896; i++) {
+ for (i = 0; i < FIRST_KERNEL_PAGETABLE; i++) {
kfree_page(pd->tables[i]);
}
kfree_page(pd->tablesPhysical);
@@ -130,7 +132,7 @@ uint32_t paging_fault(struct registers *regs) {
}
if (seg != 0) {
- if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2) && (regs->eip < 0xE0000000)) != 0) seg = 0;
+ if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2) && (regs->eip < K_HIGHHALF_ADDR)) != 0) seg = 0;
}
if (seg == 0) {
@@ -158,7 +160,7 @@ struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int ma
return &pd->tables[table_idx]->pages[address % 1024];
} else if (make) {
pd->tables[table_idx] = kmalloc_page(pd->tablesPhysical + table_idx);
- if (table_idx >= 896)
+ if (table_idx >= FIRST_KERNEL_PAGETABLE)
tasking_updateKernelPagetable(table_idx, pd->tables[table_idx], pd->tablesPhysical[table_idx]);
memset((uint8_t*)pd->tables[table_idx], 0, 0x1000);
pd->tablesPhysical[table_idx] |= 0x07;
diff --git a/src/kernel/task/syscall.c b/src/kernel/task/syscall.c
index 3ae546f..5d40596 100644
--- a/src/kernel/task/syscall.c
+++ b/src/kernel/task/syscall.c
@@ -23,8 +23,6 @@ CALL1(monitor_write, printk_sc);
CALL1V(idt_waitIrq, irq_wait_sc);
CALL0(proc_priv, proc_priv_sc);
CALL2(process_setheapseg, proc_setheap_sc);
-CALL2(shm_create, shm_create_sc);
-CALL1(shm_delete, shm_delete_sc);
static void thread_new_sc(struct registers* r) {
cli();
@@ -42,6 +40,4 @@ int_callback syscalls[NUMBER_OF_SYSCALLS] = {
irq_wait_sc,
proc_priv_sc,
proc_setheap_sc,
- shm_create_sc,
- shm_delete_sc, //10
0 };
diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c
index 3d322c1..a6becdb 100644
--- a/src/kernel/task/task.c
+++ b/src/kernel/task/task.c
@@ -42,7 +42,7 @@ void tasking_init() {
monitor_write("[Tasking] ");
}
-/* Called by the paging functions when a page table is allocated in the kernel space (>0xE0000000).
+/* Called by the paging functions when a page table is allocated in the kernel space (>K_HIGHHALF_ADDR).
Updates the page directories of all the processes. */
void tasking_updateKernelPagetable(uint32_t idx, struct page_table *table, uint32_t tablephysical) {
if (idx < 896) return;
@@ -103,7 +103,7 @@ uint32_t tasking_handleException(struct registers *regs) {
"Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"};
monitor_write(exception_messages[regs->int_no]);
monitor_write("'\teip:"); monitor_writeHex(regs->eip);
- if (regs->eip >= 0xE0000000) {
+ if (regs->eip >= K_HIGHHALF_ADDR) {
monitor_write("\n Exception stack trace :\n");
stack_trace(regs->ebp);
PANIC("Kernel error'd.");
@@ -342,7 +342,7 @@ static void process_delete(struct process *pr) {
/* System call. Called by the app to define the place for the heap. */
int process_setheapseg(size_t start, size_t end) { //syscall
struct process *p = current_thread->process;
- if (start >= 0xE0000000 || end >= 0xE0000000) return -1;
+ if (start >= K_HIGHHALF_ADDR || end >= K_HIGHHALF_ADDR) return -1;
if (p->heapseg == 0) {
struct segment *s = simpleseg_make(start, end - start, 1);
if (s == 0) return -5;