diff options
| -rw-r--r-- | arch/arm/include/asm/efi.h | 3 | ||||
| -rw-r--r-- | arch/arm64/include/asm/efi.h | 3 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/eboot.c | 63 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/arm-stub.c | 25 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-helper.c | 31 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efistub.h | 3 | ||||
| -rw-r--r-- | include/linux/efi.h | 10 |
7 files changed, 45 insertions, 93 deletions
diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 17f1f1a814ff..38badaae8d9d 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h | |||
| @@ -58,6 +58,9 @@ void efi_virtmap_unload(void); | |||
| 58 | #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) | 58 | #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) |
| 59 | #define efi_is_64bit() (false) | 59 | #define efi_is_64bit() (false) |
| 60 | 60 | ||
| 61 | #define efi_table_attr(table, attr, instance) \ | ||
| 62 | ((table##_t *)instance)->attr | ||
| 63 | |||
| 61 | #define efi_call_proto(protocol, f, instance, ...) \ | 64 | #define efi_call_proto(protocol, f, instance, ...) \ |
| 62 | ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) | 65 | ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) |
| 63 | 66 | ||
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 192d791f1103..7ed320895d1f 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h | |||
| @@ -87,6 +87,9 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base, | |||
| 87 | #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) | 87 | #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) |
| 88 | #define efi_is_64bit() (true) | 88 | #define efi_is_64bit() (true) |
| 89 | 89 | ||
| 90 | #define efi_table_attr(table, attr, instance) \ | ||
| 91 | ((table##_t *)instance)->attr | ||
| 92 | |||
| 90 | #define efi_call_proto(protocol, f, instance, ...) \ | 93 | #define efi_call_proto(protocol, f, instance, ...) \ |
| 91 | ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) | 94 | ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) |
| 92 | 95 | ||
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 92b573fd239c..915c64edbe8e 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c | |||
| @@ -41,69 +41,6 @@ static void setup_boot_services##bits(struct efi_config *c) \ | |||
| 41 | BOOT_SERVICES(32); | 41 | BOOT_SERVICES(32); |
| 42 | BOOT_SERVICES(64); | 42 | BOOT_SERVICES(64); |
| 43 | 43 | ||
| 44 | static inline efi_status_t __open_volume32(void *__image, void **__fh) | ||
| 45 | { | ||
| 46 | efi_file_io_interface_t *io; | ||
| 47 | efi_loaded_image_32_t *image = __image; | ||
| 48 | efi_file_handle_32_t *fh; | ||
| 49 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
| 50 | efi_status_t status; | ||
| 51 | void *handle = (void *)(unsigned long)image->device_handle; | ||
| 52 | unsigned long func; | ||
| 53 | |||
| 54 | status = efi_call_early(handle_protocol, handle, | ||
| 55 | &fs_proto, (void **)&io); | ||
| 56 | if (status != EFI_SUCCESS) { | ||
| 57 | efi_printk(sys_table, "Failed to handle fs_proto\n"); | ||
| 58 | return status; | ||
| 59 | } | ||
| 60 | |||
| 61 | func = (unsigned long)io->open_volume; | ||
| 62 | status = efi_early->call(func, io, &fh); | ||
| 63 | if (status != EFI_SUCCESS) | ||
| 64 | efi_printk(sys_table, "Failed to open volume\n"); | ||
| 65 | |||
| 66 | *__fh = fh; | ||
| 67 | |||
| 68 | return status; | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline efi_status_t __open_volume64(void *__image, void **__fh) | ||
| 72 | { | ||
| 73 | efi_file_io_interface_t *io; | ||
| 74 | efi_loaded_image_64_t *image = __image; | ||
| 75 | efi_file_handle_64_t *fh; | ||
| 76 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
| 77 | efi_status_t status; | ||
| 78 | void *handle = (void *)(unsigned long)image->device_handle; | ||
| 79 | unsigned long func; | ||
| 80 | |||
| 81 | status = efi_call_early(handle_protocol, handle, | ||
| 82 | &fs_proto, (void **)&io); | ||
| 83 | if (status != EFI_SUCCESS) { | ||
| 84 | efi_printk(sys_table, "Failed to handle fs_proto\n"); | ||
| 85 | return status; | ||
| 86 | } | ||
| 87 | |||
| 88 | func = (unsigned long)io->open_volume; | ||
| 89 | status = efi_early->call(func, io, &fh); | ||
| 90 | if (status != EFI_SUCCESS) | ||
| 91 | efi_printk(sys_table, "Failed to open volume\n"); | ||
| 92 | |||
| 93 | *__fh = fh; | ||
| 94 | |||
| 95 | return status; | ||
| 96 | } | ||
| 97 | |||
| 98 | efi_status_t | ||
| 99 | efi_open_volume(efi_system_table_t *sys_table, void *__image, void **__fh) | ||
| 100 | { | ||
| 101 | if (efi_early->is64) | ||
| 102 | return __open_volume64(__image, __fh); | ||
| 103 | |||
| 104 | return __open_volume32(__image, __fh); | ||
| 105 | } | ||
| 106 | |||
| 107 | void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) | 44 | void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) |
| 108 | { | 45 | { |
| 109 | efi_call_proto(efi_simple_text_output_protocol, output_string, | 46 | efi_call_proto(efi_simple_text_output_protocol, output_string, |
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index c98b1856fc3d..6920033de6d4 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c | |||
| @@ -40,31 +40,6 @@ | |||
| 40 | 40 | ||
| 41 | static u64 virtmap_base = EFI_RT_VIRTUAL_BASE; | 41 | static u64 virtmap_base = EFI_RT_VIRTUAL_BASE; |
| 42 | 42 | ||
| 43 | efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, | ||
| 44 | void *__image, void **__fh) | ||
| 45 | { | ||
| 46 | efi_file_io_interface_t *io; | ||
| 47 | efi_loaded_image_t *image = __image; | ||
| 48 | efi_file_handle_t *fh; | ||
| 49 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
| 50 | efi_status_t status; | ||
| 51 | void *handle = (void *)(unsigned long)image->device_handle; | ||
| 52 | |||
| 53 | status = sys_table_arg->boottime->handle_protocol(handle, | ||
| 54 | &fs_proto, (void **)&io); | ||
| 55 | if (status != EFI_SUCCESS) { | ||
| 56 | efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); | ||
| 57 | return status; | ||
| 58 | } | ||
| 59 | |||
| 60 | status = io->open_volume(io, &fh); | ||
| 61 | if (status != EFI_SUCCESS) | ||
| 62 | efi_printk(sys_table_arg, "Failed to open volume\n"); | ||
| 63 | |||
| 64 | *__fh = fh; | ||
| 65 | return status; | ||
| 66 | } | ||
| 67 | |||
| 68 | void efi_char16_printk(efi_system_table_t *sys_table_arg, | 43 | void efi_char16_printk(efi_system_table_t *sys_table_arg, |
| 69 | efi_char16_t *str) | 44 | efi_char16_t *str) |
| 70 | { | 45 | { |
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 50a9cab5a834..e94975f4655b 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c | |||
| @@ -413,6 +413,34 @@ static efi_status_t efi_file_close(void *handle) | |||
| 413 | return efi_call_proto(efi_file_handle, close, handle); | 413 | return efi_call_proto(efi_file_handle, close, handle); |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | static efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, | ||
| 417 | efi_loaded_image_t *image, | ||
| 418 | efi_file_handle_t **__fh) | ||
| 419 | { | ||
| 420 | efi_file_io_interface_t *io; | ||
| 421 | efi_file_handle_t *fh; | ||
| 422 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
| 423 | efi_status_t status; | ||
| 424 | void *handle = (void *)(unsigned long)efi_table_attr(efi_loaded_image, | ||
| 425 | device_handle, | ||
| 426 | image); | ||
| 427 | |||
| 428 | status = efi_call_early(handle_protocol, handle, | ||
| 429 | &fs_proto, (void **)&io); | ||
| 430 | if (status != EFI_SUCCESS) { | ||
| 431 | efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); | ||
| 432 | return status; | ||
| 433 | } | ||
| 434 | |||
| 435 | status = efi_call_proto(efi_file_io_interface, open_volume, io, &fh); | ||
| 436 | if (status != EFI_SUCCESS) | ||
| 437 | efi_printk(sys_table_arg, "Failed to open volume\n"); | ||
| 438 | else | ||
| 439 | *__fh = fh; | ||
| 440 | |||
| 441 | return status; | ||
| 442 | } | ||
| 443 | |||
| 416 | /* | 444 | /* |
| 417 | * Parse the ASCII string 'cmdline' for EFI options, denoted by the efi= | 445 | * Parse the ASCII string 'cmdline' for EFI options, denoted by the efi= |
| 418 | * option, e.g. efi=nochunk. | 446 | * option, e.g. efi=nochunk. |
| @@ -563,8 +591,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 563 | 591 | ||
| 564 | /* Only open the volume once. */ | 592 | /* Only open the volume once. */ |
| 565 | if (!i) { | 593 | if (!i) { |
| 566 | status = efi_open_volume(sys_table_arg, image, | 594 | status = efi_open_volume(sys_table_arg, image, &fh); |
| 567 | (void **)&fh); | ||
| 568 | if (status != EFI_SUCCESS) | 595 | if (status != EFI_SUCCESS) |
| 569 | goto free_files; | 596 | goto free_files; |
| 570 | } | 597 | } |
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index f59564b72ddc..32799cf039ef 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h | |||
| @@ -36,9 +36,6 @@ extern int __pure is_quiet(void); | |||
| 36 | 36 | ||
| 37 | void efi_char16_printk(efi_system_table_t *, efi_char16_t *); | 37 | void efi_char16_printk(efi_system_table_t *, efi_char16_t *); |
| 38 | 38 | ||
| 39 | efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, | ||
| 40 | void **__fh); | ||
| 41 | |||
| 42 | unsigned long get_dram_base(efi_system_table_t *sys_table_arg); | 39 | unsigned long get_dram_base(efi_system_table_t *sys_table_arg); |
| 43 | 40 | ||
| 44 | efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | 41 | efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, |
diff --git a/include/linux/efi.h b/include/linux/efi.h index e190652f5ef9..401e4b254e30 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
| @@ -894,6 +894,16 @@ typedef struct _efi_file_handle { | |||
| 894 | void *flush; | 894 | void *flush; |
| 895 | } efi_file_handle_t; | 895 | } efi_file_handle_t; |
| 896 | 896 | ||
| 897 | typedef struct { | ||
| 898 | u64 revision; | ||
| 899 | u32 open_volume; | ||
| 900 | } efi_file_io_interface_32_t; | ||
| 901 | |||
| 902 | typedef struct { | ||
| 903 | u64 revision; | ||
| 904 | u64 open_volume; | ||
| 905 | } efi_file_io_interface_64_t; | ||
| 906 | |||
| 897 | typedef struct _efi_file_io_interface { | 907 | typedef struct _efi_file_io_interface { |
| 898 | u64 revision; | 908 | u64 revision; |
| 899 | int (*open_volume)(struct _efi_file_io_interface *, | 909 | int (*open_volume)(struct _efi_file_io_interface *, |
