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: 21a0919ddcdb
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: cbdc1ba46f4a
Choose a head ref
  • 3 commits
  • 19 files changed
  • 1 contributor

Commits on Apr 4, 2015

  1. remove gpio driver

    sbourdeauducq committed Apr 4, 2015
    Copy the full SHA
    8331784 View commit details
  2. Copy the full SHA
    277e038 View commit details
  3. Copy the full SHA
    cbdc1ba View commit details
16 changes: 0 additions & 16 deletions artiq/coredevice/gpio.py

This file was deleted.

1 change: 0 additions & 1 deletion artiq/coredevice/runtime.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
llvm.initialize_all_asmprinters()

_syscalls = {
"gpio_set": "ib:n",
"rtio_oe": "ib:n",
"rtio_set": "Iii:n",
"rtio_get_counter": "n:I",
13 changes: 6 additions & 7 deletions examples/master/ddb.pyon
Original file line number Diff line number Diff line change
@@ -12,13 +12,6 @@
"arguments": {}
},

"led": {
"type": "local",
"module": "artiq.coredevice.gpio",
"class": "GPIOOut",
"arguments": {"channel": 0}
},

"pmt0": {
"type": "local",
"module": "artiq.coredevice.rtio",
@@ -50,6 +43,12 @@
"class": "RTIOOut",
"arguments": {"channel": 4}
},
"led": {
"type": "local",
"module": "artiq.coredevice.rtio",
"class": "RTIOOut",
"arguments": {"channel": 18}
},

"dds0": {
"type": "local",
41 changes: 26 additions & 15 deletions soc/runtime/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
include $(MSCDIR)/software/common.mak

BOARD=papilio_pro
SERIAL=/dev/ttyUSB1

OBJECTS=isr.o elf_loader.o kernelcpu.o exception_jmp.o exceptions.o services.o comm_serial.o gpio.o rtio.o dds.o ksupport_data.o test_mode.o main.o
OBJECTS_SERVICES=exception_jmp.o exceptions.o rtio.o dds.o
OBJECTS=isr.o elf_loader.o services.o comm_serial.o test_mode.o main.o

UNIPROCESSOR := $(shell echo -e "\#include <generated/csr.h>\nCSR_KERNEL_CPU_BASE" | $(CC_normal) $(CFLAGS) -E - | tail -n 1 | grep -c CSR_KERNEL_CPU_BASE)

ifeq ($(UNIPROCESSOR),0)
OBJECTS += kernelcpu.o ksupport_data.o
CFLAGS += -DARTIQ_BIPROCESSOR
SERVICE_TABLE_INPUT = ksupport.elf
else
ifeq ($(UNIPROCESSOR),1)
OBJECTS += $(OBJECTS_SERVICES)
else
$(error failed to determine uniprocessor/biprocessor build)
endif
endif

all: runtime.bin

@@ -30,17 +42,22 @@ runtime.elf: $(OBJECTS) libs
-lbase -lcompiler-rt
@chmod -x $@

ksupport.elf: ksupport.o
ksupport.elf: $(OBJECTS_SERVICES) ksupport.o
$(LD) $(LDFLAGS) \
-T ksupport.ld \
-N -o $@ \
$(MSCDIR)/software/libbase/crt0-$(CPU).o \
ksupport.o
$^
@chmod -x $@

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

service_table.h: $(SERVICE_TABLE_INPUT)
@echo " GEN " $@ && ./gen_service_table.py $(SERVICE_TABLE_INPUT) > $@

services.c: service_table.h

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

@@ -54,15 +71,9 @@ libs:
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
$(MAKE) -C $(MSCDIR)/software/libbase

load: runtime.bin
$(MAKE) -C $(MSCDIR)/tools
$(MSCDIR)/tools/flterm --port $(SERIAL) --kernel runtime.bin

flash: runtime.fbi
$(MSCDIR)/flash_extra.py $(BOARD) runtime.fbi 0x70000

clean:
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) runtime.elf runtime.bin runtime.fbi .*~ *~
$(RM) ksupport.d ksupport.o ksupport.elf ksupport.bin
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) $(OBJECTS_SERVICES) $(OBJECTS_SERVICES:.o=.d)
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
$(RM) service_table.h ksupport.d ksupport.o ksupport.elf ksupport.bin

