Subversion Repositories HelenOS

Rev

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

Rev 3181 Rev 3222
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 157... Line 158...
157
   
158
   
158
    /*
159
    /*
159
     * Create user tasks, load RAM disk images.
160
     * Create user tasks, load RAM disk images.
160
     */
161
     */
161
    count_t i;
162
    count_t i;
162
    thread_t *threads[CONFIG_INIT_TASKS];
163
    program_t programs[CONFIG_INIT_TASKS];
163
   
164
   
164
    for (i = 0; i < init.cnt; i++) {
165
    for (i = 0; i < init.cnt; i++) {
165
        if (init.tasks[i].addr % FRAME_SIZE) {
166
        if (init.tasks[i].addr % FRAME_SIZE) {
166
            printf("init[%" PRIc "].addr is not frame aligned", i);
167
            printf("init[%" PRIc "].addr is not frame aligned", i);
167
            continue;
168
            continue;
168
        }
169
        }
169
 
170
 
170
        threads[i] = thread_create_program((void *) init.tasks[i].addr,
171
        int rc = program_create_from_image((void *) init.tasks[i].addr,
171
            "uspace");
172
            &programs[i]);
172
       
173
 
173
        if (threads[i] != NULL) {
174
        if (rc == 0 && programs[i].task != NULL) {
174
            /*
175
            /*
175
             * Set capabilities to init userspace tasks.
176
             * Set capabilities to init userspace tasks.
176
             */
177
             */
177
            cap_set(threads[i]->task, CAP_CAP | CAP_MEM_MANAGER |
178
            cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
178
                CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
179
                CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
-
 
180
 
179
           
181
           
180
            if (!ipc_phone_0)
182
            if (!ipc_phone_0)
181
                ipc_phone_0 = &threads[i]->task->answerbox;
183
                ipc_phone_0 = &programs[i].task->answerbox;
-
 
184
        } else if (rc == 0) {
-
 
185
            /* It was the program loader and was registered */
182
        } else {
186
        } else {
-
 
187
            /* RAM disk image */
183
            int rd = init_rd((rd_header_t *) init.tasks[i].addr,
188
            int rd = init_rd((rd_header_t *) init.tasks[i].addr,
184
                init.tasks[i].size);
189
                init.tasks[i].size);
185
           
190
           
186
            if (rd != RE_OK)
191
            if (rd != RE_OK)
187
                printf("Init binary %" PRIc " not used, error "
192
                printf("Init binary %" PRIc " not used, error "
Line 191... Line 196...
191
   
196
   
192
    /*
197
    /*
193
     * Run user tasks with reasonable delays
198
     * Run user tasks with reasonable delays
194
     */
199
     */
195
    for (i = 0; i < init.cnt; i++) {
200
    for (i = 0; i < init.cnt; i++) {
196
        if (threads[i] != NULL) {
201
        if (programs[i].task != NULL) {
197
            thread_usleep(50000);
202
            thread_usleep(50000);
198
            thread_ready(threads[i]);
203
            program_ready(&programs[i]);
199
        }
204
        }
200
    }
205
    }
201
 
206
 
202
    if (!stdin) {
207
    if (!stdin) {
203
        while (1) {
208
        while (1) {