Browse Source

Merge pull request #68 from riscv/no-platform

Remove the platform interface
pull/69/head
Palmer Dabbelt 9 years ago
committed by GitHub
parent
commit
37a68944a4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Makefile.in
  2. 4
      bbl/bbl.ac
  3. 1
      bbl/bbl.c
  4. 1
      bbl/bbl.lds
  5. 2
      bbl/bbl.mk.in
  6. 5
      bbl/logo.c
  7. 7
      bbl/raw_logo.S
  8. 23
      bbl/riscv_logo.txt
  9. 3
      config.h.in
  10. 74
      configure
  11. 8
      configure.ac
  12. 51
      machine/htif.c
  13. 2
      machine/htif.h
  14. 1
      machine/machine.mk.in
  15. 3
      machine/minit.c
  16. 7
      machine/mtrap.c
  17. 1
      pk/pk.lds
  18. 1
      pk/pk.mk.in
  19. 0
      platform/platform.ac
  20. 9
      platform/platform.mk.in
  21. 25
      platform/platform_interface.h
  22. 39
      platform/sifive-vc707-devkit.c
  23. 36
      platform/spike.c

2
Makefile.in

@ -85,7 +85,7 @@ VPATH := $(addprefix $(src_dir)/, $(sprojs_enabled))
CC := @CC@
READELF := @READELF@
OBJCOPY := @OBJCOPY@
CFLAGS := @CFLAGS@ $(CFLAGS) -DBBL_PAYLOAD=\"bbl_payload\"
CFLAGS := @CFLAGS@ $(CFLAGS) -DBBL_PAYLOAD=\"bbl_payload\" -DBBL_LOGO_FILE=\"@BBL_LOGO_FILE@\"
BBL_PAYLOAD := @BBL_PAYLOAD@
COMPILE := $(CC) -MMD -MP $(CFLAGS) \
$(sprojs_include)

4
bbl/bbl.ac

