Subversion Repositories HelenOS-historic

Rev

Rev 673 | Rev 717 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 673 Rev 703
Line 37... Line 37...
37
#include <func.h>
37
#include <func.h>
38
#include <cpu.h>
38
#include <cpu.h>
39
#include <arch/asm.h>
39
#include <arch/asm.h>
40
#include <mm/page.h>
40
#include <mm/page.h>
41
#include <arch/mm/page.h>
41
#include <arch/mm/page.h>
42
#include <mm/vm.h>
42
#include <mm/as.h>
43
#include <mm/frame.h>
43
#include <mm/frame.h>
44
#include <print.h>
44
#include <print.h>
45
#include <memstr.h>
45
#include <memstr.h>
46
#include <console/console.h>
46
#include <console/console.h>
47
#include <interrupt.h>
47
#include <interrupt.h>
Line 68... Line 68...
68
 */
68
 */
69
void kinit(void *arg)
69
void kinit(void *arg)
70
{
70
{
71
    thread_t *t;
71
    thread_t *t;
72
#ifdef CONFIG_USERSPACE
72
#ifdef CONFIG_USERSPACE
73
    vm_t *m;
73
    as_t *as;
74
    vm_area_t *a;
74
    as_area_t *a;
-
 
75
    __address frame;
-
 
76
    index_t pfn[1];
75
    task_t *u;
77
    task_t *u;
76
#endif
78
#endif
77
 
79
 
78
    interrupts_disable();
80
    interrupts_disable();
79
 
81
 
Line 139... Line 141...
139
 
141
 
140
#ifdef CONFIG_USERSPACE
142
#ifdef CONFIG_USERSPACE
141
    /*
143
    /*
142
     * Create the first user task.
144
     * Create the first user task.
143
     */
145
     */
144
    m = vm_create(NULL);
146
    as = as_create(NULL);
145
    if (!m)
147
    if (!as)
146
        panic("vm_create\n");
148
        panic("as_create\n");
147
    u = task_create(m);
149
    u = task_create(as);
148
    if (!u)
150
    if (!u)
149
        panic("task_create\n");
151
        panic("task_create\n");
150
    t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
152
    t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
151
    if (!t)
153
    if (!t)
152
        panic("thread_create\n");
154
        panic("thread_create\n");
153
 
155
 
154
    /*
156
    /*
155
     * Create the text vm_area and copy the userspace code there.
157
     * Create the text as_area and copy the userspace code there.
156
     */
158
     */
157
    a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS);
159
    a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
158
    if (!a)
160
    if (!a)
159
        panic("vm_area_create: vm_text\n");
161
        panic("as_area_create: text\n");
-
 
162
 
160
    vm_area_map(a, m);
163
    frame = frame_alloc(0, ONE_FRAME, NULL);
-
 
164
 
161
    if (config.init_size > 0)
165
    if (config.init_size > 0)
162
        memcpy((void *) PA2KA(a->mapping[0]), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
166
        memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
163
    else
167
    else
164
        memcpy((void *) PA2KA(a->mapping[0]), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
168
        memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
-
 
169
   
-
 
170
    pfn[0] = frame / FRAME_SIZE;
-
 
171
    as_area_load_mapping(a, pfn);
165
 
172
 
166
    /*
173
    /*
167
     * Create the data vm_area.
174
     * Create the data as_area.
168
     */
175
     */
169
    a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS);
176
    a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
170
    if (!a)
177
    if (!a)
171
        panic("vm_area_create: vm_stack\n");
178
        panic("as_area_create: stack\n");
172
    vm_area_map(a, m);
-
 
173
   
179
   
174
    thread_ready(t);
180
    thread_ready(t);
175
#endif /* CONFIG_USERSPACE */
181
#endif /* CONFIG_USERSPACE */
176
 
182
 
177
#ifdef CONFIG_TEST
183
#ifdef CONFIG_TEST