aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-04-05 17:46:48 -0700
committerAndrew Waterman <andrew@sifive.com>2017-04-05 17:47:23 -0700
commita2c8937e631f7531c3d59e4f179369f51eb44d19 (patch)
treef55997f6c78411dd0ed557bddd822afd6b0471bf
parentdce2b7dd8ede804f54f54fafabd82b24c1a0be62 (diff)
downloadriscv-pk-a2c8937e631f7531c3d59e4f179369f51eb44d19.zip
riscv-pk-a2c8937e631f7531c3d59e4f179369f51eb44d19.tar.gz
riscv-pk-a2c8937e631f7531c3d59e4f179369f51eb44d19.tar.bz2
Remove num_harts; use hart_mask exclusively
-rw-r--r--machine/fdt.c6
-rw-r--r--machine/minit.c1
-rw-r--r--machine/mtrap.c3
-rw-r--r--machine/mtrap.h1
4 files changed, 5 insertions, 6 deletions
diff --git a/machine/fdt.c b/machine/fdt.c
index 34ff87b..cfa7ee9 100644
--- a/machine/fdt.c
+++ b/machine/fdt.c
@@ -239,7 +239,6 @@ static void hart_done(const struct fdt_scan_node *node, void *extra)
if (scan->hart < MAX_HARTS) {
hart_phandles[scan->hart] = scan->phandle;
hart_mask |= 1 << scan->hart;
- if (scan->hart >= num_harts) num_harts = scan->hart + 1;
hls_init(scan->hart);
}
}
@@ -266,9 +265,10 @@ void query_harts(uintptr_t fdt)
cb.close= hart_close;
cb.extra = &scan;
- num_harts = 0;
fdt_scan(fdt, &cb);
- assert (num_harts > 0);
+
+ // The current hart should have been detected
+ assert ((hart_mask >> read_csr(mhartid)) != 0);
}
///////////////////////////////////////////// CLINT SCAN /////////////////////////////////////////
diff --git a/machine/minit.c b/machine/minit.c
index 0052eb7..e78bbbb 100644
--- a/machine/minit.c
+++ b/machine/minit.c
@@ -9,7 +9,6 @@
pte_t* root_page_table;
uintptr_t mem_size;
-uintptr_t num_harts;
volatile uint64_t* mtime;
volatile uint32_t* plic_priorities;
size_t plic_ndevs;
diff --git a/machine/mtrap.c b/machine/mtrap.c
index 49d652f..c114757 100644
--- a/machine/mtrap.c
+++ b/machine/mtrap.c
@@ -5,6 +5,7 @@
#include "bits.h"
#include "vm.h"
#include "uart.h"
+#include "fdt.h"
#include "unprivileged_memory.h"
#include <errno.h>
#include <stdarg.h>
@@ -86,7 +87,7 @@ static uintptr_t mcall_set_timer(uint64_t when)
static void send_ipi_many(uintptr_t* pmask, int event)
{
_Static_assert(MAX_HARTS <= 8 * sizeof(*pmask), "# harts > uintptr_t bits");
- uintptr_t mask = ((uintptr_t)1 << num_harts) - 1;
+ uintptr_t mask = hart_mask;
if (pmask)
mask &= load_uintptr_t(pmask, read_csr(mepc));
diff --git a/machine/mtrap.h b/machine/mtrap.h
index ead7150..16453d7 100644
--- a/machine/mtrap.h
+++ b/machine/mtrap.h
@@ -32,7 +32,6 @@ static inline int xlen()
}
extern uintptr_t mem_size;
-extern uintptr_t num_harts;
extern volatile uint64_t* mtime;
extern volatile uint32_t* plic_priorities;
extern size_t plic_ndevs;