Changeset 57d44dd in mainline for kernel/generic/src/main/kinit.c


Ignore:
Timestamp:
2018-04-10T18:51:14Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20287223
Parents:
e3f819f
Message:

Instead of using .interp section, determine loader by name.

File:
1 edited

Legend:

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

    re3f819f r57d44dd  
    253253                assert(page);
    254254
     255                if (str_cmp(name, "loader") == 0) {
     256                        /* Register image as the program loader */
     257                        if (program_loader == NULL) {
     258                                program_loader = (void *) page;
     259                                log(LF_OTHER, LVL_NOTE, "Program loader at %p",
     260                                    program_loader);
     261                        } else {
     262                                log(LF_OTHER, LVL_ERROR,
     263                                    "init[%zu]: Second binary named \"loader\""
     264                                    " present.", i);
     265                        }
     266                        continue;
     267                }
     268
    255269                errno_t rc = program_create_from_image((void *) page, namebuf,
    256270                    &programs[i]);
    257271
    258272                if (rc == 0) {
    259                         if (programs[i].task != NULL) {
     273                        assert(programs[i].task != NULL);
     274
     275                        /*
     276                         * Set permissions to init userspace tasks.
     277                         */
     278                        perm_set(programs[i].task,
     279                            PERM_PERM | PERM_MEM_MANAGER |
     280                            PERM_IO_MANAGER | PERM_IRQ_REG);
     281
     282                        if (!ipc_box_0) {
     283                                ipc_box_0 = &programs[i].task->answerbox;
    260284                                /*
    261                                  * Set permissions to init userspace tasks.
     285                                 * Hold the first task so that
     286                                 * ipc_box_0 remains a valid pointer
     287                                 * even if the first task exits for
     288                                 * whatever reason.
    262289                                 */
    263                                 perm_set(programs[i].task,
    264                                     PERM_PERM | PERM_MEM_MANAGER |
    265                                     PERM_IO_MANAGER | PERM_IRQ_REG);
    266 
    267                                 if (!ipc_box_0) {
    268                                         ipc_box_0 = &programs[i].task->answerbox;
    269                                         /*
    270                                          * Hold the first task so that
    271                                          * ipc_box_0 remains a valid pointer
    272                                          * even if the first task exits for
    273                                          * whatever reason.
    274                                          */
    275                                         task_hold(programs[i].task);
    276                                 }
     290                                task_hold(programs[i].task);
    277291                        }
    278292
    279                         /*
    280                          * If programs[i].task == NULL then it is
    281                          * the program loader and it was registered
    282                          * successfully.
    283                          */
    284293                } else if (i == init.cnt - 1) {
    285294                        /*
     
    287296                         */
    288297                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    289                 } else
     298                } else {
    290299                        log(LF_OTHER, LVL_ERROR,
    291300                            "init[%zu]: Init binary load failed "
    292301                            "(error %s, loader status %u)", i,
    293302                            str_error_name(rc), programs[i].loader_status);
     303                }
    294304        }
    295305
Note: See TracChangeset for help on using the changeset viewer.