Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2814 → Rev 2815

/branches/tracing/kernel/generic/src/udebug/udebug_ipc.c
10,6 → 10,7
#include <console/klog.h>
#include <proc/task.h>
#include <proc/thread.h>
#include <arch.h>
#include <errno.h>
#include <ipc/ipc.h>
#include <syscall/copy.h>
221,6 → 222,60
return 0;
}
 
static void udebug_receive_mem_read(call_t *call)
{
unative_t uspace_dst;
void *uspace_ptr;
unsigned size;
void *buffer;
int rc;
 
klog_printf("debug_mem_read()");
uspace_dst = IPC_GET_ARG2(call->data);
uspace_ptr = (void *)IPC_GET_ARG3(call->data);
size = IPC_GET_ARG4(call->data);
 
buffer = malloc(size, 0); // ???
klog_printf("debug_mem_read: src=%u, size=%u", uspace_ptr, size);
 
/* NOTE: this is not strictly from a syscall... but that shouldn't
* be a problem */
rc = copy_from_uspace(buffer, uspace_ptr, size);
if (rc) {
IPC_SET_RETVAL(call->data, rc);
return;
}
 
klog_printf("first word: %u", *((unative_t *)buffer));
 
IPC_SET_RETVAL(call->data, 0);
/* Hack: ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
same code in process_answer() can be used
(no way to distinguish method in answer) */
IPC_SET_ARG1(call->data, uspace_dst);
IPC_SET_ARG2(call->data, size);
call->buffer = buffer;
 
ipc_answer(&TASK->kernel_box, call);
}
 
/**
* Handle a debug call received on the kernel answerbox.
*
* This is called by the kbox servicing thread.
*/
void udebug_call_receive(call_t *call)
{
int debug_method;
 
debug_method = IPC_GET_ARG1(call->data);
 
switch (debug_method) {
case UDEBUG_M_MEM_READ:
udebug_receive_mem_read(call);
break;
}
}
 
/** @}
*/