Subversion Repositories HelenOS

Rev

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

Rev 3597 Rev 4377
Line 30... Line 30...
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file
34
 * @file
35
 * @brief   Main initialization kernel function for all processors.
35
 * @brief Main initialization kernel function for all processors.
36
 *
36
 *
37
 * During kernel boot, all processors, after architecture dependent
37
 * During kernel boot, all processors, after architecture dependent
38
 * initialization, start executing code found in this file. After
38
 * initialization, start executing code found in this file. After
39
 * bringing up all subsystems, control is passed to scheduler().
39
 * bringing up all subsystems, control is passed to scheduler().
40
 *
40
 *
Line 79... Line 79...
79
#include <ipc/ipc.h>
79
#include <ipc/ipc.h>
80
#include <macros.h>
80
#include <macros.h>
81
#include <adt/btree.h>
81
#include <adt/btree.h>
82
#include <smp/smp.h>
82
#include <smp/smp.h>
83
#include <ddi/ddi.h>
83
#include <ddi/ddi.h>
84
 
-
 
-
 
84
#include <main/main.h>
-
 
85
#include <ipc/event.h>
85
 
86
 
86
/** Global configuration structure. */
87
/** Global configuration structure. */
87
config_t config;
88
config_t config;
88
 
89
 
89
/** Initial user-space tasks */
90
/** Initial user-space tasks */
Line 103... Line 104...
103
 * These 'hardcoded' variables will be intialized by
104
 * These 'hardcoded' variables will be intialized by
104
 * the linker or the low level assembler code with
105
 * the linker or the low level assembler code with
105
 * appropriate sizes and addresses.
106
 * appropriate sizes and addresses.
106
 */
107
 */
107
 
108
 
108
/**< Virtual address of where the kernel is loaded. */
109
/** Virtual address of where the kernel is loaded. */
109
uintptr_t hardcoded_load_address = 0;
110
uintptr_t hardcoded_load_address = 0;
110
/**< Size of the kernel code in bytes. */
111
/** Size of the kernel code in bytes. */
111
size_t hardcoded_ktext_size = 0;
112
size_t hardcoded_ktext_size = 0;
112
/**< Size of the kernel data in bytes. */
113
/** Size of the kernel data in bytes. */
113
size_t hardcoded_kdata_size = 0;
114
size_t hardcoded_kdata_size = 0;
114
/**< Lowest safe stack virtual address. */
115
/** Lowest safe stack virtual address. */
115
uintptr_t stack_safe = 0;      
116
uintptr_t stack_safe = 0;      
116
 
117
 
117
void main_bsp(void);
-
 
118
void main_ap(void);
-
 
119
 
-
 
120
/*
118
/*
121
 * These two functions prevent stack from underflowing during the
119
 * These two functions prevent stack from underflowing during the
122
 * kernel boot phase when SP is set to the very top of the reserved
120
 * kernel boot phase when SP is set to the very top of the reserved
123
 * space. The stack could get corrupted by a fooled compiler-generated
121
 * space. The stack could get corrupted by a fooled compiler-generated
124
 * pop sequence otherwise.
122
 * pop sequence otherwise.
Line 189... Line 187...
189
 */
187
 */
190
void main_bsp_separated_stack(void)
188
void main_bsp_separated_stack(void)
191
{
189
{
192
    /* Keep this the first thing. */
190
    /* Keep this the first thing. */
193
    the_initialize(THE);
191
    the_initialize(THE);
194
 
-
 
195
    LOG();
-
 
196
   
192
   
197
    version_print();
193
    version_print();
198
   
194
   
199
    LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
195
    LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
200
        "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
196
        "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
201
        config.base, config.kernel_size, config.stack_base,
197
        config.base, config.kernel_size, config.stack_base,
202
        config.stack_size);
198
        config.stack_size);
203
   
199
   
204
 
-
 
-
 
200
#ifdef CONFIG_KCONSOLE
205
    /*
201
    /*
206
     * kconsole data structures must be initialized very early
202
     * kconsole data structures must be initialized very early
207
     * because other subsystems will register their respective
203
     * because other subsystems will register their respective
208
     * commands.
204
     * commands.
209
     */
205
     */
210
    LOG_EXEC(kconsole_init());
206
    LOG_EXEC(kconsole_init());
-
 
207
#endif
211
   
208
   
212
    /*
209
    /*
213
     * Exception handler initialization, before architecture
210
     * Exception handler initialization, before architecture
214
     * starts adding its own handlers
211
     * starts adding its own handlers
215
     */
212
     */
216
    LOG_EXEC(exc_init());
213
    LOG_EXEC(exc_init());
217
 
214
   
218
    /*
215
    /*
219
     * Memory management subsystems initialization.
216
     * Memory management subsystems initialization.
220
     */
217
     */
221
    LOG_EXEC(arch_pre_mm_init());
218
    LOG_EXEC(arch_pre_mm_init());
222
    LOG_EXEC(frame_init());
219
    LOG_EXEC(frame_init());
Line 250... Line 247...
250
    LOG_EXEC(futex_init());
247
    LOG_EXEC(futex_init());
251
   
248
   
252
    if (init.cnt > 0) {
249
    if (init.cnt > 0) {
253
        count_t i;
250
        count_t i;
254
        for (i = 0; i < init.cnt; i++)
251
        for (i = 0; i < init.cnt; i++)
255
            printf("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc
252
            LOG("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc
256
                "].size=%#" PRIs "\n", i, init.tasks[i].addr, i,
253
                "].size=%#" PRIs "\n", i, init.tasks[i].addr, i,
257
                init.tasks[i].size);
254
                init.tasks[i].size);
258
    } else
255
    } else
259
        printf("No init binaries found\n");
256
        printf("No init binaries found\n");
260
   
257
   
261
    LOG_EXEC(ipc_init());
258
    LOG_EXEC(ipc_init());
-
 
259
    LOG_EXEC(event_init());
262
    LOG_EXEC(klog_init());
260
    LOG_EXEC(klog_init());
263
 
261
   
264
    /*
262
    /*
265
     * Create kernel task.
263
     * Create kernel task.
266
     */
264
     */
267
    task_t *kernel = task_create(AS_KERNEL, "kernel");
265
    task_t *kernel = task_create(AS_KERNEL, "kernel");
268
    if (!kernel)
266
    if (!kernel)
269
        panic("Can't create kernel task\n");
267
        panic("Cannot create kernel task.");
270
   
268
   
271
    /*
269
    /*
272
     * Create the first thread.
270
     * Create the first thread.
273
     */
271
     */
-
 
272
    thread_t *kinit_thread
274
    thread_t *kinit_thread = thread_create(kinit, NULL, kernel, 0, "kinit",
273
        = thread_create(kinit, NULL, kernel, 0, "kinit", true);
275
        true);
-
 
276
    if (!kinit_thread)
274
    if (!kinit_thread)
277
        panic("Can't create kinit thread\n");
275
        panic("Cannot create kinit thread.");
278
    LOG_EXEC(thread_ready(kinit_thread));
276
    LOG_EXEC(thread_ready(kinit_thread));
279
   
277
   
280
    /*
278
    /*
281
     * This call to scheduler() will return to kinit,
279
     * This call to scheduler() will return to kinit,
282
     * starting the thread of kernel threads.
280
     * starting the thread of kernel threads.