Subversion Repositories HelenOS

Rev

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

Rev 3424 Rev 3425
Line 45... Line 45...
45
#include <config.h>
45
#include <config.h>
46
#include <arch.h>
46
#include <arch.h>
47
#include <proc/scheduler.h>
47
#include <proc/scheduler.h>
48
#include <proc/task.h>
48
#include <proc/task.h>
49
#include <proc/thread.h>
49
#include <proc/thread.h>
-
 
50
#include <proc/program.h>
50
#include <panic.h>
51
#include <panic.h>
51
#include <func.h>
52
#include <func.h>
52
#include <cpu.h>
53
#include <cpu.h>
53
#include <arch/asm.h>
54
#include <arch/asm.h>
54
#include <mm/page.h>
55
#include <mm/page.h>
Line 144... Line 145...
144
    arch_post_smp_init();
145
    arch_post_smp_init();
145
 
146
 
146
    /*
147
    /*
147
     * Create kernel console.
148
     * Create kernel console.
148
     */
149
     */
149
    t = thread_create(kconsole, (void *) "kconsole", TASK, 0, "kconsole", false);
150
    t = thread_create(kconsole, (void *) "kconsole", TASK, 0, "kconsole",
-
 
151
        false);
150
    if (t)
152
    if (t)
151
        thread_ready(t);
153
        thread_ready(t);
152
    else
154
    else
153
        panic("thread_create/kconsole\n");
155
        panic("thread_create/kconsole\n");
154
 
156
 
Line 156... Line 158...
156
   
158
   
157
    /*
159
    /*
158
     * Create user tasks, load RAM disk images.
160
     * Create user tasks, load RAM disk images.
159
     */
161
     */
160
    count_t i;
162
    count_t i;
161
    thread_t *threads[CONFIG_INIT_TASKS];
163
    program_t programs[CONFIG_INIT_TASKS];
162
   
164
   
163
    for (i = 0; i < init.cnt; i++) {
165
    for (i = 0; i < init.cnt; i++) {
164
        if (init.tasks[i].addr % FRAME_SIZE) {
166
        if (init.tasks[i].addr % FRAME_SIZE) {
165
            printf("init[%" PRIc "].addr is not frame aligned", i);
167
            printf("init[%" PRIc "].addr is not frame aligned", i);
166
            continue;
168
            continue;
167
        }
169
        }
168
 
170
 
169
        threads[i] = thread_create_program(
171
        int rc = program_create_from_image((void *) init.tasks[i].addr,
170
            (void *) init.tasks[i].addr, "uspace");
172
            &programs[i]);
171
       
173
 
172
        if (threads[i] != NULL) {
174
        if (rc == 0 && programs[i].task != NULL) {
173
            /*
175
            /*
174
             * Set capabilities to init userspace tasks.
176
             * Set capabilities to init userspace tasks.
175
             */
177
             */
176
            cap_set(threads[i]->task, CAP_CAP | CAP_MEM_MANAGER |
178
            cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
177
                CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
179
                CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
178
           
180
           
179
            if (!ipc_phone_0)
181
            if (!ipc_phone_0)
180
                ipc_phone_0 = &threads[i]->task->answerbox;
182
                ipc_phone_0 = &programs[i].task->answerbox;
-
 
183
        } else if (rc == 0) {
-
 
184
            /* It was the program loader and was registered */
181
        } else {
185
        } else {
-
 
186
            /* RAM disk image */
182
            int rd = init_rd((rd_header_t *) init.tasks[i].addr,
187
            int rd = init_rd((rd_header_t *) init.tasks[i].addr,
183
                init.tasks[i].size);
188
                init.tasks[i].size);
184
           
189
           
185
            if (rd != RE_OK)
190
            if (rd != RE_OK)
186
                printf("Init binary %" PRIc " not used, error code %d.\n", i, rd);
191
                printf("Init binary %" PRIc " not used, error "
-
 
192
                    "code %d.\n", i, rd);
187
        }
193
        }
188
    }
194
    }
189
   
195
   
190
    /*
196
    /*
191
     * Run user tasks with reasonable delays
197
     * Run user tasks with reasonable delays
192
     */
198
     */
193
    for (i = 0; i < init.cnt; i++) {
199
    for (i = 0; i < init.cnt; i++) {
194
        if (threads[i] != NULL) {
200
        if (programs[i].task != NULL) {
195
            thread_usleep(50000);
201
            thread_usleep(50000);
196
            thread_ready(threads[i]);
202
            program_ready(&programs[i]);
197
        }
203
        }
198
    }
204
    }
199
 
205
 
200
    if (!stdin) {
206
    if (!stdin) {
201
        while (1) {
207
        while (1) {