Changeset 4470e26 in mainline for uspace/srv/loader/main.c


Ignore:
Timestamp:
2008-09-24T10:57:21Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0993087
Parents:
45454e9b
Message:

Separate load and run commands for loader. Update tracer - no events get missed on startup anymore.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/main.c

    r45454e9b r4470e26  
    4747#include <stdlib.h>
    4848#include <unistd.h>
     49#include <bool.h>
    4950#include <fcntl.h>
    5051#include <sys/types.h>
     
    7879static char *arg_buf = NULL;
    7980
    80 static int loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     81static elf_info_t prog_info;
     82static elf_info_t interp_info;
     83
     84static bool is_dyn_linked;
     85
     86
     87static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
    8188{
    8289        ipc_callid_t callid;
     
    213220}
    214221
    215 
    216 /** Load and run the previously selected program.
     222/** Load the previously selected program.
    217223 *
    218224 * @param rid
     
    220226 * @return 0 on success, !0 on error.
    221227 */
    222 static int loader_run(ipc_callid_t rid, ipc_call_t *request)
     228static int loader_load(ipc_callid_t rid, ipc_call_t *request)
    223229{
    224230        int rc;
    225 
    226         elf_info_t prog_info;
    227         elf_info_t interp_info;
    228231
    229232//      printf("Load program '%s'\n", pathname);
     
    246249//              printf("Run statically linked program\n");
    247250//              printf("entry point: 0x%llx\n", prog_info.entry);
     251                is_dyn_linked = false;
    248252                ipc_answer_0(rid, EOK);
    249                 close_console();
    250                 elf_run(&prog_info, &pcb);
    251253                return 0;
    252254        }
     
    266268        pcb.rtld_bias = RTLD_BIAS;
    267269
    268         printf("run dynamic linker\n");
    269         printf("entry point: 0x%llx\n", interp_info.entry);
    270         close_console();
    271 
     270        is_dyn_linked = true;
    272271        ipc_answer_0(rid, EOK);
    273         elf_run(&interp_info, &pcb);
     272
     273        return 0;
     274}
     275
     276
     277/** Run the previously loaded program.
     278 *
     279 * @param rid
     280 * @param request
     281 * @return 0 on success, !0 on error.
     282 */
     283static void loader_run(ipc_callid_t rid, ipc_call_t *request)
     284{
     285        if (is_dyn_linked == true) {
     286                /* Dynamically linked program */
     287                printf("run dynamic linker\n");
     288                printf("entry point: 0x%llx\n", interp_info.entry);
     289                close_console();
     290
     291                ipc_answer_0(rid, EOK);
     292                elf_run(&interp_info, &pcb);
     293
     294        } else {
     295                /* Statically linked program */
     296                close_console();
     297                ipc_answer_0(rid, EOK);
     298                elf_run(&prog_info, &pcb);
     299        }
    274300
    275301        /* Not reached */
    276         return 0;
    277302}
    278303
     
    293318        while (1) {
    294319                callid = async_get_call(&call);
    295 //              printf("received call from phone %d, method=%d\n",
    296 //                      call.in_phone_hash, IPC_GET_METHOD(call));
     320
    297321                switch (IPC_GET_METHOD(call)) {
    298322                case LOADER_GET_TASKID:
     
    304328                case LOADER_SET_ARGS:
    305329                        loader_set_args(callid, &call);
     330                        continue;
     331                case LOADER_LOAD:
     332                        loader_load(callid, &call);
     333                        continue;
    306334                case LOADER_RUN:
    307335                        loader_run(callid, &call);
    308                         exit(0);
    309                         continue;
     336                        /* Not reached */
    310337                default:
    311338                        retval = ENOENT;
Note: See TracChangeset for help on using the changeset viewer.