Browse Source

Remove the platform interface

We now automatically detect everything that the platform interface used
to be used for, so it's now obsolete!
pull/68/head
Palmer Dabbelt 9 years ago
parent
commit
d1849cb5e3
  1. 1
      bbl/bbl.c
  2. 1
      bbl/bbl.lds
  3. 1
      bbl/bbl.mk.in
  4. 28
      bbl/logo.c
  5. 3
      config.h.in
  6. 60
      configure
  7. 8
      configure.ac
  8. 51
      machine/htif.c
  9. 2
      machine/htif.h
  10. 1
      machine/machine.mk.in
  11. 3
      machine/minit.c
  12. 7
      machine/mtrap.c
  13. 1
      pk/pk.lds
  14. 1
      pk/pk.mk.in
  15. 0
      platform/platform.ac
  16. 9
      platform/platform.mk.in
  17. 25
      platform/platform_interface.h
  18. 39
      platform/sifive-vc707-devkit.c
  19. 36
      platform/spike.c

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);

1
bbl/bbl.mk.in

@ -3,7 +3,6 @@ bbl_subproject_deps = \
softfloat \
machine \
dummy_payload \
platform \
bbl_hdrs = \
bbl.h \

28
bbl/logo.c

@ -1,10 +1,32 @@
#include <string.h>
#include "mtrap.h"
#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";
void print_logo()
{
const char *logo = platform__get_logo();
if (logo != NULL)
putstring(logo);
}

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

60
configure

@ -592,7 +592,6 @@ subprojects_enabled
subprojects
BBL_PAYLOAD
install_subdir
PLATFORM_NAME
RISCV
EGREP
GREP
@ -670,7 +669,6 @@ ac_user_opts='
enable_option_checking
enable_stow
enable_32bit
with_platform
enable_print_device_tree
enable_optional_subprojects
enable_vm
@ -1330,7 +1328,6 @@ 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
Some influential environment variables:
@ -4095,17 +4092,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;
@ -4463,51 +4449,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 +5171,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