.PHONY: all main.o clean libs load
16 changes: 16 additions & 0 deletions soc/runtime/comm_serial.c
Original file line number Diff line number Diff line change
@@ -151,7 +151,12 @@ static void receive_and_run_kernel(kernel_runner run_kernel)
send_char(MSGTYPE_KERNEL_EXCEPTION);
send_int(eid);
for(i=0;i<3;i++)
#ifdef ARTIQ_BIPROCESSOR
#warning TODO
send_llint(0LL);
#else
send_llint(exception_params[i]);
#endif
break;
case KERNEL_RUN_STARTUP_FAILED:
send_char(MSGTYPE_KERNEL_STARTUP_FAILED);
@@ -172,9 +177,16 @@ void comm_serve(object_loader load_object, kernel_runner run_kernel)
if(msgtype == MSGTYPE_REQUEST_IDENT) {
send_char(MSGTYPE_IDENT);
send_int(0x41524f52); /* "AROR" - ARTIQ runtime on OpenRISC */
#ifdef ARTIQ_BIPROCESSOR
#warning TODO
send_int(125*1000*1000);
send_char(0);
send_char(1);
#else
send_int(rtio_frequency_i_read());
send_char(rtio_frequency_fn_read());
send_char(rtio_frequency_fd_read());
#endif
} else if(msgtype == MSGTYPE_LOAD_OBJECT)
receive_and_load_object(load_object);
else if(msgtype == MSGTYPE_RUN_KERNEL)
@@ -253,8 +265,12 @@ int comm_rpc(int rpc_num, ...)
eid = receive_int();
retval = receive_int();

#ifdef ARTIQ_BIPROCESSOR
#warning TODO
#else
if(eid != EID_NONE)
exception_raise(eid);
#endif

return retval;
}
8 changes: 8 additions & 0 deletions soc/runtime/exceptions.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <generated/csr.h>

#include "exceptions.h"
#ifndef ARTIQ_BIPROCESSOR
#include "comm.h"
#endif

#define MAX_EXCEPTION_CONTEXTS 64

@@ -45,7 +49,11 @@ void exception_raise_params(int id,
exception_params[2] = p2;
exception_longjmp(exception_contexts[--ec_top].jb);
} else {
#ifdef ARTIQ_BIPROCESSOR
#warning TODO
#else
comm_log("ERROR: uncaught exception, ID=%d\n", id);
#endif
while(1);
}
}
62 changes: 62 additions & 0 deletions soc/runtime/gen_service_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3

import sys


services = [
("syscalls", [
("rpc", "comm_rpc"),
("rtio_oe", "rtio_oe"),
("rtio_set", "rtio_set"),
("rtio_get_counter", "rtio_get_counter"),
("rtio_get", "rtio_get"),
("rtio_pileup_count", "rtio_pileup_count"),
("dds_phase_clear_en", "dds_phase_clear_en"),
("dds_program", "dds_program"),
]),
("eh", [
("setjmp", "exception_setjmp"),
("push", "exception_push"),
("pop", "exception_pop"),
("getid", "exception_getid"),
("raise", "exception_raise"),
])
]


def print_uniprocessor():
for name, contents in services:
print("static const struct symbol {}[] = {{".format(name))
for name, value in contents:
print(" {{\"{}\", {}}},".format(name, value))
print(" {NULL, NULL}")
print("};")


def print_biprocessor(ksupport_elf_filename):
from elftools.elf.elffile import ELFFile
with open(ksupport_elf_filename, "rb") as f:
elf = ELFFile(f)
symtab = elf.get_section_by_name(b".symtab")
symbols = {symbol.name: symbol.entry.st_value
for symbol in symtab.iter_symbols()}
for name, contents in services:
print("static const struct symbol {}[] = {{".format(name))
for name, value in contents:
print(" {{\"{}\", (void *)0x{:08x}}},"
.format(name, symbols[bytes(value, "ascii")]))
print(" {NULL, NULL}")
print("};")


def main():
if len(sys.argv) == 1:
print_uniprocessor()
elif len(sys.argv) == 2:
print_biprocessor(sys.argv[1])
else:
print("Incorrect number of command line arguments")
sys.exit(1)

