Add support for BL3-2 in BL3-1
This patch adds the following support to the BL3-1 stage:
1. BL3-1 allows runtime services to specify and determine the security
state of the next image after BL3-1. This has been done by adding
the `bl31_set_next_image_type()` & `bl31_get_next_image_type()`
apis. The default security state is non-secure. The platform api
`bl31_get_next_image_info()` has been modified to let the platform
decide which is the next image in the desired security state.
2. BL3-1 exports the `bl31_prepare_next_image_entry()` function to
program entry into the target security state. It uses the apis
introduced in 1. to do so.
3. BL3-1 reads the information populated by BL2 about the BL3-2 image
into its internal data structures.
4. BL3-1 introduces a weakly defined reference `bl32_init()` to allow
initialisation of a BL3-2 image. A runtime service like the Secure
payload dispatcher will define this function if present.
Change-Id: Icc46dcdb9e475ce6575dd3f9a5dc7a48a83d21d1
diff --git a/docs/porting-guide.md b/docs/porting-guide.md
index 720c877..460dbcc 100644
--- a/docs/porting-guide.md
+++ b/docs/porting-guide.md
@@ -709,6 +709,12 @@
service. See Section 3.3 below for details of porting the PSCI
implementation.
+4. Optionally passing control to the BL3-2 image, pre-loaded at a platform-
+ specific address by BL2. BL3-1 exports a set of apis that allow runtime
+ services to specify the security state in which the next image should be
+ executed and run the corresponding image. BL3-1 uses the `el_change_info`
+ and `meminfo` structure populated by BL2 to do this.
+
The following functions must be implemented by the platform port to enable BL3-1
to perform the above tasks.
@@ -771,16 +777,18 @@
### Function : bl31_get_next_image_info() [mandatory]
- Argument : unsigned long
+ Argument : unsigned int
Return : el_change_info *
This function may execute with the MMU and data caches enabled if the platform
port does the necessary initializations in `bl31_plat_arch_setup()`.
This function is called by `bl31_main()` to retrieve information provided by
-BL2, so that BL3-1 can pass control to the normal world software image. This
-function must return a pointer to the `el_change_info` structure (that was
-copied during `bl31_early_platform_setup()`).
+BL2 for the next image in the security state specified by the argument. BL3-1
+uses this information to pass control to that image in the specified security
+state. This function must return a pointer to the `el_change_info` structure
+(that was copied during `bl31_early_platform_setup()`) if the image exists. It
+should return NULL otherwise.
### Function : bl31_plat_sec_mem_layout() [mandatory]
@@ -798,6 +806,21 @@
`bl31_early_platform_setup()` above.
+### Function : bl31_plat_get_bl32_mem_layout() [mandatory]
+
+ Argument : void
+ Return : meminfo *
+
+This function should only be called on the cold boot path. This function may
+execute with the MMU and data caches enabled if the platform port does the
+necessary initializations in `bl31_plat_arch_setup()`. It is only called by the
+primary CPU.
+
+The purpose of this function is to return a pointer to a `meminfo` structure
+populated with the extents of memory available for BL3-2 to use. See
+`bl31_early_platform_setup()` above.
+
+
3.3 Power State Coordination Interface (in BL3-1)
------------------------------------------------
diff --git a/docs/user-guide.md b/docs/user-guide.md
index 589d0b1..ffad7f4 100644
--- a/docs/user-guide.md
+++ b/docs/user-guide.md
@@ -955,6 +955,13 @@
[SMCCC].
+### BL3-2 (Secure Payload) image initialization
+
+BL2 is responsible for loading a BL3-2 image in memory specified by the platform.
+BL3-1 provides an api that uses the entrypoint and memory layout information for
+the BL3-2 image provided by BL2 to initialise BL3-2 in S-EL1.
+
+
### Normal world software execution
BL3-1 uses the entrypoint information provided by BL2 to jump to the normal