rpi3: Add support for direct Linux kernel boot
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Sun, 15 Jul 2018 11:32:32 +0000 (12:32 +0100)
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Mon, 16 Jul 2018 14:56:42 +0000 (15:56 +0100)
This option allows the Trusted Firmware to pass the correct arguments to
a 32 or 64-bit Linux kernel without the need of an intermediate loader
such as U-Boot.

Change-Id: I2b22e8933fad6a614588ace559f893e97329801f
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
plat/rpi3/platform.mk
plat/rpi3/rpi3_bl31_setup.c

index 2f18af6a87381fca0fec099530b8bd1d0d9cc2f5..4276c84f8841057916af11df9e09d1801dbf585e 100644 (file)
@@ -114,6 +114,9 @@ MULTI_CONSOLE_API           := 1
 # BL33 images are in AArch64 by default
 RPI3_BL33_IN_AARCH32           := 0
 
+# Assume that BL33 isn't the Linux kernel by default
+RPI3_DIRECT_LINUX_BOOT         := 0
+
 # BL32 location
 RPI3_BL32_RAM_LOCATION := tdram
 ifeq (${RPI3_BL32_RAM_LOCATION}, tsram)
@@ -129,9 +132,17 @@ endif
 
 $(eval $(call add_define,RPI3_BL32_RAM_LOCATION_ID))
 $(eval $(call add_define,RPI3_BL33_IN_AARCH32))
+$(eval $(call add_define,RPI3_DIRECT_LINUX_BOOT))
+$(eval $(call add_define,RPI3_PRELOADED_DTB_BASE))
 
 # Verify build config
 # -------------------
+#
+ifneq (${RPI3_DIRECT_LINUX_BOOT}, 0)
+  ifndef RPI3_PRELOADED_DTB_BASE
+    $(error Error: RPI3_PRELOADED_DTB_BASE needed if RPI3_DIRECT_LINUX_BOOT=1)
+  endif
+endif
 
 ifneq (${LOAD_IMAGE_V2}, 1)
   $(error Error: rpi3 needs LOAD_IMAGE_V2=1)
index 4ea1bcf9052c654b648c4d7fb80cabfe527c0d10..5bbb13c868f6c95233c93e550df4dd8cb3b80402 100644 (file)
@@ -96,6 +96,34 @@ void bl31_early_platform_setup(void *from_bl2,
        if (bl33_image_ep_info.pc == 0) {
                panic();
        }
+
+#if RPI3_DIRECT_LINUX_BOOT
+# if RPI3_BL33_IN_AARCH32
+       /*
+        * According to the file ``Documentation/arm/Booting`` of the Linux
+        * kernel tree, Linux expects:
+        * r0 = 0
+        * r1 = machine type number, optional in DT-only platforms (~0 if so)
+        * r2 = Physical address of the device tree blob
+        */
+       VERBOSE("rpi3: Preparing to boot 32-bit Linux kernel\n");
+       bl33_image_ep_info.args.arg0 = 0U;
+       bl33_image_ep_info.args.arg1 = ~0U;
+       bl33_image_ep_info.args.arg2 = (u_register_t) RPI3_PRELOADED_DTB_BASE;
+# else
+       /*
+        * According to the file ``Documentation/arm64/booting.txt`` of the
+        * Linux kernel tree, Linux expects the physical address of the device
+        * tree blob (DTB) in x0, while x1-x3 are reserved for future use and
+        * must be 0.
+        */
+       VERBOSE("rpi3: Preparing to boot 64-bit Linux kernel\n");
+       bl33_image_ep_info.args.arg0 = (u_register_t) RPI3_PRELOADED_DTB_BASE;
+       bl33_image_ep_info.args.arg1 = 0ULL;
+       bl33_image_ep_info.args.arg2 = 0ULL;
+       bl33_image_ep_info.args.arg3 = 0ULL;
+# endif /* RPI3_BL33_IN_AARCH32 */
+#endif /* RPI3_DIRECT_LINUX_BOOT */
 }
 
 void bl31_plat_arch_setup(void)