forked from M-Labs/artiq
runtime: support RPC exceptions on AMP
This commit is contained in:
parent
45bb9d8840
commit
5538ad5c70
|
@ -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, ...);
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
#include <generated/csr.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
|
@ -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, ...)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ struct msg_rpc_request {
|
|||
|
||||
struct msg_rpc_reply {
|
||||
int type;
|
||||
int ret_val;
|
||||
int eid;
|
||||
int retval;
|
||||
};
|
||||
|
||||
struct msg_log {
|
||||
|
|
Loading…
Reference in New Issue