aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPalmer Dabbelt <palmer@dabbelt.com>2017-07-28 14:10:20 -0700
committerPalmer Dabbelt <palmer@dabbelt.com>2017-08-02 12:32:45 -0700
commit62effc6bfe4f1a7e8a771c49966c4ab7755d6612 (patch)
tree5c43ece292d162809e0a0544817d1d20abbef73b
parentbb19fef663a5ce32d7e2d3557362a51da8d99365 (diff)
downloadpk-62effc6bfe4f1a7e8a771c49966c4ab7755d6612.zip
pk-62effc6bfe4f1a7e8a771c49966c4ab7755d6612.tar.gz
pk-62effc6bfe4f1a7e8a771c49966c4ab7755d6612.tar.bz2
Allow the platform to disable HTIF
-rw-r--r--machine/mtrap.c13
-rw-r--r--platform/platform_interface.h3
-rw-r--r--platform/spike.c6
3 files changed, 18 insertions, 4 deletions
diff --git a/machine/mtrap.c b/machine/mtrap.c
index d0c1684..ff4eb60 100644
--- a/machine/mtrap.c
+++ b/machine/mtrap.c
@@ -7,6 +7,7 @@
#include "uart.h"
#include "fdt.h"
#include "unprivileged_memory.h"
+#include "platform_interface.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -20,7 +21,7 @@ static uintptr_t mcall_console_putchar(uint8_t ch)
{
if (uart) {
uart_putchar(ch);
- } else {
+ } else if (platform__use_htif()) {
htif_console_putchar(ch);
}
return 0;
@@ -28,7 +29,11 @@ static uintptr_t mcall_console_putchar(uint8_t ch)
void poweroff()
{
- htif_poweroff();
+ if (platform__use_htif()) {
+ htif_poweroff();
+ } else {
+ while (1);
+ }
}
void putstring(const char* s)
@@ -61,8 +66,10 @@ static uintptr_t mcall_console_getchar()
{
if (uart) {
return uart_getchar();
- } else {
+ } else if (platform__use_htif()) {
return htif_console_getchar();
+ } else {
+ return '\0';
}
}
diff --git a/platform/platform_interface.h b/platform/platform_interface.h
index 9c52cde..dd521e3 100644
--- a/platform/platform_interface.h
+++ b/platform/platform_interface.h
@@ -15,4 +15,7 @@
* 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
diff --git a/platform/spike.c b/platform/spike.c
index 06aa742..159255f 100644
--- a/platform/spike.c
+++ b/platform/spike.c
@@ -25,8 +25,12 @@ static const char logo[] =
"\n"
" INSTRUCTION SETS WANT TO BE FREE\n";
-
const char *platform__get_logo(void)
{
return logo;
}
+
+int platform__use_htif(void)
+{
+ return 1;
+}