Changeset bfd1546 in mainline for uspace/srv/loader/main.c


Ignore:
Timestamp:
2009-02-15T00:01:06Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08b777e
Parents:
4cac212c
Message:

More elegant way of invoking the loader - as a 'cloneable' service. Task names functionality lost for the time being.

File:
1 edited

Legend:

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

    r4cac212c rbfd1546  
    5151#include <sys/types.h>
    5252#include <ipc/ipc.h>
     53#include <ipc/services.h>
    5354#include <ipc/loader.h>
    5455#include <loader/pcb.h>
     
    8081static bool is_dyn_linked;
    8182
     83/** Used to limit number of connections to one. */
     84static bool connected;
    8285
    8386static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     
    297300        ipc_call_t call;
    298301        int retval;
     302
     303        /* Already have a connection? */
     304        if (connected) {
     305                ipc_answer_0(iid, ELIMIT);
     306                return;
     307        }
     308
     309        connected = true;
     310       
     311        /* Accept the connection */
     312        ipc_answer_0(iid, EOK);
    299313
    300314        /* Ignore parameters, the connection is already open */
     
    339353int main(int argc, char *argv[])
    340354{
    341         ipc_callid_t callid;
    342         ipc_call_t call;
    343         ipcarg_t phone_hash;
    344 
    345         /* The first call only communicates the incoming phone hash */
    346         callid = ipc_wait_for_call(&call);
    347 
    348         if (IPC_GET_METHOD(call) != LOADER_HELLO) {
    349                 if (IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP)
    350                         ipc_answer_0(callid, EINVAL);
    351                 return 1;
    352         }
    353 
    354         ipc_answer_0(callid, EOK);
    355         phone_hash = call.in_phone_hash;
    356 
    357         /*
    358          * Up until now async must not be used as it couldn't
    359          * handle incoming requests. (Which means e.g. printf()
    360          * cannot be used)
    361          */
    362         async_new_connection(phone_hash, 0, NULL, loader_connection);
     355        ipcarg_t phonead;
     356
     357        connected = false;
     358       
     359        /* Set a handler of incomming connections. */
     360        async_set_client_connection(loader_connection);
     361
     362        /* Register at naming service. */
     363        if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)
     364                return -1;
     365       
    363366        async_manager();
    364367
    365         /* not reached */
     368        /* Never reached */
    366369        return 0;
    367370}
Note: See TracChangeset for help on using the changeset viewer.