Skip to content

Commit

Permalink
Integrate libdyld and libunwind.
Browse files Browse the repository at this point in the history
It is currently possible to run the idle experiment, and it
can raise and catch exceptions, but exceptions are not yet
propagated across RPC boundaries.
  • Loading branch information
whitequark committed Aug 2, 2015
1 parent 6db93b3 commit 122b3b0
Show file tree
Hide file tree
Showing 22 changed files with 401 additions and 793 deletions.
4 changes: 2 additions & 2 deletions artiq/coredevice/comm_generic.py
Expand Up @@ -16,7 +16,7 @@ class _H2DMsgType(Enum):
IDENT_REQUEST = 2
SWITCH_CLOCK = 3

LOAD_OBJECT = 4
LOAD_LIBRARY = 4
RUN_KERNEL = 5

RPC_REPLY = 6
Expand Down Expand Up @@ -124,7 +124,7 @@ def switch_clock(self, external):
raise IOError("Incorrect reply from device: {}".format(ty))

def load(self, kcode):
self._write_header(len(kcode) + 9, _H2DMsgType.LOAD_OBJECT)
self._write_header(len(kcode) + 9, _H2DMsgType.LOAD_LIBRARY)
self.write(kcode)
_, ty = self._read_header()
if ty != _D2HMsgType.LOAD_COMPLETED:
Expand Down
35 changes: 21 additions & 14 deletions soc/runtime/Makefile
@@ -1,9 +1,15 @@
include $(MSCDIR)/software/common.mak

OBJECTS := isr.o flash_storage.o clock.o rtiocrg.o elf_loader.o services.o session.o log.o test_mode.o kloader.o bridge_ctl.o mailbox.o ksupport_data.o net_server.o moninj.o main.o
OBJECTS_KSUPPORT := ksupport.o exception_jmp.o exceptions.o mailbox.o bridge.o rtio.o ttl.o dds.o
OBJECTS := isr.o clock.o rtiocrg.o flash_storage.o mailbox.o \
session.o log.o moninj.o net_server.o bridge_ctl.o \
ksupport_data.o kloader.o test_mode.o main.o
OBJECTS_KSUPPORT := ksupport.o artiq_personality.o mailbox.o \
bridge.o rtio.o ttl.o dds.o

CFLAGS += -Ilwip/src/include -Iliblwip
CFLAGS += -I$(MSCDIR)/software/include/dyld \
-I$(MSCDIR)/software/unwinder/include \
-I$(MSCDIR)/software/libunwind \
-Ilwip/src/include -Iliblwip

all: runtime.bin runtime.fbi

Expand All @@ -19,7 +25,7 @@ all: runtime.bin runtime.fbi

runtime.elf: $(OBJECTS) libs
$(LD) $(LDFLAGS) \
-T linker.ld \
-T runtime.ld \
-N -o $@ \
$(MSCDIR)/software/libbase/crt0-$(CPU).o \
$(OBJECTS) \
Expand All @@ -29,24 +35,23 @@ runtime.elf: $(OBJECTS) libs
-lbase -lcompiler-rt -llwip
@chmod -x $@

ksupport.elf: $(OBJECTS_KSUPPORT)
ksupport.elf: $(OBJECTS_KSUPPORT) libs
$(LD) $(LDFLAGS) \
--eh-frame-hdr \
-T ksupport.ld \
-N -o $@ \
$(MSCDIR)/software/libbase/crt0-$(CPU).o \
$^ \
$(OBJECTS_KSUPPORT) \
-L$(MSCDIR)/software/libbase \
-L$(MSCDIR)/software/libcompiler-rt \
-lcompiler-rt
-L$(MSCDIR)/software/libunwind \
-L$(MSCDIR)/software/libdyld \
-lbase -lcompiler-rt -lunwind -ldyld
@chmod -x $@

ksupport_data.o: ksupport.bin
ksupport_data.o: ksupport.elf
$(LD) -r -b binary -o $@ $<

service_table.h: ksupport.elf gen_service_table.py
@echo " GEN " $@ && ./gen_service_table.py ksupport.elf > $@

services.c: service_table.h

main.o: main.c
$(compile-dep)

Expand All @@ -58,13 +63,15 @@ main.o: main.c

libs:
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
$(MAKE) -C $(MSCDIR)/software/libunwind
$(MAKE) -C $(MSCDIR)/software/libbase
$(MAKE) -C $(MSCDIR)/software/libdyld
$(MAKE) -C liblwip

clean:
$(MAKE) -C liblwip clean
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) $(OBJECTS_KSUPPORT) $(OBJECTS_KSUPPORT:.o=.d)
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
$(RM) service_table.h ksupport.elf ksupport.bin
$(RM) ksupport.elf ksupport.bin

.PHONY: all main.o clean libs load
4 changes: 3 additions & 1 deletion soc/runtime/artiq_personality.c
Expand Up @@ -246,7 +246,9 @@ struct artiq_raised_exception {
static struct artiq_raised_exception inflight;

void __artiq_raise(struct artiq_exception *artiq_exn) {
EH_LOG("===> raise (name=%s)", artiq_exn->name);
EH_LOG("===> raise (name=%s, msg=%s, params=[%lld,%lld,%lld])",
artiq_exn->name, artiq_exn->message,
artiq_exn->param[0], artiq_exn->param[1], artiq_exn->param[2]);

memmove(&inflight.artiq, artiq_exn, sizeof(struct artiq_exception));
inflight.unwind.exception_class = ARTIQ_EXCEPTION_CLASS;
Expand Down
2 changes: 1 addition & 1 deletion soc/runtime/bridge.c
Expand Up @@ -32,7 +32,7 @@ static void send_ready(void)
struct msg_base msg;

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

void bridge_main(void)
Expand Down
8 changes: 4 additions & 4 deletions soc/runtime/dds.c
@@ -1,7 +1,7 @@
#include <generated/csr.h>
#include <stdio.h>

#include "exceptions.h"
#include "artiq_personality.h"
#include "rtio.h"
#include "log.h"
#include "dds.h"
Expand Down Expand Up @@ -179,7 +179,7 @@ static struct dds_set_params batch[DDS_MAX_BATCH];
void dds_batch_enter(long long int timestamp)
{
if(batch_mode)
exception_raise(EID_DDS_BATCH_ERROR);
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
batch_mode = 1;
batch_count = 0;
batch_ref_time = timestamp;
Expand All @@ -191,7 +191,7 @@ void dds_batch_exit(void)
int i;

if(!batch_mode)
exception_raise(EID_DDS_BATCH_ERROR);
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
rtio_chan_sel_write(RTIO_DDS_CHANNEL);
/* + FUD time */
now = batch_ref_time - batch_count*(DURATION_PROGRAM + DURATION_WRITE);
Expand All @@ -208,7 +208,7 @@ void dds_set(long long int timestamp, int channel,
{
if(batch_mode) {
if(batch_count >= DDS_MAX_BATCH)
exception_raise(EID_DDS_BATCH_ERROR);
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
/* timestamp parameter ignored (determined by batch) */
batch[batch_count].channel = channel;
batch[batch_count].ftw = ftw;
Expand Down
240 changes: 0 additions & 240 deletions soc/runtime/elf_loader.c

This file was deleted.

0 comments on commit 122b3b0

Please sign in to comment.