Ignore:
File:
1 edited

Legend:

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

    rbdca26a r74cb6610  
    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);
     110                semaphore_initialize(&ap_completion_semaphore, 0);
    114111
    115112                /*
     
    125122
    126123                thread_wire(thread, &cpus[0]);
    127                 thread_ready(thread);
     124                thread_start(thread);
    128125                thread_join(thread);
    129                 thread_detach(thread);
    130126
    131127                /*
     
    139135                        if (thread != NULL) {
    140136                                thread_wire(thread, &cpus[i]);
    141                                 thread_ready(thread);
     137                                thread_start(thread);
     138                                thread_detach(thread);
    142139                        } else
    143140                                log(LF_OTHER, LVL_ERROR,
     
    155152        thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
    156153            "kload");
    157         if (thread != NULL)
    158                 thread_ready(thread);
    159         else
     154        if (thread != NULL) {
     155                thread_start(thread);
     156                thread_detach(thread);
     157        } else {
    160158                log(LF_OTHER, LVL_ERROR, "Unable to create kload thread");
     159        }
    161160
    162161#ifdef CONFIG_KCONSOLE
     
    167166                thread = thread_create(kconsole_thread, NULL, TASK,
    168167                    THREAD_FLAG_NONE, "kconsole");
    169                 if (thread != NULL)
    170                         thread_ready(thread);
    171                 else
     168                if (thread != NULL) {
     169                        thread_start(thread);
     170                        thread_detach(thread);
     171                } else {
    172172                        log(LF_OTHER, LVL_ERROR,
    173173                            "Unable to create kconsole thread");
     174                }
    174175        }
    175176#endif /* CONFIG_KCONSOLE */
     
    187188         */
    188189        size_t i;
    189         program_t programs[CONFIG_INIT_TASKS];
     190        program_t programs[CONFIG_INIT_TASKS] = { };
    190191
    191192        // FIXME: do not propagate arguments through sysinfo
     
    242243                    PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    243244                assert(page);
     245
     246                if (str_cmp(name, "kernel.dbg") == 0) {
     247                        /*
     248                         * Not an actual init task, but rather debug sections extracted
     249                         * from the kernel ELF file and handed to us here so we can use
     250                         * it for debugging.
     251                         */
     252
     253                        register_debug_data((void *) page, init.tasks[i].size);
     254                        programs[i].task = NULL;
     255                        continue;
     256                }
    244257
    245258                if (str_cmp(name, "loader") == 0) {
     
    259272                }
    260273
    261                 errno_t rc = program_create_from_image((void *) page, namebuf,
     274                errno_t rc = program_create_from_image((void *) page, init.tasks[i].size, namebuf,
    262275                    &programs[i]);
    263276
     
    300313         */
    301314        for (i = 0; i < init.cnt; i++) {
    302                 if (programs[i].task != NULL)
     315                if (programs[i].task != NULL) {
    303316                        program_ready(&programs[i]);
     317                        task_release(programs[i].task);
     318                }
    304319        }
    305320
Note: See TracChangeset for help on using the changeset viewer.