@ -6,3 +6,7 @@ AS_IF([test "x$enable_logo" == "xyes"], [
AC_ARG_WITH([payload], AS_HELP_STRING([--with-payload], [Set ELF payload for bbl]),
[AC_SUBST([BBL_PAYLOAD], $with_payload, [Kernel payload for bbl])],
[AC_SUBST([BBL_PAYLOAD], [dummy_payload], [Kernel payload for bbl])])
AC_ARG_WITH([logo], AS_HELP_STRING([--with-logo], [Specify a better logo]),
[AC_SUBST([BBL_LOGO_FILE], $with_logo, [Logo for bbl])],
[AC_SUBST([BBL_LOGO_FILE], [riscv_logo.txt], [Logo for bbl])])

1
bbl/bbl.c

@ -5,7 +5,6 @@
#include "bits.h"
#include "config.h"
#include "fdt.h"
#include "platform_interface.h"
#include <string.h>
static const void* entry_point;

1
bbl/bbl.lds

@ -46,6 +46,7 @@ SECTIONS
. = ALIGN(0x1000);
.htif :
{
PROVIDE( __htif_base = .);
*(.htif)
}
. = ALIGN(0x1000);

2
bbl/bbl.mk.in

@ -3,7 +3,6 @@ bbl_subproject_deps = \
softfloat \
machine \
dummy_payload \
platform \
bbl_hdrs = \
bbl.h \
@ -13,6 +12,7 @@ bbl_c_srcs = \
bbl_asm_srcs = \
payload.S \
raw_logo.S \
payload.o: bbl_payload

5
bbl/logo.c

@ -1,10 +1,9 @@
#include <string.h>
#include "mtrap.h"
#include "platform_interface.h"
extern const char logo[];
void print_logo()
{
const char *logo = platform__get_logo();
if (logo != NULL)
putstring(logo);
}

7
bbl/raw_logo.S

@ -0,0 +1,7 @@
#include "encoding.h"
.section .rodata
.globl logo
logo:
.incbin BBL_LOGO_FILE
.byte 0

23
bbl/riscv_logo.txt

@ -0,0 +1,23 @@
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
vvvvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv
rr vvvvvvvvvvvvvvvvvvvvvv
rr vvvvvvvvvvvvvvvvvvvvvvvv rr
rrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrr
rrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrr
rrrrrrrr vvvvvvvvvvvvvvvvvv rrrrrrrr
rrrrrrrrrr vvvvvvvvvvvvvv rrrrrrrrrr
rrrrrrrrrrrr vvvvvvvvvv rrrrrrrrrrrr
rrrrrrrrrrrrrr vvvvvv rrrrrrrrrrrrrr
rrrrrrrrrrrrrrrr vv rrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr
INSTRUCTION SETS WANT TO BE FREE

3
config.h.in

@ -42,9 +42,6 @@
/* Define if the DTS is to be displayed */
#undef PK_PRINT_DEVICE_TREE
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */
#undef PLATFORM_ENABLED
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */
#undef SOFTFLOAT_ENABLED

74
configure

@ -590,9 +590,9 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
subprojects_enabled
subprojects
BBL_LOGO_FILE
BBL_PAYLOAD
install_subdir
PLATFORM_NAME
RISCV
EGREP
GREP
@ -670,12 +670,12 @@ ac_user_opts='
enable_option_checking
enable_stow
enable_32bit
with_platform
enable_print_device_tree
enable_optional_subprojects
enable_vm
enable_logo
with_payload
with_logo
enable_fp_emulation
'
ac_precious_vars='build_alias
@ -1330,8 +1330,8 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-platform=spike Select the target platform
--with-payload Set ELF payload for bbl
--with-logo Specify a better logo
Some influential environment variables:
CC C compiler command
@ -4095,17 +4095,6 @@ case "${BUILD_32BIT}" in
;;
esac
# Check whether --with-platform was given.
if test "${with_platform+set}" = set; then :
withval=$with_platform; PLATFORM_NAME=$withval
else
PLATFORM_NAME=spike
fi
PLATFORM_NAME=$PLATFORM_NAME
# Check whether --enable-print-device-tree was given.
if test "${enable_print_device_tree+set}" = set; then :
enableval=$enable_print_device_tree;
@ -4268,6 +4257,17 @@ fi
# Check whether --with-logo was given.
if test "${with_logo+set}" = set; then :
withval=$with_logo; BBL_LOGO_FILE=$with_logo
else
BBL_LOGO_FILE=riscv_logo.txt
fi
@ -4463,51 +4463,6 @@ $as_echo "#define UTIL_ENABLED /**/" >>confdefs.h
# Determine if this is a required or an optional subproject
# Determine if there is a group with the same name
# Create variations of the subproject name suitable for use as a CPP
# enabled define, a shell enabled variable, and a shell function
# Add subproject to our running list
subprojects="$subprojects platform"
# Process the subproject appropriately. If enabled add it to the
# $enabled_subprojects running shell variable, set a
# SUBPROJECT_ENABLED C define, and include the appropriate
# 'subproject.ac'.
{ $as_echo "$as_me:${as_lineno-$LINENO}: configuring default subproject : platform" >&5
$as_echo "$as_me: configuring default subproject : platform" >&6;}
ac_config_files="$ac_config_files platform.mk:platform/platform.mk.in"
enable_platform_sproj="yes"
subprojects_enabled="$subprojects_enabled platform"
$as_echo "#define PLATFORM_ENABLED /**/" >>confdefs.h
# Output make variables
@ -5230,7 +5185,6 @@ do
"dummy_payload.mk") CONFIG_FILES="$CONFIG_FILES dummy_payload.mk:dummy_payload/dummy_payload.mk.in" ;;
"machine.mk") CONFIG_FILES="$CONFIG_FILES machine.mk:machine/machine.mk.in" ;;
"util.mk") CONFIG_FILES="$CONFIG_FILES util.mk:util/util.mk.in" ;;
"platform.mk") CONFIG_FILES="$CONFIG_FILES platform.mk:platform/platform.mk.in" ;;
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;

8
configure.ac

