Subversion Repositories HelenOS-historic

Rev

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

Rev 717 Rev 718
Line 69... Line 69...
69
void kinit(void *arg)
69
void kinit(void *arg)
70
{
70
{
71
    thread_t *t;
71
    thread_t *t;
72
    as_t *as;
72
    as_t *as;
73
    as_area_t *a;
73
    as_area_t *a;
74
    __address frame;
74
    index_t frame, frames;
75
    index_t pfn[1];
75
    index_t pfn;
76
    task_t *u;
76
    task_t *u;
77
 
77
 
78
    interrupts_disable();
78
    interrupts_disable();
79
 
79
 
80
#ifdef CONFIG_SMP           
80
#ifdef CONFIG_SMP           
Line 131... Line 131...
131
    /*
131
    /*
132
     * Create kernel console.
132
     * Create kernel console.
133
     */
133
     */
134
    if ((t = thread_create(kconsole, "kconsole", TASK, 0)))
134
    if ((t = thread_create(kconsole, "kconsole", TASK, 0)))
135
        thread_ready(t);
135
        thread_ready(t);
-
 
136
    else
136
    else panic("thread_create/kconsole\n");
137
        panic("thread_create/kconsole\n");
137
 
138
 
138
    interrupts_enable();
139
    interrupts_enable();
139
 
140
 
140
    if (config.init_size > 0) {
141
    if (config.init_size > 0) {
141
        /*
142
        /*
142
         * Create the first user task.
143
         * Create the first user task.
143
         */
144
         */
-
 
145
       
-
 
146
        if (KA2PA(config.init_addr) % FRAME_SIZE)
-
 
147
            panic("config.init_addr is not frame aligned");
-
 
148
       
144
        as = as_create(NULL);
149
        as = as_create(NULL);
145
        if (!as)
150
        if (!as)
146
            panic("as_create\n");
151
            panic("as_create\n");
147
        u = task_create(as);
152
        u = task_create(as);
148
        if (!u)
153
        if (!u)
Line 151... Line 156...
151
        if (!t)
156
        if (!t)
152
            panic("thread_create\n");
157
            panic("thread_create\n");
153
       
158
       
154
        /*
159
        /*
155
         * Create the text as_area and copy the userspace code there.
160
         * Create the text as_area and copy the userspace code there.
156
         */
161
         */
-
 
162
       
-
 
163
        frame = KA2PA(config.init_addr) / FRAME_SIZE;
-
 
164
        frames = config.init_size / FRAME_SIZE;
-
 
165
        if (config.init_size % FRAME_SIZE > 0)
-
 
166
            frames++;
-
 
167
       
157
        a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
168
        a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS);
158
        if (!a)
169
        if (!a)
159
            panic("as_area_create: text\n");
170
            panic("as_area_create: text\n");
160
       
171
       
161
        // FIXME: Better way to initialize static code/data
-
 
162
        frame = frame_alloc(0, ONE_FRAME, NULL);
-
 
163
        memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
-
 
164
       
-
 
165
        pfn[0] = frame / FRAME_SIZE;
172
        for (pfn = 0; pfn < frames; pfn++)
166
        as_area_load_mapping(a, pfn);
173
            as_area_set_mapping(a, pfn, frame + pfn);
167
   
174
   
168
        /*
175
        /*
169
         * Create the data as_area.
176
         * Create the data as_area.
170
         */
177
         */
171
        a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
178
        a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);