Ignore:
File:
1 edited

Legend:

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

    r6eef3c4 r7e752b2  
    5757#include <mm/as.h>
    5858#include <mm/frame.h>
    59 #include <mm/km.h>
    6059#include <print.h>
    6160#include <memstr.h>
     
    6968#include <str.h>
    7069#include <sysinfo/stats.h>
    71 #include <align.h>
    7270
    7371#ifdef CONFIG_SMP
     
    116114                 * Just a beautification.
    117115                 */
    118                 thread = thread_create(kmp, NULL, TASK,
    119                     THREAD_FLAG_UNCOUNTED, "kmp");
     116                thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
    120117                if (thread != NULL) {
    121                         thread_wire(thread, &cpus[0]);
     118                        irq_spinlock_lock(&thread->lock, false);
     119                        thread->cpu = &cpus[0];
     120                        irq_spinlock_unlock(&thread->lock, false);
    122121                        thread_ready(thread);
    123122                } else
     
    133132               
    134133                for (i = 0; i < config.cpu_count; i++) {
    135                         thread = thread_create(kcpulb, NULL, TASK,
    136                             THREAD_FLAG_UNCOUNTED, "kcpulb");
     134                        thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
    137135                        if (thread != NULL) {
    138                                 thread_wire(thread, &cpus[i]);
     136                                irq_spinlock_lock(&thread->lock, false);
     137                                thread->cpu = &cpus[i];
     138                                irq_spinlock_unlock(&thread->lock, false);
    139139                                thread_ready(thread);
    140140                        } else
     
    150150       
    151151        /* Start thread computing system load */
    152         thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
    153             "kload");
     152        thread = thread_create(kload, NULL, TASK, 0, "kload", false);
    154153        if (thread != NULL)
    155154                thread_ready(thread);
     
    162161                 * Create kernel console.
    163162                 */
    164                 thread = thread_create(kconsole_thread, NULL, TASK,
    165                     THREAD_FLAG_NONE, "kconsole");
     163                thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false);
    166164                if (thread != NULL)
    167165                        thread_ready(thread);
     
    180178       
    181179        for (i = 0; i < init.cnt; i++) {
    182                 if (init.tasks[i].paddr % FRAME_SIZE) {
    183                         printf("init[%zu]: Address is not frame aligned\n", i);
     180                if (init.tasks[i].addr % FRAME_SIZE) {
     181                        printf("init[%zu].addr is not frame aligned\n", i);
    184182                        programs[i].task = NULL;
    185183                        continue;
     
    202200                    TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name);
    203201               
    204                 /*
    205                  * Create virtual memory mappings for init task images.
    206                  */
    207                 uintptr_t page = km_map(init.tasks[i].paddr,
    208                     init.tasks[i].size,
    209                     PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    210                 ASSERT(page);
    211                
    212                 int rc = program_create_from_image((void *) page, namebuf,
    213                     &programs[i]);
    214                
    215                 if (rc == 0) {
    216                         if (programs[i].task != NULL) {
    217                                 /*
    218                                  * Set capabilities to init userspace tasks.
    219                                  */
    220                                 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
    221                                     CAP_IO_MANAGER | CAP_IRQ_REG);
    222                                
    223                                 if (!ipc_phone_0)
    224                                         ipc_phone_0 = &programs[i].task->answerbox;
    225                         }
     202                int rc = program_create_from_image((void *) init.tasks[i].addr,
     203                    namebuf, &programs[i]);
     204               
     205                if ((rc == 0) && (programs[i].task != NULL)) {
     206                        /*
     207                         * Set capabilities to init userspace tasks.
     208                         */
     209                        cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
     210                            CAP_IO_MANAGER | CAP_IRQ_REG);
    226211                       
    227                         /*
    228                          * If programs[i].task == NULL then it is
    229                          * the program loader and it was registered
    230                          * successfully.
    231                          */
    232                 } else if (i == init.cnt - 1) {
    233                         /*
    234                          * Assume the last task is the RAM disk.
    235                          */
    236                         init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    237                 } else
    238                         printf("init[%zu]: Init binary load failed "
    239                             "(error %d, loader status %u)\n", i, rc,
    240                             programs[i].loader_status);
     212                        if (!ipc_phone_0)
     213                                ipc_phone_0 = &programs[i].task->answerbox;
     214                } else if (rc == 0) {
     215                        /* It was the program loader and was registered */
     216                } else {
     217                        /* RAM disk image */
     218                        int rd = init_rd((rd_header_t *) init.tasks[i].addr, init.tasks[i].size);
     219                       
     220                        if (rd != RE_OK)
     221                                printf("Init binary %zu not used (error %d)\n", i, rd);
     222                }
    241223        }
    242224       
Note: See TracChangeset for help on using the changeset viewer.