Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 05dd11a60d21
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aba2d3f112ff
Choose a head ref
  • 5 commits
  • 9 files changed
  • 1 contributor

Commits on Jul 25, 2015

  1. Copy the full SHA
    61f45f5 View commit details
  2. Copy the full SHA
    696bceb View commit details
  3. Copy the full SHA
    3c6a4b8 View commit details
  4. Copy the full SHA
    d14a31f View commit details
  5. Copy the full SHA
    aba2d3f View commit details
Showing with 91 additions and 45 deletions.
  1. +1 −1 artiq/frontend/artiq_gui.py
  2. +1 −1 artiq/frontend/artiq_run.py
  3. +3 −1 artiq/gui/schedule.py
  4. +5 −0 artiq/gui/tools.py
  5. +1 −1 examples/master/ddb.pyon
  6. +63 −0 soc/runtime/kloader.c
  7. +6 −0 soc/runtime/kloader.h
  8. +4 −1 soc/runtime/main.c
  9. +7 −40 soc/runtime/session.c
2 changes: 1 addition & 1 deletion artiq/frontend/artiq_gui.py
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ def main():
area.addDock(d_params, "above", d_results)
area.addDock(d_explorer, "above", d_params)

d_schedule = ScheduleDock(schedule_ctl)
d_schedule = ScheduleDock(status_bar, schedule_ctl)
loop.run_until_complete(d_schedule.sub_connect(
args.server, args.port_notify))
atexit.register(lambda: loop.run_until_complete(d_schedule.sub_close()))
2 changes: 1 addition & 1 deletion artiq/frontend/artiq_run.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def build(self):
def run(self):
with open(self.file, "rb") as f:
self.core.comm.load(f.read())
self.core.comm.run("run", False)
self.core.comm.run("run")
self.core.comm.serve(dict(), dict())


4 changes: 3 additions & 1 deletion artiq/gui/schedule.py
Original file line number Diff line number Diff line change
@@ -46,9 +46,10 @@ def convert(self, k, v, column):


class ScheduleDock(dockarea.Dock):
def __init__(self, schedule_ctl):
def __init__(self, status_bar, schedule_ctl):
dockarea.Dock.__init__(self, "Schedule", size=(1000, 300))

self.status_bar = status_bar
self.schedule_ctl = schedule_ctl

self.table = QtGui.QTableView()
@@ -86,4 +87,5 @@ def delete_clicked(self):
if idx:
row = idx[0].row()
rid = self.table_model.row_to_key[row]
self.status_bar.showMessage("Deleted RID {}".format(rid))
asyncio.async(self.delete(rid))
5 changes: 5 additions & 0 deletions artiq/gui/tools.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,11 @@ def short_format(v):
t = type(v)
if t is int or t is float:
return str(v)
elif t is str:
if len(v) < 15:
return "\"" + v + "\""
else:
return "\"" + v[:12] + "\"..."
else:
r = t.__name__
if t is list or t is dict or t is set:
2 changes: 1 addition & 1 deletion examples/master/ddb.pyon
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 18}
"arguments": {"channel": 17}
},

"dds_bus": {
63 changes: 63 additions & 0 deletions soc/runtime/kloader.c
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include "log.h"
#include "flash_storage.h"
#include "mailbox.h"
#include "messages.h"
#include "elf_loader.h"
#include "services.h"
#include "kloader.h"
@@ -122,3 +123,65 @@ void kloader_stop(void)
kernel_cpu_reset_write(1);
mailbox_acknowledge();
}

int kloader_validate_kpointer(void *p)
{
unsigned int v = (unsigned int)p;
if((v < 0x40400000) || (v > (0x4fffffff - 1024*1024))) {
log("Received invalid pointer from kernel CPU: 0x%08x", v);
return 0;
}
return 1;
}

int kloader_is_essential_kmsg(int msgtype)
{
switch(msgtype) {
case MESSAGE_TYPE_NOW_INIT_REQUEST:
case MESSAGE_TYPE_NOW_SAVE:
case MESSAGE_TYPE_LOG:
return 1;
default:
return 0;
}
}

long long int now;

