Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 716 → Rev 717

/kernel/trunk/generic/src/main/kinit.c
69,13 → 69,11
void kinit(void *arg)
{
thread_t *t;
#ifdef CONFIG_USERSPACE
as_t *as;
as_area_t *a;
__address frame;
index_t pfn[1];
task_t *u;
#endif
 
interrupts_disable();
 
139,46 → 137,43
 
interrupts_enable();
 
#ifdef CONFIG_USERSPACE
/*
* Create the first user task.
*/
as = as_create(NULL);
if (!as)
panic("as_create\n");
u = task_create(as);
if (!u)
panic("task_create\n");
t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
if (!t)
panic("thread_create\n");
 
/*
* Create the text as_area and copy the userspace code there.
*/
a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
if (!a)
panic("as_area_create: text\n");
 
frame = frame_alloc(0, ONE_FRAME, NULL);
 
if (config.init_size > 0)
if (config.init_size > 0) {
/*
* Create the first user task.
*/
as = as_create(NULL);
if (!as)
panic("as_create\n");
u = task_create(as);
if (!u)
panic("task_create\n");
t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
if (!t)
panic("thread_create\n");
/*
* Create the text as_area and copy the userspace code there.
*/
a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
if (!a)
panic("as_area_create: text\n");
// FIXME: Better way to initialize static code/data
frame = frame_alloc(0, ONE_FRAME, NULL);
memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
else
memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
pfn[0] = frame / FRAME_SIZE;
as_area_load_mapping(a, pfn);
pfn[0] = frame / FRAME_SIZE;
as_area_load_mapping(a, pfn);
 
/*
* Create the data as_area.
*/
a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
if (!a)
panic("as_area_create: stack\n");
/*
* Create the data as_area.
*/
a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
if (!a)
panic("as_area_create: stack\n");
thread_ready(t);
#endif /* CONFIG_USERSPACE */
thread_ready(t);
}
 
#ifdef CONFIG_TEST
test();