Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2800 → Rev 2801

/branches/tracing/kernel/generic/src/ipc/sysipc.c
290,13 → 290,76
return 0;
}
 
static task_t *get_lock_callee_task(phone_t *phone)
{
answerbox_t *answerbox;
task_t *ta;
 
// FIXME: locking!!!
 
answerbox = phone->callee;
ta = answerbox->task;
 
spinlock_lock(&ta->lock);
 
return ta;
}
 
#include <console/klog.h>
 
static void debug_begin(call_t *call, phone_t *phone)
{
task_t *ta;
 
klog_printf("debug_begin()");
ta = get_lock_callee_task(phone);
klog_printf("debugging task %llu\n", ta->taskid);
 
if (ta->being_debugged != false) {
IPC_SET_RETVAL(call->data, EBUSY);
ipc_answer(&ta->answerbox, call);
 
spinlock_unlock(&ta->lock);
return;
}
 
ta->being_debugged = true;
ta->stop_request = true;
ta->debug_begin_call = call;
spinlock_unlock(&ta->lock);
 
klog_printf("debug_begin() done");
}
 
static void debug_go(call_t *call, phone_t *phone)
{
thread_t *t;
link_t *l;
task_t *ta;
 
klog_printf("debug_go()");
ta = get_lock_callee_task(phone);
 
l = ta->th_head.next;
if (l != &TASK->th_head) {
t = list_get_instance(l, thread_t, th_link);
waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
}
 
ta->debug_go_call = call;
spinlock_unlock(&ta->lock);
}
 
 
/** Called before the request is sent.
*
* @param call Call structure with the request.
* @param phone Phone that the call will be sent through.
*
* @return Return 0 on success, ELIMIT or EPERM on error.
*/
static int request_preprocess(call_t *call)
static int request_preprocess(call_t *call, phone_t *phone)
{
int newphid;
size_t size;
338,6 → 401,12
return rc;
}
break;
case IPC_M_DEBUG_BEGIN:
debug_begin(call, phone);
break;
case IPC_M_DEBUG_GO:
debug_go(call, phone);
break;
default:
break;
}
397,7 → 466,17
return -1;
}
IPC_SET_ARG5(call->data, phoneid);
}
}
switch (IPC_GET_METHOD(call->data)) {
case IPC_M_DEBUG_BEGIN:
case IPC_M_DEBUG_END:
case IPC_M_DEBUG_GO:
case IPC_M_DEBUG_STOP:
case IPC_M_DEBUG_GUARD:
return -1;
default:
break;
}
return 0;
}
 
439,7 → 518,7
IPC_SET_ARG4(call.data, 0);
IPC_SET_ARG5(call.data, 0);
 
if (!(res = request_preprocess(&call))) {
if (!(res = request_preprocess(&call, phone))) {
ipc_call_sync(phone, &call);
process_answer(&call);
} else {
477,7 → 556,7
 
GET_CHECK_PHONE(phone, phoneid, return ENOENT);
 
if (!(res = request_preprocess(&call))) {
if (!(res = request_preprocess(&call, phone))) {
ipc_call_sync(phone, &call);
process_answer(&call);
} else
544,7 → 623,7
*/
IPC_SET_ARG5(call->data, 0);
 
if (!(res = request_preprocess(call)))
if (!(res = request_preprocess(call, phone)))
ipc_call(phone, call);
else
ipc_backsend_err(phone, call, res);
578,7 → 657,7
ipc_call_free(call);
return (unative_t) rc;
}
if (!(res = request_preprocess(call)))
if (!(res = request_preprocess(call, phone)))
ipc_call(phone, call);
else
ipc_backsend_err(phone, call, res);
862,5 → 941,26
return 0;
}
 
#include <console/klog.h>
 
/**
* Syscall connect to a task by id.
*
* @return Phone id on success, or negative error code.
*/
unative_t sys_ipc_connect_task(sysarg64_t *uspace_taskid_arg)
{
sysarg64_t taskid_arg;
int rc;
rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
if (rc != 0)
return (unative_t) rc;
 
klog_printf("sys_ipc_connect_kbox(%lld, %d)", taskid_arg.value);
 
return ipc_connect_task(taskid_arg.value);
}
 
/** @}
*/