aboutsummaryrefslogtreecommitdiff
path: root/pk/bbl.c
blob: 031fa08f11f8dc5d490636709d514f0a6cdbb0e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "boot.h"
#include "mtrap.h"
#include "vm.h"
#include "config.h"

static volatile int elf_loaded;

static void enter_entry_point()
{
  prepare_supervisor_mode();
  write_csr(mepc, current.entry);
  asm volatile("eret");
  __builtin_unreachable();
}

void run_loaded_program(struct mainvars* args)
{
  if (!current.is_supervisor)
    die("bbl can't run user binaries; try using pk instead");

  supervisor_vm_init();
#ifdef PK_ENABLE_LOGO
  print_logo();
#endif
  mb();
  elf_loaded = 1;
  enter_entry_point();
}

void boot_other_hart()
{
  while (!elf_loaded)
    ;
  mb();
  enter_entry_point();
}