fixed syntax errors and compiler warnings in new branch

This commit is contained in:
Steffen Vogel 2014-11-28 03:20:31 +01:00
parent 1a20a9fb45
commit 2cf3c89a40
2 changed files with 23 additions and 8 deletions

View file

@ -58,6 +58,12 @@ static size_t* self[PAGE_LEVELS] = {
(size_t *) 0xFFFFF000 (size_t *) 0xFFFFF000
}; };
/** An other self-reference for page_map_copy() */
static size_t * other[PAGE_LEVELS] = {
(size_t *) 0xFF800000,
(size_t *) 0xFFFFE000
};
/* Addresses of child/parent tables */ /* Addresses of child/parent tables */
#define CHILD(map, lvl, vpn) &map[lvl-1][vpn<<PAGE_MAP_BITS] #define CHILD(map, lvl, vpn) &map[lvl-1][vpn<<PAGE_MAP_BITS]
#define PARENT(map, lvl, vpn) &map[lvl+1][vpn>>PAGE_MAP_BITS] #define PARENT(map, lvl, vpn) &map[lvl+1][vpn>>PAGE_MAP_BITS]
@ -184,9 +190,8 @@ int page_map_copy(size_t dest)
if (BUILTIN_EXPECT(phyaddr, 0)) if (BUILTIN_EXPECT(phyaddr, 0))
return -ENOMEM; return -ENOMEM;
other[lvl][vpn] = phyaddr;
new[lvl][vpn] = phyaddr; other[lvl][vpn] |= self[lvl][vpn] & ~PAGE_MASK;
new[lvl][vpn] |= self[lvl][vpn] & ~PAGE_MASK;
memcpy(CHILD(other, lvl, vpn), CHILD(self, lvl, vpn), PAGE_SIZE); memcpy(CHILD(other, lvl, vpn), CHILD(self, lvl, vpn), PAGE_SIZE);

View file

@ -34,14 +34,17 @@
#include <eduos/spinlock.h> #include <eduos/spinlock.h>
#include <eduos/errno.h> #include <eduos/errno.h>
#include <eduos/syscall.h> #include <eduos/syscall.h>
#include <eduos/memory.h>
#include <asm/page.h>
/** @brief Array of task structures (aka PCB) /** @brief Array of task structures (aka PCB)
* *
* A task's id will be its position in this array. * A task's id will be its position in this array.
*/ */
static task_t task_table[MAX_TASKS] = { \ static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_IDLE, NULL, NULL, 0, NULL, SPINLOCK_IRQSAVE_INIT, ATOMIC_INIT(0), NULL, NULL}, \ [0] = {0, TASK_IDLE, NULL, NULL, 0, 0, SPINLOCK_IRQSAVE_INIT, ATOMIC_INIT(0), NULL, NULL}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, NULL, NULL, 0, NULL, SPINLOCK_IRQSAVE_INIT, ATOMIC_INIT(0), NULL, NULL}}; [1 ... MAX_TASKS-1] = {0, TASK_INVALID, NULL, NULL, 0, 0, SPINLOCK_IRQSAVE_INIT, ATOMIC_INIT(0), NULL, NULL}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT; static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
@ -118,6 +121,8 @@ static void NORETURN do_exit(int arg)
kprintf("Terminate task: %u, return value %d\n", curr_task->id, arg); kprintf("Terminate task: %u, return value %d\n", curr_task->id, arg);
page_map_drop();
curr_task->status = TASK_FINISHED; curr_task->status = TASK_FINISHED;
reschedule(); reschedule();
@ -194,13 +199,17 @@ static int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
task_table[i].last_stack_pointer = NULL; task_table[i].last_stack_pointer = NULL;
task_table[i].stack = create_stack(i); task_table[i].stack = create_stack(i);
task_table[i].prio = prio; task_table[i].prio = prio;
task_table[i].page_map = get_pages(1);
/** @todo: Check if get_pages(1) was successful */
spinlock_irqsave_init(&task_table[i].page_lock); spinlock_irqsave_init(&task_table[i].page_lock);
atomic_int32_set(&task_table[i].user_usage, 0); atomic_int32_set(&task_table[i].user_usage, 0);
//page_map_copy(&task_table[i]); /* Allocated new PGD or PML4 and copy page table */
size_t map = get_pages(1);
if (BUILTIN_EXPECT(map, 0))
goto out;
page_map_copy(map);
task_table[i].page_map = map;
if (id) if (id)
*id = i; *id = i;
@ -226,6 +235,7 @@ static int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
} }
} }
out:
spinlock_irqsave_unlock(&table_lock); spinlock_irqsave_unlock(&table_lock);
return ret; return ret;