Subversion Repositories HelenOS-historic

Rev

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

Rev 703 Rev 717
Line 67... Line 67...
67
 * @param arg Not used.
67
 * @param arg Not used.
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
-
 
73
    as_t *as;
72
    as_t *as;
74
    as_area_t *a;
73
    as_area_t *a;
75
    __address frame;
74
    __address frame;
76
    index_t pfn[1];
75
    index_t pfn[1];
77
    task_t *u;
76
    task_t *u;
78
#endif
-
 
79
 
77
 
80
    interrupts_disable();
78
    interrupts_disable();
81
 
79
 
82
#ifdef CONFIG_SMP           
80
#ifdef CONFIG_SMP           
83
    if (config.cpu_count > 1) {
81
    if (config.cpu_count > 1) {
Line 137... Line 135...
137
        thread_ready(t);
135
        thread_ready(t);
138
    else panic("thread_create/kconsole\n");
136
    else panic("thread_create/kconsole\n");
139
 
137
 
140
    interrupts_enable();
138
    interrupts_enable();
141
 
139
 
142
#ifdef CONFIG_USERSPACE
140
    if (config.init_size > 0) {
143
    /*
141
        /*
144
     * Create the first user task.
142
         * Create the first user task.
145
     */
143
         */
146
    as = as_create(NULL);
144
        as = as_create(NULL);
147
    if (!as)
145
        if (!as)
148
        panic("as_create\n");
146
            panic("as_create\n");
149
    u = task_create(as);
147
        u = task_create(as);
150
    if (!u)
148
        if (!u)
151
        panic("task_create\n");
149
            panic("task_create\n");
152
    t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
150
        t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
153
    if (!t)
151
        if (!t)
154
        panic("thread_create\n");
152
            panic("thread_create\n");
155
 
153
       
156
    /*
154
        /*
157
     * Create the text as_area and copy the userspace code there.
155
         * Create the text as_area and copy the userspace code there.
158
     */
156
         */
159
    a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
157
        a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
160
    if (!a)
158
        if (!a)
161
        panic("as_area_create: text\n");
159
            panic("as_area_create: text\n");
162
 
160
       
-
 
161
        // FIXME: Better way to initialize static code/data
163
    frame = frame_alloc(0, ONE_FRAME, NULL);
162
        frame = frame_alloc(0, ONE_FRAME, NULL);
164
 
-
 
165
    if (config.init_size > 0)
-
 
166
        memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
163
        memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
167
    else
164
       
168
        memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
165
        pfn[0] = frame / FRAME_SIZE;
-
 
166
        as_area_load_mapping(a, pfn);
169
   
167
   
170
    pfn[0] = frame / FRAME_SIZE;
-
 
171
    as_area_load_mapping(a, pfn);
-
 
172
 
-
 
173
    /*
168
        /*
174
     * Create the data as_area.
169
         * Create the data as_area.
175
     */
170
         */
176
    a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
171
        a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
177
    if (!a)
172
        if (!a)
178
        panic("as_area_create: stack\n");
173
            panic("as_area_create: stack\n");
179
   
174
   
180
    thread_ready(t);
175
        thread_ready(t);
181
#endif /* CONFIG_USERSPACE */
-
 
-
 
176
    }
182
 
177
 
183
#ifdef CONFIG_TEST
178
#ifdef CONFIG_TEST
184
    test();
179
    test();
185
#endif /* CONFIG_TEST */
180
#endif /* CONFIG_TEST */
186
 
181