xref: /aosp_15_r20/bootable/libbootloader/gbl/docs/efi_protocols.md (revision 5225e6b173e52d2efc6bcf950c27374fd72adabc)
1*5225e6b1SAndroid Build Coastguard Worker# GBL UEFI Protocols
2*5225e6b1SAndroid Build Coastguard Worker
3*5225e6b1SAndroid Build Coastguard WorkerThis document lists every UEFI protocol that GBL may potentially use, and
4*5225e6b1SAndroid Build Coastguard Workerdescribes the use case with any requirements.
5*5225e6b1SAndroid Build Coastguard Worker
6*5225e6b1SAndroid Build Coastguard Worker## Upstream Protocols
7*5225e6b1SAndroid Build Coastguard Worker
8*5225e6b1SAndroid Build Coastguard WorkerThese protocols are taken from an external source, typically the UEFI spec.
9*5225e6b1SAndroid Build Coastguard Worker
10*5225e6b1SAndroid Build Coastguard Worker### BlockIoProtocol
11*5225e6b1SAndroid Build Coastguard Worker
12*5225e6b1SAndroid Build Coastguard Worker* [`EFI_BLOCK_IO_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#efi-block-io-protocol)
13*5225e6b1SAndroid Build Coastguard Worker* required
14*5225e6b1SAndroid Build Coastguard Worker
15*5225e6b1SAndroid Build Coastguard WorkerUsed to read the GPT, load images from disk, and write data back to disk in
16*5225e6b1SAndroid Build Coastguard Workere.g. in fastboot.
17*5225e6b1SAndroid Build Coastguard Worker
18*5225e6b1SAndroid Build Coastguard WorkerThis is required even if the Block I/O 2 Protocol is provided, as some use cases
19*5225e6b1SAndroid Build Coastguard Workermight want to use this simpler API.
20*5225e6b1SAndroid Build Coastguard Worker
21*5225e6b1SAndroid Build Coastguard Worker### BlockIo2Protocol
22*5225e6b1SAndroid Build Coastguard Worker
23*5225e6b1SAndroid Build Coastguard Worker* [`EFI_BLOCK_IO2_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#block-i-o-2-protocol)
24*5225e6b1SAndroid Build Coastguard Worker* optional: enables performance optimizations
25*5225e6b1SAndroid Build Coastguard Worker
26*5225e6b1SAndroid Build Coastguard WorkerIf provided, GBL may use this protocol instead of the Block I/O Protocol as a
27*5225e6b1SAndroid Build Coastguard Workerperformance optimization; for example during fastboot flashing it may flash to
28*5225e6b1SAndroid Build Coastguard Workerdisk while concurrently receiving the next image over USB.
29*5225e6b1SAndroid Build Coastguard Worker
30*5225e6b1SAndroid Build Coastguard Worker### DevicePathProtocol
31*5225e6b1SAndroid Build Coastguard Worker
32*5225e6b1SAndroid Build Coastguard Worker* [`EFI_DEVICE_PATH_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/10_Protocols_Device_Path_Protocol.html#efi-device-path-protocol)
33*5225e6b1SAndroid Build Coastguard Worker* optional: enables logging the image path on GBL start
34*5225e6b1SAndroid Build Coastguard Worker
35*5225e6b1SAndroid Build Coastguard WorkerUsed for logging the GBL image path to the console on load. This can be useful
36*5225e6b1SAndroid Build Coastguard Workeras a "Hello world" proof-of-concept that GBL is running and can interact with
37*5225e6b1SAndroid Build Coastguard Workerthe UEFI protocols.
38*5225e6b1SAndroid Build Coastguard Worker
39*5225e6b1SAndroid Build Coastguard WorkerThis logging requires all three of:
40*5225e6b1SAndroid Build Coastguard Worker* Device Path Protocol
41*5225e6b1SAndroid Build Coastguard Worker* Device Path to Text Protocol
42*5225e6b1SAndroid Build Coastguard Worker* Loaded Image Protocol
43*5225e6b1SAndroid Build Coastguard Worker
44*5225e6b1SAndroid Build Coastguard Worker### DevicePathToTextProtocol
45*5225e6b1SAndroid Build Coastguard Worker
46*5225e6b1SAndroid Build Coastguard Worker* [`EFI_DEVICE_PATH_TO_TEXT_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/10_Protocols_Device_Path_Protocol.html#device-path-to-text-protocol)
47*5225e6b1SAndroid Build Coastguard Worker* optional: enables logging the image path on GBL start
48*5225e6b1SAndroid Build Coastguard Worker
49*5225e6b1SAndroid Build Coastguard WorkerUsed for logging the GBL image path to the console on load. This can be useful
50*5225e6b1SAndroid Build Coastguard Workeras a "Hello world" proof-of-concept that GBL is running and can interact with
51*5225e6b1SAndroid Build Coastguard Workerthe UEFI protocols.
52*5225e6b1SAndroid Build Coastguard Worker
53*5225e6b1SAndroid Build Coastguard WorkerThis logging requires all three of:
54*5225e6b1SAndroid Build Coastguard Worker* Device Path Protocol
55*5225e6b1SAndroid Build Coastguard Worker* Device Path to Text Protocol
56*5225e6b1SAndroid Build Coastguard Worker* Loaded Image Protocol
57*5225e6b1SAndroid Build Coastguard Worker
58*5225e6b1SAndroid Build Coastguard Worker### LoadedImageProtocol
59*5225e6b1SAndroid Build Coastguard Worker
60*5225e6b1SAndroid Build Coastguard Worker* [`EFI_LOADED_IMAGE_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/09_Protocols_EFI_Loaded_Image.html#efi-loaded-image-protocol)
61*5225e6b1SAndroid Build Coastguard Worker* optional: enables logging the image path on GBL start
62*5225e6b1SAndroid Build Coastguard Worker
63*5225e6b1SAndroid Build Coastguard WorkerUsed for logging the GBL image path to the console on load. This can be useful
64*5225e6b1SAndroid Build Coastguard Workeras a "Hello world" proof-of-concept that GBL is running and can interact with
65*5225e6b1SAndroid Build Coastguard Workerthe UEFI protocols.
66*5225e6b1SAndroid Build Coastguard Worker
67*5225e6b1SAndroid Build Coastguard WorkerThis logging requires all three of:
68*5225e6b1SAndroid Build Coastguard Worker* Device Path Protocol
69*5225e6b1SAndroid Build Coastguard Worker* Device Path to Text Protocol
70*5225e6b1SAndroid Build Coastguard Worker* Loaded Image Protocol
71*5225e6b1SAndroid Build Coastguard Worker
72*5225e6b1SAndroid Build Coastguard Worker### Memory Allocation Services
73*5225e6b1SAndroid Build Coastguard Worker
74*5225e6b1SAndroid Build Coastguard Worker* [Memory allocation services](https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html#memory-allocation-services)
75*5225e6b1SAndroid Build Coastguard Worker* all required
76*5225e6b1SAndroid Build Coastguard Worker
77*5225e6b1SAndroid Build Coastguard WorkerUsed by libavb for image verification.
78*5225e6b1SAndroid Build Coastguard Worker
79*5225e6b1SAndroid Build Coastguard WorkerDynamic memory allocation can be minimized, but not completely eliminated, by
80*5225e6b1SAndroid Build Coastguard Workerproviding preallocated image buffers via the GBL Image Loading Protocol.
81*5225e6b1SAndroid Build Coastguard Worker
82*5225e6b1SAndroid Build Coastguard Worker### RiscvBootProtocol
83*5225e6b1SAndroid Build Coastguard Worker
84*5225e6b1SAndroid Build Coastguard Worker* [`RISCV_EFI_BOOT_PROTOCOL`](https://github.com/riscv-non-isa/riscv-uefi/blob/main/boot_protocol.adoc)
85*5225e6b1SAndroid Build Coastguard Worker* required for RISC-V targets
86*5225e6b1SAndroid Build Coastguard Worker
87*5225e6b1SAndroid Build Coastguard WorkerUsed to query the boot hart ID which is required to pass to the kernel.
88*5225e6b1SAndroid Build Coastguard Worker
89*5225e6b1SAndroid Build Coastguard Worker### SimpleNetworkProtocol
90*5225e6b1SAndroid Build Coastguard Worker
91*5225e6b1SAndroid Build Coastguard Worker* [`EFI_SIMPLE_NETWORK_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/24_Network_Protocols_SNP_PXE_BIS.html#simple-network-protocol)
92*5225e6b1SAndroid Build Coastguard Worker* optional: enables fastboot over TCP
93*5225e6b1SAndroid Build Coastguard Worker
94*5225e6b1SAndroid Build Coastguard WorkerUsed to provide fastboot over TCP. This can be enabled by itself, or in
95*5225e6b1SAndroid Build Coastguard Workeraddition to fastboot over USB.
96*5225e6b1SAndroid Build Coastguard Worker
97*5225e6b1SAndroid Build Coastguard WorkerCurrently if this protocol is available GBL will always start fastboot over TCP,
98*5225e6b1SAndroid Build Coastguard Workerbut in the future this functionality will be restricted to dev builds only.
99*5225e6b1SAndroid Build Coastguard WorkerProduction devices should not expose fastboot over TCP.
100*5225e6b1SAndroid Build Coastguard Worker
101*5225e6b1SAndroid Build Coastguard WorkerGBL only uses the Simple Network Protocol, and will not use higher-level
102*5225e6b1SAndroid Build Coastguard Workerprotocols such as the TCP4/6 Protocols even if they are available.
103*5225e6b1SAndroid Build Coastguard Worker
104*5225e6b1SAndroid Build Coastguard Worker### SimpleTextInputProtocol
105*5225e6b1SAndroid Build Coastguard Worker
106*5225e6b1SAndroid Build Coastguard Worker* [`EFI_SIMPLE_TEXT_INPUT_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/12_Protocols_Console_Support.html#simple-text-input-protocol)
107*5225e6b1SAndroid Build Coastguard Worker* optional: enables the 'f' key to enter fastboot
108*5225e6b1SAndroid Build Coastguard Worker
109*5225e6b1SAndroid Build Coastguard WorkerThis is currently used to look for the 'f' key on the serial line during boot,
110*5225e6b1SAndroid Build Coastguard Workerwhich will trigger GBL to enter fastboot mode. If not provided, GBL will skip
111*5225e6b1SAndroid Build Coastguard Workerthis check.
112*5225e6b1SAndroid Build Coastguard Worker
113*5225e6b1SAndroid Build Coastguard WorkerWe plan to remove this and instead use a more general protocol to allow devices
114*5225e6b1SAndroid Build Coastguard Workerto specify their own custom fastboot triggers.
115*5225e6b1SAndroid Build Coastguard Worker
116*5225e6b1SAndroid Build Coastguard Worker### SimpleTextOutputProtocol
117*5225e6b1SAndroid Build Coastguard Worker
118*5225e6b1SAndroid Build Coastguard Worker* [`EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/12_Protocols_Console_Support.html#simple-text-output-protocol)
119*5225e6b1SAndroid Build Coastguard Worker* required, but can be no-op
120*5225e6b1SAndroid Build Coastguard Worker
121*5225e6b1SAndroid Build Coastguard WorkerUsed for logging and debugging. Implementations must provide this protocol, but
122*5225e6b1SAndroid Build Coastguard Workerthe functions may be no-ops.
123*5225e6b1SAndroid Build Coastguard Worker
124*5225e6b1SAndroid Build Coastguard Worker## Community Protocols
125*5225e6b1SAndroid Build Coastguard Worker
126*5225e6b1SAndroid Build Coastguard WorkerProtocols defined by a community and used across the ecosystem, but not officially
127*5225e6b1SAndroid Build Coastguard Workerpart of the UEFI specification. None of these protocols are required.
128*5225e6b1SAndroid Build Coastguard Worker
129*5225e6b1SAndroid Build Coastguard Worker### DtFixupProtocol
130*5225e6b1SAndroid Build Coastguard Worker
131*5225e6b1SAndroid Build Coastguard Worker* original [proposal](https://github.com/U-Boot-EFI/EFI_DT_FIXUP_PROTOCOL)
132*5225e6b1SAndroid Build Coastguard Worker* [upstream](https://github.com/u-boot/u-boot/blob/master/include/efi_dt_fixup.h)
133*5225e6b1SAndroid Build Coastguard Worker* optional: allows FW to modify the final device tree
134*5225e6b1SAndroid Build Coastguard Worker
135*5225e6b1SAndroid Build Coastguard WorkerThis protocol allows the firmware (FW) to inspect the final device tree and apply
136*5225e6b1SAndroid Build Coastguard Workernecessary fixups.
137*5225e6b1SAndroid Build Coastguard Worker
138*5225e6b1SAndroid Build Coastguard WorkerGBL will validate the applied changes and prevent booting if any of the security
139*5225e6b1SAndroid Build Coastguard Workerlimitations (listed below) are violated. Any errors will be reported through the
140*5225e6b1SAndroid Build Coastguard WorkerUEFI log.
141*5225e6b1SAndroid Build Coastguard Worker
142*5225e6b1SAndroid Build Coastguard WorkerTODO (b/353272981): Add limitations
143*5225e6b1SAndroid Build Coastguard Worker
144*5225e6b1SAndroid Build Coastguard WorkerThis protocol was proposed by U-Boot and is currently used by the Kernel UEFI stub.
145*5225e6b1SAndroid Build Coastguard Worker
146*5225e6b1SAndroid Build Coastguard Worker## GBL Custom Protocols
147*5225e6b1SAndroid Build Coastguard Worker
148*5225e6b1SAndroid Build Coastguard WorkerThese protocols are defined by GBL to provide specific functionality that is
149*5225e6b1SAndroid Build Coastguard Workernot available elsewhere.
150*5225e6b1SAndroid Build Coastguard Worker
151*5225e6b1SAndroid Build Coastguard WorkerMajority of these custom protocols aren't required, with the intention that dev
152*5225e6b1SAndroid Build Coastguard Workerboards that support a typical set of UEFI protocols should be able to use GBL
153*5225e6b1SAndroid Build Coastguard Workerwith a minimal firmware modifications and still get some basic booting functionality.
154*5225e6b1SAndroid Build Coastguard Worker
155*5225e6b1SAndroid Build Coastguard WorkerHowever, without these protocols GBL will be missing key features such as
156*5225e6b1SAndroid Build Coastguard WorkerUSB fastboot and verified boot, so production targets and more full-featured dev
157*5225e6b1SAndroid Build Coastguard Workerboards will need to implement them.
158*5225e6b1SAndroid Build Coastguard Worker
159*5225e6b1SAndroid Build Coastguard Worker### GblFastbootProtocol
160*5225e6b1SAndroid Build Coastguard Worker
161*5225e6b1SAndroid Build Coastguard Worker* [`GBL_EFI_FASTBOOT_PROTOCOL`](./gbl_efi_fastboot_protocol.md)
162*5225e6b1SAndroid Build Coastguard Worker* optional: enables custom fastboot functionality.
163*5225e6b1SAndroid Build Coastguard Worker
164*5225e6b1SAndroid Build Coastguard WorkerUsed to provide an interface for
165*5225e6b1SAndroid Build Coastguard Worker* Custom variables
166*5225e6b1SAndroid Build Coastguard Worker* OEM commands
167*5225e6b1SAndroid Build Coastguard Worker* Device lock/unlock controls
168*5225e6b1SAndroid Build Coastguard Worker* Lock-contingent partition permission information
169*5225e6b1SAndroid Build Coastguard Worker* User data erasure
170*5225e6b1SAndroid Build Coastguard Worker
171*5225e6b1SAndroid Build Coastguard Worker### GblFastbootUsbProtocol
172*5225e6b1SAndroid Build Coastguard Worker
173*5225e6b1SAndroid Build Coastguard Worker* [`GBL_EFI_FASTBOOT_USB_PROTOCOL`](./GBL_EFI_FASTBOOT_USB_PROTOCOL.md)
174*5225e6b1SAndroid Build Coastguard Worker* optional: enables fastboot over USB
175*5225e6b1SAndroid Build Coastguard Worker
176*5225e6b1SAndroid Build Coastguard WorkerUsed to provide fastboot over USB. This can be enabled by itself, or in
177*5225e6b1SAndroid Build Coastguard Workeraddition to fastboot over TCP.
178*5225e6b1SAndroid Build Coastguard Worker
179*5225e6b1SAndroid Build Coastguard Worker### GblOsConfigurationProtocol
180*5225e6b1SAndroid Build Coastguard Worker
181*5225e6b1SAndroid Build Coastguard Worker* [`GBL_EFI_OS_CONFIGURATION_PROTOCOL`](./gbl_os_configuration_protocol.md)
182*5225e6b1SAndroid Build Coastguard Worker* optional: enables runtime fixups of OS data
183*5225e6b1SAndroid Build Coastguard Worker
184*5225e6b1SAndroid Build Coastguard WorkerUsed for runtime fixups of data provided to the OS such as command line and
185*5225e6b1SAndroid Build Coastguard Workerdevice tree. If not provided, the data in the OS images loaded from disk will
186*5225e6b1SAndroid Build Coastguard Workerbe used without modification.
187*5225e6b1SAndroid Build Coastguard Worker
188*5225e6b1SAndroid Build Coastguard Worker### GblSlotProtocol
189*5225e6b1SAndroid Build Coastguard Worker
190*5225e6b1SAndroid Build Coastguard Worker* TODO(b/359946695): link documentation
191*5225e6b1SAndroid Build Coastguard Worker* optional: enables A/B slotted booting
192*5225e6b1SAndroid Build Coastguard Worker
193*5225e6b1SAndroid Build Coastguard WorkerUsed to read and write A/B slot metadata. If not provided, GBL will
194*5225e6b1SAndroid Build Coastguard Workerload from either the `_a` slot or a slotless boot partition.
195*5225e6b1SAndroid Build Coastguard Worker
196*5225e6b1SAndroid Build Coastguard WorkerAll components that interact with A/B slot metadata must use the same format.
197*5225e6b1SAndroid Build Coastguard WorkerTypically these components are:
198*5225e6b1SAndroid Build Coastguard Worker
199*5225e6b1SAndroid Build Coastguard Worker1. The UEFI firmware selecting which GBL slot to load
200*5225e6b1SAndroid Build Coastguard Worker2. GBL selecting which OS slot to load
201*5225e6b1SAndroid Build Coastguard Worker3. The OS update engine updating the metadata when a new version is downloaded
202*5225e6b1SAndroid Build Coastguard Worker
203*5225e6b1SAndroid Build Coastguard WorkerThis protocol allows the device to implement its own A/B metadata format while
204*5225e6b1SAndroid Build Coastguard Workerstill allowing GBL to implement the boot flow logic.
205*5225e6b1SAndroid Build Coastguard Worker
206*5225e6b1SAndroid Build Coastguard Worker### GblImageLoadingProtocol
207*5225e6b1SAndroid Build Coastguard Worker
208*5225e6b1SAndroid Build Coastguard Worker* TODO(b/359946775): link documentation
209*5225e6b1SAndroid Build Coastguard Worker* optional: enables loading images to predefined memory locations
210*5225e6b1SAndroid Build Coastguard Worker
211*5225e6b1SAndroid Build Coastguard WorkerUsed to provide buffers to load the images for verification and boot process.
212*5225e6b1SAndroid Build Coastguard Worker
213*5225e6b1SAndroid Build Coastguard WorkerIn addition this protocol provides a list of additional custom partitions to be
214*5225e6b1SAndroid Build Coastguard Workerverified before booting, for boards that want to verify data in addition to the
215*5225e6b1SAndroid Build Coastguard Workerstandard boot partitions.
216*5225e6b1SAndroid Build Coastguard Worker
217*5225e6b1SAndroid Build Coastguard Worker### GblAvbProtocol
218*5225e6b1SAndroid Build Coastguard Worker
219*5225e6b1SAndroid Build Coastguard Worker* [`GBL_EFI_AVB_PROTOCOL`](./gbl_avb_protocol.md)
220*5225e6b1SAndroid Build Coastguard Worker* required for production devices: enables AVB-related firmware callbacks.
221*5225e6b1SAndroid Build Coastguard Worker
222*5225e6b1SAndroid Build Coastguard WorkerThis protocol delegates some of AVB-related logic to the firmware, including
223*5225e6b1SAndroid Build Coastguard Workertasks such as verifying public keys, handling verification results, and
224*5225e6b1SAndroid Build Coastguard Workermanaging the device’s secure state (e.g., ROT, lock state, rollback indexes,
225*5225e6b1SAndroid Build Coastguard Workeretc.).
226