firmware: remove FW_TEXT_START

Now opensbi can run at any address via dynamic relocation. We can
remove FW_TEXT_START.

Signed-off-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Xiang W
2024-04-08 23:27:42 +08:00
committed by Anup Patel
parent 73344d4724
commit d4d2582eef
15 changed files with 15 additions and 39 deletions

View File

@@ -61,8 +61,6 @@ Firmware Configuration and Compilation
All firmware types support the following common compile time configuration All firmware types support the following common compile time configuration
parameters: parameters:
* **FW_TEXT_START** - Defines the execution address of the OpenSBI firmware.
This configuration parameter is mandatory.
* **FW_FDT_PATH** - Path to an external flattened device tree binary file to * **FW_FDT_PATH** - Path to an external flattened device tree binary file to
be embedded in the *.rodata* section of the final firmware. If this option be embedded in the *.rodata* section of the final firmware. If this option
is not provided then the firmware will expect the FDT to be passed as an is not provided then the firmware will expect the FDT to be passed as an

View File

@@ -35,7 +35,7 @@ follows:
At least one of *FW_JUMP_ADDR* and *FW_JUMP_OFFSET* (see below) should be At least one of *FW_JUMP_ADDR* and *FW_JUMP_OFFSET* (see below) should be
defined. Compilation errors will result from not defining one of them. defined. Compilation errors will result from not defining one of them.
* **FW_JUMP_OFFSET** - Address offset from the *FW_TEXT_START* where the * **FW_JUMP_OFFSET** - Address offset from the opensbi load address where the
entry point of the next booting stage is located. This offset is used as entry point of the next booting stage is located. This offset is used as
relocatable address of the next booting stage entry point. If *FW_JUMP_ADDR* relocatable address of the next booting stage entry point. If *FW_JUMP_ADDR*
is also defined, the firmware will prefer *FW_JUMP_ADDR*. is also defined, the firmware will prefer *FW_JUMP_ADDR*.
@@ -62,7 +62,7 @@ follows:
echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
``` ```
* **FW_JUMP_FDT_OFFSET** - Address offset from the *FW_TEXT_START* where * **FW_JUMP_FDT_OFFSET** - Address offset from the opensbi load address where
the FDT will be passed to the next booting stage. This offset is used the FDT will be passed to the next booting stage. This offset is used
as relocatable address of the FDT passed to the next booting stage. If as relocatable address of the FDT passed to the next booting stage. If
*FW_JUMP_FDT_ADDR* is also defined, the firmware will prefer *FW_JUMP_FDT_ADDR* is also defined, the firmware will prefer

View File

@@ -36,8 +36,8 @@ options. These configuration parameters can be defined using either the top
level `make` command line or the target platform *objects.mk* configuration level `make` command line or the target platform *objects.mk* configuration
file. The parameters currently defined are as follows: file. The parameters currently defined are as follows:
* **FW_PAYLOAD_OFFSET** - Offset from *FW_TEXT_START* where the payload binary * **FW_PAYLOAD_OFFSET** - Offset from the opensbi load address where the payload
will be linked in the final *FW_PAYLOAD* firmware binary image. This binary will be linked in the final *FW_PAYLOAD* firmware binary image. This
configuration parameter is mandatory if *FW_PAYLOAD_ALIGN* is not defined. configuration parameter is mandatory if *FW_PAYLOAD_ALIGN* is not defined.
Compilation errors will result from an incorrect definition of Compilation errors will result from an incorrect definition of
*FW_PAYLOAD_OFFSET* or of *FW_PAYLOAD_ALIGN*, or if neither of these *FW_PAYLOAD_OFFSET* or of *FW_PAYLOAD_ALIGN*, or if neither of these
@@ -62,7 +62,7 @@ file. The parameters currently defined are as follows:
firmware will pass the FDT address passed by the previous booting stage firmware will pass the FDT address passed by the previous booting stage
to the next booting stage. to the next booting stage.
* **FW_PAYLOAD_FDT_OFFSET** - Address offset from the *FW_TEXT_START* where * **FW_PAYLOAD_FDT_OFFSET** - Address offset from the opensbi load address where
the FDT will be passed to the next booting stage. This offset is used as the FDT will be passed to the next booting stage. This offset is used as
relocatable address of the FDT passed to the next booting stage. If relocatable address of the FDT passed to the next booting stage. If
*FW_PAYLOAD_FDT_ADDR* is also defined, the firmware will prefer *FW_PAYLOAD_FDT_ADDR*. *FW_PAYLOAD_FDT_ADDR* is also defined, the firmware will prefer *FW_PAYLOAD_FDT_ADDR*.

