Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2816 → Rev 2817

/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c
127,6 → 127,96
return 1; /* actually need becksend with retval 0 */
}
 
static int udebug_rp_regs_read(call_t *call, phone_t *phone)
{
thread_t *t;
task_t *ta;
void *uspace_buffer;
unative_t to_copy;
int rc;
istate_t *state;
 
klog_printf("debug_regs_read()");
// FIXME: verify task/thread state
 
state = THREAD->uspace_state;
if (state == NULL) {
klog_printf("debug_regs_read() - istate not available");
return EBUSY;
}
 
ta = get_lock_callee_task(phone);
t = (thread_t *) IPC_GET_ARG2(call->data);
if (!thread_exists(t)) {
spinlock_unlock(&ta->lock);
return ENOENT;
}
 
uspace_buffer = (void *)IPC_GET_ARG3(call->data);
to_copy = IPC_GET_ARG4(call->data);
if (to_copy > sizeof(istate_t)) to_copy = sizeof(istate_t);
 
rc = copy_to_uspace(uspace_buffer, t->uspace_state, to_copy);
if (rc != 0) {
spinlock_unlock(&ta->lock);
klog_printf("debug_regs_read() - copy failed");
return rc;
}
 
spinlock_unlock(&ta->lock);
 
IPC_SET_ARG1(call->data, to_copy);
IPC_SET_ARG2(call->data, sizeof(istate_t));
 
klog_printf("debug_regs_read() done");
return 1; /* actually need becksend with retval 0 */
}
 
static int udebug_rp_regs_write(call_t *call, phone_t *phone)
{
thread_t *t;
task_t *ta;
void *uspace_data;
unative_t to_copy;
int rc;
istate_t *state;
 
klog_printf("debug_regs_write()");
// FIXME: verify task/thread state
 
state = THREAD->uspace_state;
if (state == NULL) {
klog_printf("debug_regs_write() - istate not available");
return EBUSY;
}
 
ta = get_lock_callee_task(phone);
t = (thread_t *) IPC_GET_ARG2(call->data);
if (!thread_exists(t)) {
spinlock_unlock(&ta->lock);
return ENOENT;
}
 
uspace_data = (void *)IPC_GET_ARG3(call->data);
to_copy = IPC_GET_ARG4(call->data);
if (to_copy > sizeof(istate_t)) to_copy = sizeof(istate_t);
 
rc = copy_from_uspace(t->uspace_state, uspace_data, to_copy);
if (rc != 0) {
spinlock_unlock(&ta->lock);
klog_printf("debug_regs_write() - copy failed");
return rc;
}
 
spinlock_unlock(&ta->lock);
 
IPC_SET_ARG1(call->data, to_copy);
IPC_SET_ARG2(call->data, sizeof(istate_t));
 
klog_printf("debug_regs_write() done");
return 1; /* actually need becksend with retval 0 */
}
 
static int udebug_rp_thread_read(call_t *call, phone_t *phone)
{
thread_t *t;
200,6 → 290,12
case UDEBUG_M_ARGS_READ:
rc = udebug_rp_args_read(call, phone);
return rc;
case UDEBUG_M_REGS_READ:
rc = udebug_rp_regs_read(call, phone);
return rc;
case UDEBUG_M_REGS_WRITE:
rc = udebug_rp_regs_write(call, phone);
return rc;
case UDEBUG_M_THREAD_READ:
rc = udebug_rp_thread_read(call, phone);
return rc;