Rev 3004 | Rev 3148 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3004 | Rev 3102 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2006 Jakub Jermar |
2 | * Copyright (c) 2006 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup libc |
29 | /** @addtogroup libc |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <task.h> |
35 | #include <task.h> |
36 | #include <ipc/ipc.h> |
36 | #include <ipc/ipc.h> |
- | 37 | #include <libc.h> |
|
37 | #include <async.h> |
38 | #include <async.h> |
38 | #include <errno.h> |
39 | #include <errno.h> |
39 | 40 | ||
40 | task_id_t task_get_id(void) |
41 | task_id_t task_get_id(void) |
41 | { |
42 | { |
42 | task_id_t task_id; |
43 | task_id_t task_id; |
43 | 44 | ||
44 | (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); |
45 | (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); |
45 | 46 | ||
46 | return task_id; |
47 | return task_id; |
47 | } |
48 | } |
48 | 49 | ||
49 | static int task_spawn_loader(void) |
50 | static int task_spawn_loader(void) |
50 | { |
51 | { |
51 | int phone_id, rc; |
52 | int phone_id, rc; |
52 | 53 | ||
53 | rc = __SYSCALL1(SYS_TASK_SPAWN, (sysarg_t) &phone_id); |
54 | rc = __SYSCALL1(SYS_TASK_SPAWN, (sysarg_t) &phone_id); |
54 | if (rc != 0) |
55 | if (rc != 0) |
55 | return rc; |
56 | return rc; |
56 | 57 | ||
57 | return phone_id; |
58 | return phone_id; |
58 | } |
59 | } |
59 | #include <stdio.h> |
60 | #include <stdio.h> |
60 | #include <unistd.h> |
61 | #include <unistd.h> |
61 | task_id_t task_spawn(const char *path, const char *argv[]) |
62 | task_id_t task_spawn(const char *path, const char *argv[]) |
62 | { |
63 | { |
63 | int phone_id; |
64 | int phone_id; |
64 | ipc_call_t answer; |
65 | ipc_call_t answer; |
65 | aid_t req; |
66 | aid_t req; |
66 | int rc; |
67 | int rc; |
67 | 68 | ||
68 | phone_id = task_spawn_loader(); |
69 | phone_id = task_spawn_loader(); |
69 | if (phone_id < 0) return 0; |
70 | if (phone_id < 0) return 0; |
70 | printf("phone_id:%d\n", phone_id); |
71 | printf("phone_id:%d\n", phone_id); |
71 | 72 | ||
72 | // getchar(); |
73 | // getchar(); |
73 | 74 | ||
74 | // req = async_send_0(phone_id, 1024, &answer); |
75 | // req = async_send_0(phone_id, 1024, &answer); |
75 | rc = ipc_data_write_start(phone_id, (void *)path, strlen(path)); |
76 | rc = ipc_data_write_start(phone_id, (void *)path, strlen(path)); |
76 | printf("->%d\n", rc); |
77 | printf("->%d\n", rc); |
77 | if (rc != EOK) { |
78 | if (rc != EOK) { |
78 | // async_wait_for(req, NULL); |
79 | // async_wait_for(req, NULL); |
79 | return 1; |
80 | return 1; |
80 | } |
81 | } |
81 | // async_wait_for(req, &rc); |
82 | // async_wait_for(req, &rc); |
82 | 83 | ||
83 | if (rc != EOK) return 0; |
84 | if (rc != EOK) return 0; |
84 | 85 | ||
85 | // rc = async_req_0_0(phone_id, 1025); |
86 | // rc = async_req_0_0(phone_id, 1025); |
86 | // printf("->%d\n", rc); |
87 | // printf("->%d\n", rc); |
87 | // if (rc != EOK) return 0; |
88 | // if (rc != EOK) return 0; |
88 | 89 | ||
89 | // ipc_hangup(phone_id); |
90 | // ipc_hangup(phone_id); |
90 | 91 | ||
91 | return 1; |
92 | return 1; |
92 | } |
93 | } |
93 | 94 | ||
94 | /** @} |
95 | /** @} |
95 | */ |
96 | */ |
96 | 97 |