Browse Source

Support --without-payload for OpenSBI fw_jump-style booting (#186)

We expect the firmware to load the external payload at the second
megapage, and that there is space to put the filtered FDT at 0x2200000
past the start of memory. With a default MEM_START of 0x80000000, this
matches the standard OpenSBI values for FW_JUMP_ADDR and
FW_JUMP_FDT_ADDR of 0x80400000/0x80200000 (RV32/RV64) and 0x82200000
respectively, so payloads linked for one should work with the other.
pull/202/head
Jessica Clarke 6 years ago
committed by GitHub
parent
commit
d5f5d91b84
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      Makefile.in
  2. 14
      bbl/bbl.c
  3. 12
      bbl/bbl.mk.in

5
Makefile.in

@ -111,7 +111,10 @@ VPATH := $(addprefix $(src_dir)/, $(sprojs_enabled))
CC := @CC@
READELF := @READELF@
OBJCOPY := @OBJCOPY@
CFLAGS := @CFLAGS@ $(CFLAGS) $(march) $(mabi) -DBBL_PAYLOAD=\"bbl_payload\" -DBBL_LOGO_FILE=\"bbl_logo_file\" -fno-stack-protector -U_FORTIFY_SOURCE
CFLAGS := @CFLAGS@ $(CFLAGS) $(march) $(mabi) -DBBL_LOGO_FILE=\"bbl_logo_file\" -DMEM_START=@MEM_START@ -fno-stack-protector -U_FORTIFY_SOURCE
ifneq (@BBL_PAYLOAD@,no)
CFLAGS := $(CFLAGS) -DBBL_PAYLOAD=\"bbl_payload\"
endif
BBL_PAYLOAD := @BBL_PAYLOAD@
COMPILE := $(CC) -MMD -MP $(CFLAGS) \
$(sprojs_include)

14
bbl/bbl.c

@ -9,7 +9,14 @@
#include "fdt.h"
#include <string.h>
#ifdef BBL_PAYLOAD
extern char _payload_start, _payload_end; /* internal payload */
# define PAYLOAD_START &_payload_start
# define PAYLOAD_END ROUNDUP((uintptr_t)&_payload_end, MEGAPAGE_SIZE)
#else
# define PAYLOAD_START (void*)(MEM_START + MEGAPAGE_SIZE)
# define PAYLOAD_END (void*)(MEM_START + 0x2200000)
#endif
static const void* entry_point;
long disabled_hart_mask;
@ -23,8 +30,9 @@ static uintptr_t dtb_output()
* address. The kernel's virtual mapping begins at its load address,
* thus mandating device-tree is in physical memory after the kernel.
*/
uintptr_t end = kernel_end ? (uintptr_t)kernel_end : (uintptr_t)&_payload_end;
return (end + MEGAPAGE_SIZE - 1) / MEGAPAGE_SIZE * MEGAPAGE_SIZE;
uintptr_t end = kernel_end ? ROUNDUP((uintptr_t)kernel_end, MEGAPAGE_SIZE)
: (uintptr_t)PAYLOAD_END;
return end;
}
static void filter_dtb(uintptr_t source)
@ -123,6 +131,6 @@ void boot_loader(uintptr_t dtb)
#endif
mb();
/* Use optional FDT preloaded external payload if present */
entry_point = kernel_start ? kernel_start : &_payload_start;
entry_point = kernel_start ? kernel_start : PAYLOAD_START;
boot_other_hart(0);
}

12
bbl/bbl.mk.in

@ -4,7 +4,6 @@ bbl_subproject_deps = \
util \
softfloat \
machine \
dummy_payload \
bbl_hdrs = \
bbl.h \
@ -13,13 +12,22 @@ bbl_c_srcs = \
logo.c \
bbl_asm_srcs = \
payload.S \
raw_logo.S \
ifeq (@BBL_PAYLOAD@,dummy_payload)
bbl_subproject_deps += \
dummy_payload
endif
ifneq (@BBL_PAYLOAD@,no)
bbl_asm_srcs += \
payload.S
payload.o: bbl_payload
bbl_payload: $(BBL_PAYLOAD)
if $(READELF) -h $< 2> /dev/null > /dev/null; then $(OBJCOPY) -O binary --set-section-flags .bss=alloc,load,contents $< $@; else cp $< $@; fi
endif
raw_logo.o: bbl_logo_file

Loading…
Cancel
Save