Skip to content

Commit

Permalink
runtime: support test mode on AMP
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Apr 16, 2015
1 parent 546996f commit 6a5f58e
Showing 7 changed files with 311 additions and 69 deletions.
2 changes: 1 addition & 1 deletion soc/runtime/Makefile
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ UNIPROCESSOR := $(shell printf "\#include <generated/csr.h>\nCSR_KERNEL_CPU_BASE

ifeq ($(UNIPROCESSOR),0)
OBJECTS += mailbox.o kernelcpu.o ksupport_data.o
OBJECTS_KSUPPORT += mailbox.o ksupport.o
OBJECTS_KSUPPORT += mailbox.o bridge.o ksupport.o
CFLAGS += -DARTIQ_AMP
SERVICE_TABLE_INPUT = ksupport.elf
else
79 changes: 79 additions & 0 deletions soc/runtime/bridge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "mailbox.h"
#include "messages.h"
#include "rtio.h"
#include "dds.h"
#include "bridge.h"

static void send_ready(void)
{
struct msg_base msg;

msg.type = MESSAGE_TYPE_BRG_READY;
mailbox_send_and_wait(&msg);
}

void bridge_main(void)
{
struct msg_base *umsg;

send_ready();
while(1) {
umsg = mailbox_wait_and_receive();
switch(umsg->type) {
case MESSAGE_TYPE_BRG_TTL_OUT: {
struct msg_brg_ttl_out *msg;

msg = (struct msg_brg_ttl_out *)umsg;
rtio_init();
rtio_set_oe(rtio_get_counter() + 8000, msg->channel, 1);
rtio_set_o(rtio_get_counter() + 8000, msg->channel, msg->value);
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_BRG_DDS_SEL: {
struct msg_brg_dds_sel *msg;

msg = (struct msg_brg_dds_sel *)umsg;
DDS_WRITE(DDS_GPIO, msg->channel);
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_BRG_DDS_RESET: {
unsigned int g;

g = DDS_READ(DDS_GPIO);
DDS_WRITE(DDS_GPIO, g | (1 << 7));
DDS_WRITE(DDS_GPIO, g);

mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_BRG_DDS_READ_REQUEST: {
struct msg_brg_dds_read_request *msg;
struct msg_brg_dds_read_reply rmsg;

msg = (struct msg_brg_dds_read_request *)umsg;
rmsg.type = MESSAGE_TYPE_BRG_DDS_READ_REPLY;
rmsg.data = DDS_READ(msg->address);
mailbox_send_and_wait(&rmsg);
break;
}
case MESSAGE_TYPE_BRG_DDS_WRITE: {
struct msg_brg_dds_write *msg;

msg = (struct msg_brg_dds_write *)umsg;
DDS_WRITE(msg->address, msg->data);
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_BRG_DDS_FUD:
rtio_init();
rtio_fud(rtio_get_counter() + 8000);
mailbox_acknowledge();
break;
default:
mailbox_acknowledge();
break;
}
}
}
6 changes: 6 additions & 0 deletions soc/runtime/bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __BRIDGE_H
#define __BRIDGE_H

void bridge_main(void);

#endif /* __BRIDGE_H */
44 changes: 24 additions & 20 deletions soc/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdarg.h>

#include "exceptions.h"
#include "bridge.h"
#include "mailbox.h"
#include "messages.h"
#include "rtio.h"
@@ -31,26 +32,29 @@ int main(void)
kernel_function k;
void *jb;

jb = exception_push();
if(exception_setjmp(jb)) {
struct msg_exception msg;

msg.type = MESSAGE_TYPE_EXCEPTION;
msg.eid = exception_getid(msg.eparams);
mailbox_send_and_wait(&msg);
} else {
struct msg_finished msg;

k = mailbox_receive();
if(!k)
exception_raise(EID_INTERNAL_ERROR);
dds_init();
rtio_init();
k();
exception_pop(1);

msg.type = MESSAGE_TYPE_FINISHED;
mailbox_send_and_wait(&msg);
k = mailbox_receive();

if(k == NULL)
bridge_main();
else {
jb = exception_push();
if(exception_setjmp(jb)) {
struct msg_exception msg;

msg.type = MESSAGE_TYPE_EXCEPTION;
msg.eid = exception_getid(msg.eparams);
mailbox_send_and_wait(&msg);
} else {
struct msg_base msg;

dds_init();
rtio_init();
k();
exception_pop(1);

msg.type = MESSAGE_TYPE_FINISHED;
mailbox_send_and_wait(&msg);
}
}
while(1);
}
4 changes: 2 additions & 2 deletions soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ static int load_object(void *buffer, int length)


#ifdef ARTIQ_AMP
static int process_msg(struct msg_unknown *umsg, int *eid, long long int *eparams)
static int process_msg(struct msg_base *umsg, int *eid, long long int *eparams)
{
int i;

@@ -129,7 +129,7 @@ static int run_kernel(const char *kernel_name, int *eid, long long int *eparams)
#ifdef ARTIQ_AMP
kernelcpu_start(k);
while(1) {
struct msg_unknown *umsg;
struct msg_base *umsg;

umsg = mailbox_receive();
r = KERNEL_RUN_INVALID_STATUS;
46 changes: 41 additions & 5 deletions soc/runtime/messages.h
Original file line number Diff line number Diff line change
@@ -8,17 +8,24 @@ enum {
MESSAGE_TYPE_EXCEPTION,
MESSAGE_TYPE_RPC_REQUEST,
MESSAGE_TYPE_RPC_REPLY,
MESSAGE_TYPE_LOG
};
MESSAGE_TYPE_LOG,

struct msg_unknown {
int type;
MESSAGE_TYPE_BRG_READY,
MESSAGE_TYPE_BRG_TTL_OUT,
MESSAGE_TYPE_BRG_DDS_SEL,
MESSAGE_TYPE_BRG_DDS_RESET,
MESSAGE_TYPE_BRG_DDS_READ_REQUEST,
MESSAGE_TYPE_BRG_DDS_READ_REPLY,
MESSAGE_TYPE_BRG_DDS_WRITE,
MESSAGE_TYPE_BRG_DDS_FUD,
};

struct msg_finished {
struct msg_base {
int type;
};

/* kernel messages */

struct msg_exception {
int type;
int eid;
@@ -43,4 +50,33 @@ struct msg_log {
va_list args;
};

/* bridge messages */

struct msg_brg_ttl_out {
int type;
int channel;
int value;
};

struct msg_brg_dds_sel {
int type;
int channel;
};

struct msg_brg_dds_read_request {
int type;
unsigned int address;
};

struct msg_brg_dds_read_reply {
int type;
unsigned int data;
};

struct msg_brg_dds_write {
int type;
unsigned int address;
unsigned int data;
};

#endif /* __MESSAGES_H */
Loading

0 comments on commit 6a5f58e

Please sign in to comment.