Skip to content

Commit

Permalink
runtime: support RPC exceptions on AMP
Browse files Browse the repository at this point in the history
sbourdeauducq committed Apr 6, 2015
1 parent 45bb9d8 commit 5538ad5
Showing 5 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion soc/runtime/comm.h
Original file line number Diff line number Diff line change
@@ -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, ...);
32 changes: 15 additions & 17 deletions soc/runtime/comm_serial.c
Original file line number Diff line number Diff line change
@@ -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)
{
10 changes: 7 additions & 3 deletions soc/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -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, ...)
2 changes: 1 addition & 1 deletion soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 2 additions & 1 deletion soc/runtime/messages.h
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@ struct msg_rpc_request {

struct msg_rpc_reply {
int type;
int ret_val;
int eid;
int retval;
};

struct msg_log {

0 comments on commit 5538ad5

Please sign in to comment.