Tom Rini | 70df9d6 | 2018-05-07 17:02:21 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Uclass for EFI drivers |
| 4 | * |
| 5 | * Copyright (c) 2017 Heinrich Schuchardt |
| 6 | * |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 7 | * For each EFI driver the uclass |
| 8 | * - creates a handle |
| 9 | * - installs the driver binding protocol |
| 10 | * |
| 11 | * The uclass provides the bind, start, and stop entry points for the driver |
| 12 | * binding protocol. |
| 13 | * |
Heinrich Schuchardt | 3f712db | 2022-10-03 10:35:35 +0200 | [diff] [blame] | 14 | * In supported() and bind() it checks if the controller implements the protocol |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 15 | * supported by the EFI driver. In the start() function it calls the bind() |
| 16 | * function of the EFI driver. In the stop() function it destroys the child |
| 17 | * controllers. |
| 18 | */ |
| 19 | |
Simon Glass | f6977c1 | 2020-07-19 10:15:43 -0600 | [diff] [blame] | 20 | #include <common.h> |
| 21 | #include <dm.h> |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 22 | #include <efi_driver.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 23 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 24 | #include <malloc.h> |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 25 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 26 | /** |
| 27 | * check_node_type() - check node type |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 28 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 29 | * We do not support partitions as controller handles. |
| 30 | * |
| 31 | * @handle: handle to be checked |
| 32 | * Return: status code |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 33 | */ |
| 34 | static efi_status_t check_node_type(efi_handle_t handle) |
| 35 | { |
| 36 | efi_status_t r, ret = EFI_SUCCESS; |
| 37 | const struct efi_device_path *dp; |
| 38 | |
| 39 | /* Open the device path protocol */ |
| 40 | r = EFI_CALL(systab.boottime->open_protocol( |
| 41 | handle, &efi_guid_device_path, (void **)&dp, |
| 42 | NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)); |
| 43 | if (r == EFI_SUCCESS && dp) { |
| 44 | /* Get the last node */ |
| 45 | const struct efi_device_path *node = efi_dp_last_node(dp); |
| 46 | /* We do not support partitions as controller */ |
| 47 | if (!node || node->type == DEVICE_PATH_TYPE_MEDIA_DEVICE) |
| 48 | ret = EFI_UNSUPPORTED; |
| 49 | } |
| 50 | return ret; |
| 51 | } |
| 52 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 53 | /** |
| 54 | * efi_uc_supported() - check if the driver supports the controller |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 55 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 56 | * @this: driver binding protocol |
| 57 | * @controller_handle: handle of the controller |
| 58 | * @remaining_device_path: path specifying the child controller |
| 59 | * Return: status code |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 60 | */ |
| 61 | static efi_status_t EFIAPI efi_uc_supported( |
| 62 | struct efi_driver_binding_protocol *this, |
| 63 | efi_handle_t controller_handle, |
| 64 | struct efi_device_path *remaining_device_path) |
| 65 | { |
| 66 | efi_status_t r, ret; |
| 67 | void *interface; |
| 68 | struct efi_driver_binding_extended_protocol *bp = |
| 69 | (struct efi_driver_binding_extended_protocol *)this; |
| 70 | |
| 71 | EFI_ENTRY("%p, %p, %ls", this, controller_handle, |
| 72 | efi_dp_str(remaining_device_path)); |
| 73 | |
Heinrich Schuchardt | 4fdaaf9 | 2022-09-09 06:57:58 +0000 | [diff] [blame] | 74 | /* |
| 75 | * U-Boot internal devices install protocols interfaces without calling |
| 76 | * ConnectController(). Hence we should not bind an extra driver. |
| 77 | */ |
| 78 | if (controller_handle->dev) { |
| 79 | ret = EFI_UNSUPPORTED; |
| 80 | goto out; |
| 81 | } |
| 82 | |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 83 | ret = EFI_CALL(systab.boottime->open_protocol( |
| 84 | controller_handle, bp->ops->protocol, |
| 85 | &interface, this->driver_binding_handle, |
| 86 | controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER)); |
| 87 | switch (ret) { |
| 88 | case EFI_ACCESS_DENIED: |
| 89 | case EFI_ALREADY_STARTED: |
| 90 | goto out; |
| 91 | case EFI_SUCCESS: |
| 92 | break; |
| 93 | default: |
| 94 | ret = EFI_UNSUPPORTED; |
| 95 | goto out; |
| 96 | } |
| 97 | |
| 98 | ret = check_node_type(controller_handle); |
| 99 | |
Heinrich Schuchardt | 64304a1 | 2022-10-07 16:12:54 +0200 | [diff] [blame] | 100 | r = efi_close_protocol(controller_handle, bp->ops->protocol, |
| 101 | this->driver_binding_handle, |
| 102 | controller_handle); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 103 | if (r != EFI_SUCCESS) |
| 104 | ret = EFI_UNSUPPORTED; |
| 105 | out: |
| 106 | return EFI_EXIT(ret); |
| 107 | } |
| 108 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 109 | /** |
| 110 | * efi_uc_start() - create child controllers and attach driver |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 111 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 112 | * @this: driver binding protocol |
| 113 | * @controller_handle: handle of the controller |
| 114 | * @remaining_device_path: path specifying the child controller |
| 115 | * Return: status code |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 116 | */ |
| 117 | static efi_status_t EFIAPI efi_uc_start( |
| 118 | struct efi_driver_binding_protocol *this, |
| 119 | efi_handle_t controller_handle, |
| 120 | struct efi_device_path *remaining_device_path) |
| 121 | { |
| 122 | efi_status_t r, ret; |
| 123 | void *interface = NULL; |
| 124 | struct efi_driver_binding_extended_protocol *bp = |
| 125 | (struct efi_driver_binding_extended_protocol *)this; |
| 126 | |
Heinrich Schuchardt | 64dc7af | 2020-01-10 12:33:16 +0100 | [diff] [blame] | 127 | EFI_ENTRY("%p, %p, %ls", this, controller_handle, |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 128 | efi_dp_str(remaining_device_path)); |
| 129 | |
| 130 | /* Attach driver to controller */ |
| 131 | ret = EFI_CALL(systab.boottime->open_protocol( |
| 132 | controller_handle, bp->ops->protocol, |
| 133 | &interface, this->driver_binding_handle, |
| 134 | controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER)); |
| 135 | switch (ret) { |
| 136 | case EFI_ACCESS_DENIED: |
| 137 | case EFI_ALREADY_STARTED: |
| 138 | goto out; |
| 139 | case EFI_SUCCESS: |
| 140 | break; |
| 141 | default: |
| 142 | ret = EFI_UNSUPPORTED; |
| 143 | goto out; |
| 144 | } |
| 145 | ret = check_node_type(controller_handle); |
Heinrich Schuchardt | 3f712db | 2022-10-03 10:35:35 +0200 | [diff] [blame] | 146 | if (ret != EFI_SUCCESS) |
| 147 | goto err; |
Heinrich Schuchardt | ff1d50b | 2022-10-04 19:12:59 +0200 | [diff] [blame] | 148 | ret = bp->ops->bind(bp, controller_handle, interface); |
Heinrich Schuchardt | 3f712db | 2022-10-03 10:35:35 +0200 | [diff] [blame] | 149 | if (ret == EFI_SUCCESS) |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 150 | goto out; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 151 | |
Heinrich Schuchardt | 3f712db | 2022-10-03 10:35:35 +0200 | [diff] [blame] | 152 | err: |
Heinrich Schuchardt | 64304a1 | 2022-10-07 16:12:54 +0200 | [diff] [blame] | 153 | r = efi_close_protocol(controller_handle, bp->ops->protocol, |
| 154 | this->driver_binding_handle, |
| 155 | controller_handle); |
Heinrich Schuchardt | 3f712db | 2022-10-03 10:35:35 +0200 | [diff] [blame] | 156 | if (r != EFI_SUCCESS) |
| 157 | EFI_PRINT("Failure to close handle\n"); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 158 | |
| 159 | out: |
| 160 | return EFI_EXIT(ret); |
| 161 | } |
| 162 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 163 | /** |
| 164 | * disconnect_child() - remove a single child controller from the parent |
| 165 | * controller |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 166 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 167 | * @controller_handle: parent controller |
| 168 | * @child_handle: child controller |
| 169 | * Return: status code |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 170 | */ |
| 171 | static efi_status_t disconnect_child(efi_handle_t controller_handle, |
| 172 | efi_handle_t child_handle) |
| 173 | { |
| 174 | efi_status_t ret; |
| 175 | efi_guid_t *guid_controller = NULL; |
| 176 | efi_guid_t *guid_child_controller = NULL; |
| 177 | |
Heinrich Schuchardt | 64304a1 | 2022-10-07 16:12:54 +0200 | [diff] [blame] | 178 | ret = efi_close_protocol(controller_handle, guid_controller, |
| 179 | child_handle, child_handle); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 180 | if (ret != EFI_SUCCESS) { |
| 181 | EFI_PRINT("Cannot close protocol\n"); |
| 182 | return ret; |
| 183 | } |
| 184 | ret = EFI_CALL(systab.boottime->uninstall_protocol_interface( |
| 185 | child_handle, guid_child_controller, NULL)); |
| 186 | if (ret != EFI_SUCCESS) { |
| 187 | EFI_PRINT("Cannot uninstall protocol interface\n"); |
| 188 | return ret; |
| 189 | } |
| 190 | return ret; |
| 191 | } |
| 192 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 193 | /** |
| 194 | * efi_uc_stop() - Remove child controllers and disconnect the controller |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 195 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 196 | * @this: driver binding protocol |
| 197 | * @controller_handle: handle of the controller |
| 198 | * @number_of_children: number of child controllers to remove |
| 199 | * @child_handle_buffer: handles of the child controllers to remove |
| 200 | * Return: status code |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 201 | */ |
| 202 | static efi_status_t EFIAPI efi_uc_stop( |
| 203 | struct efi_driver_binding_protocol *this, |
| 204 | efi_handle_t controller_handle, |
| 205 | size_t number_of_children, |
| 206 | efi_handle_t *child_handle_buffer) |
| 207 | { |
| 208 | efi_status_t ret; |
| 209 | efi_uintn_t count; |
| 210 | struct efi_open_protocol_info_entry *entry_buffer; |
Heinrich Schuchardt | a3a4a9c | 2020-01-09 23:26:43 +0100 | [diff] [blame] | 211 | struct efi_driver_binding_extended_protocol *bp = |
| 212 | (struct efi_driver_binding_extended_protocol *)this; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 213 | |
Heinrich Schuchardt | 64dc7af | 2020-01-10 12:33:16 +0100 | [diff] [blame] | 214 | EFI_ENTRY("%p, %p, %zu, %p", this, controller_handle, |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 215 | number_of_children, child_handle_buffer); |
| 216 | |
| 217 | /* Destroy provided child controllers */ |
| 218 | if (number_of_children) { |
| 219 | efi_uintn_t i; |
| 220 | |
| 221 | for (i = 0; i < number_of_children; ++i) { |
| 222 | ret = disconnect_child(controller_handle, |
| 223 | child_handle_buffer[i]); |
| 224 | if (ret != EFI_SUCCESS) |
Heinrich Schuchardt | adbbe1c | 2022-10-07 23:53:38 +0200 | [diff] [blame] | 225 | goto out; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 226 | } |
Heinrich Schuchardt | adbbe1c | 2022-10-07 23:53:38 +0200 | [diff] [blame] | 227 | ret = EFI_SUCCESS; |
| 228 | goto out; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /* Destroy all children */ |
| 232 | ret = EFI_CALL(systab.boottime->open_protocol_information( |
Heinrich Schuchardt | a3a4a9c | 2020-01-09 23:26:43 +0100 | [diff] [blame] | 233 | controller_handle, bp->ops->protocol, |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 234 | &entry_buffer, &count)); |
| 235 | if (ret != EFI_SUCCESS) |
| 236 | goto out; |
| 237 | while (count) { |
| 238 | if (entry_buffer[--count].attributes & |
| 239 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) { |
| 240 | ret = disconnect_child( |
| 241 | controller_handle, |
| 242 | entry_buffer[count].agent_handle); |
| 243 | if (ret != EFI_SUCCESS) |
| 244 | goto out; |
| 245 | } |
| 246 | } |
Heinrich Schuchardt | 8a7112e | 2022-10-04 12:50:51 +0200 | [diff] [blame] | 247 | ret = efi_free_pool(entry_buffer); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 248 | if (ret != EFI_SUCCESS) |
Heinrich Schuchardt | 42c8ba2 | 2020-12-01 09:06:29 +0100 | [diff] [blame] | 249 | log_err("Cannot free EFI memory pool\n"); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 250 | |
| 251 | /* Detach driver from controller */ |
Heinrich Schuchardt | 64304a1 | 2022-10-07 16:12:54 +0200 | [diff] [blame] | 252 | ret = efi_close_protocol(controller_handle, bp->ops->protocol, |
| 253 | this->driver_binding_handle, |
| 254 | controller_handle); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 255 | out: |
| 256 | return EFI_EXIT(ret); |
| 257 | } |
| 258 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 259 | /** |
| 260 | * efi_add_driver() - add driver |
| 261 | * |
| 262 | * @drv: driver to add |
| 263 | * Return: status code |
| 264 | */ |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 265 | static efi_status_t efi_add_driver(struct driver *drv) |
| 266 | { |
| 267 | efi_status_t ret; |
| 268 | const struct efi_driver_ops *ops = drv->ops; |
| 269 | struct efi_driver_binding_extended_protocol *bp; |
| 270 | |
Heinrich Schuchardt | 42c8ba2 | 2020-12-01 09:06:29 +0100 | [diff] [blame] | 271 | log_debug("Adding EFI driver '%s'\n", drv->name); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 272 | if (!ops->protocol) { |
Heinrich Schuchardt | 42c8ba2 | 2020-12-01 09:06:29 +0100 | [diff] [blame] | 273 | log_err("EFI protocol GUID missing for driver '%s'\n", |
| 274 | drv->name); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 275 | return EFI_INVALID_PARAMETER; |
| 276 | } |
| 277 | bp = calloc(1, sizeof(struct efi_driver_binding_extended_protocol)); |
| 278 | if (!bp) |
| 279 | return EFI_OUT_OF_RESOURCES; |
| 280 | |
| 281 | bp->bp.supported = efi_uc_supported; |
| 282 | bp->bp.start = efi_uc_start; |
| 283 | bp->bp.stop = efi_uc_stop; |
| 284 | bp->bp.version = 0xffffffff; |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 285 | bp->ops = ops; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 286 | |
| 287 | ret = efi_create_handle(&bp->bp.driver_binding_handle); |
Ilias Apalodimas | b09ecf1 | 2023-07-24 13:17:36 +0300 | [diff] [blame] | 288 | if (ret != EFI_SUCCESS) |
| 289 | goto err; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 290 | bp->bp.image_handle = bp->bp.driver_binding_handle; |
| 291 | ret = efi_add_protocol(bp->bp.driver_binding_handle, |
| 292 | &efi_guid_driver_binding_protocol, bp); |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 293 | if (ret != EFI_SUCCESS) |
| 294 | goto err; |
| 295 | if (ops->init) { |
| 296 | ret = ops->init(bp); |
| 297 | if (ret != EFI_SUCCESS) |
| 298 | goto err; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 299 | } |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 300 | |
Ilias Apalodimas | b09ecf1 | 2023-07-24 13:17:36 +0300 | [diff] [blame] | 301 | return ret; |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 302 | err: |
Ilias Apalodimas | b09ecf1 | 2023-07-24 13:17:36 +0300 | [diff] [blame] | 303 | if (bp->bp.driver_binding_handle) |
| 304 | efi_delete_handle(bp->bp.driver_binding_handle); |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 305 | free(bp); |
| 306 | return ret; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 307 | } |
| 308 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 309 | /** |
| 310 | * efi_driver_init() - initialize the EFI drivers |
| 311 | * |
| 312 | * Called by efi_init_obj_list(). |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 313 | * |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 314 | * Return: 0 = success, any other value will stop further execution |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 315 | */ |
Heinrich Schuchardt | 8f3cc5b | 2018-02-01 12:53:32 +0100 | [diff] [blame] | 316 | efi_status_t efi_driver_init(void) |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 317 | { |
| 318 | struct driver *drv; |
Heinrich Schuchardt | 8f3cc5b | 2018-02-01 12:53:32 +0100 | [diff] [blame] | 319 | efi_status_t ret = EFI_SUCCESS; |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 320 | |
Heinrich Schuchardt | 42c8ba2 | 2020-12-01 09:06:29 +0100 | [diff] [blame] | 321 | log_debug("Initializing EFI driver framework\n"); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 322 | for (drv = ll_entry_start(struct driver, driver); |
| 323 | drv < ll_entry_end(struct driver, driver); ++drv) { |
Simon Glass | 15c4d67 | 2021-12-04 08:56:30 -0700 | [diff] [blame] | 324 | if (drv->id == UCLASS_EFI_LOADER) { |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 325 | ret = efi_add_driver(drv); |
Heinrich Schuchardt | 8f3cc5b | 2018-02-01 12:53:32 +0100 | [diff] [blame] | 326 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | 42c8ba2 | 2020-12-01 09:06:29 +0100 | [diff] [blame] | 327 | log_err("Failed to add EFI driver %s\n", |
| 328 | drv->name); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 329 | break; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | return ret; |
| 334 | } |
| 335 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 336 | /** |
| 337 | * efi_uc_init() - initialize the EFI uclass |
| 338 | * |
| 339 | * @class: the EFI uclass |
| 340 | * Return: 0 = success |
| 341 | */ |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 342 | static int efi_uc_init(struct uclass *class) |
| 343 | { |
Simon Glass | 15c4d67 | 2021-12-04 08:56:30 -0700 | [diff] [blame] | 344 | log_debug("Initializing UCLASS_EFI_LOADER\n"); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 345 | return 0; |
| 346 | } |
| 347 | |
Heinrich Schuchardt | 55de100 | 2018-09-18 18:52:46 +0200 | [diff] [blame] | 348 | /** |
| 349 | * efi_uc_destroy() - destroy the EFI uclass |
| 350 | * |
| 351 | * @class: the EFI uclass |
| 352 | * Return: 0 = success |
| 353 | */ |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 354 | static int efi_uc_destroy(struct uclass *class) |
| 355 | { |
Simon Glass | 15c4d67 | 2021-12-04 08:56:30 -0700 | [diff] [blame] | 356 | log_debug("Destroying UCLASS_EFI_LOADER\n"); |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | UCLASS_DRIVER(efi) = { |
| 361 | .name = "efi", |
Simon Glass | 15c4d67 | 2021-12-04 08:56:30 -0700 | [diff] [blame] | 362 | .id = UCLASS_EFI_LOADER, |
Heinrich Schuchardt | 11206f4 | 2018-01-21 19:29:30 +0100 | [diff] [blame] | 363 | .init = efi_uc_init, |
| 364 | .destroy = efi_uc_destroy, |
| 365 | }; |