Commit 9dfd84da8ce930d3f0522213945f7bb59b57ddb2
Committed by
Alexander Graf
1 parent
f768619239
Exists in
smarc_8mq_lf_v2020.04
and in
20 other branches
efi_loader: allow creation of more device part nodes
Create device path nodes for UCLASS_ETH udevices. Create device path nodes of block device children of UCLASS_MMC udevices. Consistently use debug for unsupported nodes. Set the log level to error. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Fix build failure by adding #ifdef CONFIG_DM_ETH] Signed-off-by: Alexander Graf <agraf@suse.de>
Showing 1 changed file with 49 additions and 5 deletions Side-by-side Diff
lib/efi_loader/efi_device_path.c
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#define LOG_CATEGORY LOGL_ERR | |
| 10 | + | |
| 9 | 11 | #include <common.h> |
| 10 | 12 | #include <blk.h> |
| 11 | 13 | #include <dm.h> |
| ... | ... | @@ -111,7 +113,6 @@ |
| 111 | 113 | } |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | - | |
| 115 | 116 | /* |
| 116 | 117 | * See UEFI spec (section 3.1.2, about short-form device-paths.. |
| 117 | 118 | * tl;dr: we can have a device-path that starts with a USB WWID |
| ... | ... | @@ -184,7 +185,6 @@ |
| 184 | 185 | return NULL; |
| 185 | 186 | } |
| 186 | 187 | |
| 187 | - | |
| 188 | 188 | /* |
| 189 | 189 | * Find an efiobj from device-path, if 'rem' is not NULL, returns the |
| 190 | 190 | * remaining part of the device path after the matched object. |
| ... | ... | @@ -328,6 +328,9 @@ |
| 328 | 328 | case UCLASS_SIMPLE_BUS: |
| 329 | 329 | /* stop traversing parents at this point: */ |
| 330 | 330 | return sizeof(ROOT); |
| 331 | + case UCLASS_ETH: | |
| 332 | + return dp_size(dev->parent) + | |
| 333 | + sizeof(struct efi_device_path_mac_addr); | |
| 331 | 334 | #ifdef CONFIG_BLK |
| 332 | 335 | case UCLASS_BLK: |
| 333 | 336 | switch (dev->parent->uclass->uc_drv->id) { |
| 334 | 337 | |
| 335 | 338 | |
| ... | ... | @@ -341,13 +344,20 @@ |
| 341 | 344 | return dp_size(dev->parent) + |
| 342 | 345 | sizeof(struct efi_device_path_scsi); |
| 343 | 346 | #endif |
| 347 | +#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC) | |
| 348 | + case UCLASS_MMC: | |
| 349 | + return dp_size(dev->parent) + | |
| 350 | + sizeof(struct efi_device_path_sd_mmc_path); | |
| 351 | +#endif | |
| 344 | 352 | default: |
| 345 | 353 | return dp_size(dev->parent); |
| 346 | 354 | } |
| 347 | 355 | #endif |
| 356 | +#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC) | |
| 348 | 357 | case UCLASS_MMC: |
| 349 | 358 | return dp_size(dev->parent) + |
| 350 | 359 | sizeof(struct efi_device_path_sd_mmc_path); |
| 360 | +#endif | |
| 351 | 361 | case UCLASS_MASS_STORAGE: |
| 352 | 362 | case UCLASS_USB_HUB: |
| 353 | 363 | return dp_size(dev->parent) + |
| ... | ... | @@ -378,6 +388,23 @@ |
| 378 | 388 | *vdp = ROOT; |
| 379 | 389 | return &vdp[1]; |
| 380 | 390 | } |
| 391 | +#ifdef CONFIG_DM_ETH | |
| 392 | + case UCLASS_ETH: { | |
| 393 | + struct efi_device_path_mac_addr *dp = | |
| 394 | + dp_fill(buf, dev->parent); | |
| 395 | + struct eth_pdata *pdata = dev->platdata; | |
| 396 | + | |
| 397 | + dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; | |
| 398 | + dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR; | |
| 399 | + dp->dp.length = sizeof(*dp); | |
| 400 | + memset(&dp->mac, 0, sizeof(dp->mac)); | |
| 401 | + /* We only support IPv4 */ | |
| 402 | + memcpy(&dp->mac, &pdata->enetaddr, ARP_HLEN); | |
| 403 | + /* Ethernet */ | |
| 404 | + dp->if_type = 1; | |
| 405 | + return &dp[1]; | |
| 406 | + } | |
| 407 | +#endif | |
| 381 | 408 | #ifdef CONFIG_BLK |
| 382 | 409 | case UCLASS_BLK: |
| 383 | 410 | switch (dev->parent->uclass->uc_drv->id) { |
| 384 | 411 | |
| ... | ... | @@ -412,9 +439,25 @@ |
| 412 | 439 | return &dp[1]; |
| 413 | 440 | } |
| 414 | 441 | #endif |
| 442 | +#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC) | |
| 443 | + case UCLASS_MMC: { | |
| 444 | + struct efi_device_path_sd_mmc_path *sddp = | |
| 445 | + dp_fill(buf, dev->parent); | |
| 446 | + struct blk_desc *desc = dev_get_uclass_platdata(dev); | |
| 447 | + | |
| 448 | + sddp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; | |
| 449 | + sddp->dp.sub_type = is_sd(desc) ? | |
| 450 | + DEVICE_PATH_SUB_TYPE_MSG_SD : | |
| 451 | + DEVICE_PATH_SUB_TYPE_MSG_MMC; | |
| 452 | + sddp->dp.length = sizeof(*sddp); | |
| 453 | + sddp->slot_number = dev->seq; | |
| 454 | + return &sddp[1]; | |
| 455 | + } | |
| 456 | +#endif | |
| 415 | 457 | default: |
| 416 | - printf("unhandled parent class: %s (%u)\n", | |
| 417 | - dev->name, dev->driver->id); | |
| 458 | + debug("%s(%u) %s: unhandled parent class: %s (%u)\n", | |
| 459 | + __FILE__, __LINE__, __func__, | |
| 460 | + dev->name, dev->parent->uclass->uc_drv->id); | |
| 418 | 461 | return dp_fill(buf, dev->parent); |
| 419 | 462 | } |
| 420 | 463 | #endif |
| ... | ... | @@ -454,7 +497,8 @@ |
| 454 | 497 | return &udp[1]; |
| 455 | 498 | } |
| 456 | 499 | default: |
| 457 | - debug("unhandled device class: %s (%u)\n", | |
| 500 | + debug("%s(%u) %s: unhandled device class: %s (%u)\n", | |
| 501 | + __FILE__, __LINE__, __func__, | |
| 458 | 502 | dev->name, dev->driver->id); |
| 459 | 503 | return dp_fill(buf, dev->parent); |
| 460 | 504 | } |