blob: 03d6fd0c6aa8c2670222d063d84cd7d7206450bf [file] [log] [blame]
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +02001.. SPDX-License-Identifier: GPL-2.0+
2.. Copyright (c) 2018 Heinrich Schuchardt
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +01003
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +02004UEFI on U-Boot
5==============
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +01006
7The Unified Extensible Firmware Interface Specification (UEFI) [1] has become
8the default for booting on AArch64 and x86 systems. It provides a stable API for
9the interaction of drivers and applications with the firmware. The API comprises
10access to block storage, network, and console to name a few. The Linux kernel
11and boot loaders like GRUB or the FreeBSD loader can be executed.
12
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020013Development target
14------------------
Heinrich Schuchardta28d0732019-03-28 08:09:16 +010015
Heinrich Schuchardt9ec8f5e2019-04-10 08:04:38 +020016The implementation of UEFI in U-Boot strives to reach the requirements described
17in the "Embedded Base Boot Requirements (EBBR) Specification - Release v1.0"
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020018[2]. The "Server Base Boot Requirements System Software on ARM Platforms" [3]
Heinrich Schuchardt9ec8f5e2019-04-10 08:04:38 +020019describes a superset of the EBBR specification and may be used as further
20reference.
Heinrich Schuchardta28d0732019-03-28 08:09:16 +010021
22A full blown UEFI implementation would contradict the U-Boot design principle
23"keep it small".
24
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020025Building U-Boot for UEFI
26------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010027
Heinrich Schuchardt10288402018-12-30 12:54:36 +010028The UEFI standard supports only little-endian systems. The UEFI support can be
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020029activated for ARM and x86 by specifying::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010030
31 CONFIG_CMD_BOOTEFI=y
32 CONFIG_EFI_LOADER=y
33
34in the .config file.
35
36Support for attaching virtual block devices, e.g. iSCSI drives connected by the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020037loaded UEFI application [4], requires::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010038
39 CONFIG_BLK=y
40 CONFIG_PARTITIONS=y
41
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020042Executing a UEFI binary
43~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010044
45The bootefi command is used to start UEFI applications or to install UEFI
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020046drivers. It takes two parameters::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010047
48 bootefi <image address> [fdt address]
49
50* image address - the memory address of the UEFI binary
51* fdt address - the memory address of the flattened device tree
52
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020053Below you find the output of an example session starting GRUB::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010054
55 => load mmc 0:2 ${fdt_addr_r} boot/dtb
56 29830 bytes read in 14 ms (2 MiB/s)
57 => load mmc 0:1 ${kernel_addr_r} efi/debian/grubaa64.efi
58 reading efi/debian/grubaa64.efi
59 120832 bytes read in 7 ms (16.5 MiB/s)
60 => bootefi ${kernel_addr_r} ${fdt_addr_r}
61
62The environment variable 'bootargs' is passed as load options in the UEFI system
63table. The Linux kernel EFI stub uses the load options as command line
64arguments.
65
Cristian Ciocaltea62bb8902019-12-24 18:05:41 +020066Launching a UEFI binary from a FIT image
67~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
69A signed FIT image can be used to securely boot a UEFI image via the
70bootm command. This feature is available if U-Boot is configured with::
71
72 CONFIG_BOOTM_EFI=y
73
74A sample configuration is provided as file doc/uImage.FIT/uefi.its.
75
76Below you find the output of an example session starting GRUB::
77
78 => load mmc 0:1 ${kernel_addr_r} image.fit
79 4620426 bytes read in 83 ms (53.1 MiB/s)
80 => bootm ${kernel_addr_r}#config-grub-nofdt
81 ## Loading kernel from FIT Image at 40400000 ...
82 Using 'config-grub-nofdt' configuration
83 Verifying Hash Integrity ... sha256,rsa2048:dev+ OK
84 Trying 'efi-grub' kernel subimage
85 Description: GRUB EFI Firmware
86 Created: 2019-11-20 8:18:16 UTC
87 Type: Kernel Image (no loading done)
88 Compression: uncompressed
89 Data Start: 0x404000d0
90 Data Size: 450560 Bytes = 440 KiB
91 Hash algo: sha256
92 Hash value: 4dbee00021112df618f58b3f7cf5e1595533d543094064b9ce991e8b054a9eec
93 Verifying Hash Integrity ... sha256+ OK
94 XIP Kernel Image (no loading done)
95 ## Transferring control to EFI (at address 404000d0) ...
96 Welcome to GRUB!
97
98See doc/uImage.FIT/howto.txt for an introduction to FIT images.
99
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900100Configuring UEFI secure boot
101~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200103The UEFI specification[1] defines a secure way of executing UEFI images
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900104by verifying a signature (or message digest) of image with certificates.
105This feature on U-Boot is enabled with::
106
107 CONFIG_UEFI_SECURE_BOOT=y
108
109To make the boot sequence safe, you need to establish a chain of trust;
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200110In UEFI secure boot the chain trust is defined by the following UEFI variables
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900111
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200112* PK - Platform Key
113* KEK - Key Exchange Keys
114* db - white list database
115* dbx - black list database
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900116
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200117An in depth description of UEFI secure boot is beyond the scope of this
118document. Please, refer to the UEFI specification and available online
119documentation. Here is a simple example that you can follow for your initial
120attempt (Please note that the actual steps will depend on your system and
121environment.):
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900122
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200123Install the required tools on your host
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900124
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200125* openssl
126* efitools
127* sbsigntool
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900128
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200129Create signing keys and the key database on your host:
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900130
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200131The platform key
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900132
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200133.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900134
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200135 openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_PK/ \
136 -keyout PK.key -out PK.crt -nodes -days 365
137 cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
138 PK.crt PK.esl;
139 sign-efi-sig-list -c PK.crt -k PK.key PK PK.esl PK.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900140
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200141The key exchange keys
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900142
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200143.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900144
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200145 openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_KEK/ \
146 -keyout KEK.key -out KEK.crt -nodes -days 365
147 cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
148 KEK.crt KEK.esl
149 sign-efi-sig-list -c PK.crt -k PK.key KEK KEK.esl KEK.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900150
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200151The whitelist database
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900152
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200153.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900154
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200155 $ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_db/ \
156 -keyout db.key -out db.crt -nodes -days 365
157 $ cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
158 db.crt db.esl
159 $ sign-efi-sig-list -c KEK.crt -k KEK.key db db.esl db.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900160
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200161Copy the \*.auth files to media, say mmc, that is accessible from U-Boot.
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900162
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200163Sign an image with one of the keys in "db" on your host
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900164
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200165.. code-block:: bash
166
167 sbsign --key db.key --cert db.crt helloworld.efi
168
169Now in U-Boot install the keys on your board::
170
171 fatload mmc 0:1 <tmpaddr> PK.auth
172 setenv -e -nv -bs -rt -at -i <tmpaddr>,$filesize PK
173 fatload mmc 0:1 <tmpaddr> KEK.auth
174 setenv -e -nv -bs -rt -at -i <tmpaddr>,$filesize KEK
175 fatload mmc 0:1 <tmpaddr> db.auth
176 setenv -e -nv -bs -rt -at -i <tmpaddr>,$filesize db
177
178Set up boot parameters on your board::
179
180 efidebug boot add 1 HELLO mmc 0:1 /helloworld.efi.signed ""
181
182Now your board can run the signed image via the boot manager (see below).
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900183You can also try this sequence by running Pytest, test_efi_secboot,
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200184on the sandbox
185
186.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900187
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200188 cd <U-Boot source directory>
189 pytest.py test/py/tests/test_efi_secboot/test_signed.py --bd sandbox
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900190
Ilias Apalodimasef8bd412020-05-17 22:25:47 +0300191Using OP-TEE for EFI variables
192~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193
194Instead of implementing UEFI variable services inside U-Boot they can
195also be provided in the secure world by a module for OP-TEE[1]. The
196interface between U-Boot and OP-TEE for variable services is enabled by
197CONFIG_EFI_MM_COMM_TEE=y.
198
199Tianocore EDK II's standalone management mode driver for variables can
200be linked to OP-TEE for this purpose. This module uses the Replay
201Protected Memory Block (RPMB) of an eMMC device for persisting
202non-volatile variables. When calling the variable services via the
203OP-TEE API U-Boot's OP-TEE supplicant relays calls to the RPMB driver
204which has to be enabled via CONFIG_SUPPORT_EMMC_RPMB=y.
205
206[1] https://optee.readthedocs.io/ - OP-TEE documentation
207
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200208Executing the boot manager
209~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100210
Heinrich Schuchardt10288402018-12-30 12:54:36 +0100211The UEFI specification foresees to define boot entries and boot sequence via UEFI
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200212variables. Booting according to these variables is possible via::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100213
214 bootefi bootmgr [fdt address]
215
216As of U-Boot v2018.03 UEFI variables are not persisted and cannot be set at
217runtime.
218
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200219Executing the built in hello world application
220~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100221
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200222A hello world UEFI application can be built with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100223
224 CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
225
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200226It can be embedded into the U-Boot binary with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100227
228 CONFIG_CMD_BOOTEFI_HELLO=y
229
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200230The bootefi command is used to start the embedded hello world application::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100231
232 bootefi hello [fdt address]
233
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200234Below you find the output of an example session::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100235
236 => bootefi hello ${fdtcontroladdr}
237 ## Starting EFI application at 01000000 ...
238 WARNING: using memory device/image path, this may confuse some payloads!
239 Hello, world!
240 Running on UEFI 2.7
241 Have SMBIOS table
242 Have device tree
243 Load options: root=/dev/sdb3 init=/sbin/init rootwait ro
244 ## Application terminated, r = 0
245
246The environment variable fdtcontroladdr points to U-Boot's internal device tree
247(if available).
248
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200249Executing the built-in self-test
250~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100251
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200252An UEFI self-test suite can be embedded in U-Boot by building with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100253
254 CONFIG_CMD_BOOTEFI_SELFTEST=y
255
256For testing the UEFI implementation the bootefi command can be used to start the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200257self-test::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100258
259 bootefi selftest [fdt address]
260
261The environment variable 'efi_selftest' can be used to select a single test. If
262it is not provided all tests are executed except those marked as 'on request'.
263If the environment variable is set to 'list' a list of all tests is shown.
264
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200265Below you can find the output of an example session::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100266
267 => setenv efi_selftest simple network protocol
268 => bootefi selftest
269 Testing EFI API implementation
270 Selected test: 'simple network protocol'
271 Setting up 'simple network protocol'
272 Setting up 'simple network protocol' succeeded
273 Executing 'simple network protocol'
274 DHCP Discover
275 DHCP reply received from 192.168.76.2 (52:55:c0:a8:4c:02)
276 as broadcast message.
277 Executing 'simple network protocol' succeeded
278 Tearing down 'simple network protocol'
279 Tearing down 'simple network protocol' succeeded
280 Boot services terminated
281 Summary: 0 failures
282 Preparing for reset. Press any key.
283
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200284The UEFI life cycle
285-------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100286
287After the U-Boot platform has been initialized the UEFI API provides two kinds
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200288of services:
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100289
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200290* boot services
291* runtime services
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100292
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200293The API can be extended by loading UEFI drivers which come in two variants:
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100294
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200295* boot drivers
296* runtime drivers
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100297
298UEFI drivers are installed with U-Boot's bootefi command. With the same command
299UEFI applications can be executed.
300
301Loaded images of UEFI drivers stay in memory after returning to U-Boot while
302loaded images of applications are removed from memory.
303
304An UEFI application (e.g. an operating system) that wants to take full control
305of the system calls ExitBootServices. After a UEFI application calls
306ExitBootServices
307
308* boot services are not available anymore
309* timer events are stopped
310* the memory used by U-Boot except for runtime services is released
311* the memory used by boot time drivers is released
312
313So this is a point of no return. Afterwards the UEFI application can only return
314to U-Boot by rebooting.
315
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200316The UEFI object model
317---------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100318
319UEFI offers a flexible and expandable object model. The objects in the UEFI API
320are devices, drivers, and loaded images. These objects are referenced by
321handles.
322
323The interfaces implemented by the objects are referred to as protocols. These
324are identified by GUIDs. They can be installed and uninstalled by calling the
325appropriate boot services.
326
327Handles are created by the InstallProtocolInterface or the
328InstallMultipleProtocolinterfaces service if NULL is passed as handle.
329
330Handles are deleted when the last protocol has been removed with the
331UninstallProtocolInterface or the UninstallMultipleProtocolInterfaces service.
332
333Devices offer the EFI_DEVICE_PATH_PROTOCOL. A device path is the concatenation
334of device nodes. By their device paths all devices of a system are arranged in a
335tree.
336
337Drivers offer the EFI_DRIVER_BINDING_PROTOCOL. This protocol is used to connect
338a driver to devices (which are referenced as controllers in this context).
339
340Loaded images offer the EFI_LOADED_IMAGE_PROTOCOL. This protocol provides meta
341information about the image and a pointer to the unload callback function.
342
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200343The UEFI events
344---------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100345
346In the UEFI terminology an event is a data object referencing a notification
347function which is queued for calling when the event is signaled. The following
348types of events exist:
349
350* periodic and single shot timer events
351* exit boot services events, triggered by calling the ExitBootServices() service
352* virtual address change events
353* memory map change events
354* read to boot events
355* reset system events
356* system table events
357* events that are only triggered programmatically
358
359Events can be created with the CreateEvent service and deleted with CloseEvent
360service.
361
362Events can be assigned to an event group. If any of the events in a group is
363signaled, all other events in the group are also set to the signaled state.
364
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200365The UEFI driver model
366---------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100367
368A driver is specific for a single protocol installed on a device. To install a
369driver on a device the ConnectController service is called. In this context
370controller refers to the device for which the driver is installed.
371
372The relevant drivers are identified using the EFI_DRIVER_BINDING_PROTOCOL. This
373protocol has has three functions:
374
375* supported - determines if the driver is compatible with the device
376* start - installs the driver by opening the relevant protocol with
377 attribute EFI_OPEN_PROTOCOL_BY_DRIVER
378* stop - uninstalls the driver
379
380The driver may create child controllers (child devices). E.g. a driver for block
381IO devices will create the device handles for the partitions. The child
382controllers will open the supported protocol with the attribute
383EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
384
385A driver can be detached from a device using the DisconnectController service.
386
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200387U-Boot devices mapped as UEFI devices
388-------------------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100389
390Some of the U-Boot devices are mapped as UEFI devices
391
392* block IO devices
393* console
394* graphical output
395* network adapter
396
397As of U-Boot 2018.03 the logic for doing this is hard coded.
398
399The development target is to integrate the setup of these UEFI devices with the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200400U-Boot driver model [5]. So when a U-Boot device is discovered a handle should
401be created and the device path protocol and the relevant IO protocol should be
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100402installed. The UEFI driver then would be attached by calling ConnectController.
403When a U-Boot device is removed DisconnectController should be called.
404
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200405UEFI devices mapped as U-Boot devices
406-------------------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100407
408UEFI drivers binaries and applications may create new (virtual) devices, install
409a protocol and call the ConnectController service. Now the matching UEFI driver
410is determined by iterating over the implementations of the
411EFI_DRIVER_BINDING_PROTOCOL.
412
413It is the task of the UEFI driver to create a corresponding U-Boot device and to
414proxy calls for this U-Boot device to the controller.
415
416In U-Boot 2018.03 this has only been implemented for block IO devices.
417
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200418UEFI uclass
419~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100420
421An UEFI uclass driver (lib/efi_driver/efi_uclass.c) has been created that
422takes care of initializing the UEFI drivers and providing the
423EFI_DRIVER_BINDING_PROTOCOL implementation for the UEFI drivers.
424
425A linker created list is used to keep track of the UEFI drivers. To create an
426entry in the list the UEFI driver uses the U_BOOT_DRIVER macro specifying
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200427UCLASS_EFI as the ID of its uclass, e.g::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100428
429 /* Identify as UEFI driver */
430 U_BOOT_DRIVER(efi_block) = {
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200431 .name = "EFI block driver",
432 .id = UCLASS_EFI,
433 .ops = &driver_ops,
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100434 };
435
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200436The available operations are defined via the structure struct efi_driver_ops::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100437
438 struct efi_driver_ops {
439 const efi_guid_t *protocol;
440 const efi_guid_t *child_protocol;
441 int (*bind)(efi_handle_t handle, void *interface);
442 };
443
444When the supported() function of the EFI_DRIVER_BINDING_PROTOCOL is called the
445uclass checks if the protocol GUID matches the protocol GUID of the UEFI driver.
446In the start() function the bind() function of the UEFI driver is called after
447checking the GUID.
448The stop() function of the EFI_DRIVER_BINDING_PROTOCOL disconnects the child
449controllers created by the UEFI driver and the UEFI driver. (In U-Boot v2013.03
450this is not yet completely implemented.)
451
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200452UEFI block IO driver
453~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100454
455The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
456
457When connected it creates a new U-Boot block IO device with interface type
458IF_TYPE_EFI, adds child controllers mapping the partitions, and installs the
459EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200460software iPXE to boot from iSCSI network drives [4].
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100461
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200462This driver is only available if U-Boot is configured with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100463
464 CONFIG_BLK=y
465 CONFIG_PARTITIONS=y
466
Heinrich Schuchardtc4d45422020-02-22 07:47:20 +0100467Miscellaneous
468-------------
469
470Load file 2 protocol
471~~~~~~~~~~~~~~~~~~~~
472
473The load file 2 protocol can be used by the Linux kernel to load the initial
474RAM disk. U-Boot can be configured to provide an implementation with::
475
476 EFI_LOAD_FILE2_INITRD=y
477 EFI_INITRD_FILESPEC=interface dev:part path_to_initrd
478
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200479Links
480-----
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100481
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200482* [1] http://uefi.org/specifications - UEFI specifications
483* [2] https://github.com/ARM-software/ebbr/releases/download/v1.0/ebbr-v1.0.pdf -
Heinrich Schuchardt9ec8f5e2019-04-10 08:04:38 +0200484 Embedded Base Boot Requirements (EBBR) Specification - Release v1.0
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200485* [3] https://developer.arm.com/docs/den0044/latest/server-base-boot-requirements-system-software-on-arm-platforms-version-11 -
Heinrich Schuchardta28d0732019-03-28 08:09:16 +0100486 Server Base Boot Requirements System Software on ARM Platforms - Version 1.1
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200487* [4] :doc:`iscsi`
488* [5] :doc:`../driver-model/index`