diff options
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | bbl/bbl.ac | 4 | ||||
-rw-r--r-- | bbl/bbl.c | 1 | ||||
-rw-r--r-- | bbl/bbl.lds | 1 | ||||
-rw-r--r-- | bbl/bbl.mk.in | 2 | ||||
-rw-r--r-- | bbl/logo.c | 7 | ||||
-rw-r--r-- | bbl/raw_logo.S | 7 | ||||
-rw-r--r-- | bbl/riscv_logo.txt | 23 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 74 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | machine/htif.c | 51 | ||||
-rw-r--r-- | machine/htif.h | 2 | ||||
-rw-r--r-- | machine/machine.mk.in | 1 | ||||
-rw-r--r-- | machine/minit.c | 3 | ||||
-rw-r--r-- | machine/mtrap.c | 7 | ||||
-rw-r--r-- | pk/pk.lds | 1 | ||||
-rw-r--r-- | pk/pk.mk.in | 1 | ||||
-rw-r--r-- | platform/platform.ac | 0 | ||||
-rw-r--r-- | platform/platform.mk.in | 9 | ||||
-rw-r--r-- | platform/platform_interface.h | 25 | ||||
-rw-r--r-- | platform/sifive-vc707-devkit.c | 39 | ||||
-rw-r--r-- | platform/spike.c | 36 |
23 files changed, 114 insertions, 193 deletions
diff --git a/Makefile.in b/Makefile.in index 7b9bb81..0d5e862 100644 --- a/Makefile.in +++ b/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) @@ -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])]) @@ -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; diff --git a/bbl/bbl.lds b/bbl/bbl.lds index b90e99f..2fd0d7c 100644 --- a/bbl/bbl.lds +++ b/bbl/bbl.lds @@ -46,6 +46,7 @@ SECTIONS . = ALIGN(0x1000); .htif : { + PROVIDE( __htif_base = .); *(.htif) } . = ALIGN(0x1000); diff --git a/bbl/bbl.mk.in b/bbl/bbl.mk.in index e3c5876..0840859 100644 --- a/bbl/bbl.mk.in +++ b/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 @@ -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); + putstring(logo); } diff --git a/bbl/raw_logo.S b/bbl/raw_logo.S new file mode 100644 index 0000000..bddf8f4 --- /dev/null +++ b/bbl/raw_logo.S @@ -0,0 +1,7 @@ +#include "encoding.h" + + .section .rodata + .globl logo +logo: + .incbin BBL_LOGO_FILE + .byte 0 diff --git a/bbl/riscv_logo.txt b/bbl/riscv_logo.txt new file mode 100644 index 0000000..1f4c9f5 --- /dev/null +++ b/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 diff --git a/config.h.in b/config.h.in index 179cbf0..4674a2e 100644 --- a/config.h.in +++ b/config.h.in @@ -43,9 +43,6 @@ #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 /* Define to 1 if you have the ANSI C header files. */ @@ -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" ;; diff --git a/configure.ac b/configure.ac index 31b275f..4cf9b61 100644 --- a/configure.ac +++ b/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 diff --git a/machine/htif.c b/machine/htif.c index fa3db53..44ec2dd 100644 --- a/machine/htif.c +++ b/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); +} diff --git a/machine/htif.h b/machine/htif.h index fa768d8..a96bf60 100644 --- a/machine/htif.h +++ b/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)); diff --git a/machine/machine.mk.in b/machine/machine.mk.in index 59d0eb4..dc8492f 100644 --- a/machine/machine.mk.in +++ b/machine/machine.mk.in @@ -1,6 +1,5 @@ machine_subproject_deps = \ softfloat \ - platform \ machine_hdrs = \ atomic.h \ diff --git a/machine/minit.c b/machine/minit.c index 5f98501..3623f38 100644 --- a/machine/minit.c +++ b/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 diff --git a/machine/mtrap.c b/machine/mtrap.c index dba3613..0f77def 100644 --- a/machine/mtrap.c +++ b/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'; @@ -46,6 +46,7 @@ SECTIONS . = ALIGN(0x1000); .htif : { + PROVIDE( __htif_base = . ); *(.htif) } . = ALIGN(0x1000); diff --git a/pk/pk.mk.in b/pk/pk.mk.in index d4be009..3caa25d 100644 --- a/pk/pk.mk.in +++ b/pk/pk.mk.in @@ -1,5 +1,4 @@ pk_subproject_deps = \ - platform \ util \ softfloat \ machine \ diff --git a/platform/platform.ac b/platform/platform.ac deleted file mode 100644 index e69de29..0000000 --- a/platform/platform.ac +++ /dev/null diff --git a/platform/platform.mk.in b/platform/platform.mk.in deleted file mode 100644 index eded238..0000000 --- a/platform/platform.mk.in +++ /dev/null @@ -1,9 +0,0 @@ -platform_subproject_deps = - -platform_hdrs = \ - platform_interface.h - -platform_c_srcs = \ - @PLATFORM_NAME@.c - -platform_asm_srcs = diff --git a/platform/platform_interface.h b/platform/platform_interface.h deleted file mode 100644 index 203457d..0000000 --- a/platform/platform_interface.h +++ /dev/null @@ -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 diff --git a/platform/sifive-vc707-devkit.c b/platform/sifive-vc707-devkit.c deleted file mode 100644 index bd27861..0000000 --- a/platform/sifive-vc707-devkit.c +++ /dev/null @@ -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; -} diff --git a/platform/spike.c b/platform/spike.c deleted file mode 100644 index 159255f..0000000 --- a/platform/spike.c +++ /dev/null @@ -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; -} |