Rev 2913 | Rev 3013 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2913 | Rev 2919 | ||
|---|---|---|---|
| Line 413... | Line 413... | ||
| 413 | 413 | ||
| 414 | *buffer = arg_buffer; |
414 | *buffer = arg_buffer; |
| 415 | return 0; |
415 | return 0; |
| 416 | } |
416 | } |
| 417 | 417 | ||
| 418 | int udebug_regs_read(thread_t *t, void **buffer, size_t *n) |
418 | int udebug_regs_read(thread_t *t, void *buffer) |
| 419 | { |
419 | { |
| 420 | istate_t *state; |
420 | istate_t *state; |
| 421 | void *regs_buffer; |
- | |
| 422 | int rc; |
421 | int rc; |
| 423 | ipl_t ipl; |
422 | ipl_t ipl; |
| 424 | 423 | ||
| 425 | klog_printf("udebug_regs_read()"); |
424 | klog_printf("udebug_regs_read()"); |
| 426 | 425 | ||
| 427 | /* Prepare a buffer to hold the registers */ |
- | |
| 428 | regs_buffer = malloc(sizeof(istate_t), 0); |
- | |
| 429 | - | ||
| 430 | ipl = interrupts_disable(); |
426 | ipl = interrupts_disable(); |
| 431 | 427 | ||
| 432 | /* On success, this will lock t->debug_lock */ |
428 | /* On success, this will lock t->debug_lock */ |
| 433 | rc = _thread_op_begin(t, false); |
429 | rc = _thread_op_begin(t, false); |
| 434 | if (rc != EOK) { |
430 | if (rc != EOK) { |
| Line 443... | Line 439... | ||
| 443 | klog_printf("udebug_regs_read() - istate not available"); |
439 | klog_printf("udebug_regs_read() - istate not available"); |
| 444 | return EBUSY; |
440 | return EBUSY; |
| 445 | } |
441 | } |
| 446 | 442 | ||
| 447 | /* Copy to the allocated buffer */ |
443 | /* Copy to the allocated buffer */ |
| 448 | memcpy(regs_buffer, state, sizeof(istate_t)); |
444 | memcpy(buffer, state, sizeof(istate_t)); |
| 449 | 445 | ||
| 450 | _thread_op_end(t); |
446 | _thread_op_end(t); |
| 451 | interrupts_restore(ipl); |
447 | interrupts_restore(ipl); |
| 452 | 448 | ||
| 453 | *buffer = regs_buffer; |
- | |
| 454 | *n = sizeof(istate_t); |
- | |
| 455 | - | ||
| 456 | return 0; |
449 | return 0; |
| 457 | } |
450 | } |
| 458 | 451 | ||
| 459 | int udebug_regs_write(thread_t *t, void *buffer) |
452 | int udebug_regs_write(thread_t *t, void *buffer) |
| 460 | { |
453 | { |
| Line 469... | Line 462... | ||
| 469 | ipl = interrupts_disable(); |
462 | ipl = interrupts_disable(); |
| 470 | 463 | ||
| 471 | /* On success, this will lock t->debug_lock */ |
464 | /* On success, this will lock t->debug_lock */ |
| 472 | rc = _thread_op_begin(t, false); |
465 | rc = _thread_op_begin(t, false); |
| 473 | if (rc != EOK) { |
466 | if (rc != EOK) { |
| - | 467 | klog_printf("error locking thread"); |
|
| 474 | interrupts_restore(ipl); |
468 | interrupts_restore(ipl); |
| 475 | return rc; |
469 | return rc; |
| 476 | } |
470 | } |
| 477 | 471 | ||
| 478 | state = t->uspace_state; |
472 | state = t->uspace_state; |
| Line 482... | Line 476... | ||
| 482 | klog_printf("udebug_regs_write() - istate not available"); |
476 | klog_printf("udebug_regs_write() - istate not available"); |
| 483 | 477 | ||
| 484 | return EBUSY; |
478 | return EBUSY; |
| 485 | } |
479 | } |
| 486 | 480 | ||
| 487 | memcpy(t->uspace_state, buffer, sizeof(t->uspace_state)); |
481 | memcpy(t->uspace_state, buffer, sizeof(istate_t)); |
| 488 | 482 | ||
| 489 | _thread_op_end(t); |
483 | _thread_op_end(t); |
| 490 | interrupts_restore(ipl); |
484 | interrupts_restore(ipl); |
| 491 | 485 | ||
| 492 | return 0; |
486 | return 0; |