Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/main/kinit.c

    rbdca26a ra78b0a0  
    6161#include <stdio.h>
    6262#include <log.h>
    63 #include <mem.h>
     63#include <memw.h>
    6464#include <console/console.h>
    6565#include <interrupt.h>
     
    6969#include <ipc/ipc.h>
    7070#include <str.h>
     71#include <str_error.h>
    7172#include <sysinfo/stats.h>
    7273#include <sysinfo/sysinfo.h>
    7374#include <align.h>
    7475#include <stdlib.h>
     76#include <debug/register.h>
    7577
    7678#ifdef CONFIG_SMP
     
    102104        thread_t *thread;
    103105
    104         /*
    105          * Detach kinit as nobody will call thread_join_timeout() on it.
    106          */
    107         thread_detach(THREAD);
    108 
    109106        interrupts_disable();
    110107
    111108#ifdef CONFIG_SMP
    112109        if (config.cpu_count > 1) {
    113                 waitq_initialize(&ap_completion_wq);
    114 
    115110                /*
    116111                 * Create the kmp thread and wait for its completion.
     
    125120
    126121                thread_wire(thread, &cpus[0]);
    127                 thread_ready(thread);
     122                thread_start(thread);
    128123                thread_join(thread);
    129                 thread_detach(thread);
    130124
    131125                /*
     
    139133                        if (thread != NULL) {
    140134                                thread_wire(thread, &cpus[i]);
    141                                 thread_ready(thread);
     135                                thread_start(thread);
     136                                thread_detach(thread);
    142137                        } else
    143138                                log(LF_OTHER, LVL_ERROR,
     
    155150        thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
    156151            "kload");
    157         if (thread != NULL)
    158                 thread_ready(thread);
    159         else
     152        if (thread != NULL) {
     153                thread_start(thread);
     154                thread_detach(thread);
     155        } else {
    160156                log(LF_OTHER, LVL_ERROR, "Unable to create kload thread");
     157        }
    161158
    162159#ifdef CONFIG_KCONSOLE
     
    167164                thread = thread_create(kconsole_thread, NULL, TASK,
    168165                    THREAD_FLAG_NONE, "kconsole");
    169                 if (thread != NULL)
    170                         thread_ready(thread);
    171                 else
     166                if (thread != NULL) {
     167                        thread_start(thread);
     168                        thread_detach(thread);
     169                } else {
    172170                        log(LF_OTHER, LVL_ERROR,
    173171                            "Unable to create kconsole thread");
     172                }
    174173        }
    175174#endif /* CONFIG_KCONSOLE */
     
    187186         */
    188187        size_t i;
    189         program_t programs[CONFIG_INIT_TASKS];
     188        program_t programs[CONFIG_INIT_TASKS] = { };
    190189
    191190        // FIXME: do not propagate arguments through sysinfo
     
    242241                    PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    243242                assert(page);
     243
     244                if (str_cmp(name, "kernel.dbg") == 0) {
     245                        /*
     246                         * Not an actual init task, but rather debug sections extracted
     247                         * from the kernel ELF file and handed to us here so we can use
     248                         * it for debugging.
     249                         */
     250
     251                        register_debug_data((void *) page, init.tasks[i].size);
     252                        programs[i].task = NULL;
     253                        continue;
     254                }
    244255
    245256                if (str_cmp(name, "loader") == 0) {
     
    259270                }
    260271
    261                 errno_t rc = program_create_from_image((void *) page, namebuf,
     272                errno_t rc = program_create_from_image((void *) page, init.tasks[i].size, namebuf,
    262273                    &programs[i]);
    263274
     
    283294                        }
    284295
    285                 } else if (i == init.cnt - 1) {
    286                         /*
    287                          * Assume the last task is the RAM disk.
    288                          */
     296                } else if (str_cmp(name, "initrd.img") == 0) {
    289297                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    290298                } else {
     
    300308         */
    301309        for (i = 0; i < init.cnt; i++) {
    302                 if (programs[i].task != NULL)
     310                if (programs[i].task != NULL) {
    303311                        program_ready(&programs[i]);
     312                        task_release(programs[i].task);
     313                }
    304314        }
    305315
Note: See TracChangeset for help on using the changeset viewer.