summaryrefslogtreecommitdiff
path: root/src/kernel/task
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/task')
-rw-r--r--src/kernel/task/idt.h1
-rw-r--r--src/kernel/task/idt_.asm6
-rw-r--r--src/kernel/task/syscall.c2
-rw-r--r--src/kernel/task/task.c24
-rw-r--r--src/kernel/task/task.h3
5 files changed, 29 insertions, 7 deletions
diff --git a/src/kernel/task/idt.h b/src/kernel/task/idt.h
index ed37eb0..b12d6c5 100644
--- a/src/kernel/task/idt.h
+++ b/src/kernel/task/idt.h
@@ -17,7 +17,6 @@ struct idt_ptr {
} __attribute__((packed));
struct registers {
- uint32_t cr3; //page directory physical address
uint32_t ds; // Data segment selector
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha.
uint32_t int_no, err_code; // Interrupt number and error code (if applicable)
diff --git a/src/kernel/task/idt_.asm b/src/kernel/task/idt_.asm
index 1a594ca..95878c0 100644
--- a/src/kernel/task/idt_.asm
+++ b/src/kernel/task/idt_.asm
@@ -47,14 +47,8 @@ idt_flush:
mov fs, ax
mov gs, ax
- mov eax, cr3
- push eax
-
call idt_%1Handler
- pop eax
- mov cr3, eax
-
pop eax ; reload the original data segment descriptor
mov ds, ax
mov es, ax
diff --git a/src/kernel/task/syscall.c b/src/kernel/task/syscall.c
index dd909e0..9a1ce81 100644
--- a/src/kernel/task/syscall.c
+++ b/src/kernel/task/syscall.c
@@ -31,6 +31,7 @@ CALL3V(request_answer, request_answer_sc);
CALL3(request_mapShm, request_mapShm_sc);
CALL2(request, request_sc);
CALL2(send_msg, send_msg_sc);
+CALL2(process_setheapseg, proc_setheap_sc);
static void thread_new_sc(struct registers* r) {
thread_new(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx);
@@ -56,4 +57,5 @@ int_callback syscalls[] = {
request_mapShm_sc,
request_sc,
send_msg_sc,
+ proc_setheap_sc,
0 };
diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c
index dec7565..9221813 100644
--- a/src/kernel/task/task.c
+++ b/src/kernel/task/task.c
@@ -77,6 +77,7 @@ void tasking_switch() {
}
current_thread = thread_next();
+ pagedir_switch(current_thread->process->pagedir);
gdt_setKernelStack(((uint32_t)current_thread->kernelStack_addr) + current_thread->kernelStack_size);
@@ -278,6 +279,7 @@ struct process *process_new(struct process* parent, uint32_t uid, uint32_t privi
p->pagedir = pagedir_new();
p->next = processes;
p->stacksBottom = 0xDF000000;
+ p->heapseg = 0;
p->next_objdesc = 0;
p->objects = 0;
@@ -289,6 +291,7 @@ struct process *process_new(struct process* parent, uint32_t uid, uint32_t privi
static void thread_delete(struct thread *th) {
kfree(th->kernelStack_addr);
+ if (th->userStack_seg != 0) seg_unmap(th->userStack_seg);
th->process->threads--;
if (threads == th) {
threads = th->next;
@@ -319,3 +322,24 @@ static void process_delete(struct process *pr) {
}
kfree(pr);
}
+
+int process_setheapseg(size_t start, size_t end) { //syscall
+ struct process *p = current_thread->process;
+ if (start >= 0xE0000000 || end >= 0xE0000000) return -1;
+ if (p->heapseg == 0) {
+ struct segment *s = simpleseg_make(start, end - start, 1);
+ if (s == 0) return -5;
+ p->heapseg = seg_map(s, p->pagedir, 0);
+ if (p->heapseg == 0) return -1;
+ return 0;
+ } else if (p->heapseg->start != start) {
+ seg_unmap(p->heapseg);
+ struct segment *s = simpleseg_make(start, end - start, 1);
+ if (s == 0) return -5;
+ p->heapseg = seg_map(s, p->pagedir, 0);
+ if (p->heapseg == 0) return -1;
+ return 0;
+ } else {
+ return simpleseg_resize(p->heapseg, end - start);
+ }
+}
diff --git a/src/kernel/task/task.h b/src/kernel/task/task.h
index 1c22785..3dad63d 100644
--- a/src/kernel/task/task.h
+++ b/src/kernel/task/task.h
@@ -32,6 +32,8 @@ struct process {
struct obj_descriptor *objects;
uint32_t next_objdesc;
+ struct segment_map *heapseg;
+
struct process *next; //Forms a linked list
};
@@ -62,5 +64,6 @@ void thread_exit();
void process_exit(uint32_t retval);
struct thread * thread_new(struct process *proc, thread_entry entry_point, void *data);
struct process* process_new(struct process *parent, uint32_t uid, uint32_t privilege);
+int process_setheapseg(size_t start, size_t end); //syscall
#endif