Ignore:
File:
1 edited

Legend:

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

    r221c9ec ra4e23f8c  
    6969#include <str.h>
    7070#include <sysinfo/stats.h>
     71#include <sysinfo/sysinfo.h>
    7172#include <align.h>
    7273
     
    116117                 * Just a beautification.
    117118                 */
    118                 thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
     119                thread = thread_create(kmp, NULL, TASK,
     120                    THREAD_FLAG_UNCOUNTED, "kmp");
    119121                if (thread != NULL) {
    120                         irq_spinlock_lock(&thread->lock, false);
    121                         thread->cpu = &cpus[0];
    122                         irq_spinlock_unlock(&thread->lock, false);
     122                        thread_wire(thread, &cpus[0]);
    123123                        thread_ready(thread);
    124124                } else
     
    134134               
    135135                for (i = 0; i < config.cpu_count; i++) {
    136                         thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
     136                        thread = thread_create(kcpulb, NULL, TASK,
     137                            THREAD_FLAG_UNCOUNTED, "kcpulb");
    137138                        if (thread != NULL) {
    138                                 irq_spinlock_lock(&thread->lock, false);
    139                                 thread->cpu = &cpus[i];
    140                                 irq_spinlock_unlock(&thread->lock, false);
     139                                thread_wire(thread, &cpus[i]);
    141140                                thread_ready(thread);
    142141                        } else
     
    152151       
    153152        /* Start thread computing system load */
    154         thread = thread_create(kload, NULL, TASK, 0, "kload", false);
     153        thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
     154            "kload");
    155155        if (thread != NULL)
    156156                thread_ready(thread);
     
    163163                 * Create kernel console.
    164164                 */
    165                 thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false);
     165                thread = thread_create(kconsole_thread, NULL, TASK,
     166                    THREAD_FLAG_NONE, "kconsole");
    166167                if (thread != NULL)
    167168                        thread_ready(thread);
     
    171172#endif /* CONFIG_KCONSOLE */
    172173       
     174        /*
     175         * Store the default stack size in sysinfo so that uspace can create
     176         * stack with this default size.
     177         */
     178        sysinfo_set_item_val("default.stack_size", NULL, STACK_SIZE_USER);
     179       
    173180        interrupts_enable();
    174181       
     
    179186        program_t programs[CONFIG_INIT_TASKS];
    180187       
     188        // FIXME: do not propagate arguments through sysinfo
     189        // but pass them directly to the tasks
     190        for (i = 0; i < init.cnt; i++) {
     191                const char *arguments = init.tasks[i].arguments;
     192                if (str_length(arguments) == 0)
     193                        continue;
     194                if (str_length(init.tasks[i].name) == 0)
     195                        continue;
     196                size_t arguments_size = str_size(arguments);
     197
     198                void *arguments_copy = malloc(arguments_size, 0);
     199                if (arguments_copy == NULL)
     200                        continue;
     201                memcpy(arguments_copy, arguments, arguments_size);
     202
     203                char item_name[CONFIG_TASK_NAME_BUFLEN + 15];
     204                snprintf(item_name, CONFIG_TASK_NAME_BUFLEN + 15,
     205                    "init_args.%s", init.tasks[i].name);
     206
     207                sysinfo_set_item_data(item_name, NULL, arguments_copy, arguments_size);
     208        }
     209
    181210        for (i = 0; i < init.cnt; i++) {
    182211                if (init.tasks[i].paddr % FRAME_SIZE) {
     
    201230                str_cpy(namebuf + INIT_PREFIX_LEN,
    202231                    TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name);
    203 
     232               
    204233                /*
    205234                 * Create virtual memory mappings for init task images.
     
    221250                                    CAP_IO_MANAGER | CAP_IRQ_REG);
    222251                               
    223                                 if (!ipc_phone_0)
     252                                if (!ipc_phone_0) {
    224253                                        ipc_phone_0 = &programs[i].task->answerbox;
     254                                        /*
     255                                         * Hold the first task so that the
     256                                         * ipc_phone_0 remains a valid pointer
     257                                         * even if the first task exits for
     258                                         * whatever reason.
     259                                         */
     260                                        task_hold(programs[i].task);
     261                                }
    225262                        }
    226263                       
     
    236273                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    237274                } else
    238                         printf("init[%zu]: Init binary load failed (error %d)\n", i, rc);
     275                        printf("init[%zu]: Init binary load failed "
     276                            "(error %d, loader status %u)\n", i, rc,
     277                            programs[i].loader_status);
    239278        }
    240279       
Note: See TracChangeset for help on using the changeset viewer.