@ -99,12 +99,6 @@ case "${BUILD_32BIT}" in
;;
esac
AC_ARG_WITH([platform],
AS_HELP_STRING([--with-platform=spike], [Select the target platform]),
PLATFORM_NAME=$withval,
PLATFORM_NAME=spike)
AC_SUBST(PLATFORM_NAME, $PLATFORM_NAME)
AC_ARG_ENABLE([print-device-tree], AS_HELP_STRING([--enable-print-device-tree], [Print DTS when booting]))
AS_IF([test "x$enable_print_device_tree" == "xyes"], [
AC_DEFINE([PK_PRINT_DEVICE_TREE],,[Define if the DTS is to be displayed])
@ -122,7 +116,7 @@ AC_SUBST(install_subdir)
# The '*' suffix indicates an optional subproject. The '**' suffix
# indicates an optional subproject which is also the name of a group.
MCPPBS_SUBPROJECTS([ pk, bbl, softfloat, dummy_payload, machine, util, platform ])
MCPPBS_SUBPROJECTS([ pk, bbl, softfloat, dummy_payload, machine, util ])
#-------------------------------------------------------------------------
# MCPPBS subproject groups

51
machine/htif.c

@ -1,11 +1,21 @@
#include "htif.h"
#include "atomic.h"
#include "mtrap.h"
#include "fdt.h"
#include <string.h>
extern uint64_t __htif_base;
volatile uint64_t tohost __attribute__((section(".htif")));
volatile uint64_t fromhost __attribute__((section(".htif")));
volatile int htif_console_buf;
static spinlock_t htif_lock = SPINLOCK_INIT;
uintptr_t htif;
#define TOHOST(base_int) (uint64_t *)(base_int + TOHOST_OFFSET)
#define FROMHOST(base_int) (uint64_t *)(base_int + FROMHOST_OFFSET)
#define TOHOST_OFFSET ((uintptr_t)tohost - (uintptr_t)__htif_base)
#define FROMHOST_OFFSET ((uintptr_t)fromhost - (uintptr_t)__htif_base)
static void __check_fromhost()
{
@ -85,3 +95,44 @@ void htif_poweroff()
tohost = 1;
}
}
struct htif_scan
{
int compat;
};
static void htif_open(const struct fdt_scan_node *node, void *extra)
{
struct htif_scan *scan = (struct htif_scan *)extra;
memset(scan, 0, sizeof(*scan));
}
static void htif_prop(const struct fdt_scan_prop *prop, void *extra)
{
struct htif_scan *scan = (struct htif_scan *)extra;
if (!strcmp(prop->name, "compatible") && !strcmp((const char*)prop->value, "ucb,htif0")) {
scan->compat = 1;
}
}
static void htif_done(const struct fdt_scan_node *node, void *extra)
{
struct htif_scan *scan = (struct htif_scan *)extra;
if (!scan->compat) return;
htif = 1;
}
void query_htif(uintptr_t fdt)
{
struct fdt_cb cb;
struct htif_scan scan;
memset(&cb, 0, sizeof(cb));
cb.open = htif_open;
cb.prop = htif_prop;
cb.done = htif_done;
cb.extra = &scan;
fdt_scan(fdt, &cb);
}

2
machine/htif.h

@ -15,6 +15,8 @@
#define FROMHOST_CMD(fromhost_value) ((uint64_t)(fromhost_value) << 8 >> 56)
#define FROMHOST_DATA(fromhost_value) ((uint64_t)(fromhost_value) << 16 >> 16)
extern uintptr_t htif;
void query_htif(uintptr_t dtb);
void htif_console_putchar(uint8_t);
int htif_console_getchar();
void htif_poweroff() __attribute__((noreturn));

1
machine/machine.mk.in

@ -1,6 +1,5 @@
machine_subproject_deps = \
softfloat \
platform \
machine_hdrs = \
atomic.h \

3
machine/minit.c

@ -5,8 +5,8 @@
#include "fdt.h"
#include "uart.h"
#include "finisher.h"
#include "platform_interface.h"
#include "disabled_hart_mask.h"
#include "htif.h"
#include <string.h>
#include <limits.h>
@ -141,6 +141,7 @@ void init_first_hart(uintptr_t hartid, uintptr_t dtb)
{
// Confirm console as early as possible
query_uart(dtb);
query_htif(dtb);
hart_init();
hls_init(0); // this might get called again from parse_config_string

7
machine/mtrap.c

@ -8,7 +8,6 @@
#include "finisher.h"
#include "fdt.h"
#include "unprivileged_memory.h"
#include "platform_interface.h"
#include "disabled_hart_mask.h"
#include <errno.h>
#include <stdarg.h>
@ -23,7 +22,7 @@ static uintptr_t mcall_console_putchar(uint8_t ch)
{
if (uart) {
uart_putchar(ch);
} else if (platform__use_htif()) {
} else if (htif) {
htif_console_putchar(ch);
}
return 0;
@ -33,7 +32,7 @@ void poweroff(uint16_t code)
{
printm("Power off\n");
finisher_exit(code);
if (platform__use_htif()) {
if (htif) {
htif_poweroff();
} else {
while (1);
@ -74,7 +73,7 @@ static uintptr_t mcall_console_getchar()
{
if (uart) {
return uart_getchar();
} else if (platform__use_htif()) {
} else if (htif) {
return htif_console_getchar();
} else {
return '\0';

1
pk/pk.lds

@ -46,6 +46,7 @@ SECTIONS
. = ALIGN(0x1000);
.htif :
{
PROVIDE( __htif_base = . );
*(.htif)
}
. = ALIGN(0x1000);

1
pk/pk.mk.in

@ -1,5 +1,4 @@
pk_subproject_deps = \
platform \
util \
softfloat \
machine \

0
platform/platform.ac

9
platform/platform.mk.in

@ -1,9 +0,0 @@
platform_subproject_deps =
platform_hdrs = \
platform_interface.h
platform_c_srcs = \
@PLATFORM_NAME@.c
platform_asm_srcs =

25
platform/platform_interface.h

@ -1,25 +0,0 @@
#ifndef PLATFORM__PLATFORM_H
#define PLATFORM__PLATFORM_H
#ifndef __ASSEMBLY__
/* This interface is designed to allow BBL/PK to be portable to multiple target
* platforms. The current interface has been hacked up based on SiFive's fork
* of pk that runs on our FPGA boards. The idea here is that rather than
* forking pk and touching things all over the tree, changes should be local to
* the target directory.
*
* This interface isn't meant to be stable or sane, just better than what we
* had before.
*/
/* Returns a pointer to what's expected to be a staticly allocated logo string.
* This will be printed when BBL boots. */
const char *platform__get_logo(void);
/* Returns TRUE if it's valid to use the HTIF */
int platform__use_htif(void);
#endif
#endif

39
platform/sifive-vc707-devkit.c

@ -1,39 +0,0 @@
#include "platform_interface.h"
static const char logo[] =
"\r\n"
" SIFIVE, INC.\r\n"
"\r\n"
" 5555555555555555555555555\r\n"
" 5555 5555\r\n"
" 5555 5555\r\n"
" 5555 5555\r\n"
" 5555 5555555555555555555555\r\n"
" 5555 555555555555555555555555\r\n"
" 5555 5555\r\n"
" 5555 5555\r\n"
" 5555 5555\r\n"
"5555555555555555555555555555 55555\r\n"
" 55555 555555555 55555\r\n"
" 55555 55555 55555\r\n"
" 55555 5 55555\r\n"
" 55555 55555\r\n"
" 55555 55555\r\n"
" 55555 55555\r\n"
" 55555 55555\r\n"
" 55555 55555\r\n"
" 555555555\r\n"
" 55555\r\n"
" 5\r\n"
"\r\n"
" SiFive RISC-V Coreplex\r\n";
const char *platform__get_logo(void)
{
return logo;
}
int platform__use_htif(void)
{
return 0;
}

36
platform/spike.c

@ -1,36 +0,0 @@
#include "platform_interface.h"
static const char logo[] =
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"
" vvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
"rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv \n"
"rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv \n"
"rr vvvvvvvvvvvvvvvvvvvvvv \n"
"rr vvvvvvvvvvvvvvvvvvvvvvvv rr\n"
"rrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrr\n"
"rrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrr\n"
"rrrrrrrr vvvvvvvvvvvvvvvvvv rrrrrrrr\n"
"rrrrrrrrrr vvvvvvvvvvvvvv rrrrrrrrrr\n"
"rrrrrrrrrrrr vvvvvvvvvv rrrrrrrrrrrr\n"
"rrrrrrrrrrrrrr vvvvvv rrrrrrrrrrrrrr\n"
"rrrrrrrrrrrrrrrr vv rrrrrrrrrrrrrrrr\n"
"rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr\n"
"rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr\n"
"rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr\n"
"\n"
" INSTRUCTION SETS WANT TO BE FREE\n";
const char *platform__get_logo(void)
{
return logo;
}
int platform__use_htif(void)
{
return 1;
}
Loading…
Cancel
Save