diff --git a/soc/runtime/comm.h b/soc/runtime/comm.h index f30431448..bf4d9f91e 100644 --- a/soc/runtime/comm.h +++ b/soc/runtime/comm.h @@ -15,7 +15,7 @@ typedef int (*object_loader)(void *, int); typedef int (*kernel_runner)(const char *, int *, long long int *); void comm_serve(object_loader load_object, kernel_runner run_kernel); -int comm_rpc_va(int rpc_num, va_list args); +void comm_rpc_va(int rpc_num, va_list args, int *eid, int *retval); int comm_rpc(int rpc_num, ...); void comm_log_va(const char *fmt, va_list args); void comm_log(const char *fmt, ...); diff --git a/soc/runtime/comm_serial.c b/soc/runtime/comm_serial.c index 546010e44..77bbcce95 100644 --- a/soc/runtime/comm_serial.c +++ b/soc/runtime/comm_serial.c @@ -4,7 +4,11 @@ #include #include "comm.h" + +#ifndef ARTIQ_AMP #include "exceptions.h" +#endif + /* host to device */ enum { @@ -242,11 +246,9 @@ static int send_value(int type_tag, void *value) return 0; } -int comm_rpc_va(int rpc_num, va_list args) +void comm_rpc_va(int rpc_num, va_list args, int *eid, int *retval) { int type_tag; - int eid; - int retval; send_char(MSGTYPE_RPC_REQUEST); send_sint(rpc_num); @@ -255,29 +257,25 @@ int comm_rpc_va(int rpc_num, va_list args) send_value(type_tag, type_tag == 'n' ? NULL : va_arg(args, void *)); send_char(0); - eid = receive_int(); - retval = receive_int(); - -#ifdef ARTIQ_AMP -#warning TODO -#else - if(eid != EID_NONE) - exception_raise(eid); -#endif - - return retval; + *eid = receive_int(); + *retval = receive_int(); } +#ifndef ARTIQ_AMP int comm_rpc(int rpc_num, ...) { va_list args; - int r; + int eid, retval; va_start(args, rpc_num); - r = comm_rpc_va(rpc_num, args); + comm_rpc_va(rpc_num, args, &eid, &retval); va_end(args); - return r; + + if(eid != EID_NONE) + exception_raise(eid); + return retval; } +#endif void comm_log_va(const char *fmt, va_list args) { diff --git a/soc/runtime/ksupport.c b/soc/runtime/ksupport.c index a9828592c..935d742f2 100644 --- a/soc/runtime/ksupport.c +++ b/soc/runtime/ksupport.c @@ -59,7 +59,7 @@ int comm_rpc(int rpc_num, ...) { struct msg_rpc_request request; struct msg_rpc_reply *reply; - int r; + int eid, retval; request.type = MESSAGE_TYPE_RPC_REQUEST; request.rpc_num = rpc_num; @@ -70,9 +70,13 @@ int comm_rpc(int rpc_num, ...) reply = mailbox_wait_and_receive(); if(reply->type != MESSAGE_TYPE_RPC_REPLY) exception_raise(EID_INTERNAL_ERROR); - r = reply->ret_val; + eid = reply->eid; + retval = reply->retval; mailbox_acknowledge(); - return r; + + if(eid != EID_NONE) + exception_raise(eid); + return retval; } void comm_log(const char *fmt, ...) diff --git a/soc/runtime/main.c b/soc/runtime/main.c index 36291c55b..4167037fe 100644 --- a/soc/runtime/main.c +++ b/soc/runtime/main.c @@ -90,7 +90,7 @@ static int process_msg(struct msg_unknown *umsg, int *eid, long long int *eparam struct msg_rpc_reply reply; reply.type = MESSAGE_TYPE_RPC_REPLY; - reply.ret_val = comm_rpc_va(msg->rpc_num, msg->args); + comm_rpc_va(msg->rpc_num, msg->args, &reply.eid, &reply.retval); mailbox_send_and_wait(&reply); return KERNEL_RUN_INVALID_STATUS; } diff --git a/soc/runtime/messages.h b/soc/runtime/messages.h index d79d8e354..274d40cf1 100644 --- a/soc/runtime/messages.h +++ b/soc/runtime/messages.h @@ -33,7 +33,8 @@ struct msg_rpc_request { struct msg_rpc_reply { int type; - int ret_val; + int eid; + int retval; }; struct msg_log {