Rev 3102 | Rev 3150 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3102 | Rev 3148 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /* |
1 | /* |
| 2 | * Copyright (c) 2006 Jakub Jermar |
2 | * Copyright (c) 2006 Jakub Jermar |
| - | 3 | * Copyright (c) 2008 Jiri Svoboda |
|
| 3 | * All rights reserved. |
4 | * All rights reserved. |
| 4 | * |
5 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
6 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
7 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
8 | * are met: |
| Line 32... | Line 33... | ||
| 32 | /** @file |
33 | /** @file |
| 33 | */ |
34 | */ |
| 34 | 35 | ||
| 35 | #include <task.h> |
36 | #include <task.h> |
| 36 | #include <ipc/ipc.h> |
37 | #include <ipc/ipc.h> |
| - | 38 | #include <ipc/loader.h> |
|
| 37 | #include <libc.h> |
39 | #include <libc.h> |
| - | 40 | #include <string.h> |
|
| 38 | #include <async.h> |
41 | #include <async.h> |
| 39 | #include <errno.h> |
42 | #include <errno.h> |
| 40 | 43 | ||
| 41 | task_id_t task_get_id(void) |
44 | task_id_t task_get_id(void) |
| 42 | { |
45 | { |
| Line 55... | Line 58... | ||
| 55 | if (rc != 0) |
58 | if (rc != 0) |
| 56 | return rc; |
59 | return rc; |
| 57 | 60 | ||
| 58 | return phone_id; |
61 | return phone_id; |
| 59 | } |
62 | } |
| - | 63 | ||
| - | 64 | /** Create a new task by running an executable from VFS. |
|
| - | 65 | * |
|
| 60 | #include <stdio.h> |
66 | * @param path pathname of the binary to execute |
| 61 | #include <unistd.h> |
67 | * @param argv command-line arguments |
| - | 68 | * @return ID of the newly created task or zero on error. |
|
| - | 69 | */ |
|
| 62 | task_id_t task_spawn(const char *path, const char *argv[]) |
70 | task_id_t task_spawn(const char *path, const char *argv[]) |
| 63 | { |
71 | { |
| 64 | int phone_id; |
72 | int phone_id; |
| 65 | ipc_call_t answer; |
73 | ipc_call_t answer; |
| 66 | aid_t req; |
74 | aid_t req; |
| 67 | int rc; |
75 | int rc; |
| 68 | 76 | ||
| - | 77 | /* Spawn a program loader */ |
|
| 69 | phone_id = task_spawn_loader(); |
78 | phone_id = task_spawn_loader(); |
| 70 | if (phone_id < 0) return 0; |
79 | if (phone_id < 0) return 0; |
| 71 | printf("phone_id:%d\n", phone_id); |
- | |
| 72 | 80 | ||
| - | 81 | /* |
|
| - | 82 | * Say hello so that the loader knows the incoming connection's |
|
| 73 | // getchar(); |
83 | * phone hash. |
| - | 84 | */ |
|
| - | 85 | rc = async_req_0_0(phone_id, LOADER_HELLO); |
|
| - | 86 | if (rc != EOK) return 0; |
|
| 74 | 87 | ||
| - | 88 | /* Send program pathname */ |
|
| 75 | // req = async_send_0(phone_id, 1024, &answer); |
89 | req = async_send_0(phone_id, LOADER_SET_PATHNAME, &answer); |
| 76 | rc = ipc_data_write_start(phone_id, (void *)path, strlen(path)); |
90 | rc = ipc_data_write_start(phone_id, (void *)path, strlen(path)); |
| 77 | printf("->%d\n", rc); |
- | |
| 78 | if (rc != EOK) { |
91 | if (rc != EOK) { |
| 79 | // async_wait_for(req, NULL); |
92 | async_wait_for(req, NULL); |
| 80 | return 1; |
93 | return 1; |
| 81 | } |
94 | } |
| 82 | // async_wait_for(req, &rc); |
- | |
| 83 | 95 | ||
| - | 96 | async_wait_for(req, &rc); |
|
| - | 97 | if (rc != EOK) return 0; |
|
| - | 98 | ||
| - | 99 | /* Request loader to start the program */ |
|
| - | 100 | rc = async_req_0_0(phone_id, LOADER_RUN); |
|
| 84 | if (rc != EOK) return 0; |
101 | if (rc != EOK) return 0; |
| 85 | - | ||
| 86 | // rc = async_req_0_0(phone_id, 1025); |
- | |
| 87 | // printf("->%d\n", rc); |
- | |
| 88 | // if (rc != EOK) return 0; |
- | |
| 89 | 102 | ||
| 90 | // ipc_hangup(phone_id); |
103 | ipc_hangup(phone_id); |
| 91 | 104 | ||
| 92 | return 1; |
105 | return 1; |
| 93 | } |
106 | } |
| 94 | 107 | ||
| 95 | /** @} |
108 | /** @} |