View File

@@ -9,10 +9,9 @@ boards.
By default, the generic FDT platform makes following assumptions: By default, the generic FDT platform makes following assumptions:
1. platform FW_TEXT_START is 0x80000000 1. platform features are default
2. platform features are default 2. platform stack size is default
3. platform stack size is default 3. platform has no quirks or work-arounds
4. platform has no quirks or work-arounds
The above assumptions (except 1) can be overridden by adding special platform The above assumptions (except 1) can be overridden by adding special platform
callbacks which will be called based on FDT root node compatible string. callbacks which will be called based on FDT root node compatible string.
@@ -33,10 +32,6 @@ Users of the generic FDT platform will have to ensure that:
To build the platform-specific library and firmware images, provide the To build the platform-specific library and firmware images, provide the
*PLATFORM=generic* parameter to the top level `make` command. *PLATFORM=generic* parameter to the top level `make` command.
For custom FW_TEXT_START, we can build the platform-specific library and
firmware images by passing *PLATFORM=generic FW_TEXT_START=<custom_text_start>*
parameter to the top level `make` command.
Platform Options Platform Options
---------------- ----------------

View File

@@ -53,9 +53,7 @@ _try_lottery:
bnez a6, _wait_for_boot_hart bnez a6, _wait_for_boot_hart
/* relocate the global table content */ /* relocate the global table content */
li t0, FW_TEXT_START /* link start */ lla t2, _fw_start
lla t1, _fw_start /* load start */
sub t2, t1, t0 /* load offset */
lla t0, __rel_dyn_start lla t0, __rel_dyn_start
lla t1, __rel_dyn_end lla t1, __rel_dyn_end
beq t0, t1, _relocate_done beq t0, t1, _relocate_done

View File

@@ -7,8 +7,7 @@
* Anup Patel <anup.patel@wdc.com> * Anup Patel <anup.patel@wdc.com>
*/ */
. = FW_TEXT_START; /* Don't add any section before _fw_start */
/* Don't add any section between FW_TEXT_START and _fw_start */
PROVIDE(_fw_start = .); PROVIDE(_fw_start = .);
. = ALIGN(0x1000); /* Need this to create proper sections */ . = ALIGN(0x1000); /* Need this to create proper sections */

View File

@@ -15,7 +15,7 @@ SECTIONS
#include "fw_base.ldS" #include "fw_base.ldS"
#ifdef FW_PAYLOAD_OFFSET #ifdef FW_PAYLOAD_OFFSET
. = FW_TEXT_START + FW_PAYLOAD_OFFSET; . = FW_PAYLOAD_OFFSET;
#else #else
. = ALIGN(FW_PAYLOAD_ALIGN); . = ALIGN(FW_PAYLOAD_ALIGN);
#endif #endif

View File

@@ -13,10 +13,6 @@ firmware-cflags-y +=
firmware-asflags-y += firmware-asflags-y +=
firmware-ldflags-y += firmware-ldflags-y +=
ifdef FW_TEXT_START
firmware-genflags-y += -DFW_TEXT_START=$(FW_TEXT_START)
endif
ifdef FW_FDT_PATH ifdef FW_FDT_PATH
firmware-genflags-y += -DFW_FDT_PATH=\"$(FW_FDT_PATH)\" firmware-genflags-y += -DFW_FDT_PATH=\"$(FW_FDT_PATH)\"
ifdef FW_FDT_PADDING ifdef FW_FDT_PADDING

View File

