xref: /aosp_15_r20/external/arm-trusted-firmware/docs/design/reset-design.rst (revision 54fd6939e177f8ff529b10183254802c76df6d08)
1*54fd6939SJiyong ParkCPU Reset
2*54fd6939SJiyong Park=========
3*54fd6939SJiyong Park
4*54fd6939SJiyong ParkThis document describes the high-level design of the framework to handle CPU
5*54fd6939SJiyong Parkresets in Trusted Firmware-A (TF-A). It also describes how the platform
6*54fd6939SJiyong Parkintegrator can tailor this code to the system configuration to some extent,
7*54fd6939SJiyong Parkresulting in a simplified and more optimised boot flow.
8*54fd6939SJiyong Park
9*54fd6939SJiyong ParkThis document should be used in conjunction with the :ref:`Firmware Design`
10*54fd6939SJiyong Parkdocument which provides greater implementation details around the reset code,
11*54fd6939SJiyong Parkspecifically for the cold boot path.
12*54fd6939SJiyong Park
13*54fd6939SJiyong ParkGeneral reset code flow
14*54fd6939SJiyong Park-----------------------
15*54fd6939SJiyong Park
16*54fd6939SJiyong ParkThe TF-A reset code is implemented in BL1 by default. The following high-level
17*54fd6939SJiyong Parkdiagram illustrates this:
18*54fd6939SJiyong Park
19*54fd6939SJiyong Park|Default reset code flow|
20*54fd6939SJiyong Park
21*54fd6939SJiyong ParkThis diagram shows the default, unoptimised reset flow. Depending on the system
22*54fd6939SJiyong Parkconfiguration, some of these steps might be unnecessary. The following sections
23*54fd6939SJiyong Parkguide the platform integrator by indicating which build options exclude which
24*54fd6939SJiyong Parksteps, depending on the capability of the platform.
25*54fd6939SJiyong Park
26*54fd6939SJiyong Park.. note::
27*54fd6939SJiyong Park   If BL31 is used as the TF-A entry point instead of BL1, the diagram
28*54fd6939SJiyong Park   above is still relevant, as all these operations will occur in BL31 in
29*54fd6939SJiyong Park   this case. Please refer to section 6 "Using BL31 entrypoint as the reset
30*54fd6939SJiyong Park   address" for more information.
31*54fd6939SJiyong Park
32*54fd6939SJiyong ParkProgrammable CPU reset address
33*54fd6939SJiyong Park------------------------------
34*54fd6939SJiyong Park
35*54fd6939SJiyong ParkBy default, TF-A assumes that the CPU reset address is not programmable.
36*54fd6939SJiyong ParkTherefore, all CPUs start at the same address (typically address 0) whenever
37*54fd6939SJiyong Parkthey reset. Further logic is then required to identify whether it is a cold or
38*54fd6939SJiyong Parkwarm boot to direct CPUs to the right execution path.
39*54fd6939SJiyong Park
40*54fd6939SJiyong ParkIf the reset vector address (reflected in the reset vector base address register
41*54fd6939SJiyong Park``RVBAR_EL3``) is programmable then it is possible to make each CPU start directly
42*54fd6939SJiyong Parkat the right address, both on a cold and warm reset. Therefore, the boot type
43*54fd6939SJiyong Parkdetection can be skipped, resulting in the following boot flow:
44*54fd6939SJiyong Park
45*54fd6939SJiyong Park|Reset code flow with programmable reset address|
46*54fd6939SJiyong Park
47*54fd6939SJiyong ParkTo enable this boot flow, compile TF-A with ``PROGRAMMABLE_RESET_ADDRESS=1``.
48*54fd6939SJiyong ParkThis option only affects the TF-A reset image, which is BL1 by default or BL31 if
49*54fd6939SJiyong Park``RESET_TO_BL31=1``.
50*54fd6939SJiyong Park
51*54fd6939SJiyong ParkOn both the FVP and Juno platforms, the reset vector address is not programmable
52*54fd6939SJiyong Parkso both ports use ``PROGRAMMABLE_RESET_ADDRESS=0``.
53*54fd6939SJiyong Park
54*54fd6939SJiyong ParkCold boot on a single CPU
55*54fd6939SJiyong Park-------------------------
56*54fd6939SJiyong Park
57*54fd6939SJiyong ParkBy default, TF-A assumes that several CPUs may be released out of reset.
58*54fd6939SJiyong ParkTherefore, the cold boot code has to arbitrate access to hardware resources
59*54fd6939SJiyong Parkshared amongst CPUs. This is done by nominating one of the CPUs as the primary,
60*54fd6939SJiyong Parkwhich is responsible for initialising shared hardware and coordinating the boot
61*54fd6939SJiyong Parkflow with the other CPUs.
62*54fd6939SJiyong Park
63*54fd6939SJiyong ParkIf the platform guarantees that only a single CPU will ever be brought up then
64*54fd6939SJiyong Parkno arbitration is required. The notion of primary/secondary CPU itself no longer
65*54fd6939SJiyong Parkapplies. This results in the following boot flow:
66*54fd6939SJiyong Park
67*54fd6939SJiyong Park|Reset code flow with single CPU released out of reset|
68*54fd6939SJiyong Park
69*54fd6939SJiyong ParkTo enable this boot flow, compile TF-A with ``COLD_BOOT_SINGLE_CPU=1``. This
70*54fd6939SJiyong Parkoption only affects the TF-A reset image, which is BL1 by default or BL31 if
71*54fd6939SJiyong Park``RESET_TO_BL31=1``.
72*54fd6939SJiyong Park
73*54fd6939SJiyong ParkOn both the FVP and Juno platforms, although only one core is powered up by
74*54fd6939SJiyong Parkdefault, there are platform-specific ways to release any number of cores out of
75*54fd6939SJiyong Parkreset. Therefore, both platform ports use ``COLD_BOOT_SINGLE_CPU=0``.
76*54fd6939SJiyong Park
77*54fd6939SJiyong ParkProgrammable CPU reset address, Cold boot on a single CPU
78*54fd6939SJiyong Park---------------------------------------------------------
79*54fd6939SJiyong Park
80*54fd6939SJiyong ParkIt is obviously possible to combine both optimisations on platforms that have
81*54fd6939SJiyong Parka programmable CPU reset address and which release a single CPU out of reset.
82*54fd6939SJiyong ParkThis results in the following boot flow:
83*54fd6939SJiyong Park
84*54fd6939SJiyong Park
85*54fd6939SJiyong Park|Reset code flow with programmable reset address and single CPU released out of reset|
86*54fd6939SJiyong Park
87*54fd6939SJiyong ParkTo enable this boot flow, compile TF-A with both ``COLD_BOOT_SINGLE_CPU=1``
88*54fd6939SJiyong Parkand ``PROGRAMMABLE_RESET_ADDRESS=1``. These options only affect the TF-A reset
89*54fd6939SJiyong Parkimage, which is BL1 by default or BL31 if ``RESET_TO_BL31=1``.
90*54fd6939SJiyong Park
91*54fd6939SJiyong ParkUsing BL31 entrypoint as the reset address
92*54fd6939SJiyong Park------------------------------------------
93*54fd6939SJiyong Park
94*54fd6939SJiyong ParkOn some platforms the runtime firmware (BL3x images) for the application
95*54fd6939SJiyong Parkprocessors are loaded by some firmware running on a secure system processor
96*54fd6939SJiyong Parkon the SoC, rather than by BL1 and BL2 running on the primary application
97*54fd6939SJiyong Parkprocessor. For this type of SoC it is desirable for the application processor
98*54fd6939SJiyong Parkto always reset to BL31 which eliminates the need for BL1 and BL2.
99*54fd6939SJiyong Park
100*54fd6939SJiyong ParkTF-A provides a build-time option ``RESET_TO_BL31`` that includes some additional
101*54fd6939SJiyong Parklogic in the BL31 entry point to support this use case.
102*54fd6939SJiyong Park
103*54fd6939SJiyong ParkIn this configuration, the platform's Trusted Boot Firmware must ensure that
104*54fd6939SJiyong ParkBL31 is loaded to its runtime address, which must match the CPU's ``RVBAR_EL3``
105*54fd6939SJiyong Parkreset vector base address, before the application processor is powered on.
106*54fd6939SJiyong ParkAdditionally, platform software is responsible for loading the other BL3x images
107*54fd6939SJiyong Parkrequired and providing entry point information for them to BL31. Loading these
108*54fd6939SJiyong Parkimages might be done by the Trusted Boot Firmware or by platform code in BL31.
109*54fd6939SJiyong Park
110*54fd6939SJiyong ParkAlthough the Arm FVP platform does not support programming the reset base
111*54fd6939SJiyong Parkaddress dynamically at run-time, it is possible to set the initial value of the
112*54fd6939SJiyong Park``RVBAR_EL3`` register at start-up. This feature is provided on the Base FVP
113*54fd6939SJiyong Parkonly.
114*54fd6939SJiyong Park
115*54fd6939SJiyong ParkIt allows the Arm FVP port to support the ``RESET_TO_BL31`` configuration, in
116*54fd6939SJiyong Parkwhich case the ``bl31.bin`` image must be loaded to its run address in Trusted
117*54fd6939SJiyong ParkSRAM and all CPU reset vectors be changed from the default ``0x0`` to this run
118*54fd6939SJiyong Parkaddress. See the :ref:`Arm Fixed Virtual Platforms (FVP)` for details of running
119*54fd6939SJiyong Parkthe FVP models in this way.
120*54fd6939SJiyong Park
121*54fd6939SJiyong ParkAlthough technically it would be possible to program the reset base address with
122*54fd6939SJiyong Parkthe right support in the SCP firmware, this is currently not implemented so the
123*54fd6939SJiyong ParkJuno port doesn't support the ``RESET_TO_BL31`` configuration.
124*54fd6939SJiyong Park
125*54fd6939SJiyong ParkThe ``RESET_TO_BL31`` configuration requires some additions and changes in the
126*54fd6939SJiyong ParkBL31 functionality:
127*54fd6939SJiyong Park
128*54fd6939SJiyong ParkDetermination of boot path
129*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~~~~~~~~
130*54fd6939SJiyong Park
131*54fd6939SJiyong ParkIn this configuration, BL31 uses the same reset framework and code as the one
132*54fd6939SJiyong Parkdescribed for BL1 above. Therefore, it is affected by the
133*54fd6939SJiyong Park``PROGRAMMABLE_RESET_ADDRESS`` and ``COLD_BOOT_SINGLE_CPU`` build options in the
134*54fd6939SJiyong Parksame way.
135*54fd6939SJiyong Park
136*54fd6939SJiyong ParkIn the default, unoptimised BL31 reset flow, on a warm boot a CPU is directed
137*54fd6939SJiyong Parkto the PSCI implementation via a platform defined mechanism. On a cold boot,
138*54fd6939SJiyong Parkthe platform must place any secondary CPUs into a safe state while the primary
139*54fd6939SJiyong ParkCPU executes a modified BL31 initialization, as described below.
140*54fd6939SJiyong Park
141*54fd6939SJiyong ParkPlatform initialization
142*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~~~~~
143*54fd6939SJiyong Park
144*54fd6939SJiyong ParkIn this configuration, when the CPU resets to BL31 there are no parameters that
145*54fd6939SJiyong Parkcan be passed in registers by previous boot stages. Instead, the platform code
146*54fd6939SJiyong Parkin BL31 needs to know, or be able to determine, the location of the BL32 (if
147*54fd6939SJiyong Parkrequired) and BL33 images and provide this information in response to the
148*54fd6939SJiyong Park``bl31_plat_get_next_image_ep_info()`` function.
149*54fd6939SJiyong Park
150*54fd6939SJiyong ParkAdditionally, platform software is responsible for carrying out any security
151*54fd6939SJiyong Parkinitialisation, for example programming a TrustZone address space controller.
152*54fd6939SJiyong ParkThis might be done by the Trusted Boot Firmware or by platform code in BL31.
153*54fd6939SJiyong Park
154*54fd6939SJiyong Park--------------
155*54fd6939SJiyong Park
156*54fd6939SJiyong Park*Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.*
157*54fd6939SJiyong Park
158*54fd6939SJiyong Park.. |Default reset code flow| image:: ../resources/diagrams/default_reset_code.png
159*54fd6939SJiyong Park.. |Reset code flow with programmable reset address| image:: ../resources/diagrams/reset_code_no_boot_type_check.png
160*54fd6939SJiyong Park.. |Reset code flow with single CPU released out of reset| image:: ../resources/diagrams/reset_code_no_cpu_check.png
161*54fd6939SJiyong Park.. |Reset code flow with programmable reset address and single CPU released out of reset| image:: ../resources/diagrams/reset_code_no_checks.png
162