From 9037b1d9f2130770228be62c66b88b47fccd99b6 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 27 Jul 2017 13:23:49 -0700 Subject: Add a platform interface SiFive's pk fork is the second one I've had to maintain, and it's a huge pain because people keep just leaving changes all over the tree. I want to introduce an interface that the platform-specific details can live behind so I don't have to keep doing these painful merges. --- bbl/bbl.mk.in | 1 + config.h.in | 3 +++ configure | 46 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 2 +- machine/machine.mk.in | 1 + pk/pk.mk.in | 1 + platform/platform.ac | 0 platform/platform.mk.in | 9 +++++++++ platform/platform_interface.h | 14 +++++++++++++ platform/spike.c | 1 + 10 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 platform/platform.ac create mode 100644 platform/platform.mk.in create mode 100644 platform/platform_interface.h create mode 100644 platform/spike.c diff --git a/bbl/bbl.mk.in b/bbl/bbl.mk.in index 5abe2cd..e3c5876 100644 --- a/bbl/bbl.mk.in +++ b/bbl/bbl.mk.in @@ -3,6 +3,7 @@ bbl_subproject_deps = \ softfloat \ machine \ dummy_payload \ + platform \ bbl_hdrs = \ bbl.h \ diff --git a/config.h.in b/config.h.in index bc6369e..9557930 100644 --- a/config.h.in +++ b/config.h.in @@ -40,6 +40,9 @@ #undef PK_ENABLE_VM /* 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. */ diff --git a/configure b/configure index c1b2b73..25de84d 100755 --- a/configure +++ b/configure @@ -4433,6 +4433,51 @@ $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 @@ -5155,6 +5200,7 @@ 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 b4a58fd..d4db795 100644 --- a/configure.ac +++ b/configure.ac @@ -111,7 +111,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 ]) +MCPPBS_SUBPROJECTS([ pk, bbl, softfloat, dummy_payload, machine, util, platform ]) #------------------------------------------------------------------------- # MCPPBS subproject groups diff --git a/machine/machine.mk.in b/machine/machine.mk.in index cdcb4a7..76e02d9 100644 --- a/machine/machine.mk.in +++ b/machine/machine.mk.in @@ -1,5 +1,6 @@ machine_subproject_deps = \ softfloat \ + platform \ machine_hdrs = \ atomic.h \ diff --git a/pk/pk.mk.in b/pk/pk.mk.in index 3caa25d..d4be009 100644 --- a/pk/pk.mk.in +++ b/pk/pk.mk.in @@ -1,4 +1,5 @@ pk_subproject_deps = \ + platform \ util \ softfloat \ machine \ diff --git a/platform/platform.ac b/platform/platform.ac new file mode 100644 index 0000000..e69de29 diff --git a/platform/platform.mk.in b/platform/platform.mk.in new file mode 100644 index 0000000..90ee269 --- /dev/null +++ b/platform/platform.mk.in @@ -0,0 +1,9 @@ +platform_subproject_deps = + +platform_hdrs = \ + platform_interface.h + +platform_c_srcs = \ + spike.c + +platform_asm_srcs = diff --git a/platform/platform_interface.h b/platform/platform_interface.h new file mode 100644 index 0000000..0f49056 --- /dev/null +++ b/platform/platform_interface.h @@ -0,0 +1,14 @@ +#ifndef PLATFORM__PLATFORM_H +#define PLATFORM__PLATFORM_H + +/* 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. + */ + +#endif diff --git a/platform/spike.c b/platform/spike.c new file mode 100644 index 0000000..9764057 --- /dev/null +++ b/platform/spike.c @@ -0,0 +1 @@ +#include "platform_interface.h" -- cgit v1.1