aboutsummaryrefslogtreecommitdiff
path: root/machine
diff options
context:
space:
mode:
Diffstat (limited to 'machine')
-rw-r--r--machine/machine.mk.in1
-rw-r--r--machine/mentry.S9
-rw-r--r--machine/minit.c3
-rw-r--r--machine/mtrap.c15
-rw-r--r--machine/mtrap.h5
5 files changed, 21 insertions, 12 deletions
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/machine/mentry.S b/machine/mentry.S
index 64fb507..33d7be4 100644
--- a/machine/mentry.S
+++ b/machine/mentry.S
@@ -258,7 +258,11 @@ do_reset:
add sp, sp, a2
# Boot on the first unmasked hart
- li a4, (~DISABLED_HART_MASK & (DISABLED_HART_MASK+1))
+ la a4, platform__disabled_hart_mask
+ LOAD a4, 0(a4)
+ addi a5, a4, 1
+ not a4, a4
+ and a4, a4, a5
srl a4, a4, a3
andi a4, a4, 1
bnez a4, init_first_hart
@@ -273,7 +277,8 @@ do_reset:
wfi
# masked harts never start
- li a4, DISABLED_HART_MASK
+ la a4, platform__disabled_hart_mask
+ LOAD a4, 0(a4)
srl a4, a4, a3
andi a4, a4, 1
bnez a4, .LmultiHart
diff --git a/machine/minit.c b/machine/minit.c
index e78bbbb..0fb5f21 100644
--- a/machine/minit.c
+++ b/machine/minit.c
@@ -4,6 +4,7 @@
#include "fp_emulation.h"
#include "fdt.h"
#include "uart.h"
+#include "platform_interface.h"
#include <string.h>
#include <limits.h>
@@ -123,7 +124,7 @@ static void hart_plic_init()
static void wake_harts()
{
for (int hart = 0; hart < MAX_HARTS; ++hart)
- if ((((~DISABLED_HART_MASK & hart_mask) >> hart) & 1))
+ if ((((~platform__disabled_hart_mask & hart_mask) >> hart) & 1))
*OTHER_HLS(hart)->ipi = 1; // wakeup the hart
}
diff --git a/machine/mtrap.c b/machine/mtrap.c
index d0c1684..62137ff 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)
@@ -51,7 +56,7 @@ void printm(const char* s, ...)
static void send_ipi(uintptr_t recipient, int event)
{
- if (((DISABLED_HART_MASK >> recipient) & 1)) return;
+ if (((platform__disabled_hart_mask >> recipient) & 1)) return;
atomic_or(&OTHER_HLS(recipient)->mipi_pending, event);
mb();
*OTHER_HLS(recipient)->ipi = 1;
@@ -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/machine/mtrap.h b/machine/mtrap.h
index df71797..4ec0924 100644
--- a/machine/mtrap.h
+++ b/machine/mtrap.h
@@ -9,11 +9,6 @@
# define MAX_HARTS 1
#endif
-// These harts will be prevented from booting beyond bbl
-#ifndef DISABLED_HART_MASK
-#define DISABLED_HART_MASK 0x0UL
-#endif
-
#ifndef __ASSEMBLER__
#include <stdint.h>