firmware: remove FW_TEXT_START
authorXiang W <wxjstz@126.com>
Mon, 8 Apr 2024 15:27:42 +0000 (23:27 +0800)
committerAnup Patel <anup@brainfault.org>
Wed, 10 Apr 2024 04:20:24 +0000 (09:50 +0530)
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>
15 files changed:
docs/firmware/fw.md
docs/firmware/fw_jump.md
docs/firmware/fw_payload.md
docs/platform/generic.md
firmware/fw_base.S
firmware/fw_base.ldS
firmware/fw_payload.elf.ldS
firmware/objects.mk
firmware/payloads/test.elf.ldS
platform/fpga/ariane/objects.mk
platform/fpga/openpiton/objects.mk
platform/generic/objects.mk
platform/kendryte/k210/objects.mk
platform/nuclei/ux600/objects.mk
platform/template/objects.mk

index 2f4deb55fc3b6e141d9da5662c9d423f09fba1b8..3cc0262afa9ff33fe4500a9187928af661819f16 100644 (file)
@@ -61,8 +61,6 @@ Firmware Configuration and Compilation
 All firmware types support the following common compile time configuration
 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
   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
index 2ee6b291fa040169b6418e72ea6ca5772fd65d10..66be016902ca4ae05657630b41097c4dbc963e15 100644 (file)
@@ -35,7 +35,7 @@ follows:
   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.
 
