Subversion Repositories HelenOS

Rev

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

Rev 3153 Rev 3191
Line 129... Line 129...
129
 
129
 
130
#define CONFIG_STACK_SIZE   ((1 << STACK_FRAMES) * STACK_SIZE)
130
#define CONFIG_STACK_SIZE   ((1 << STACK_FRAMES) * STACK_SIZE)
131
 
131
 
132
/** Main kernel routine for bootstrap CPU.
132
/** Main kernel routine for bootstrap CPU.
133
 *
133
 *
134
 * Initializes the kernel by bootstrap CPU.
134
 * The code here still runs on the boot stack, which knows nothing about
135
 * This function passes control directly to
135
 * preemption counts.  Because of that, this function cannot directly call
-
 
136
 * functions that disable or enable preemption (e.g. spinlock_lock()). The
-
 
137
 * primary task of this function is to calculate address of a new stack and
136
 * main_bsp_separated_stack().
138
 * switch to it.
137
 *
139
 *
138
 * Assuming interrupts_disable().
140
 * Assuming interrupts_disable().
139
 *
141
 *
140
 */
142
 */
141
void main_bsp(void)
143
void main_bsp(void)
142
{
144
{
143
    LOG();
-
 
144
   
-
 
145
    config.cpu_count = 1;
145
    config.cpu_count = 1;
146
    config.cpu_active = 1;
146
    config.cpu_active = 1;
147
   
147
   
148
    config.base = hardcoded_load_address;
148
    config.base = hardcoded_load_address;
149
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
149
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
Line 171... Line 171...
171
    }
171
    }
172
   
172
   
173
    if (config.stack_base < stack_safe)
173
    if (config.stack_base < stack_safe)
174
        config.stack_base = ALIGN_UP(stack_safe, PAGE_SIZE);
174
        config.stack_base = ALIGN_UP(stack_safe, PAGE_SIZE);
175
   
175
   
176
    version_print();
-
 
177
   
-
 
178
    LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
-
 
179
        "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
-
 
180
        config.base, config.kernel_size,
-
 
181
        config.stack_base, config.stack_size);
-
 
182
   
-
 
183
    context_save(&ctx);
176
    context_save(&ctx);
184
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
177
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
185
        THREAD_STACK_SIZE);
178
        THREAD_STACK_SIZE);
186
    context_restore(&ctx);
179
    context_restore(&ctx);
187
    /* not reached */
180
    /* not reached */
Line 193... Line 186...
193
 * Second part of main_bsp().
186
 * Second part of main_bsp().
194
 *
187
 *
195
 */
188
 */
196
void main_bsp_separated_stack(void)
189
void main_bsp_separated_stack(void)
197
{
190
{
-
 
191
    /* Keep this the first thing. */
-
 
192
    the_initialize(THE);
-
 
193
 
198
    LOG();
194
    LOG();
199
   
195
   
200
    the_initialize(THE);
196
    version_print();
-
 
197
   
-
 
198
    LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
-
 
199
        "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
-
 
200
        config.base, config.kernel_size, config.stack_base,
-
 
201
        config.stack_size);
-
 
202
   
201
 
203
 
202
    /*
204
    /*
203
     * kconsole data structures must be initialized very early
205
     * kconsole data structures must be initialized very early
204
     * because other subsystems will register their respective
206
     * because other subsystems will register their respective
205
     * commands.
207
     * commands.
Line 247... Line 249...
247
    LOG_EXEC(futex_init());
249
    LOG_EXEC(futex_init());
248
   
250
   
249
    if (init.cnt > 0) {
251
    if (init.cnt > 0) {
250
        count_t i;
252
        count_t i;
251
        for (i = 0; i < init.cnt; i++)
253
        for (i = 0; i < init.cnt; i++)
252
            printf("init[%" PRIc "].addr=%#" PRIp
254
            printf("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc
253
                ", init[%" PRIc "].size=%#" PRIs "\n",
-
 
254
                i, init.tasks[i].addr,
255
                "].size=%#" PRIs "\n", i, init.tasks[i].addr,
255
                i, init.tasks[i].size);
256
                i, init.tasks[i].size);
256
    } else
257
    } else
257
        printf("No init binaries found\n");
258
        printf("No init binaries found\n");
258
   
259
   
259
    LOG_EXEC(ipc_init());
260
    LOG_EXEC(ipc_init());
260
    LOG_EXEC(klog_init());
261
    LOG_EXEC(klog_init());
Line 267... Line 268...
267
        panic("Can't create kernel task\n");
268
        panic("Can't create kernel task\n");
268
   
269
   
269
    /*
270
    /*
270
     * Create the first thread.
271
     * Create the first thread.
271
     */
272
     */
272
    thread_t *kinit_thread = thread_create(kinit, NULL, kernel, 0, "kinit", true);
273
    thread_t *kinit_thread = thread_create(kinit, NULL, kernel, 0, "kinit",
-
 
274
        true);
273
    if (!kinit_thread)
275
    if (!kinit_thread)
274
        panic("Can't create kinit thread\n");
276
        panic("Can't create kinit thread\n");
275
    LOG_EXEC(thread_ready(kinit_thread));
277
    LOG_EXEC(thread_ready(kinit_thread));
276
   
278
   
277
    /*
279
    /*