diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-05 08:53:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-05 08:53:56 +0100 |
commit | 4160c616e2c7b89920e4af251818133990404565 (patch) | |
tree | 7793d2bf5b1e2fe13bb3c222c0c0c41cae404e80 /drivers | |
parent | d76450cb737840af6a13d9c615f96f2502f8383e (diff) | |
parent | 443eb41376d93f291049738b018e9f0c0c5a56e1 (diff) | |
download | barebox-4160c616e2c7b89920e4af251818133990404565.tar.gz barebox-4160c616e2c7b89920e4af251818133990404565.tar.xz |
Merge branch 'for-next/efi'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/efi/efi-device.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c index 9975aea6f7..3a27323a00 100644 --- a/drivers/efi/efi-device.c +++ b/drivers/efi/efi-device.c @@ -17,6 +17,7 @@ * */ +#include <bootsource.h> #include <command.h> #include <common.h> #include <driver.h> @@ -385,6 +386,51 @@ static int efi_is_setup_mode(void) return ret != 1; } +static int is_bio_usbdev(struct efi_device *efidev) +{ + int i; + + for (i = 0; i < efidev->num_guids; i++) { + if (!efi_guidcmp(efidev->guids[i], EFI_USB_IO_PROTOCOL_GUID)) + return 1; + } + + return 0; +} + +static void efi_set_bootsource(void) +{ + enum bootsource src = BOOTSOURCE_UNKNOWN; + int instance = BOOTSOURCE_INSTANCE_UNKNOWN; + + efi_handle_t *efi_parent; + struct efi_device *bootdev; + + if (!efi_loaded_image->parent_handle) + goto out; + + efi_parent = efi_find_parent(efi_loaded_image->device_handle); + + if (!efi_parent) + goto out; + + bootdev = efi_find_device(efi_parent); + + if (!bootdev) + goto out; + + if (is_bio_usbdev(bootdev)) { + src = BOOTSOURCE_USB; + } else { + src = BOOTSOURCE_HD; + } + +out: + + bootsource_set(src); + bootsource_set_instance(instance); +} + static int efi_init_devices(void) { char *fw_vendor = NULL; @@ -415,6 +461,8 @@ static int efi_init_devices(void) efi_register_devices(); + efi_set_bootsource(); + return 0; } core_initcall(efi_init_devices); |