Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2808 → Rev 2809

/branches/tracing/kernel/generic/src/ipc/ipc.c
608,15 → 608,59
 
#include <ipc/ipcrsc.h>
#include <console/klog.h>
#include <syscall/copy.h>
 
static void debug_mem_read(call_t *call)
{
void *uspace_ptr;
unsigned size;
void *buffer;
int rc;
 
klog_printf("debug_mem_read()");
uspace_ptr = (void *)IPC_GET_ARG2(call->data);
size = IPC_GET_ARG3(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_ARG2(call->data, size);
call->buffer = buffer;
 
ipc_answer(&TASK->kernel_box, call);
}
 
static void kbox_thread_proc(void *arg)
{
call_t *call;
int method;
 
(void)arg;
klog_printf("kbox_thread_proc()");
while (1) {
klog_printf("kbox: wait for call");
ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT,
call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT,
SYNCH_FLAGS_NONE);
if (call != NULL) {
method = IPC_GET_METHOD(call->data);
if (method == IPC_M_DEBUG_MEM_READ) {
debug_mem_read(call);
}
}
}
}