if __name__ == "__main__":
main()
14 changes: 0 additions & 14 deletions soc/runtime/gpio.c

This file was deleted.

6 changes: 0 additions & 6 deletions soc/runtime/gpio.h

This file was deleted.

11 changes: 4 additions & 7 deletions soc/runtime/kernelcpu.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#include <generated/csr.h>

#ifdef CSR_KERNEL_CPU_BASE

#include <stdio.h>
#include <string.h>
#include <system.h>

#include <generated/csr.h>

#include "kernelcpu.h"

extern char _binary_ksupport_bin_start;
extern char _binary_ksupport_bin_end;

void kernelcpu_start(void)
void kernelcpu_start(void *addr)
{
memcpy((void *)KERNELCPU_EXEC_ADDRESS, &_binary_ksupport_bin_start,
&_binary_ksupport_bin_end - &_binary_ksupport_bin_start);
KERNELCPU_MAILBOX = (unsigned int)addr;
flush_l2_cache();
kernel_cpu_reset_write(0);
}
@@ -23,5 +22,3 @@ void kernelcpu_stop(void)
{
kernel_cpu_reset_write(1);
}

#endif /* CSR_KERNEL_CPU_BASE */
4 changes: 2 additions & 2 deletions soc/runtime/kernelcpu.h
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
#include <hw/common.h>

#define KERNELCPU_EXEC_ADDRESS 0x40020000
#define KERNELCPU_KMAIN_ADDRESS 0x40022000
#define KERNELCPU_PAYLOAD_ADDRESS 0x40024000

#define KERNELCPU_MAILBOX MMPTR(0xd0000000)

void kernelcpu_start(void);
void kernelcpu_start(void *addr);
void kernelcpu_stop(void);

#endif /* __KERNELCPU_H */
32 changes: 29 additions & 3 deletions soc/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
#include "kernelcpu.h"
#include "exceptions.h"
#include "comm.h"
#include "rtio.h"
#include "dds.h"

void exception_handler(unsigned long vect, unsigned long *sp);
void exception_handler(unsigned long vect, unsigned long *sp)
{
/* TODO: report hardware exception to comm CPU */
for(;;);
}

extern void kmain(void);
typedef void (*kernel_function)(void);

int main(void);
int main(void)
{
kmain();
/* TODO: report end of kernel to comm CPU */
kernel_function k;
void *jb;

k = (kernel_function)KERNELCPU_MAILBOX;

jb = exception_push();
if(exception_setjmp(jb))
KERNELCPU_MAILBOX = KERNEL_RUN_EXCEPTION;
else {
dds_init();
rtio_init();
k();
exception_pop(1);
KERNELCPU_MAILBOX = KERNEL_RUN_FINISHED;
}
while(1);
}

int comm_rpc(int rpc_num, ...);
int comm_rpc(int rpc_num, ...)
{
/* TODO */
return 0;
}
7 changes: 2 additions & 5 deletions soc/runtime/ksupport.ld
Original file line number Diff line number Diff line change
@@ -4,15 +4,12 @@ ENTRY(_start)
INCLUDE generated/regions.ld

/* First 128K of main memory are reserved for runtime code/data
* then comes kernel memory. First 8K of kernel memory are for support code.
* then comes kernel memory. First 16K of kernel memory are for support code.
*/
MEMORY {
ksupport : ORIGIN = 0x40020000, LENGTH = 0x2000
ksupport : ORIGIN = 0x40020000, LENGTH = 0x4000
}

/* Then comes the payload. */
PROVIDE(kmain = ORIGIN(ksupport) + LENGTH(ksupport));

/* On biprocessor systems, kernel stack is at the end of main RAM,
* before the runtime stack. Leave 1M for runtime stack.
*/
5 changes: 1 addition & 4 deletions soc/runtime/linker.ld
Original file line number Diff line number Diff line change
@@ -12,10 +12,7 @@ MEMORY {

/* Kernel memory space start right after the runtime,
* and ends before the runtime stack.
*/
PROVIDE(_kmem = 0x40020000);

/* Runtime stack is always at the end of main_ram.
* Runtime stack is always at the end of main_ram.
* This stack is shared with the kernel on uniprocessor systems.
*/
PROVIDE(_fstack = 0x40000000 + LENGTH(main_ram) - 4);
Loading