Subversion Repositories HelenOS

Rev

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

Rev 2071 Rev 2087
Line 144... Line 144...
144
   
144
   
145
    config.base = hardcoded_load_address;
145
    config.base = hardcoded_load_address;
146
    config.memory_size = get_memory_size();
146
    config.memory_size = get_memory_size();
147
   
147
   
148
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
148
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
149
        hardcoded_kdata_size, PAGE_SIZE);
149
        hardcoded_kdata_size, PAGE_SIZE);
150
    config.stack_size = CONFIG_STACK_SIZE;
150
    config.stack_size = CONFIG_STACK_SIZE;
151
   
151
   
152
    /* Initialy the stack is placed just after the kernel */
152
    /* Initialy the stack is placed just after the kernel */
153
    config.stack_base = config.base + config.kernel_size;
153
    config.stack_base = config.base + config.kernel_size;
154
   
154
   
155
    /* Avoid placing stack on top of init */
155
    /* Avoid placing stack on top of init */
156
    count_t i;
156
    count_t i;
157
    for (i = 0; i < init.cnt; i++) {
157
    for (i = 0; i < init.cnt; i++) {
158
        if (PA_overlaps(config.stack_base, config.stack_size,
158
        if (PA_overlaps(config.stack_base, config.stack_size,
159
            init.tasks[i].addr, init.tasks[i].size))
159
            init.tasks[i].addr, init.tasks[i].size))
160
            config.stack_base = ALIGN_UP(init.tasks[i].addr +
160
            config.stack_base = ALIGN_UP(init.tasks[i].addr +
161
                init.tasks[i].size, config.stack_size);
161
                init.tasks[i].size, config.stack_size);
162
    }
162
    }
163
 
163
 
164
    /* Avoid placing stack on top of boot allocations. */
164
    /* Avoid placing stack on top of boot allocations. */
165
    if (ballocs.size) {
165
    if (ballocs.size) {
166
        if (PA_overlaps(config.stack_base, config.stack_size,
166
        if (PA_overlaps(config.stack_base, config.stack_size,
167
            ballocs.base, ballocs.size))
167
            ballocs.base, ballocs.size))
168
            config.stack_base = ALIGN_UP(ballocs.base +
168
            config.stack_base = ALIGN_UP(ballocs.base +
169
                ballocs.size, PAGE_SIZE);
169
                ballocs.size, PAGE_SIZE);
170
    }
170
    }
171
   
171
   
172
    if (config.stack_base < stack_safe)
172
    if (config.stack_base < stack_safe)
173
        config.stack_base = ALIGN_UP(stack_safe, PAGE_SIZE);
173
        config.stack_base = ALIGN_UP(stack_safe, PAGE_SIZE);
174
   
174
   
175
    context_save(&ctx);
175
    context_save(&ctx);
176
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
176
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
177
        THREAD_STACK_SIZE);
177
        THREAD_STACK_SIZE);
178
    context_restore(&ctx);
178
    context_restore(&ctx);
179
    /* not reached */
179
    /* not reached */
180
}
180
}
181
 
181
 
182
 
182
 
Line 220... Line 220...
220
    ddi_init();
220
    ddi_init();
221
    arch_post_mm_init();
221
    arch_post_mm_init();
222
 
222
 
223
    version_print();
223
    version_print();
224
    printf("kernel: %.*p hardcoded_ktext_size=%zdK, "
224
    printf("kernel: %.*p hardcoded_ktext_size=%zdK, "
225
        "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
225
        "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
226
        config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >>
226
        config.base, hardcoded_ktext_size >> 10,
227
        10);
227
        hardcoded_kdata_size >> 10);
228
    printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2,
228
    printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2,
229
        config.stack_base, config.stack_size >> 10);
229
        config.stack_base, config.stack_size >> 10);
230
 
230
 
231
    arch_pre_smp_init();
231
    arch_pre_smp_init();
232
    smp_init();
232
    smp_init();
233
    /* Slab must be initialized after we know the number of processors. */
233
    /* Slab must be initialized after we know the number of processors. */
234
    slab_enable_cpucache();
234
    slab_enable_cpucache();
Line 247... Line 247...
247
    klog_init();
247
    klog_init();
248
   
248
   
249
    if (init.cnt > 0) {
249
    if (init.cnt > 0) {
250
        for (i = 0; i < init.cnt; i++)
250
        for (i = 0; i < init.cnt; i++)
251
            printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i,
251
            printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i,
252
                sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
252
                sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
253
                init.tasks[i].size);
253
                init.tasks[i].size);
254
    } else
254
    } else
255
        printf("No init binaries found\n");
255
        printf("No init binaries found\n");
256
   
256
   
257
    ipc_init();
257
    ipc_init();
258
 
258
 
Line 321... Line 321...
321
     * If we woke kmp up before we left the kernel stack, we could
321
     * If we woke kmp up before we left the kernel stack, we could
322
     * collide with another CPU coming up. To prevent this, we
322
     * collide with another CPU coming up. To prevent this, we
323
     * switch to this cpu's private stack prior to waking kmp up.
323
     * switch to this cpu's private stack prior to waking kmp up.
324
     */
324
     */
325
    context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
325
    context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
326
        (uintptr_t) CPU->stack, CPU_STACK_SIZE);
326
        (uintptr_t) CPU->stack, CPU_STACK_SIZE);
327
    context_restore(&CPU->saved_context);
327
    context_restore(&CPU->saved_context);
328
    /* not reached */
328
    /* not reached */
329
}
329
}
330
 
330
 
331
 
331