HelenOS sources
This source file includes following definitions.
- udebug_request_preprocess
- udebug_receive_begin
- udebug_receive_end
- udebug_receive_set_evmask
- udebug_receive_go
- udebug_receive_stop
- udebug_receive_thread_read
- udebug_receive_name_read
- udebug_receive_areas_read
- udebug_receive_args_read
- udebug_receive_regs_read
- udebug_receive_mem_read
- udebug_call_receive
#include <assert.h>
#include <proc/task.h>
#include <proc/thread.h>
#include <mm/as.h>
#include <arch.h>
#include <errno.h>
#include <ipc/ipc.h>
#include <syscall/copy.h>
#include <udebug/udebug.h>
#include <udebug/udebug_ops.h>
#include <udebug/udebug_ipc.h>
errno_t udebug_request_preprocess(call_t *call, phone_t *phone)
{
switch (ipc_get_arg1(&call->data)) {
default:
break;
}
return EOK;
}
static void udebug_receive_begin(call_t *call)
{
errno_t rc;
bool active;
rc = udebug_begin(call, &active);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
if (active) {
ipc_set_retval(&call->data, EOK);
ipc_answer(&TASK->kb.box, call);
}
}
static void udebug_receive_end(call_t *call)
{
errno_t rc;
rc = udebug_end();
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_set_evmask(call_t *call)
{
errno_t rc;
udebug_evmask_t mask;
mask = ipc_get_arg2(&call->data);
rc = udebug_set_evmask(mask);
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_go(call_t *call)
{
thread_t *t;
errno_t rc;
t = (thread_t *)ipc_get_arg2(&call->data);
rc = udebug_go(t, call);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
}
static void udebug_receive_stop(call_t *call)
{
thread_t *t;
errno_t rc;
t = (thread_t *)ipc_get_arg2(&call->data);
rc = udebug_stop(t, call);
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_thread_read(call_t *call)
{
uintptr_t uspace_addr;
size_t buf_size;
void *buffer;
size_t copied, needed;
errno_t rc;
uspace_addr = ipc_get_arg2(&call->data);
buf_size = ipc_get_arg3(&call->data);
rc = udebug_thread_read(&buffer, buf_size, &copied, &needed);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_addr);
ipc_set_arg2(&call->data, copied);
ipc_set_arg3(&call->data, needed);
call->buffer = buffer;
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_name_read(call_t *call)
{
sysarg_t uspace_addr;
sysarg_t to_copy;
size_t data_size;
size_t buf_size;
void *data;
errno_t rc;
uspace_addr = ipc_get_arg2(&call->data);
buf_size = ipc_get_arg3(&call->data);
rc = udebug_name_read((char **) &data, &data_size);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
if (buf_size > data_size)
to_copy = data_size;
else
to_copy = buf_size;
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_addr);
ipc_set_arg2(&call->data, to_copy);
ipc_set_arg3(&call->data, data_size);
call->buffer = data;
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_areas_read(call_t *call)
{
sysarg_t uspace_addr;
sysarg_t to_copy;
size_t data_size;
size_t buf_size;
as_area_info_t *data;
uspace_addr = ipc_get_arg2(&call->data);
buf_size = ipc_get_arg3(&call->data);
data = as_get_area_info(AS, &data_size);
if (!data) {
ipc_set_retval(&call->data, ENOMEM);
ipc_answer(&TASK->kb.box, call);
return;
}
if (buf_size > data_size)
to_copy = data_size;
else
to_copy = buf_size;
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_addr);
ipc_set_arg2(&call->data, to_copy);
ipc_set_arg3(&call->data, data_size);
call->buffer = (uint8_t *) data;
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_args_read(call_t *call)
{
thread_t *t;
sysarg_t uspace_addr;
errno_t rc;
void *buffer;
t = (thread_t *)ipc_get_arg2(&call->data);
rc = udebug_args_read(t, &buffer);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
uspace_addr = ipc_get_arg3(&call->data);
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_addr);
ipc_set_arg2(&call->data, 6 * sizeof(sysarg_t));
call->buffer = buffer;
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_regs_read(call_t *call)
{
thread_t *t;
sysarg_t uspace_addr;
sysarg_t to_copy;
void *buffer = NULL;
errno_t rc;
t = (thread_t *) ipc_get_arg2(&call->data);
rc = udebug_regs_read(t, &buffer);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
assert(buffer != NULL);
uspace_addr = ipc_get_arg3(&call->data);
to_copy = sizeof(istate_t);
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_addr);
ipc_set_arg2(&call->data, to_copy);
call->buffer = buffer;
ipc_answer(&TASK->kb.box, call);
}
static void udebug_receive_mem_read(call_t *call)
{
uspace_addr_t uspace_dst;
uspace_addr_t uspace_src;
unsigned size;
void *buffer = NULL;
errno_t rc;
uspace_dst = ipc_get_arg2(&call->data);
uspace_src = ipc_get_arg3(&call->data);
size = ipc_get_arg4(&call->data);
rc = udebug_mem_read(uspace_src, size, &buffer);
if (rc != EOK) {
ipc_set_retval(&call->data, rc);
ipc_answer(&TASK->kb.box, call);
return;
}
assert(buffer != NULL);
ipc_set_retval(&call->data, EOK);
ipc_set_arg1(&call->data, uspace_dst);
ipc_set_arg2(&call->data, size);
call->buffer = buffer;
ipc_answer(&TASK->kb.box, call);
}
void udebug_call_receive(call_t *call)
{
int debug_method;
debug_method = ipc_get_arg1(&call->data);
if (debug_method != UDEBUG_M_BEGIN) {
if (TASK->udebug.debugger != call->sender) {
ipc_set_retval(&call->data, EINVAL);
ipc_answer(&TASK->kb.box, call);
return;
}
}
switch (debug_method) {
case UDEBUG_M_BEGIN:
udebug_receive_begin(call);
break;
case UDEBUG_M_END:
udebug_receive_end(call);
break;
case UDEBUG_M_SET_EVMASK:
udebug_receive_set_evmask(call);
break;
case UDEBUG_M_GO:
udebug_receive_go(call);
break;
case UDEBUG_M_STOP:
udebug_receive_stop(call);
break;
case UDEBUG_M_THREAD_READ:
udebug_receive_thread_read(call);
break;
case UDEBUG_M_NAME_READ:
udebug_receive_name_read(call);
break;
case UDEBUG_M_AREAS_READ:
udebug_receive_areas_read(call);
break;
case UDEBUG_M_ARGS_READ:
udebug_receive_args_read(call);
break;
case UDEBUG_M_REGS_READ:
udebug_receive_regs_read(call);
break;
case UDEBUG_M_MEM_READ:
udebug_receive_mem_read(call);
break;
}
}
HelenOS homepage, sources at GitHub