Subversion Repositories HelenOS

Rev

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

Rev 4337 Rev 4343
Line 32... Line 32...
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <ipc/ipc.h>
35
#include <ipc/ipc.h>
36
#include <ipc/loader.h>
36
#include <ipc/loader.h>
-
 
37
#include <ipc/services.h>
37
#include <libc.h>
38
#include <libc.h>
38
#include <task.h>
39
#include <task.h>
39
#include <string.h>
40
#include <string.h>
40
#include <stdlib.h>
41
#include <stdlib.h>
41
#include <async.h>
42
#include <async.h>
Line 48... Line 49...
48
 * Spawns a new program loader task and returns the connection structure.
49
 * Spawns a new program loader task and returns the connection structure.
49
 * @param name  Symbolic name to set on the newly created task.
50
 * @param name  Symbolic name to set on the newly created task.
50
 * @return  Pointer to the loader connection structure (should be
51
 * @return  Pointer to the loader connection structure (should be
51
 *      de-allocated using free() after use).
52
 *      de-allocated using free() after use).
52
 */
53
 */
53
loader_t *loader_spawn(const char *name)
54
int loader_spawn(const char *name)
54
{
55
{
55
    int phone_id, rc;
56
    return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER,
56
    loader_t *ldr;
57
        (sysarg_t) name, strlen(name));
-
 
58
}
57
 
59
 
58
    /*
-
 
59
     * Ask kernel to spawn a new loader task.
60
loader_t *loader_connect(void)
60
     */
61
{
61
    rc = __SYSCALL3(SYS_PROGRAM_SPAWN_LOADER, (sysarg_t) &phone_id,
-
 
62
        (sysarg_t) name, strlen(name));
-
 
63
    if (rc != 0)
62
    loader_t *ldr;
64
        return NULL;
63
    int phone_id;
65
 
64
 
66
    /*
-
 
67
     * Say hello so that the loader knows the incoming connection's
-
 
68
     * phone hash.
-
 
69
     */
-
 
70
    rc = async_req_0_0(phone_id, LOADER_HELLO);
65
    phone_id = ipc_connect_me_to(PHONE_NS, SERVICE_LOAD, 0, 0);
71
    if (rc != EOK)
66
    if (phone_id < 0)
72
        return NULL;
67
        return NULL;
73
 
68
 
74
    ldr = malloc(sizeof(loader_t));
69
    ldr = malloc(sizeof(loader_t));
75
    if (ldr == NULL)
70
    if (ldr == NULL)
76
        return NULL;
71
        return NULL;
77
 
72
 
78
    ldr->phone_id = phone_id;
73
    ldr->phone_id = phone_id;
79
    return ldr;
74
    return ldr;
80
}
75
}
81
 
76
 
82
/** Get ID of the new task.
77
/** Get ID of the new task.
83
 *
78
 *
84
 * Retrieves the ID of the new task from the loader.
79
 * Retrieves the ID of the new task from the loader.