Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2814 → Rev 2815

/branches/tracing/kernel/generic/include/udebug/udebug_ipc.h
10,7 → 10,9
#include <ipc/ipc.h>
 
int udebug_request_preprocess(call_t *call, phone_t *phone);
void udebug_call_receive(call_t *call);
 
 
#endif
 
/** @}
/branches/tracing/kernel/generic/src/ipc/ipc.c
608,51 → 608,12
 
#include <ipc/ipcrsc.h>
#include <console/klog.h>
#include <syscall/copy.h>
#include <udebug/udebug.h>
#include <udebug/udebug_ipc.h>
 
static void debug_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);
}
 
static void kbox_thread_proc(void *arg)
{
call_t *call;
int method;
int dm;
 
(void)arg;
klog_printf("kbox_thread_proc()");
662,11 → 623,9
SYNCH_FLAGS_NONE);
if (call != NULL) {
method = IPC_GET_METHOD(call->data);
dm = IPC_GET_ARG1(call->data);
 
if (method == IPC_M_DEBUG_ALL &&
dm == UDEBUG_M_MEM_READ) {
debug_mem_read(call);
if (method == IPC_M_DEBUG_ALL) {
udebug_call_receive(call);
}
}
}
/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;
}
}
 
/** @}
*/