Rev 955 | Rev 965 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 955 | Rev 959 | ||
---|---|---|---|
Line 103... | Line 103... | ||
103 | spinlock_lock(&box->lock); |
103 | spinlock_lock(&box->lock); |
104 | list_remove(&phone->list); |
104 | list_remove(&phone->list); |
105 | spinlock_unlock(&box->lock); |
105 | spinlock_unlock(&box->lock); |
106 | } |
106 | } |
107 | 107 | ||
- | 108 | /** Helper function to facilitate synchronous calls */ |
|
- | 109 | void ipc_call_sync(phone_t *phone, call_t *request) |
|
- | 110 | { |
|
- | 111 | answerbox_t sync_box; |
|
- | 112 | ||
- | 113 | ipc_answerbox_init(&sync_box); |
|
- | 114 | ||
- | 115 | /* We will receive data on special box */ |
|
- | 116 | request->callerbox = &sync_box; |
|
- | 117 | ||
- | 118 | ipc_call(phone, request); |
|
- | 119 | ipc_wait_for_call(&sync_box, 0); |
|
- | 120 | } |
|
108 | 121 | ||
109 | /** Send a request using phone to answerbox |
122 | /** Send a asynchronous request using phone to answerbox |
110 | * |
123 | * |
111 | * @param phone Phone connected to answerbox |
124 | * @param phone Phone connected to answerbox |
112 | * @param request Request to be sent |
125 | * @param request Request to be sent |
113 | */ |
126 | */ |
114 | void ipc_call(phone_t *phone, call_t *request) |
127 | void ipc_call(phone_t *phone, call_t *request) |
Line 197... | Line 210... | ||
197 | printf("Phone company started.\n"); |
210 | printf("Phone company started.\n"); |
198 | while (1) { |
211 | while (1) { |
199 | call = ipc_wait_for_call(&TASK->answerbox, 0); |
212 | call = ipc_wait_for_call(&TASK->answerbox, 0); |
200 | printf("Received phone call - %P %P\n", |
213 | printf("Received phone call - %P %P\n", |
201 | call->data[0], call->data[1]); |
214 | call->data[0], call->data[1]); |
- | 215 | call->data[0] = 0xbabaaaee;; |
|
- | 216 | call->data[1] = 0xaaaaeeee; |
|
202 | ipc_answer(&TASK->answerbox, call); |
217 | ipc_answer(&TASK->answerbox, call); |
203 | printf("Call answered.\n"); |
218 | printf("Call answered.\n"); |
204 | } |
219 | } |
205 | } |
220 | } |
206 | 221 |