void kloader_service_essential_kmsg(void)
{
struct msg_base *umsg;

umsg = mailbox_receive();
if(umsg) {
if(!kloader_validate_kpointer(umsg))
return;
switch(umsg->type) {
case MESSAGE_TYPE_NOW_INIT_REQUEST: {
struct msg_now_init_reply reply;

reply.type = MESSAGE_TYPE_NOW_INIT_REPLY;
reply.now = now;
mailbox_send_and_wait(&reply);
break;
}
case MESSAGE_TYPE_NOW_SAVE: {
struct msg_now_save *msg = (struct msg_now_save *)umsg;

now = msg->now;
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_LOG: {
struct msg_log *msg = (struct msg_log *)umsg;

log_va(msg->fmt, msg->args);
mailbox_acknowledge();
break;
}
default:
/* handled elsewhere */
break;
}
}
}
6 changes: 6 additions & 0 deletions soc/runtime/kloader.h
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
#define KERNELCPU_EXEC_ADDRESS 0x40400000
#define KERNELCPU_PAYLOAD_ADDRESS 0x40404000

extern long long int now;

typedef void (*kernel_function)(void);

int kloader_load(void *buffer, int length);
@@ -14,4 +16,8 @@ void kloader_start_idle_kernel(void);
void kloader_start_user_kernel(kernel_function k);
void kloader_stop(void);

int kloader_validate_kpointer(void *p);
int kloader_is_essential_kmsg(int msgtype);
void kloader_service_essential_kmsg(void);

#endif /* __KLOADER_H */
5 changes: 4 additions & 1 deletion soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -143,6 +143,7 @@ static void regular_main(void)
session_end();
while(1) {
lwip_service();
kloader_service_essential_kmsg();
kserver_service();
}
}
@@ -201,8 +202,10 @@ static void regular_main(void)

/* Open the session for the serial control. */
session_start();
while(1)
while(1) {
kloader_service_essential_kmsg();
serial_service();
}
}

#endif
47 changes: 7 additions & 40 deletions soc/runtime/session.c
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@
#include "log.h"
#include "kloader.h"
#include "exceptions.h"
#include "session.h"
#include "flash_storage.h"
#include "session.h"

#define BUFFER_IN_SIZE (1024*1024)
#define BUFFER_OUT_SIZE (1024*1024)
@@ -55,7 +55,6 @@ static void submit_output(int len)
}

static int user_kernel_state;
static long long int now;

enum {
USER_KERNEL_NONE = 0,
@@ -153,7 +152,7 @@ static int process_input(void)
log("Attempted to switch RTIO clock while kernel running");
buffer_out[8] = REMOTEMSG_TYPE_CLOCK_SWITCH_FAILED;
submit_output(9);
break;
break;
}
rtio_crg_clock_sel_write(buffer_in[9]);
buffer_out[8] = REMOTEMSG_TYPE_CLOCK_SWITCH_COMPLETED;
@@ -421,16 +420,6 @@ static int add_rpc_value(int bi, int type_tag, void *value)
return bi - obi;
}

static int validate_kpointer(void *p)
{
unsigned int v = (unsigned int)p;
if((v < 0x40400000) || (v > (0x4fffffff - 1024*1024))) {
log("Received invalid pointer from kernel CPU: 0x%08x", v);
return 0;
}
return 1;
}

static int send_rpc_request(int rpc_num, va_list args)
{
int r;
@@ -448,7 +437,7 @@ static int send_rpc_request(int rpc_num, va_list args)
v = NULL;
else {
v = va_arg(args, void *);
if(!validate_kpointer(v))
if(!kloader_validate_kpointer(v))
return 0;
}
r = add_rpc_value(bi, type_tag, v);
@@ -467,31 +456,16 @@ static int send_rpc_request(int rpc_num, va_list args)
/* assumes output buffer is empty when called */
static int process_kmsg(struct msg_base *umsg)
{
if(!validate_kpointer(umsg))
if(!kloader_validate_kpointer(umsg))
return 0;
if((user_kernel_state != USER_KERNEL_RUNNING)
&& (umsg->type != MESSAGE_TYPE_NOW_INIT_REQUEST)
&& (umsg->type != MESSAGE_TYPE_NOW_SAVE)) {
if(kloader_is_essential_kmsg(umsg->type))
return 1; /* handled elsewhere */
if(user_kernel_state != USER_KERNEL_RUNNING) {
log("Received unexpected message from kernel CPU while not in running state");
return 0;
}

switch(umsg->type) {
case MESSAGE_TYPE_NOW_INIT_REQUEST: {
struct msg_now_init_reply reply;

reply.type = MESSAGE_TYPE_NOW_INIT_REPLY;
reply.now = now;
mailbox_send_and_wait(&reply);
break;
}
case MESSAGE_TYPE_NOW_SAVE: {
struct msg_now_save *msg = (struct msg_now_save *)umsg;

now = msg->now;
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_FINISHED:
buffer_out[8] = REMOTEMSG_TYPE_KERNEL_FINISHED;
submit_output(9);
@@ -538,13 +512,6 @@ static int process_kmsg(struct msg_base *umsg)
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_LOG: {
struct msg_log *msg = (struct msg_log *)umsg;

log_va(msg->fmt, msg->args);
mailbox_acknowledge();
break;
}
default: {
log("Received invalid message type from kernel CPU");
return 0;