Browse Source

Move DISABLED_HART_MASK to the platform

Some platforms can't boot Linux on all the harts.  This commit allows
platforms to define the set of harts that should be prevented from
booting past BBL.  This is essentially just a new mechanism for defining
the DISABLED_HART_MASK.
pull/58/head
Palmer Dabbelt 9 years ago
parent
commit
298984cbe6
  1. 3
      bbl/bbl.c
  2. 9
      machine/mentry.S
  3. 3
      machine/minit.c
  4. 2
      machine/mtrap.c
  5. 5
      machine/mtrap.h
  6. 8
      platform/platform_interface.h
  7. 2
      platform/spike.c

3
bbl/bbl.c

@ -5,6 +5,7 @@
#include "bits.h"
#include "config.h"
#include "fdt.h"
#include "platform_interface.h"
#include <string.h>
static const void* entry_point;
@ -23,7 +24,7 @@ static void filter_dtb(uintptr_t source)
memcpy((void*)dest, (void*)source, size);
// Remove information from the chained FDT
filter_harts(dest, DISABLED_HART_MASK);
filter_harts(dest, platform__disabled_hart_mask);
filter_plic(dest);
filter_compat(dest, "riscv,clint0");
filter_compat(dest, "riscv,debug-013");

9
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

3
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
}

2
machine/mtrap.c

@ -56,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;

5
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>

8
platform/platform_interface.h

@ -1,6 +1,8 @@
#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
@ -18,4 +20,10 @@ const char *platform__get_logo(void);
/* Returns TRUE if it's valid to use the HTIF */
int platform__use_htif(void);
/* The harts that should be excluded from booting to the target program and
* should intsead be held in a loop. */
extern long platform__disabled_hart_mask;
#endif
#endif

2
platform/spike.c

@ -25,6 +25,8 @@ static const char logo[] =
"\n"
" INSTRUCTION SETS WANT TO BE FREE\n";
long platform__disabled_hart_mask = 0;
const char *platform__get_logo(void)
{
return logo;

Loading…
Cancel
Save