Skip to content

Commit 5538ad5

Browse files
committedApr 6, 2015
runtime: support RPC exceptions on AMP
1 parent 45bb9d8 commit 5538ad5

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed
 

Diff for: ‎soc/runtime/comm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef int (*object_loader)(void *, int);
1515
typedef int (*kernel_runner)(const char *, int *, long long int *);
1616

1717
void comm_serve(object_loader load_object, kernel_runner run_kernel);
18-
int comm_rpc_va(int rpc_num, va_list args);
18+
void comm_rpc_va(int rpc_num, va_list args, int *eid, int *retval);
1919
int comm_rpc(int rpc_num, ...);
2020
void comm_log_va(const char *fmt, va_list args);
2121
void comm_log(const char *fmt, ...);

Diff for: ‎soc/runtime/comm_serial.c

+15-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
#include <generated/csr.h>
55

66
#include "comm.h"
7+
8+
#ifndef ARTIQ_AMP
79
#include "exceptions.h"
10+
#endif
11+
812

913
/* host to device */
1014
enum {
@@ -242,11 +246,9 @@ static int send_value(int type_tag, void *value)
242246
return 0;
243247
}
244248

245-
int comm_rpc_va(int rpc_num, va_list args)
249+
void comm_rpc_va(int rpc_num, va_list args, int *eid, int *retval)
246250
{
247251
int type_tag;
248-
int eid;
249-
int retval;
250252

251253
send_char(MSGTYPE_RPC_REQUEST);
252254
send_sint(rpc_num);
@@ -255,29 +257,25 @@ int comm_rpc_va(int rpc_num, va_list args)
255257
send_value(type_tag, type_tag == 'n' ? NULL : va_arg(args, void *));
256258
send_char(0);
257259

258-
eid = receive_int();
259-
retval = receive_int();
260-
261-
#ifdef ARTIQ_AMP
262-
#warning TODO
263-
#else
264-
if(eid != EID_NONE)
265-
exception_raise(eid);
266-
#endif
267-
268-
return retval;
260+
*eid = receive_int();
261+
*retval = receive_int();
269262
}
270263

264+
#ifndef ARTIQ_AMP
271265
int comm_rpc(int rpc_num, ...)
272266
{
273267
va_list args;
274-
int r;
268+
int eid, retval;
275269

276270
va_start(args, rpc_num);
277-
r = comm_rpc_va(rpc_num, args);
271+
comm_rpc_va(rpc_num, args, &eid, &retval);
278272
va_end(args);
279-
return r;
273+
274+
if(eid != EID_NONE)
275+
exception_raise(eid);
276+
return retval;
280277
}
278+
#endif
281279

282280
void comm_log_va(const char *fmt, va_list args)
283281
{

Diff for: ‎soc/runtime/ksupport.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int comm_rpc(int rpc_num, ...)
5959
{
6060
struct msg_rpc_request request;
6161
struct msg_rpc_reply *reply;
62-
int r;
62+
int eid, retval;
6363

6464
request.type = MESSAGE_TYPE_RPC_REQUEST;
6565
request.rpc_num = rpc_num;
@@ -70,9 +70,13 @@ int comm_rpc(int rpc_num, ...)
7070
reply = mailbox_wait_and_receive();
7171
if(reply->type != MESSAGE_TYPE_RPC_REPLY)
7272
exception_raise(EID_INTERNAL_ERROR);
73-
r = reply->ret_val;
73+
eid = reply->eid;
74+
retval = reply->retval;
7475
mailbox_acknowledge();
75-
return r;
76+
77+
if(eid != EID_NONE)
78+
exception_raise(eid);
79+
return retval;
7680
}
7781

7882
void comm_log(const char *fmt, ...)

Diff for: ‎soc/runtime/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int process_msg(struct msg_unknown *umsg, int *eid, long long int *eparam
9090
struct msg_rpc_reply reply;
9191

9292
reply.type = MESSAGE_TYPE_RPC_REPLY;
93-
reply.ret_val = comm_rpc_va(msg->rpc_num, msg->args);
93+
comm_rpc_va(msg->rpc_num, msg->args, &reply.eid, &reply.retval);
9494
mailbox_send_and_wait(&reply);
9595
return KERNEL_RUN_INVALID_STATUS;
9696
}

Diff for: ‎soc/runtime/messages.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ struct msg_rpc_request {
3333

3434
struct msg_rpc_reply {
3535
int type;
36-
int ret_val;
36+
int eid;
37+
int retval;
3738
};
3839

3940
struct msg_log {

0 commit comments

Comments
 (0)
Please sign in to comment.