Rev 2913 | Rev 3014 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2913 | Rev 2919 | ||
|---|---|---|---|
| Line 54... | Line 54... | ||
| 54 | void *buffer; |
54 | void *buffer; |
| 55 | 55 | ||
| 56 | klog_printf("debug_regs_write()"); |
56 | klog_printf("debug_regs_write()"); |
| 57 | 57 | ||
| 58 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
58 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
| 59 | to_copy = IPC_GET_ARG4(call->data); |
59 | to_copy = sizeof(istate_t); |
| 60 | if (to_copy > sizeof(istate_t)) to_copy = sizeof(istate_t); |
- | |
| 61 | - | ||
| 62 | buffer = malloc(to_copy, 0); |
60 | buffer = malloc(to_copy, 0); |
| 63 | 61 | ||
| 64 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
62 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
| 65 | if (rc != 0) { |
63 | if (rc != 0) { |
| 66 | klog_printf("debug_regs_write() - copy failed"); |
64 | klog_printf("debug_regs_write() - copy failed"); |
| Line 275... | Line 273... | ||
| 275 | static void udebug_receive_regs_read(call_t *call) |
273 | static void udebug_receive_regs_read(call_t *call) |
| 276 | { |
274 | { |
| 277 | thread_t *t; |
275 | thread_t *t; |
| 278 | unative_t uspace_addr; |
276 | unative_t uspace_addr; |
| 279 | unative_t to_copy; |
277 | unative_t to_copy; |
| 280 | unative_t buf_size; |
- | |
| 281 | unative_t total_bytes; |
- | |
| 282 | void *buffer; |
278 | void *buffer; |
| 283 | int rc; |
279 | int rc; |
| 284 | size_t n; |
- | |
| 285 | 280 | ||
| 286 | klog_printf("debug_regs_read()"); |
281 | klog_printf("debug_regs_read()"); |
| 287 | 282 | ||
| 288 | t = (thread_t *) IPC_GET_ARG2(call->data); |
283 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| - | 284 | buffer = malloc(sizeof(istate_t), 0); |
|
| 289 | 285 | ||
| 290 | rc = udebug_regs_read(t, &buffer, &n); |
286 | rc = udebug_regs_read(t, buffer); |
| 291 | if (rc < 0) { |
287 | if (rc < 0) { |
| 292 | IPC_SET_RETVAL(call->data, rc); |
288 | IPC_SET_RETVAL(call->data, rc); |
| 293 | ipc_answer(&TASK->kernel_box, call); |
289 | ipc_answer(&TASK->kernel_box, call); |
| 294 | return; |
290 | return; |
| 295 | } |
291 | } |
| Line 297... | Line 293... | ||
| 297 | /* |
293 | /* |
| 298 | * Make use of call->buffer to transfer data to caller's userspace |
294 | * Make use of call->buffer to transfer data to caller's userspace |
| 299 | */ |
295 | */ |
| 300 | 296 | ||
| 301 | uspace_addr = IPC_GET_ARG3(call->data); |
297 | uspace_addr = IPC_GET_ARG3(call->data); |
| 302 | buf_size = IPC_GET_ARG4(call->data); |
- | |
| 303 | - | ||
| 304 | total_bytes = n; |
- | |
| 305 | - | ||
| 306 | if (buf_size > total_bytes) |
- | |
| 307 | to_copy = total_bytes; |
298 | to_copy = sizeof(istate_t); |
| 308 | else |
- | |
| 309 | to_copy = buf_size; |
- | |
| 310 | 299 | ||
| 311 | IPC_SET_RETVAL(call->data, 0); |
300 | IPC_SET_RETVAL(call->data, 0); |
| 312 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
301 | /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that |
| 313 | same code in process_answer() can be used |
302 | same code in process_answer() can be used |
| 314 | (no way to distinguish method in answer) */ |
303 | (no way to distinguish method in answer) */ |
| 315 | IPC_SET_ARG1(call->data, uspace_addr); |
304 | IPC_SET_ARG1(call->data, uspace_addr); |
| 316 | IPC_SET_ARG2(call->data, to_copy); |
305 | IPC_SET_ARG2(call->data, to_copy); |
| 317 | 306 | ||
| 318 | IPC_SET_ARG3(call->data, total_bytes); |
- | |
| 319 | call->buffer = buffer; |
307 | call->buffer = buffer; |
| 320 | 308 | ||
| 321 | ipc_answer(&TASK->kernel_box, call); |
309 | ipc_answer(&TASK->kernel_box, call); |
| 322 | } |
310 | } |
| 323 | 311 | ||
| 324 | static void udebug_receive_regs_write(call_t *call) |
312 | static void udebug_receive_regs_write(call_t *call) |
| 325 | { |
313 | { |
| 326 | thread_t *t; |
314 | thread_t *t; |
| 327 | void *uspace_data; |
315 | void *uspace_data; |
| 328 | unative_t to_copy; |
- | |
| 329 | int rc; |
316 | int rc; |
| 330 | 317 | ||
| 331 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
- | |
| 332 | to_copy = IPC_GET_ARG4(call->data); |
- | |
| 333 | - | ||
| 334 | t = (thread_t *) IPC_GET_ARG2(call->data); |
318 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| - | 319 | uspace_data = (void *)IPC_GET_ARG3(call->data); |
|
| 335 | 320 | ||
| 336 | rc = udebug_regs_write(t, call->buffer); |
321 | rc = udebug_regs_write(t, call->buffer); |
| 337 | if (rc < 0) { |
322 | if (rc < 0) { |
| 338 | IPC_SET_RETVAL(call->data, rc); |
323 | IPC_SET_RETVAL(call->data, rc); |
| 339 | ipc_answer(&TASK->kernel_box, call); |
324 | ipc_answer(&TASK->kernel_box, call); |
| 340 | return; |
325 | return; |
| 341 | } |
326 | } |
| 342 | 327 | ||
| 343 | /* Set answer values */ |
328 | /* Set answer values */ |
| 344 | 329 | ||
| 345 | IPC_SET_ARG1(call->data, to_copy); |
- | |
| 346 | IPC_SET_ARG2(call->data, sizeof(istate_t)); |
- | |
| 347 | - | ||
| 348 | IPC_SET_RETVAL(call->data, 0); |
330 | IPC_SET_RETVAL(call->data, 0); |
| 349 | free(call->buffer); |
331 | free(call->buffer); |
| 350 | call->buffer = NULL; |
332 | call->buffer = NULL; |
| 351 | 333 | ||
| 352 | ipc_answer(&TASK->kernel_box, call); |
334 | ipc_answer(&TASK->kernel_box, call); |