Rev 2888 | Rev 2894 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2888 | Rev 2892 | ||
---|---|---|---|
1 | /** @addtogroup generic |
1 | /** @addtogroup generic |
2 | * @{ |
2 | * @{ |
3 | */ |
3 | */ |
4 | 4 | ||
5 | /** |
5 | /** |
6 | * @file |
6 | * @file |
7 | * @brief Tdebug. |
7 | * @brief Tdebug. |
8 | */ |
8 | */ |
9 | 9 | ||
10 | #include <console/klog.h> |
10 | #include <console/klog.h> |
11 | #include <proc/task.h> |
11 | #include <proc/task.h> |
12 | #include <proc/thread.h> |
12 | #include <proc/thread.h> |
13 | #include <arch.h> |
13 | #include <arch.h> |
14 | #include <errno.h> |
14 | #include <errno.h> |
15 | #include <ipc/ipc.h> |
15 | #include <ipc/ipc.h> |
16 | #include <syscall/copy.h> |
16 | #include <syscall/copy.h> |
17 | #include <udebug/udebug.h> |
17 | #include <udebug/udebug.h> |
18 | #include <udebug/udebug_ops.h> |
18 | #include <udebug/udebug_ops.h> |
19 | #include <udebug/udebug_ipc.h> |
19 | #include <udebug/udebug_ipc.h> |
20 | 20 | ||
21 | static int udebug_rp_regs_write(call_t *call, phone_t *phone) |
21 | static int udebug_rp_regs_write(call_t *call, phone_t *phone) |
22 | { |
22 | { |
23 | void *uspace_data; |
23 | void *uspace_data; |
24 | unative_t to_copy; |
24 | unative_t to_copy; |
25 | int rc; |
25 | int rc; |
26 | void *buffer; |
26 | void *buffer; |
27 | 27 | ||
28 | klog_printf("debug_regs_write()"); |
28 | klog_printf("debug_regs_write()"); |
29 | 29 | ||
30 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
30 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
31 | to_copy = IPC_GET_ARG4(call->data); |
31 | to_copy = IPC_GET_ARG4(call->data); |
32 | if (to_copy > sizeof(istate_t)) to_copy = sizeof(istate_t); |
32 | if (to_copy > sizeof(istate_t)) to_copy = sizeof(istate_t); |
33 | 33 | ||
34 | buffer = malloc(to_copy, 0); // ??? |
34 | buffer = malloc(to_copy, 0); // ??? |
35 | 35 | ||
36 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
36 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
37 | if (rc != 0) { |
37 | if (rc != 0) { |
38 | klog_printf("debug_regs_write() - copy failed"); |
38 | klog_printf("debug_regs_write() - copy failed"); |
39 | return rc; |
39 | return rc; |
40 | } |
40 | } |
41 | 41 | ||
42 | call->buffer = buffer; |
42 | call->buffer = buffer; |
43 | 43 | ||
44 | klog_printf(" - done"); |
44 | klog_printf(" - done"); |
45 | return 0; /* No backsend */ |
45 | return 0; |
46 | } |
46 | } |
47 | 47 | ||
48 | static int udebug_rp_mem_write(call_t *call, phone_t *phone) |
48 | static int udebug_rp_mem_write(call_t *call, phone_t *phone) |
49 | { |
49 | { |
50 | void *uspace_data; |
50 | void *uspace_data; |
51 | unative_t to_copy; |
51 | unative_t to_copy; |
52 | int rc; |
52 | int rc; |
53 | void *buffer; |
53 | void *buffer; |
54 | 54 | ||
55 | klog_printf("udebug_rp_mem_write()"); |
55 | klog_printf("udebug_rp_mem_write()"); |
56 | 56 | ||
57 | uspace_data = (void *)IPC_GET_ARG2(call->data); |
57 | uspace_data = (void *)IPC_GET_ARG2(call->data); |
58 | to_copy = IPC_GET_ARG4(call->data); |
58 | to_copy = IPC_GET_ARG4(call->data); |
59 | 59 | ||
60 | buffer = malloc(to_copy, 0); // ??? |
60 | buffer = malloc(to_copy, 0); // ??? |
61 | 61 | ||
62 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
62 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
63 | if (rc != 0) { |
63 | if (rc != 0) { |
64 | klog_printf(" - copy failed"); |
64 | klog_printf(" - copy failed"); |
65 | return rc; |
65 | return rc; |
66 | } |
66 | } |
67 | 67 | ||
68 | call->buffer = buffer; |
68 | call->buffer = buffer; |
69 | 69 | ||
70 | klog_printf(" - done"); |
70 | klog_printf(" - done"); |
71 | return 1; /* actually need becksend with retval 0 */ |
71 | return 0; |
72 | } |
72 | } |
73 | 73 | ||
74 | 74 | ||
75 | int udebug_request_preprocess(call_t *call, phone_t *phone) |
75 | int udebug_request_preprocess(call_t *call, phone_t *phone) |
76 | { |
76 | { |
77 | int rc; |
77 | int rc; |
78 | 78 | ||
79 | switch (IPC_GET_ARG1(call->data)) { |
79 | switch (IPC_GET_ARG1(call->data)) { |
80 | case UDEBUG_M_REGS_WRITE: |
80 | case UDEBUG_M_REGS_WRITE: |
81 | rc = udebug_rp_regs_write(call, phone); |
81 | rc = udebug_rp_regs_write(call, phone); |
82 | return rc; |
82 | return rc; |
83 | case UDEBUG_M_MEM_WRITE: |
83 | case UDEBUG_M_MEM_WRITE: |
84 | rc = udebug_rp_mem_write(call, phone); |
84 | rc = udebug_rp_mem_write(call, phone); |
85 | return rc; |
85 | return rc; |
86 | default: |
86 | default: |
87 | break; |
87 | break; |
88 | } |
88 | } |
89 | 89 | ||
90 | return 0; |
90 | return 0; |
91 | } |
91 | } |
92 | 92 | ||
93 | static void udebug_receive_begin(call_t *call) |
93 | static void udebug_receive_begin(call_t *call) |
94 | { |
94 | { |
95 | int rc; |
95 | int rc; |
96 | 96 | ||
97 | rc = udebug_begin(call); |
97 | rc = udebug_begin(call); |
98 | if (rc < 0) { |
98 | if (rc < 0) { |
99 | IPC_SET_RETVAL(call->data, rc); |
99 | IPC_SET_RETVAL(call->data, rc); |
100 | ipc_answer(&TASK->kernel_box, call); |
100 | ipc_answer(&TASK->kernel_box, call); |
101 | return; |
101 | return; |
102 | } |
102 | } |
103 | 103 | ||
104 | if (rc != 0) { |
104 | if (rc != 0) { |
105 | IPC_SET_RETVAL(call->data, 0); |
105 | IPC_SET_RETVAL(call->data, 0); |
106 | ipc_answer(&TASK->kernel_box, call); |
106 | ipc_answer(&TASK->kernel_box, call); |
107 | } |
107 | } |
108 | } |
108 | } |
109 | 109 | ||
110 | static void udebug_receive_end(call_t *call) |
110 | static void udebug_receive_end(call_t *call) |
111 | { |
111 | { |
112 | int rc; |
112 | int rc; |
113 | 113 | ||
114 | rc = udebug_end(); |
114 | rc = udebug_end(); |
115 | 115 | ||
116 | IPC_SET_RETVAL(call->data, rc); |
116 | IPC_SET_RETVAL(call->data, rc); |
117 | ipc_answer(&TASK->kernel_box, call); |
117 | ipc_answer(&TASK->kernel_box, call); |
118 | } |
118 | } |
119 | 119 | ||
120 | static void udebug_receive_go(call_t *call) |
120 | static void udebug_receive_go(call_t *call) |
121 | { |
121 | { |
122 | thread_t *t; |
122 | thread_t *t; |
123 | int rc; |
123 | int rc; |
124 | 124 | ||
125 | klog_printf("debug_go()"); |
125 | klog_printf("debug_go()"); |
126 | 126 | ||
127 | t = (thread_t *)IPC_GET_ARG2(call->data); |
127 | t = (thread_t *)IPC_GET_ARG2(call->data); |
128 | 128 | ||
129 | rc = udebug_go(t, call); |
129 | rc = udebug_go(t, call); |
130 | if (rc < 0) { |
130 | if (rc < 0) { |
131 | IPC_SET_RETVAL(call->data, rc); |
131 | IPC_SET_RETVAL(call->data, rc); |
132 | ipc_answer(&TASK->kernel_box, call); |
132 | ipc_answer(&TASK->kernel_box, call); |
133 | return; |
133 | return; |
134 | } |
134 | } |
135 | } |
135 | } |
136 | 136 | ||
137 | 137 | ||
138 | static void udebug_receive_thread_read(call_t *call) |
138 | static void udebug_receive_thread_read(call_t *call) |
139 | { |
139 | { |
140 | unative_t uspace_addr; |
140 | unative_t uspace_addr; |
141 | unative_t to_copy; |
141 | unative_t to_copy; |
142 | unsigned total_bytes; |
142 | unsigned total_bytes; |
143 | unsigned buf_size; |
143 | unsigned buf_size; |
144 | void *buffer; |
144 | void *buffer; |
145 | size_t n; |
145 | size_t n; |
146 | int rc; |
146 | int rc; |
147 | 147 | ||
148 | rc = udebug_thread_read(&buffer, &n); |
148 | rc = udebug_thread_read(&buffer, &n); |
149 | if (rc < 0) { |
149 | if (rc < 0) { |
150 | IPC_SET_RETVAL(call->data, rc); |
150 | IPC_SET_RETVAL(call->data, rc); |
151 | ipc_answer(&TASK->kernel_box, call); |
151 | ipc_answer(&TASK->kernel_box, call); |
152 | return; |
152 | return; |
153 | } |
153 | } |
154 | 154 | ||
155 | /* |
155 | /* |
156 | * Make use of call->buffer to transfer data to caller's userspace |
156 | * Make use of call->buffer to transfer data to caller's userspace |
157 | */ |
157 | */ |
158 | 158 | ||
159 | uspace_addr = IPC_GET_ARG2(call->data); |
159 | uspace_addr = IPC_GET_ARG2(call->data); |
160 | buf_size = IPC_GET_ARG3(call->data); |
160 | buf_size = IPC_GET_ARG3(call->data); |
161 | 161 | ||
162 | total_bytes = n; |
162 | total_bytes = n; |
163 | 163 | ||
164 | if (buf_size > total_bytes) |
164 | if (buf_size > total_bytes) |
165 | to_copy = total_bytes; |
165 | to_copy = total_bytes; |
166 | else |
166 | else |
167 | to_copy = buf_size; |
167 | to_copy = buf_size; |
168 | 168 | ||
169 | IPC_SET_RETVAL(call->data, 0); |
169 | IPC_SET_RETVAL(call->data, 0); |
170 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
170 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
171 | same code in process_answer() can be used |
171 | same code in process_answer() can be used |
172 | (no way to distinguish method in answer) */ |
172 | (no way to distinguish method in answer) */ |
173 | IPC_SET_ARG1(call->data, uspace_addr); |
173 | IPC_SET_ARG1(call->data, uspace_addr); |
174 | IPC_SET_ARG2(call->data, to_copy); |
174 | IPC_SET_ARG2(call->data, to_copy); |
175 | 175 | ||
176 | IPC_SET_ARG3(call->data, total_bytes); |
176 | IPC_SET_ARG3(call->data, total_bytes); |
177 | call->buffer = buffer; |
177 | call->buffer = buffer; |
178 | 178 | ||
179 | ipc_answer(&TASK->kernel_box, call); |
179 | ipc_answer(&TASK->kernel_box, call); |
180 | } |
180 | } |
181 | 181 | ||
182 | static void udebug_receive_args_read(call_t *call) |
182 | static void udebug_receive_args_read(call_t *call) |
183 | { |
183 | { |
184 | thread_t *t; |
184 | thread_t *t; |
185 | unative_t uspace_addr; |
185 | unative_t uspace_addr; |
186 | int rc; |
186 | int rc; |
187 | void *buffer; |
187 | void *buffer; |
188 | 188 | ||
189 | t = (thread_t *)IPC_GET_ARG2(call->data); |
189 | t = (thread_t *)IPC_GET_ARG2(call->data); |
190 | 190 | ||
191 | rc = udebug_args_read(t, &buffer); |
191 | rc = udebug_args_read(t, &buffer); |
192 | if (rc != EOK) { |
192 | if (rc != EOK) { |
193 | IPC_SET_RETVAL(call->data, rc); |
193 | IPC_SET_RETVAL(call->data, rc); |
194 | ipc_answer(&TASK->kernel_box, call); |
194 | ipc_answer(&TASK->kernel_box, call); |
195 | return; |
195 | return; |
196 | } |
196 | } |
197 | 197 | ||
198 | /* |
198 | /* |
199 | * Make use of call->buffer to transfer data to caller's userspace |
199 | * Make use of call->buffer to transfer data to caller's userspace |
200 | */ |
200 | */ |
201 | 201 | ||
202 | uspace_addr = IPC_GET_ARG3(call->data); |
202 | uspace_addr = IPC_GET_ARG3(call->data); |
203 | 203 | ||
204 | IPC_SET_RETVAL(call->data, 0); |
204 | IPC_SET_RETVAL(call->data, 0); |
205 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
205 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
206 | same code in process_answer() can be used |
206 | same code in process_answer() can be used |
207 | (no way to distinguish method in answer) */ |
207 | (no way to distinguish method in answer) */ |
208 | IPC_SET_ARG1(call->data, uspace_addr); |
208 | IPC_SET_ARG1(call->data, uspace_addr); |
209 | IPC_SET_ARG2(call->data, 6 * sizeof(unative_t)); |
209 | IPC_SET_ARG2(call->data, 6 * sizeof(unative_t)); |
210 | call->buffer = buffer; |
210 | call->buffer = buffer; |
211 | 211 | ||
212 | ipc_answer(&TASK->kernel_box, call); |
212 | ipc_answer(&TASK->kernel_box, call); |
213 | } |
213 | } |
214 | 214 | ||
215 | static void udebug_receive_regs_read(call_t *call) |
215 | static void udebug_receive_regs_read(call_t *call) |
216 | { |
216 | { |
217 | thread_t *t; |
217 | thread_t *t; |
218 | unative_t uspace_addr; |
218 | unative_t uspace_addr; |
219 | unative_t to_copy; |
219 | unative_t to_copy; |
220 | unative_t buf_size; |
220 | unative_t buf_size; |
221 | unative_t total_bytes; |
221 | unative_t total_bytes; |
222 | void *buffer; |
222 | void *buffer; |
223 | int rc; |
223 | int rc; |
224 | size_t n; |
224 | size_t n; |
225 | 225 | ||
226 | klog_printf("debug_regs_read()"); |
226 | klog_printf("debug_regs_read()"); |
227 | 227 | ||
228 | t = (thread_t *) IPC_GET_ARG2(call->data); |
228 | t = (thread_t *) IPC_GET_ARG2(call->data); |
229 | 229 | ||
230 | rc = udebug_regs_read(t, &buffer, &n); |
230 | rc = udebug_regs_read(t, &buffer, &n); |
231 | if (rc < 0) { |
231 | if (rc < 0) { |
232 | IPC_SET_RETVAL(call->data, rc); |
232 | IPC_SET_RETVAL(call->data, rc); |
233 | ipc_answer(&TASK->kernel_box, call); |
233 | ipc_answer(&TASK->kernel_box, call); |
234 | return; |
234 | return; |
235 | } |
235 | } |
236 | 236 | ||
237 | /* |
237 | /* |
238 | * Make use of call->buffer to transfer data to caller's userspace |
238 | * Make use of call->buffer to transfer data to caller's userspace |
239 | */ |
239 | */ |
240 | 240 | ||
241 | uspace_addr = IPC_GET_ARG3(call->data); |
241 | uspace_addr = IPC_GET_ARG3(call->data); |
242 | buf_size = IPC_GET_ARG4(call->data); |
242 | buf_size = IPC_GET_ARG4(call->data); |
243 | 243 | ||
244 | total_bytes = n; |
244 | total_bytes = n; |
245 | 245 | ||
246 | if (buf_size > total_bytes) |
246 | if (buf_size > total_bytes) |
247 | to_copy = total_bytes; |
247 | to_copy = total_bytes; |
248 | else |
248 | else |
249 | to_copy = buf_size; |
249 | to_copy = buf_size; |
250 | 250 | ||
251 | IPC_SET_RETVAL(call->data, 0); |
251 | IPC_SET_RETVAL(call->data, 0); |
252 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
252 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
253 | same code in process_answer() can be used |
253 | same code in process_answer() can be used |
254 | (no way to distinguish method in answer) */ |
254 | (no way to distinguish method in answer) */ |
255 | IPC_SET_ARG1(call->data, uspace_addr); |
255 | IPC_SET_ARG1(call->data, uspace_addr); |
256 | IPC_SET_ARG2(call->data, to_copy); |
256 | IPC_SET_ARG2(call->data, to_copy); |
257 | 257 | ||
258 | IPC_SET_ARG3(call->data, total_bytes); |
258 | IPC_SET_ARG3(call->data, total_bytes); |
259 | call->buffer = buffer; |
259 | call->buffer = buffer; |
260 | 260 | ||
261 | ipc_answer(&TASK->kernel_box, call); |
261 | ipc_answer(&TASK->kernel_box, call); |
262 | } |
262 | } |
263 | 263 | ||
264 | static void udebug_receive_regs_write(call_t *call) |
264 | static void udebug_receive_regs_write(call_t *call) |
265 | { |
265 | { |
266 | thread_t *t; |
266 | thread_t *t; |
267 | void *uspace_data; |
267 | void *uspace_data; |
268 | unative_t to_copy; |
268 | unative_t to_copy; |
269 | int rc; |
269 | int rc; |
270 | 270 | ||
271 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
271 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
272 | to_copy = IPC_GET_ARG4(call->data); |
272 | to_copy = IPC_GET_ARG4(call->data); |
273 | 273 | ||
274 | t = (thread_t *) IPC_GET_ARG2(call->data); |
274 | t = (thread_t *) IPC_GET_ARG2(call->data); |
275 | 275 | ||
276 | rc = udebug_regs_write(t, call->buffer); |
276 | rc = udebug_regs_write(t, call->buffer); |
277 | if (rc < 0) { |
277 | if (rc < 0) { |
278 | IPC_SET_RETVAL(call->data, rc); |
278 | IPC_SET_RETVAL(call->data, rc); |
279 | ipc_answer(&TASK->kernel_box, call); |
279 | ipc_answer(&TASK->kernel_box, call); |
280 | return; |
280 | return; |
281 | } |
281 | } |
282 | 282 | ||
283 | /* Set answer values */ |
283 | /* Set answer values */ |
284 | 284 | ||
285 | IPC_SET_ARG1(call->data, to_copy); |
285 | IPC_SET_ARG1(call->data, to_copy); |
286 | IPC_SET_ARG2(call->data, sizeof(istate_t)); |
286 | IPC_SET_ARG2(call->data, sizeof(istate_t)); |
287 | 287 | ||
288 | IPC_SET_RETVAL(call->data, 0); |
288 | IPC_SET_RETVAL(call->data, 0); |
289 | free(call->buffer); |
289 | free(call->buffer); |
290 | call->buffer = NULL; |
290 | call->buffer = NULL; |
291 | 291 | ||
292 | ipc_answer(&TASK->kernel_box, call); |
292 | ipc_answer(&TASK->kernel_box, call); |
293 | } |
293 | } |
294 | 294 | ||
295 | 295 | ||
296 | static void udebug_receive_mem_read(call_t *call) |
296 | static void udebug_receive_mem_read(call_t *call) |
297 | { |
297 | { |
298 | unative_t uspace_dst; |
298 | unative_t uspace_dst; |
299 | unative_t uspace_src; |
299 | unative_t uspace_src; |
300 | unsigned size; |
300 | unsigned size; |
301 | void *buffer; |
301 | void *buffer; |
302 | int rc; |
302 | int rc; |
303 | 303 | ||
304 | uspace_dst = IPC_GET_ARG2(call->data); |
304 | uspace_dst = IPC_GET_ARG2(call->data); |
305 | uspace_src = IPC_GET_ARG3(call->data); |
305 | uspace_src = IPC_GET_ARG3(call->data); |
306 | size = IPC_GET_ARG4(call->data); |
306 | size = IPC_GET_ARG4(call->data); |
307 | 307 | ||
308 | rc = udebug_mem_read(uspace_src, size, &buffer); |
308 | rc = udebug_mem_read(uspace_src, size, &buffer); |
309 | if (rc < 0) { |
309 | if (rc < 0) { |
310 | IPC_SET_RETVAL(call->data, rc); |
310 | IPC_SET_RETVAL(call->data, rc); |
311 | ipc_answer(&TASK->kernel_box, call); |
311 | ipc_answer(&TASK->kernel_box, call); |
312 | return; |
312 | return; |
313 | } |
313 | } |
314 | 314 | ||
315 | IPC_SET_RETVAL(call->data, 0); |
315 | IPC_SET_RETVAL(call->data, 0); |
316 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
316 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
317 | same code in process_answer() can be used |
317 | same code in process_answer() can be used |
318 | (no way to distinguish method in answer) */ |
318 | (no way to distinguish method in answer) */ |
319 | IPC_SET_ARG1(call->data, uspace_dst); |
319 | IPC_SET_ARG1(call->data, uspace_dst); |
320 | IPC_SET_ARG2(call->data, size); |
320 | IPC_SET_ARG2(call->data, size); |
321 | call->buffer = buffer; |
321 | call->buffer = buffer; |
322 | 322 | ||
323 | ipc_answer(&TASK->kernel_box, call); |
323 | ipc_answer(&TASK->kernel_box, call); |
324 | } |
324 | } |
325 | 325 | ||
326 | static void udebug_receive_mem_write(call_t *call) |
326 | static void udebug_receive_mem_write(call_t *call) |
327 | { |
327 | { |
328 | unative_t uspace_dst; |
328 | unative_t uspace_dst; |
329 | unsigned size; |
329 | unsigned size; |
330 | int rc; |
330 | int rc; |
331 | 331 | ||
332 | klog_printf("udebug_receive_mem_write()"); |
332 | klog_printf("udebug_receive_mem_write()"); |
333 | 333 | ||
334 | uspace_dst = IPC_GET_ARG3(call->data); |
334 | uspace_dst = IPC_GET_ARG3(call->data); |
335 | size = IPC_GET_ARG4(call->data); |
335 | size = IPC_GET_ARG4(call->data); |
336 | 336 | ||
337 | rc = udebug_mem_write(uspace_dst, call->buffer, size); |
337 | rc = udebug_mem_write(uspace_dst, call->buffer, size); |
338 | if (rc < 0) { |
338 | if (rc < 0) { |
339 | IPC_SET_RETVAL(call->data, rc); |
339 | IPC_SET_RETVAL(call->data, rc); |
340 | ipc_answer(&TASK->kernel_box, call); |
340 | ipc_answer(&TASK->kernel_box, call); |
341 | return; |
341 | return; |
342 | } |
342 | } |
343 | 343 | ||
344 | IPC_SET_RETVAL(call->data, 0); |
344 | IPC_SET_RETVAL(call->data, 0); |
345 | free(call->buffer); |
345 | free(call->buffer); |
346 | call->buffer = NULL; |
346 | call->buffer = NULL; |
347 | 347 | ||
348 | ipc_answer(&TASK->kernel_box, call); |
348 | ipc_answer(&TASK->kernel_box, call); |
349 | } |
349 | } |
350 | 350 | ||
351 | 351 | ||
352 | /** |
352 | /** |
353 | * Handle a debug call received on the kernel answerbox. |
353 | * Handle a debug call received on the kernel answerbox. |
354 | * |
354 | * |
355 | * This is called by the kbox servicing thread. |
355 | * This is called by the kbox servicing thread. |
356 | */ |
356 | */ |
357 | void udebug_call_receive(call_t *call) |
357 | void udebug_call_receive(call_t *call) |
358 | { |
358 | { |
359 | int debug_method; |
359 | int debug_method; |
360 | 360 | ||
361 | debug_method = IPC_GET_ARG1(call->data); |
361 | debug_method = IPC_GET_ARG1(call->data); |
362 | 362 | ||
363 | if (debug_method != UDEBUG_M_BEGIN) { |
363 | if (debug_method != UDEBUG_M_BEGIN) { |
364 | /* |
364 | /* |
365 | * Verify that the sender is this task's debugger. |
365 | * Verify that the sender is this task's debugger. |
366 | * Note that this is the only thread that could change |
366 | * Note that this is the only thread that could change |
367 | * TASK->debugger. Therefore no locking is necessary |
367 | * TASK->debugger. Therefore no locking is necessary |
368 | * and the sender can be safely considered valid until |
368 | * and the sender can be safely considered valid until |
369 | * control exits this function. |
369 | * control exits this function. |
370 | */ |
370 | */ |
371 | if (TASK->debugger != call->sender) { |
371 | if (TASK->debugger != call->sender) { |
372 | IPC_SET_RETVAL(call->data, EINVAL); |
372 | IPC_SET_RETVAL(call->data, EINVAL); |
373 | ipc_answer(&TASK->kernel_box, call); |
373 | ipc_answer(&TASK->kernel_box, call); |
374 | return; |
374 | return; |
375 | } |
375 | } |
376 | } |
376 | } |
377 | 377 | ||
378 | switch (debug_method) { |
378 | switch (debug_method) { |
379 | case UDEBUG_M_BEGIN: |
379 | case UDEBUG_M_BEGIN: |
380 | udebug_receive_begin(call); |
380 | udebug_receive_begin(call); |
381 | break; |
381 | break; |
382 | case UDEBUG_M_END: |
382 | case UDEBUG_M_END: |
383 | udebug_receive_end(call); |
383 | udebug_receive_end(call); |
384 | break; |
384 | break; |
385 | case UDEBUG_M_GO: |
385 | case UDEBUG_M_GO: |
386 | udebug_receive_go(call); |
386 | udebug_receive_go(call); |
387 | break; |
387 | break; |
388 | case UDEBUG_M_THREAD_READ: |
388 | case UDEBUG_M_THREAD_READ: |
389 | udebug_receive_thread_read(call); |
389 | udebug_receive_thread_read(call); |
390 | break; |
390 | break; |
391 | case UDEBUG_M_ARGS_READ: |
391 | case UDEBUG_M_ARGS_READ: |
392 | udebug_receive_args_read(call); |
392 | udebug_receive_args_read(call); |
393 | break; |
393 | break; |
394 | case UDEBUG_M_REGS_READ: |
394 | case UDEBUG_M_REGS_READ: |
395 | udebug_receive_regs_read(call); |
395 | udebug_receive_regs_read(call); |
396 | break; |
396 | break; |
397 | case UDEBUG_M_REGS_WRITE: |
397 | case UDEBUG_M_REGS_WRITE: |
398 | udebug_receive_regs_write(call); |
398 | udebug_receive_regs_write(call); |
399 | break; |
399 | break; |
400 | case UDEBUG_M_MEM_READ: |
400 | case UDEBUG_M_MEM_READ: |
401 | udebug_receive_mem_read(call); |
401 | udebug_receive_mem_read(call); |
402 | break; |
402 | break; |
403 | case UDEBUG_M_MEM_WRITE: |
403 | case UDEBUG_M_MEM_WRITE: |
404 | udebug_receive_mem_write(call); |
404 | udebug_receive_mem_write(call); |
405 | break; |
405 | break; |
406 | } |
406 | } |
407 | } |
407 | } |
408 | 408 | ||
409 | /** @} |
409 | /** @} |
410 | */ |
410 | */ |
411 | 411 |