runtime: support RPC exceptions on AMP

This commit is contained in:
Sebastien Bourdeauducq 2015-04-06 22:28:10 +08:00
parent 45bb9d8840
commit 5538ad5c70
5 changed files with 26 additions and 23 deletions

View File

@ -15,7 +15,7 @@ typedef int (*object_loader)(void *, int);
typedef int (*kernel_runner)(const char *, int *, long long int *); typedef int (*kernel_runner)(const char *, int *, long long int *);
void comm_serve(object_loader load_object, kernel_runner run_kernel); 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, ...); int comm_rpc(int rpc_num, ...);
void comm_log_va(const char *fmt, va_list args); void comm_log_va(const char *fmt, va_list args);
void comm_log(const char *fmt, ...); void comm_log(const char *fmt, ...);

View File

@ -4,7 +4,11 @@
#include <generated/csr.h> #include <generated/csr.h>
#include "comm.h" #include "comm.h"
#ifndef ARTIQ_AMP
#include "exceptions.h" #include "exceptions.h"
#endif
/* host to device */ /* host to device */
enum { enum {
@ -242,11 +246,9 @@ static int send_value(int type_tag, void *value)
return 0; 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 type_tag;
int eid;
int retval;
send_char(MSGTYPE_RPC_REQUEST); send_char(MSGTYPE_RPC_REQUEST);
send_sint(rpc_num); 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_value(type_tag, type_tag == 'n' ? NULL : va_arg(args, void *));
send_char(0); send_char(0);
eid = receive_int(); *eid = receive_int();
retval = receive_int(); *retval = receive_int();
#ifdef ARTIQ_AMP
#warning TODO
#else
if(eid != EID_NONE)
exception_raise(eid);
#endif
return retval;
} }
#ifndef ARTIQ_AMP
int comm_rpc(int rpc_num, ...) int comm_rpc(int rpc_num, ...)
{ {
va_list args; va_list args;
int r; int eid, retval;
va_start(args, rpc_num); va_start(args, rpc_num);
r = comm_rpc_va(rpc_num, args); comm_rpc_va(rpc_num, args, &eid, &retval);
va_end(args); 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) void comm_log_va(const char *fmt, va_list args)
{ {

View File

@ -59,7 +59,7 @@ int comm_rpc(int rpc_num, ...)
{ {
struct msg_rpc_request request; struct msg_rpc_request request;
struct msg_rpc_reply *reply; struct msg_rpc_reply *reply;
int r; int eid, retval;
request.type = MESSAGE_TYPE_RPC_REQUEST; request.type = MESSAGE_TYPE_RPC_REQUEST;
request.rpc_num = rpc_num; request.rpc_num = rpc_num;
@ -70,9 +70,13 @@ int comm_rpc(int rpc_num, ...)
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_RPC_REPLY) if(reply->type != MESSAGE_TYPE_RPC_REPLY)
exception_raise(EID_INTERNAL_ERROR); exception_raise(EID_INTERNAL_ERROR);
r = reply->ret_val; eid = reply->eid;
retval = reply->retval;
mailbox_acknowledge(); mailbox_acknowledge();
return r;
if(eid != EID_NONE)
exception_raise(eid);
return retval;
} }
void comm_log(const char *fmt, ...) void comm_log(const char *fmt, ...)

View File

@ -90,7 +90,7 @@ static int process_msg(struct msg_unknown *umsg, int *eid, long long int *eparam
struct msg_rpc_reply reply; struct msg_rpc_reply reply;
reply.type = MESSAGE_TYPE_RPC_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); mailbox_send_and_wait(&reply);
return KERNEL_RUN_INVALID_STATUS; return KERNEL_RUN_INVALID_STATUS;
} }

View File

@ -33,7 +33,8 @@ struct msg_rpc_request {
struct msg_rpc_reply { struct msg_rpc_reply {
int type; int type;
int ret_val; int eid;
int retval;
}; };
struct msg_log { struct msg_log {