-* **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
   relocatable address of the next booting stage entry point. If *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
   ```
 
-* **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
   as relocatable address of the FDT passed to the next booting stage. If
   *FW_JUMP_FDT_ADDR* is also defined, the firmware will prefer
index a67fc50b8682d7709bd28007d0ca35dfe391cd36..d25be600c6a30b7da959e153d7247d3fec2f641f 100644 (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
 file. The parameters currently defined are as follows:
 
-* **FW_PAYLOAD_OFFSET** - Offset from *FW_TEXT_START* where the payload binary
-  will be linked in the final *FW_PAYLOAD* firmware binary image. This
+* **FW_PAYLOAD_OFFSET** - Offset from the opensbi load address where the payload
+  binary will be linked in the final *FW_PAYLOAD* firmware binary image. This
   configuration parameter is mandatory if *FW_PAYLOAD_ALIGN* is not defined.
   Compilation errors will result from an incorrect definition of
   *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
   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
   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*.
index c29eb0476073428b7b6907fbc15a11237ebe886f..709b436e7e4136265ef98faf452c3947e14dd5b8 100644 (file)
@@ -9,10 +9,9 @@ boards.
 
 By default, the generic FDT platform makes following assumptions:
 
-1. platform FW_TEXT_START is 0x80000000
-2. platform features are default
-3. platform stack size is default
-4. platform has no quirks or work-arounds
+1. platform features are default
+2. platform stack size is default
+3. platform has no quirks or work-arounds
 
 The above assumptions (except 1) can be overridden by adding special platform
 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
 *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
 ----------------
 
index b950c0b836cc32036968088885d72d82e4a3a5e6..9f995a2283be2d1a72ddfe64314a4876a894ebe4 100644 (file)
@@ -53,9 +53,7 @@ _try_lottery:
        bnez    a6, _wait_for_boot_hart
 
        /* relocate the global table content */
-       li      t0, FW_TEXT_START       /* link start */
-       lla     t1, _fw_start           /* load start */
-       sub     t2, t1, t0              /* load offset */
+       lla     t2, _fw_start
        lla     t0, __rel_dyn_start
        lla     t1, __rel_dyn_end
        beq     t0, t1, _relocate_done
index fb47984878f8101bb33a07f79de7b5aaa539ae43..9d11db56df7b75942b3a7d9b1beeeeca1611fbff 100644 (file)
@@ -7,8 +7,7 @@
  *   Anup Patel <anup.patel@wdc.com>
  */
 
-       . = FW_TEXT_START;
-       /* Don't add any section between FW_TEXT_START and _fw_start */
+       /* Don't add any section before _fw_start */
        PROVIDE(_fw_start = .);
 
        . = ALIGN(0x1000); /* Need this to create proper sections */
index f1a544b80dc01d69713a07639037439c463457ae..94e1ac69591e8218312ca1274e6631ae5e276453 100644 (file)
@@ -15,7 +15,7 @@ SECTIONS
        #include "fw_base.ldS"
 
 #ifdef FW_PAYLOAD_OFFSET
-       . = FW_TEXT_START + FW_PAYLOAD_OFFSET;
+       . = FW_PAYLOAD_OFFSET;
 #else
        . = ALIGN(FW_PAYLOAD_ALIGN);
 #endif
index e6b364b811505f24aa986f4692e062b12bf484e6..a51ff657ea4a6e5b6bedacacd0040a00edac13cd 100644 (file)
@@ -13,10 +13,6 @@ firmware-cflags-y +=
 firmware-asflags-y +=
 firmware-ldflags-y +=
 
-ifdef FW_TEXT_START
-firmware-genflags-y += -DFW_TEXT_START=$(FW_TEXT_START)
-endif
-
 ifdef FW_FDT_PATH
 firmware-genflags-y += -DFW_FDT_PATH=\"$(FW_FDT_PATH)\"
 ifdef FW_FDT_PADDING
index 2328a1b782dae068f5f0a5f1233c52338ea41538..08e008f4e334117e1d2997be5d4abdc502435188 100644 (file)
@@ -13,7 +13,7 @@ ENTRY(_start)
 SECTIONS
 {
 #ifdef FW_PAYLOAD_OFFSET
-       . = FW_TEXT_START + FW_PAYLOAD_OFFSET;
+       . = FW_PAYLOAD_OFFSET;
 #else
        . = ALIGN(FW_PAYLOAD_ALIGN);
 #endif
index 83581ac9d8cd924a7670db91c4aea57784ad3105..d1177f41b80c161af91d7fcb82655376359b2291 100644 (file)
@@ -17,7 +17,6 @@ platform-objs-y += platform.o
 PLATFORM_RISCV_XLEN = 64
 
 # Blobs to build
-FW_TEXT_START=0x80000000
 FW_JUMP=n
 
 ifeq ($(PLATFORM_RISCV_XLEN), 32)
index c8c345abfd65e255e6dd460174586d83fc546661..1a0ce0c7771acc54c6fa6aa0ef9e6efb4f97518c 100644 (file)
@@ -16,7 +16,6 @@ platform-objs-y += platform.o
 PLATFORM_RISCV_XLEN = 64
 
 # Blobs to build
-FW_TEXT_START=0x80000000
 FW_JUMP=n
 
 ifeq ($(PLATFORM_RISCV_XLEN), 32)
index 85aa723a5480e63de760cd630b1b69dc148ed26b..c215935e11a80b7b64076b9c2fdd0ccc3634455e 100644 (file)
@@ -15,14 +15,13 @@ platform-ldflags-y =
 
 # Command for platform specific "make run"
 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
 platform-objs-y += platform.o
 platform-objs-y += platform_override_modules.o
 
 # Blobs to build
-FW_TEXT_START=0x80000000
 FW_DYNAMIC=y
 FW_JUMP=y
 ifeq ($(PLATFORM_RISCV_XLEN), 32)
index 1bfb89861ecbb99a77c2520a583e5015c6c99ebd..efac3d2f95eda6fa984efab856414c2ee6f19751 100644 (file)
@@ -21,6 +21,5 @@ platform-varprefix-k210.o = dt_k210
 platform-padding-k210.o = 2048
 
 # Blobs to build
-FW_TEXT_START=0x80000000
 FW_PAYLOAD=y
 FW_PAYLOAD_ALIGN=0x1000
index 7c429e0be8f7b96071982b30377514623eba96e2..2753a7f9ab8ae838d7c046d9c5b6d1854eec3190 100644 (file)
@@ -22,7 +22,6 @@ platform-runcmd = xl_spike \
 platform-objs-y += platform.o
 
 # Blobs to build
-FW_TEXT_START=0xA0000000
 FW_DYNAMIC=y
 FW_JUMP=y
 
index b143cbc4ebce8dbe4a2932c0dda0eabd03e44590..f240a5576ebb6239b4d82ed0d8401c57a3326a2b 100644 (file)
@@ -41,9 +41,6 @@ platform-objs-y += platform.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
 # FW_FDT_PATH="path to platform flattened device tree file"
 
@@ -69,8 +66,7 @@ FW_JUMP=<y|n>
 # endif
 # FW_JUMP_FDT_OFFSET=0x2200000
 #
-# 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.
+# You can use fixed address for jump firmware as an alternative option.
 # SBI will prefer "<X>_ADDR" if both "<X>_ADDR" and "<X>_OFFSET" are
 # defined
 # ifeq ($(PLATFORM_RISCV_XLEN), 32)
@@ -97,8 +93,7 @@ endif
 # FW_PAYLOAD_PATH="path to next boot stage binary image file"
 # FW_PAYLOAD_FDT_OFFSET=0x2200000
 #
-# 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.
+# You can use fixed address for payload firmware as an alternative option.
 # SBI will prefer "FW_PAYLOAD_FDT_ADDR" if both "FW_PAYLOAD_FDT_OFFSET"
 # and "FW_PAYLOAD_FDT_ADDR" are defined.
 # FW_PAYLOAD_FDT_ADDR=0x82200000