Skip to content

Commit

Permalink
machine: add the "hifive_unleashed" machine data configuration method
Browse files Browse the repository at this point in the history
Add a "hifive_unleashed" machine data configuration method.  This can
be used when the output BBL image is explicitly targeted for the
SiFive HiFive Unleashed board with the FU540-C000 SoC.  The primary
virtue of this configuration method is that it does not rely on DT
parsing at all.  BBL will pass whatever DTB it was given to the
operating system kernel, without trying to parse or edit it.
  • Loading branch information
paul-walmsley-sifive committed Aug 2, 2019
1 parent f88fbc2 commit 65a0ece
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
68 changes: 68 additions & 0 deletions machine/configure-hifive-unleashed.c
@@ -0,0 +1,68 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "common.h"
#include "config.h"
#include "disabled_hart_mask.h"
#include "fdt.h"
#include "fdtutil.h"
#include "htif.h"
#include "mtrap.h"
#include "probe.h"
#include "uart.h"
#include "uart16550.h"

//////////////////////////////////////////// MEMORY SCAN /////////////////////////////////////////


static void query_mem(void *context)
{
mem_size = 0x200000000; /* 8GiB on the HiFive Unleashed */
}

///////////////////////////////////////////// SOC SCAN /////////////////////////////////////////

static void query_soc(void *context)
{
uintptr_t clint_base = 0x2000000;
int hart_count = 5;

plic_ndevs = 53;
hart_mask |= (1 << hart_count) - 1; /* 5 harts on the FU540 */
disabled_hart_mask = 0x1; /* hart 0, the E51 core */

common_setup_soc(clint_base, hart_count);
}

///////////////////////////////////////////// PLIC SCAN /////////////////////////////////////////

static void query_plic(void *context)
{
common_setup_plic(0xc000000); /* PLIC address */
}


//////////////////////////// UART //////////////////////////////

static void query_uart(void *context)
{
// Enable Rx/Tx channels
uart = (void *)0x10010000;
uart_enable_rx_tx();
}

//////////////////////////////////////////// CONFIG RECORD ///////////////////////////////////////////

struct machine_config_method hifive_unleashed_config_method = {
.config_mem = query_mem,
.config_harts = query_soc,
.config_clint = query_noop,
.config_plic = query_plic,
.config_uart = query_uart,
.config_uart16550 = query_noop,
.config_htif = query_noop,
.config_finisher = query_noop,
.filter_harts = filter_harts_noop,
.filter_plic = query_noop,
.filter_compat = filter_compat_noop,
};
1 change: 1 addition & 0 deletions machine/machine.mk.in
Expand Up @@ -22,6 +22,7 @@ machine_hdrs = \
machine_c_srcs = \
common.c \
configure-fdt.c \
configure-hifive-unleashed.c \
mtrap.c \
minit.c \
htif.c \
Expand Down
1 change: 1 addition & 0 deletions machine/probe.h
Expand Up @@ -18,6 +18,7 @@ struct machine_config_method {
};

extern struct machine_config_method fdt_config_method;
extern struct machine_config_method hifive_unleashed_config_method;

struct machine_config_method *cm;

Expand Down

0 comments on commit 65a0ece

Please sign in to comment.