xref: /rk3399_ARM-atf/docs/design/reset-design.rst (revision 40d553cfde38d4f68449c62967cd1ce0d6478750)
1*40d553cfSPaul BeesleyTrusted Firmware-A reset design
2*40d553cfSPaul Beesley===============================
3*40d553cfSPaul Beesley
4*40d553cfSPaul Beesley
5*40d553cfSPaul Beesley
6*40d553cfSPaul Beesley
7*40d553cfSPaul Beesley.. contents::
8*40d553cfSPaul Beesley
9*40d553cfSPaul BeesleyThis document describes the high-level design of the framework to handle CPU
10*40d553cfSPaul Beesleyresets in Trusted Firmware-A (TF-A). It also describes how the platform
11*40d553cfSPaul Beesleyintegrator can tailor this code to the system configuration to some extent,
12*40d553cfSPaul Beesleyresulting in a simplified and more optimised boot flow.
13*40d553cfSPaul Beesley
14*40d553cfSPaul BeesleyThis document should be used in conjunction with the `Firmware Design`_, which
15*40d553cfSPaul Beesleyprovides greater implementation details around the reset code, specifically
16*40d553cfSPaul Beesleyfor the cold boot path.
17*40d553cfSPaul Beesley
18*40d553cfSPaul BeesleyGeneral reset code flow
19*40d553cfSPaul Beesley-----------------------
20*40d553cfSPaul Beesley
21*40d553cfSPaul BeesleyThe TF-A reset code is implemented in BL1 by default. The following high-level
22*40d553cfSPaul Beesleydiagram illustrates this:
23*40d553cfSPaul Beesley
24*40d553cfSPaul Beesley|Default reset code flow|
25*40d553cfSPaul Beesley
26*40d553cfSPaul BeesleyThis diagram shows the default, unoptimised reset flow. Depending on the system
27*40d553cfSPaul Beesleyconfiguration, some of these steps might be unnecessary. The following sections
28*40d553cfSPaul Beesleyguide the platform integrator by indicating which build options exclude which
29*40d553cfSPaul Beesleysteps, depending on the capability of the platform.
30*40d553cfSPaul Beesley
31*40d553cfSPaul BeesleyNote: If BL31 is used as the TF-A entry point instead of BL1, the diagram
32*40d553cfSPaul Beesleyabove is still relevant, as all these operations will occur in BL31 in
33*40d553cfSPaul Beesleythis case. Please refer to section 6 "Using BL31 entrypoint as the reset
34*40d553cfSPaul Beesleyaddress" for more information.
35*40d553cfSPaul Beesley
36*40d553cfSPaul BeesleyProgrammable CPU reset address
37*40d553cfSPaul Beesley------------------------------
38*40d553cfSPaul Beesley
39*40d553cfSPaul BeesleyBy default, TF-A assumes that the CPU reset address is not programmable.
40*40d553cfSPaul BeesleyTherefore, all CPUs start at the same address (typically address 0) whenever
41*40d553cfSPaul Beesleythey reset. Further logic is then required to identify whether it is a cold or
42*40d553cfSPaul Beesleywarm boot to direct CPUs to the right execution path.
43*40d553cfSPaul Beesley
44*40d553cfSPaul BeesleyIf the reset vector address (reflected in the reset vector base address register
45*40d553cfSPaul Beesley``RVBAR_EL3``) is programmable then it is possible to make each CPU start directly
46*40d553cfSPaul Beesleyat the right address, both on a cold and warm reset. Therefore, the boot type
47*40d553cfSPaul Beesleydetection can be skipped, resulting in the following boot flow:
48*40d553cfSPaul Beesley
49*40d553cfSPaul Beesley|Reset code flow with programmable reset address|
50*40d553cfSPaul Beesley
51*40d553cfSPaul BeesleyTo enable this boot flow, compile TF-A with ``PROGRAMMABLE_RESET_ADDRESS=1``.
52*40d553cfSPaul BeesleyThis option only affects the TF-A reset image, which is BL1 by default or BL31 if
53*40d553cfSPaul Beesley``RESET_TO_BL31=1``.
54*40d553cfSPaul Beesley
55*40d553cfSPaul BeesleyOn both the FVP and Juno platforms, the reset vector address is not programmable
56*40d553cfSPaul Beesleyso both ports use ``PROGRAMMABLE_RESET_ADDRESS=0``.
57*40d553cfSPaul Beesley
58*40d553cfSPaul BeesleyCold boot on a single CPU
59*40d553cfSPaul Beesley-------------------------
60*40d553cfSPaul Beesley
61*40d553cfSPaul BeesleyBy default, TF-A assumes that several CPUs may be released out of reset.
62*40d553cfSPaul BeesleyTherefore, the cold boot code has to arbitrate access to hardware resources
63*40d553cfSPaul Beesleyshared amongst CPUs. This is done by nominating one of the CPUs as the primary,
64*40d553cfSPaul Beesleywhich is responsible for initialising shared hardware and coordinating the boot
65*40d553cfSPaul Beesleyflow with the other CPUs.
66*40d553cfSPaul Beesley
67*40d553cfSPaul BeesleyIf the platform guarantees that only a single CPU will ever be brought up then
68*40d553cfSPaul Beesleyno arbitration is required. The notion of primary/secondary CPU itself no longer
69*40d553cfSPaul Beesleyapplies. This results in the following boot flow:
70*40d553cfSPaul Beesley
71*40d553cfSPaul Beesley|Reset code flow with single CPU released out of reset|
72*40d553cfSPaul Beesley
73*40d553cfSPaul BeesleyTo enable this boot flow, compile TF-A with ``COLD_BOOT_SINGLE_CPU=1``. This
74*40d553cfSPaul Beesleyoption only affects the TF-A reset image, which is BL1 by default or BL31 if
75*40d553cfSPaul Beesley``RESET_TO_BL31=1``.
76*40d553cfSPaul Beesley
77*40d553cfSPaul BeesleyOn both the FVP and Juno platforms, although only one core is powered up by
78*40d553cfSPaul Beesleydefault, there are platform-specific ways to release any number of cores out of
79*40d553cfSPaul Beesleyreset. Therefore, both platform ports use ``COLD_BOOT_SINGLE_CPU=0``.
80*40d553cfSPaul Beesley
81*40d553cfSPaul BeesleyProgrammable CPU reset address, Cold boot on a single CPU
82*40d553cfSPaul Beesley---------------------------------------------------------
83*40d553cfSPaul Beesley
84*40d553cfSPaul BeesleyIt is obviously possible to combine both optimisations on platforms that have
85*40d553cfSPaul Beesleya programmable CPU reset address and which release a single CPU out of reset.
86*40d553cfSPaul BeesleyThis results in the following boot flow:
87*40d553cfSPaul Beesley
88*40d553cfSPaul Beesley
89*40d553cfSPaul Beesley|Reset code flow with programmable reset address and single CPU released out of reset|
90*40d553cfSPaul Beesley
91*40d553cfSPaul BeesleyTo enable this boot flow, compile TF-A with both ``COLD_BOOT_SINGLE_CPU=1``
92*40d553cfSPaul Beesleyand ``PROGRAMMABLE_RESET_ADDRESS=1``. These options only affect the TF-A reset
93*40d553cfSPaul Beesleyimage, which is BL1 by default or BL31 if ``RESET_TO_BL31=1``.
94*40d553cfSPaul Beesley
95*40d553cfSPaul BeesleyUsing BL31 entrypoint as the reset address
96*40d553cfSPaul Beesley------------------------------------------
97*40d553cfSPaul Beesley
98*40d553cfSPaul BeesleyOn some platforms the runtime firmware (BL3x images) for the application
99*40d553cfSPaul Beesleyprocessors are loaded by some firmware running on a secure system processor
100*40d553cfSPaul Beesleyon the SoC, rather than by BL1 and BL2 running on the primary application
101*40d553cfSPaul Beesleyprocessor. For this type of SoC it is desirable for the application processor
102*40d553cfSPaul Beesleyto always reset to BL31 which eliminates the need for BL1 and BL2.
103*40d553cfSPaul Beesley
104*40d553cfSPaul BeesleyTF-A provides a build-time option ``RESET_TO_BL31`` that includes some additional
105*40d553cfSPaul Beesleylogic in the BL31 entry point to support this use case.
106*40d553cfSPaul Beesley
107*40d553cfSPaul BeesleyIn this configuration, the platform's Trusted Boot Firmware must ensure that
108*40d553cfSPaul BeesleyBL31 is loaded to its runtime address, which must match the CPU's ``RVBAR_EL3``
109*40d553cfSPaul Beesleyreset vector base address, before the application processor is powered on.
110*40d553cfSPaul BeesleyAdditionally, platform software is responsible for loading the other BL3x images
111*40d553cfSPaul Beesleyrequired and providing entry point information for them to BL31. Loading these
112*40d553cfSPaul Beesleyimages might be done by the Trusted Boot Firmware or by platform code in BL31.
113*40d553cfSPaul Beesley
114*40d553cfSPaul BeesleyAlthough the Arm FVP platform does not support programming the reset base
115*40d553cfSPaul Beesleyaddress dynamically at run-time, it is possible to set the initial value of the
116*40d553cfSPaul Beesley``RVBAR_EL3`` register at start-up. This feature is provided on the Base FVP only.
117*40d553cfSPaul BeesleyIt allows the Arm FVP port to support the ``RESET_TO_BL31`` configuration, in
118*40d553cfSPaul Beesleywhich case the ``bl31.bin`` image must be loaded to its run address in Trusted
119*40d553cfSPaul BeesleySRAM and all CPU reset vectors be changed from the default ``0x0`` to this run
120*40d553cfSPaul Beesleyaddress. See the `User Guide`_ for details of running the FVP models in this way.
121*40d553cfSPaul Beesley
122*40d553cfSPaul BeesleyAlthough technically it would be possible to program the reset base address with
123*40d553cfSPaul Beesleythe right support in the SCP firmware, this is currently not implemented so the
124*40d553cfSPaul BeesleyJuno port doesn't support the ``RESET_TO_BL31`` configuration.
125*40d553cfSPaul Beesley
126*40d553cfSPaul BeesleyThe ``RESET_TO_BL31`` configuration requires some additions and changes in the
127*40d553cfSPaul BeesleyBL31 functionality:
128*40d553cfSPaul Beesley
129*40d553cfSPaul BeesleyDetermination of boot path
130*40d553cfSPaul Beesley~~~~~~~~~~~~~~~~~~~~~~~~~~
131*40d553cfSPaul Beesley
132*40d553cfSPaul BeesleyIn this configuration, BL31 uses the same reset framework and code as the one
133*40d553cfSPaul Beesleydescribed for BL1 above. Therefore, it is affected by the
134*40d553cfSPaul Beesley``PROGRAMMABLE_RESET_ADDRESS`` and ``COLD_BOOT_SINGLE_CPU`` build options in the
135*40d553cfSPaul Beesleysame way.
136*40d553cfSPaul Beesley
137*40d553cfSPaul BeesleyIn the default, unoptimised BL31 reset flow, on a warm boot a CPU is directed
138*40d553cfSPaul Beesleyto the PSCI implementation via a platform defined mechanism. On a cold boot,
139*40d553cfSPaul Beesleythe platform must place any secondary CPUs into a safe state while the primary
140*40d553cfSPaul BeesleyCPU executes a modified BL31 initialization, as described below.
141*40d553cfSPaul Beesley
142*40d553cfSPaul BeesleyPlatform initialization
143*40d553cfSPaul Beesley~~~~~~~~~~~~~~~~~~~~~~~
144*40d553cfSPaul Beesley
145*40d553cfSPaul BeesleyIn this configuration, when the CPU resets to BL31 there are no parameters that
146*40d553cfSPaul Beesleycan be passed in registers by previous boot stages. Instead, the platform code
147*40d553cfSPaul Beesleyin BL31 needs to know, or be able to determine, the location of the BL32 (if
148*40d553cfSPaul Beesleyrequired) and BL33 images and provide this information in response to the
149*40d553cfSPaul Beesley``bl31_plat_get_next_image_ep_info()`` function.
150*40d553cfSPaul Beesley
151*40d553cfSPaul BeesleyAdditionally, platform software is responsible for carrying out any security
152*40d553cfSPaul Beesleyinitialisation, for example programming a TrustZone address space controller.
153*40d553cfSPaul BeesleyThis might be done by the Trusted Boot Firmware or by platform code in BL31.
154*40d553cfSPaul Beesley
155*40d553cfSPaul Beesley--------------
156*40d553cfSPaul Beesley
157*40d553cfSPaul Beesley*Copyright (c) 2015-2018, Arm Limited and Contributors. All rights reserved.*
158*40d553cfSPaul Beesley
159*40d553cfSPaul Beesley.. _Firmware Design: firmware-design.rst
160*40d553cfSPaul Beesley.. _User Guide: ../getting_started/user-guide.rst
161*40d553cfSPaul Beesley
162*40d553cfSPaul Beesley.. |Default reset code flow| image:: ../diagrams/default_reset_code.png?raw=true
163*40d553cfSPaul Beesley.. |Reset code flow with programmable reset address| image:: ../diagrams/reset_code_no_boot_type_check.png?raw=true
164*40d553cfSPaul Beesley.. |Reset code flow with single CPU released out of reset| image:: ../diagrams/reset_code_no_cpu_check.png?raw=true
165*40d553cfSPaul Beesley.. |Reset code flow with programmable reset address and single CPU released out of reset| image:: ../diagrams/reset_code_no_checks.png?raw=true
166