Subversion Repositories HelenOS

Rev

Rev 3787 | Rev 3983 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3787 Rev 3896
Line 48... Line 48...
48
#include <unistd.h>
48
#include <unistd.h>
49
#include <bool.h>
49
#include <bool.h>
50
#include <fcntl.h>
50
#include <fcntl.h>
51
#include <sys/types.h>
51
#include <sys/types.h>
52
#include <ipc/ipc.h>
52
#include <ipc/ipc.h>
-
 
53
#include <ipc/services.h>
53
#include <ipc/loader.h>
54
#include <ipc/loader.h>
54
#include <loader/pcb.h>
55
#include <loader/pcb.h>
55
#include <errno.h>
56
#include <errno.h>
56
#include <async.h>
57
#include <async.h>
57
#include <as.h>
58
#include <as.h>
Line 77... Line 78...
77
static elf_info_t prog_info;
78
static elf_info_t prog_info;
78
static elf_info_t interp_info;
79
static elf_info_t interp_info;
79
 
80
 
80
static bool is_dyn_linked;
81
static bool is_dyn_linked;
81
 
82
 
-
 
83
/** Used to limit number of connections to one. */
-
 
84
static bool connected;
82
 
85
 
83
static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
86
static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
84
{
87
{
85
    ipc_callid_t callid;
88
    ipc_callid_t callid;
86
    task_id_t task_id;
89
    task_id_t task_id;
Line 295... Line 298...
295
{
298
{
296
    ipc_callid_t callid;
299
    ipc_callid_t callid;
297
    ipc_call_t call;
300
    ipc_call_t call;
298
    int retval;
301
    int retval;
299
 
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);
-
 
313
 
300
    /* Ignore parameters, the connection is already open */
314
    /* Ignore parameters, the connection is already open */
301
    (void)iid; (void)icall;
315
    (void)iid; (void)icall;
302
 
316
 
303
    while (1) {
317
    while (1) {
304
        callid = async_get_call(&call);
318
        callid = async_get_call(&call);
Line 336... Line 350...
336
 
350
 
337
/** Program loader main function.
351
/** Program loader main function.
338
 */
352
 */
339
int main(int argc, char *argv[])
353
int main(int argc, char *argv[])
340
{
354
{
341
    ipc_callid_t callid;
-
 
342
    ipc_call_t call;
-
 
343
    ipcarg_t phone_hash;
355
    ipcarg_t phonead;
344
 
-
 
345
    /* The first call only communicates the incoming phone hash */
-
 
346
    callid = ipc_wait_for_call(&call);
-
 
347
 
356
 
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;
357
    connected = false;
352
    }
358
   
353
 
-
 
354
    ipc_answer_0(callid, EOK);
359
    /* Set a handler of incomming connections. */
355
    phone_hash = call.in_phone_hash;
360
    async_set_client_connection(loader_connection);
356
 
361
 
357
    /*
-
 
358
     * Up until now async must not be used as it couldn't
362
    /* Register at naming service. */
359
     * handle incoming requests. (Which means e.g. printf()
363
    if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)
360
     * cannot be used)
364
        return -1;
361
     */
365
   
362
    async_new_connection(phone_hash, 0, NULL, loader_connection);
-
 
363
    async_manager();
366
    async_manager();
364
 
367
 
365
    /* not reached */
368
    /* Never reached */
366
    return 0;
369
    return 0;
367
}
370
}
368
 
371
 
369
/** @}
372
/** @}
370
 */
373
 */