xref: /arm-trusted-firmware/docs/design/reset-design.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluCPU Reset
2*91f16700Schasinglulu=========
3*91f16700Schasinglulu
4*91f16700SchasingluluThis document describes the high-level design of the framework to handle CPU
5*91f16700Schasingluluresets in Trusted Firmware-A (TF-A). It also describes how the platform
6*91f16700Schasingluluintegrator can tailor this code to the system configuration to some extent,
7*91f16700Schasingluluresulting in a simplified and more optimised boot flow.
8*91f16700Schasinglulu
9*91f16700SchasingluluThis document should be used in conjunction with the :ref:`Firmware Design`
10*91f16700Schasingluludocument which provides greater implementation details around the reset code,
11*91f16700Schasingluluspecifically for the cold boot path.
12*91f16700Schasinglulu
13*91f16700SchasingluluGeneral reset code flow
14*91f16700Schasinglulu-----------------------
15*91f16700Schasinglulu
16*91f16700SchasingluluThe TF-A reset code is implemented in BL1 by default. The following high-level
17*91f16700Schasingluludiagram illustrates this:
18*91f16700Schasinglulu
19*91f16700Schasinglulu|Default reset code flow|
20*91f16700Schasinglulu
21*91f16700SchasingluluThis diagram shows the default, unoptimised reset flow. Depending on the system
22*91f16700Schasingluluconfiguration, some of these steps might be unnecessary. The following sections
23*91f16700Schasingluluguide the platform integrator by indicating which build options exclude which
24*91f16700Schasinglulusteps, depending on the capability of the platform.
25*91f16700Schasinglulu
26*91f16700Schasinglulu.. note::
27*91f16700Schasinglulu   If BL31 is used as the TF-A entry point instead of BL1, the diagram
28*91f16700Schasinglulu   above is still relevant, as all these operations will occur in BL31 in
29*91f16700Schasinglulu   this case. Please refer to section 6 "Using BL31 entrypoint as the reset
30*91f16700Schasinglulu   address" for more information.
31*91f16700Schasinglulu
32*91f16700SchasingluluProgrammable CPU reset address
33*91f16700Schasinglulu------------------------------
34*91f16700Schasinglulu
35*91f16700SchasingluluBy default, TF-A assumes that the CPU reset address is not programmable.
36*91f16700SchasingluluTherefore, all CPUs start at the same address (typically address 0) whenever
37*91f16700Schasingluluthey reset. Further logic is then required to identify whether it is a cold or
38*91f16700Schasingluluwarm boot to direct CPUs to the right execution path.
39*91f16700Schasinglulu
40*91f16700SchasingluluIf the reset vector address (reflected in the reset vector base address register
41*91f16700Schasinglulu``RVBAR_EL3``) is programmable then it is possible to make each CPU start directly
42*91f16700Schasingluluat the right address, both on a cold and warm reset. Therefore, the boot type
43*91f16700Schasingluludetection can be skipped, resulting in the following boot flow:
44*91f16700Schasinglulu
45*91f16700Schasinglulu|Reset code flow with programmable reset address|
46*91f16700Schasinglulu
47*91f16700SchasingluluTo enable this boot flow, compile TF-A with ``PROGRAMMABLE_RESET_ADDRESS=1``.
48*91f16700SchasingluluThis option only affects the TF-A reset image, which is BL1 by default or BL31 if
49*91f16700Schasinglulu``RESET_TO_BL31=1``.
50*91f16700Schasinglulu
51*91f16700SchasingluluOn both the FVP and Juno platforms, the reset vector address is not programmable
52*91f16700Schasingluluso both ports use ``PROGRAMMABLE_RESET_ADDRESS=0``.
53*91f16700Schasinglulu
54*91f16700SchasingluluCold boot on a single CPU
55*91f16700Schasinglulu-------------------------
56*91f16700Schasinglulu
57*91f16700SchasingluluBy default, TF-A assumes that several CPUs may be released out of reset.
58*91f16700SchasingluluTherefore, the cold boot code has to arbitrate access to hardware resources
59*91f16700Schasinglulushared amongst CPUs. This is done by nominating one of the CPUs as the primary,
60*91f16700Schasingluluwhich is responsible for initialising shared hardware and coordinating the boot
61*91f16700Schasingluluflow with the other CPUs.
62*91f16700Schasinglulu
63*91f16700SchasingluluIf the platform guarantees that only a single CPU will ever be brought up then
64*91f16700Schasingluluno arbitration is required. The notion of primary/secondary CPU itself no longer
65*91f16700Schasingluluapplies. This results in the following boot flow:
66*91f16700Schasinglulu
67*91f16700Schasinglulu|Reset code flow with single CPU released out of reset|
68*91f16700Schasinglulu
69*91f16700SchasingluluTo enable this boot flow, compile TF-A with ``COLD_BOOT_SINGLE_CPU=1``. This
70*91f16700Schasingluluoption only affects the TF-A reset image, which is BL1 by default or BL31 if
71*91f16700Schasinglulu``RESET_TO_BL31=1``.
72*91f16700Schasinglulu
73*91f16700SchasingluluOn both the FVP and Juno platforms, although only one core is powered up by
74*91f16700Schasingluludefault, there are platform-specific ways to release any number of cores out of
75*91f16700Schasinglulureset. Therefore, both platform ports use ``COLD_BOOT_SINGLE_CPU=0``.
76*91f16700Schasinglulu
77*91f16700SchasingluluProgrammable CPU reset address, Cold boot on a single CPU
78*91f16700Schasinglulu---------------------------------------------------------
79*91f16700Schasinglulu
80*91f16700SchasingluluIt is obviously possible to combine both optimisations on platforms that have
81*91f16700Schasinglulua programmable CPU reset address and which release a single CPU out of reset.
82*91f16700SchasingluluThis results in the following boot flow:
83*91f16700Schasinglulu
84*91f16700Schasinglulu
85*91f16700Schasinglulu|Reset code flow with programmable reset address and single CPU released out of reset|
86*91f16700Schasinglulu
87*91f16700SchasingluluTo enable this boot flow, compile TF-A with both ``COLD_BOOT_SINGLE_CPU=1``
88*91f16700Schasingluluand ``PROGRAMMABLE_RESET_ADDRESS=1``. These options only affect the TF-A reset
89*91f16700Schasingluluimage, which is BL1 by default or BL31 if ``RESET_TO_BL31=1``.
90*91f16700Schasinglulu
91*91f16700SchasingluluUsing BL31 entrypoint as the reset address
92*91f16700Schasinglulu------------------------------------------
93*91f16700Schasinglulu
94*91f16700SchasingluluOn some platforms the runtime firmware (BL3x images) for the application
95*91f16700Schasingluluprocessors are loaded by some firmware running on a secure system processor
96*91f16700Schasingluluon the SoC, rather than by BL1 and BL2 running on the primary application
97*91f16700Schasingluluprocessor. For this type of SoC it is desirable for the application processor
98*91f16700Schasingluluto always reset to BL31 which eliminates the need for BL1 and BL2.
99*91f16700Schasinglulu
100*91f16700SchasingluluTF-A provides a build-time option ``RESET_TO_BL31`` that includes some additional
101*91f16700Schasinglululogic in the BL31 entry point to support this use case.
102*91f16700Schasinglulu
103*91f16700SchasingluluIn this configuration, the platform's Trusted Boot Firmware must ensure that
104*91f16700SchasingluluBL31 is loaded to its runtime address, which must match the CPU's ``RVBAR_EL3``
105*91f16700Schasinglulureset vector base address, before the application processor is powered on.
106*91f16700SchasingluluAdditionally, platform software is responsible for loading the other BL3x images
107*91f16700Schasinglulurequired and providing entry point information for them to BL31. Loading these
108*91f16700Schasingluluimages might be done by the Trusted Boot Firmware or by platform code in BL31.
109*91f16700Schasinglulu
110*91f16700SchasingluluAlthough the Arm FVP platform does not support programming the reset base
111*91f16700Schasingluluaddress dynamically at run-time, it is possible to set the initial value of the
112*91f16700Schasinglulu``RVBAR_EL3`` register at start-up. This feature is provided on the Base FVP
113*91f16700Schasingluluonly.
114*91f16700Schasinglulu
115*91f16700SchasingluluIt allows the Arm FVP port to support the ``RESET_TO_BL31`` configuration, in
116*91f16700Schasingluluwhich case the ``bl31.bin`` image must be loaded to its run address in Trusted
117*91f16700SchasingluluSRAM and all CPU reset vectors be changed from the default ``0x0`` to this run
118*91f16700Schasingluluaddress. See the :ref:`Arm Fixed Virtual Platforms (FVP)` for details of running
119*91f16700Schasingluluthe FVP models in this way.
120*91f16700Schasinglulu
121*91f16700SchasingluluAlthough technically it would be possible to program the reset base address with
122*91f16700Schasingluluthe right support in the SCP firmware, this is currently not implemented so the
123*91f16700SchasingluluJuno port doesn't support the ``RESET_TO_BL31`` configuration.
124*91f16700Schasinglulu
125*91f16700SchasingluluThe ``RESET_TO_BL31`` configuration requires some additions and changes in the
126*91f16700SchasingluluBL31 functionality:
127*91f16700Schasinglulu
128*91f16700SchasingluluDetermination of boot path
129*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~
130*91f16700Schasinglulu
131*91f16700SchasingluluIn this configuration, BL31 uses the same reset framework and code as the one
132*91f16700Schasingluludescribed for BL1 above. Therefore, it is affected by the
133*91f16700Schasinglulu``PROGRAMMABLE_RESET_ADDRESS`` and ``COLD_BOOT_SINGLE_CPU`` build options in the
134*91f16700Schasinglulusame way.
135*91f16700Schasinglulu
136*91f16700SchasingluluIn the default, unoptimised BL31 reset flow, on a warm boot a CPU is directed
137*91f16700Schasingluluto the PSCI implementation via a platform defined mechanism. On a cold boot,
138*91f16700Schasingluluthe platform must place any secondary CPUs into a safe state while the primary
139*91f16700SchasingluluCPU executes a modified BL31 initialization, as described below.
140*91f16700Schasinglulu
141*91f16700SchasingluluPlatform initialization
142*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~
143*91f16700Schasinglulu
144*91f16700SchasingluluIn this configuration, since the CPU resets to BL31, no parameters are expected
145*91f16700Schasingluluto be passed to BL31 (see notes below for clarification).
146*91f16700SchasingluluInstead, the platform code in BL31 needs to know, or be able to determine, the
147*91f16700Schasinglululocation of the BL32 (if required) and BL33 images and provide this information
148*91f16700Schasingluluin response to the ``bl31_plat_get_next_image_ep_info()`` function.
149*91f16700Schasinglulu
150*91f16700SchasingluluAdditionally, platform software is responsible for carrying out any security
151*91f16700Schasingluluinitialisation, for example programming a TrustZone address space controller.
152*91f16700SchasingluluThis might be done by the Trusted Boot Firmware or by platform code in BL31.
153*91f16700Schasinglulu
154*91f16700Schasinglulu.. note::
155*91f16700Schasinglulu   Even though RESET_TO_BL31 is designed such that BL31 is the reset BL image,
156*91f16700Schasinglulu   some platforms may wish to pass some arguments to BL31 as per the defined
157*91f16700Schasinglulu   contract between BL31 and previous bootloaders. Previous bootloaders can
158*91f16700Schasinglulu   pass arguments through registers x0 through x3. BL31 will preserve them and
159*91f16700Schasinglulu   propagate them to platform code, which will handle these arguments in an
160*91f16700Schasinglulu   IMPDEF manner.
161*91f16700Schasinglulu
162*91f16700Schasinglulu--------------
163*91f16700Schasinglulu
164*91f16700Schasinglulu*Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.*
165*91f16700Schasinglulu
166*91f16700Schasinglulu.. |Default reset code flow| image:: ../resources/diagrams/default_reset_code.png
167*91f16700Schasinglulu.. |Reset code flow with programmable reset address| image:: ../resources/diagrams/reset_code_no_boot_type_check.png
168*91f16700Schasinglulu.. |Reset code flow with single CPU released out of reset| image:: ../resources/diagrams/reset_code_no_cpu_check.png
169*91f16700Schasinglulu.. |Reset code flow with programmable reset address and single CPU released out of reset| image:: ../resources/diagrams/reset_code_no_checks.png
170