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