Ignore:
File:
1 edited

Legend:

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

    ra78b0a0 rbdca26a  
    6161#include <stdio.h>
    6262#include <log.h>
    63 #include <memw.h>
     63#include <mem.h>
    6464#include <console/console.h>
    6565#include <interrupt.h>
     
    6969#include <ipc/ipc.h>
    7070#include <str.h>
    71 #include <str_error.h>
    7271#include <sysinfo/stats.h>
    7372#include <sysinfo/sysinfo.h>
    7473#include <align.h>
    7574#include <stdlib.h>
    76 #include <debug/register.h>
    7775
    7876#ifdef CONFIG_SMP
     
    104102        thread_t *thread;
    105103
     104        /*
     105         * Detach kinit as nobody will call thread_join_timeout() on it.
     106         */
     107        thread_detach(THREAD);
     108
    106109        interrupts_disable();
    107110
    108111#ifdef CONFIG_SMP
    109112        if (config.cpu_count > 1) {
     113                waitq_initialize(&ap_completion_wq);
     114
    110115                /*
    111116                 * Create the kmp thread and wait for its completion.
     
    120125
    121126                thread_wire(thread, &cpus[0]);
    122                 thread_start(thread);
     127                thread_ready(thread);
    123128                thread_join(thread);
     129                thread_detach(thread);
    124130
    125131                /*
     
    133139                        if (thread != NULL) {
    134140                                thread_wire(thread, &cpus[i]);
    135                                 thread_start(thread);
    136                                 thread_detach(thread);
     141                                thread_ready(thread);
    137142                        } else
    138143                                log(LF_OTHER, LVL_ERROR,
     
    150155        thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
    151156            "kload");
    152         if (thread != NULL) {
    153                 thread_start(thread);
    154                 thread_detach(thread);
    155         } else {
     157        if (thread != NULL)
     158                thread_ready(thread);
     159        else
    156160                log(LF_OTHER, LVL_ERROR, "Unable to create kload thread");
    157         }
    158161
    159162#ifdef CONFIG_KCONSOLE
     
    164167                thread = thread_create(kconsole_thread, NULL, TASK,
    165168                    THREAD_FLAG_NONE, "kconsole");
    166                 if (thread != NULL) {
    167                         thread_start(thread);
    168                         thread_detach(thread);
    169                 } else {
     169                if (thread != NULL)
     170                        thread_ready(thread);
     171                else
    170172                        log(LF_OTHER, LVL_ERROR,
    171173                            "Unable to create kconsole thread");
    172                 }
    173174        }
    174175#endif /* CONFIG_KCONSOLE */
     
    186187         */
    187188        size_t i;
    188         program_t programs[CONFIG_INIT_TASKS] = { };
     189        program_t programs[CONFIG_INIT_TASKS];
    189190
    190191        // FIXME: do not propagate arguments through sysinfo
     
    241242                    PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    242243                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                 }
    255244
    256245                if (str_cmp(name, "loader") == 0) {
     
    270259                }
    271260
    272                 errno_t rc = program_create_from_image((void *) page, init.tasks[i].size, namebuf,
     261                errno_t rc = program_create_from_image((void *) page, namebuf,
    273262                    &programs[i]);
    274263
     
    294283                        }
    295284
    296                 } else if (str_cmp(name, "initrd.img") == 0) {
     285                } else if (i == init.cnt - 1) {
     286                        /*
     287                         * Assume the last task is the RAM disk.
     288                         */
    297289                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    298290                } else {
     
    308300         */
    309301        for (i = 0; i < init.cnt; i++) {
    310                 if (programs[i].task != NULL) {
     302                if (programs[i].task != NULL)
    311303                        program_ready(&programs[i]);
    312                         task_release(programs[i].task);
    313                 }
    314304        }
    315305
Note: See TracChangeset for help on using the changeset viewer.