@@ -13,7 +13,7 @@ ENTRY(_start)
SECTIONS SECTIONS
{ {
#ifdef FW_PAYLOAD_OFFSET #ifdef FW_PAYLOAD_OFFSET
. = FW_TEXT_START + FW_PAYLOAD_OFFSET; . = FW_PAYLOAD_OFFSET;
#else #else
. = ALIGN(FW_PAYLOAD_ALIGN); . = ALIGN(FW_PAYLOAD_ALIGN);
#endif #endif

View File

@@ -17,7 +17,6 @@ platform-objs-y += platform.o
PLATFORM_RISCV_XLEN = 64 PLATFORM_RISCV_XLEN = 64
# Blobs to build # Blobs to build
FW_TEXT_START=0x80000000
FW_JUMP=n FW_JUMP=n
ifeq ($(PLATFORM_RISCV_XLEN), 32) ifeq ($(PLATFORM_RISCV_XLEN), 32)

View File

@@ -16,7 +16,6 @@ platform-objs-y += platform.o
PLATFORM_RISCV_XLEN = 64 PLATFORM_RISCV_XLEN = 64
# Blobs to build # Blobs to build
FW_TEXT_START=0x80000000
FW_JUMP=n FW_JUMP=n
ifeq ($(PLATFORM_RISCV_XLEN), 32) ifeq ($(PLATFORM_RISCV_XLEN), 32)

View File

@@ -15,14 +15,13 @@ platform-ldflags-y =
# Command for platform specific "make run" # Command for platform specific "make run"
platform-runcmd = qemu-system-riscv$(PLATFORM_RISCV_XLEN) -M virt -m 256M \ platform-runcmd = qemu-system-riscv$(PLATFORM_RISCV_XLEN) -M virt -m 256M \
-nographic -bios $(build_dir)/platform/generic/firmware/fw_payload.elf -nographic -bios $(build_dir)/platform/generic/firmware/fw_payload.bin
# Objects to build # Objects to build
platform-objs-y += platform.o platform-objs-y += platform.o
platform-objs-y += platform_override_modules.o platform-objs-y += platform_override_modules.o
# Blobs to build # Blobs to build
FW_TEXT_START=0x80000000
FW_DYNAMIC=y FW_DYNAMIC=y
FW_JUMP=y FW_JUMP=y
ifeq ($(PLATFORM_RISCV_XLEN), 32) ifeq ($(PLATFORM_RISCV_XLEN), 32)

View File

@@ -21,6 +21,5 @@ platform-varprefix-k210.o = dt_k210
platform-padding-k210.o = 2048 platform-padding-k210.o = 2048
# Blobs to build # Blobs to build
FW_TEXT_START=0x80000000
FW_PAYLOAD=y FW_PAYLOAD=y
FW_PAYLOAD_ALIGN=0x1000 FW_PAYLOAD_ALIGN=0x1000

View File

@@ -22,7 +22,6 @@ platform-runcmd = xl_spike \
platform-objs-y += platform.o platform-objs-y += platform.o
# Blobs to build # Blobs to build
FW_TEXT_START=0xA0000000
FW_DYNAMIC=y FW_DYNAMIC=y
FW_JUMP=y FW_JUMP=y

View File

@@ -41,9 +41,6 @@ platform-objs-y += platform.o
# #
# platform-objs-y += <dt file name>.o # platform-objs-y += <dt file name>.o
# Firmware load address configuration. This is mandatory.
FW_TEXT_START=0x80000000
# Optional parameter for path to external FDT # Optional parameter for path to external FDT
# FW_FDT_PATH="path to platform flattened device tree file" # FW_FDT_PATH="path to platform flattened device tree file"
@@ -69,8 +66,7 @@ FW_JUMP=<y|n>
# endif # endif
# FW_JUMP_FDT_OFFSET=0x2200000 # FW_JUMP_FDT_OFFSET=0x2200000
# #
# You can use fixed address for jump firmware as an alternative option, # You can use fixed address for jump firmware as an alternative option.
# but this may fail when setting wrong FW_TEXT_START. Use with caution.
# SBI will prefer "<X>_ADDR" if both "<X>_ADDR" and "<X>_OFFSET" are # SBI will prefer "<X>_ADDR" if both "<X>_ADDR" and "<X>_OFFSET" are
# defined # defined
# ifeq ($(PLATFORM_RISCV_XLEN), 32) # ifeq ($(PLATFORM_RISCV_XLEN), 32)
@@ -97,8 +93,7 @@ endif
# FW_PAYLOAD_PATH="path to next boot stage binary image file" # FW_PAYLOAD_PATH="path to next boot stage binary image file"
# FW_PAYLOAD_FDT_OFFSET=0x2200000 # FW_PAYLOAD_FDT_OFFSET=0x2200000
# #
# You can use fixed address for payload firmware as an alternative option, # You can use fixed address for payload firmware as an alternative option.
# but this may fail when setting wrong FW_TEXT_START. Use with caution.
# SBI will prefer "FW_PAYLOAD_FDT_ADDR" if both "FW_PAYLOAD_FDT_OFFSET" # SBI will prefer "FW_PAYLOAD_FDT_ADDR" if both "FW_PAYLOAD_FDT_OFFSET"
# and "FW_PAYLOAD_FDT_ADDR" are defined. # and "FW_PAYLOAD_FDT_ADDR" are defined.
# FW_PAYLOAD_FDT_ADDR=0x82200000 # FW_PAYLOAD_FDT_ADDR=0x82200000