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: 541324258757
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: 6a80944c3f18
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 22, 2015

  1. Copy the full SHA
    d5d49e7 View commit details
  2. Copy the full SHA
    e4251c7 View commit details
  3. Copy the full SHA
    6a80944 View commit details
Showing with 93 additions and 9 deletions.
  1. +1 −1 artiq/gateware/amp/kernel_cpu.py
  2. +2 −0 soc/runtime/Makefile
  3. +2 −2 soc/runtime/kloader.h
  4. +2 −2 soc/runtime/ksupport.ld
  5. +1 −1 soc/runtime/linker.ld
  6. +80 −0 soc/runtime/main.c
  7. +5 −3 soc/runtime/session.c
2 changes: 1 addition & 1 deletion artiq/gateware/amp/kernel_cpu.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

class KernelCPU(Module):
def __init__(self, platform, lasmim,
exec_address=0x40020000,
exec_address=0x40400000,
main_mem_origin=0x40000000,
l2_size=8192):
self._reset = CSRStorage(reset=1)
2 changes: 2 additions & 0 deletions soc/runtime/Makefile
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ $(error failed to determine UP/AMP build)
endif
endif

CFLAGS += -Ilwip/src/include -Iliblwip

all: runtime.bin runtime.fbi

# pull in dependency info for *existing* .o files
4 changes: 2 additions & 2 deletions soc/runtime/kloader.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __KLOADER_H
#define __KLOADER_H

#define KERNELCPU_EXEC_ADDRESS 0x40020000
#define KERNELCPU_PAYLOAD_ADDRESS 0x40024000
#define KERNELCPU_EXEC_ADDRESS 0x40400000
#define KERNELCPU_PAYLOAD_ADDRESS 0x40404000

typedef void (*kernel_function)(void);

4 changes: 2 additions & 2 deletions soc/runtime/ksupport.ld
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ ENTRY(_start)

INCLUDE generated/regions.ld

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

/* On AMP systems, kernel stack is at the end of main RAM,
2 changes: 1 addition & 1 deletion soc/runtime/linker.ld
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ INCLUDE generated/regions.ld
* ld does not allow this expression here.
*/
MEMORY {
runtime : ORIGIN = 0x40000000, LENGTH = 0x20000 /* 128K */
runtime : ORIGIN = 0x40000000, LENGTH = 0x400000 /* 4M */
}

/* Kernel memory space start right after the runtime,
80 changes: 80 additions & 0 deletions soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -6,10 +6,66 @@
#include <system.h>
#include <time.h>
#include <generated/csr.h>
#include <hw/flags.h>

#ifdef CSR_ETHMAC_BASE
#include <netif/etharp.h>
#include <netif/liteethif.h>
#include <lwip/init.h>
#include <lwip/memp.h>
#include <lwip/ip4_addr.h>
#include <lwip/ip4.h>
#include <lwip/netif.h>
#include <lwip/sys.h>
#include <lwip/tcp.h>
#include <lwip/timers.h>
#endif

#include "test_mode.h"
#include "session.h"

#ifdef CSR_ETHMAC_BASE
unsigned char macadr[6] = {0x10, 0xe2, 0xd5, 0x00, 0x00, 0x00};

u32_t clock_ms;

static void clock_init(void)
{
timer0_en_write(0);
timer0_load_write(0xffffffff);
timer0_reload_write(0xffffffff);
timer0_en_write(1);
clock_ms = 0;
}

u32_t sys_now(void)
{
unsigned int freq;
unsigned int prescaler;

freq = identifier_frequency_read();
prescaler = freq/1000; /* sys_now expect time in ms */
timer0_update_value_write(1);
clock_ms += (0xffffffff - timer0_value_read())/prescaler;
/* Reset timer to avoid rollover, this will increase clock_ms
drift but we don't need precision */
timer0_en_write(0);
timer0_en_write(1);
return clock_ms;
}

static struct netif netif;

static void lwip_service(void)
{
sys_check_timeouts();
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
liteeth_input(&netif);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
}
}
#endif

void comm_service(void)
{
char *txdata;
@@ -18,6 +74,10 @@ void comm_service(void)
static int rxpending;
int r, i;

#ifdef CSR_ETHMAC_BASE
lwip_service();
#endif

if(!rxpending && uart_read_nonblock()) {
rxdata = uart_read();
rxpending = 1;
@@ -38,6 +98,26 @@ void comm_service(void)

static void regular_main(void)
{
#ifdef CSR_ETHMAC_BASE
struct ip4_addr local_ip;
struct ip4_addr netmask;
struct ip4_addr gateway_ip;

time_init();
clock_init();

IP4_ADDR(&local_ip, 192, 168, 0, 42);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gateway_ip, 192, 168, 0, 1);

lwip_init();

netif_add(&netif, &local_ip, &netmask, &gateway_ip, 0, liteeth_init, ethernet_input);
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
#endif

session_start();
while(1)
comm_service();
8 changes: 5 additions & 3 deletions soc/runtime/session.c
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@
#include "exceptions.h"
#include "session.h"

#define BUFFER_IN_SIZE (32*1024)
#define BUFFER_OUT_SIZE (32*1024)
#define BUFFER_IN_SIZE (1024*1024)
#define BUFFER_OUT_SIZE (1024*1024)

static int buffer_in_index;
/* The 9th byte (right after the header) of buffer_in must be aligned
@@ -320,10 +320,12 @@ static int process_input(void)

#ifdef ARTIQ_AMP
kloader_start_user_kernel(k);
user_kernel_state = USER_KERNEL_RUNNING;
#else
user_kernel_state = USER_KERNEL_RUNNING;
run_kernel_up(k);
user_kernel_state = USER_KERNEL_LOADED;
#endif
user_kernel_state = USER_KERNEL_RUNNING;
break;
}
case REMOTEMSG_TYPE_RPC_REPLY: {