diff options
author | Matt Fleming <matt.fleming@intel.com> | 2014-01-10 08:47:37 -0500 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2014-03-04 16:25:02 -0500 |
commit | 677703cef0a148ba07d37ced649ad25b1cda2f78 (patch) | |
tree | ca0167133614d879ec0c0f97c390e0073c925870 | |
parent | 099240ac111aac454962e6399c0cc51d1511504a (diff) |
efi: Add separate 32-bit/64-bit definitions
The traditional approach of using machine-specific types such as
'unsigned long' does not allow the kernel to interact with firmware
running in a different CPU mode, e.g. 64-bit kernel with 32-bit EFI.
Add distinct EFI structure definitions for both 32-bit and 64-bit so
that we can use them in the 32-bit and 64-bit code paths.
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | arch/x86/boot/compressed/eboot.h | 44 | ||||
-rw-r--r-- | include/linux/efi.h | 252 |
2 files changed, 296 insertions, 0 deletions
diff --git a/arch/x86/boot/compressed/eboot.h b/arch/x86/boot/compressed/eboot.h index 81b6b652b46a..d487e727f1ec 100644 --- a/arch/x86/boot/compressed/eboot.h +++ b/arch/x86/boot/compressed/eboot.h | |||
@@ -37,6 +37,24 @@ struct efi_graphics_output_mode_info { | |||
37 | u32 pixels_per_scan_line; | 37 | u32 pixels_per_scan_line; |
38 | } __packed; | 38 | } __packed; |
39 | 39 | ||
40 | struct efi_graphics_output_protocol_mode_32 { | ||
41 | u32 max_mode; | ||
42 | u32 mode; | ||
43 | u32 info; | ||
44 | u32 size_of_info; | ||
45 | u64 frame_buffer_base; | ||
46 | u32 frame_buffer_size; | ||
47 | } __packed; | ||
48 | |||
49 | struct efi_graphics_output_protocol_mode_64 { | ||
50 | u32 max_mode; | ||
51 | u32 mode; | ||
52 | u64 info; | ||
53 | u64 size_of_info; | ||
54 | u64 frame_buffer_base; | ||
55 | u64 frame_buffer_size; | ||
56 | } __packed; | ||
57 | |||
40 | struct efi_graphics_output_protocol_mode { | 58 | struct efi_graphics_output_protocol_mode { |
41 | u32 max_mode; | 59 | u32 max_mode; |
42 | u32 mode; | 60 | u32 mode; |
@@ -46,6 +64,20 @@ struct efi_graphics_output_protocol_mode { | |||
46 | unsigned long frame_buffer_size; | 64 | unsigned long frame_buffer_size; |
47 | } __packed; | 65 | } __packed; |
48 | 66 | ||
67 | struct efi_graphics_output_protocol_32 { | ||
68 | u32 query_mode; | ||
69 | u32 set_mode; | ||
70 | u32 blt; | ||
71 | u32 mode; | ||
72 | }; | ||
73 | |||
74 | struct efi_graphics_output_protocol_64 { | ||
75 | u64 query_mode; | ||
76 | u64 set_mode; | ||
77 | u64 blt; | ||
78 | u64 mode; | ||
79 | }; | ||
80 | |||
49 | struct efi_graphics_output_protocol { | 81 | struct efi_graphics_output_protocol { |
50 | void *query_mode; | 82 | void *query_mode; |
51 | unsigned long set_mode; | 83 | unsigned long set_mode; |
@@ -53,6 +85,18 @@ struct efi_graphics_output_protocol { | |||
53 | struct efi_graphics_output_protocol_mode *mode; | 85 | struct efi_graphics_output_protocol_mode *mode; |
54 | }; | 86 | }; |
55 | 87 | ||
88 | struct efi_uga_draw_protocol_32 { | ||
89 | u32 get_mode; | ||
90 | u32 set_mode; | ||
91 | u32 blt; | ||
92 | }; | ||
93 | |||
94 | struct efi_uga_draw_protocol_64 { | ||
95 | u64 get_mode; | ||
96 | u64 set_mode; | ||
97 | u64 blt; | ||
98 | }; | ||
99 | |||
56 | struct efi_uga_draw_protocol { | 100 | struct efi_uga_draw_protocol { |
57 | void *get_mode; | 101 | void *get_mode; |
58 | void *set_mode; | 102 | void *set_mode; |
diff --git a/include/linux/efi.h b/include/linux/efi.h index 0a819e7a60c9..42c662729e13 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
@@ -153,6 +153,102 @@ typedef struct { | |||
153 | u8 sets_to_zero; | 153 | u8 sets_to_zero; |
154 | } efi_time_cap_t; | 154 | } efi_time_cap_t; |
155 | 155 | ||
156 | typedef struct { | ||
157 | efi_table_hdr_t hdr; | ||
158 | u32 raise_tpl; | ||
159 | u32 restore_tpl; | ||
160 | u32 allocate_pages; | ||
161 | u32 free_pages; | ||
162 | u32 get_memory_map; | ||
163 | u32 allocate_pool; | ||
164 | u32 free_pool; | ||
165 | u32 create_event; | ||
166 | u32 set_timer; | ||
167 | u32 wait_for_event; | ||
168 | u32 signal_event; | ||
169 | u32 close_event; | ||
170 | u32 check_event; | ||
171 | u32 install_protocol_interface; | ||
172 | u32 reinstall_protocol_interface; | ||
173 | u32 uninstall_protocol_interface; | ||
174 | u32 handle_protocol; | ||
175 | u32 __reserved; | ||
176 | u32 register_protocol_notify; | ||
177 | u32 locate_handle; | ||
178 | u32 locate_device_path; | ||
179 | u32 install_configuration_table; | ||
180 | u32 load_image; | ||
181 | u32 start_image; | ||
182 | u32 exit; | ||
183 | u32 unload_image; | ||
184 | u32 exit_boot_services; | ||
185 | u32 get_next_monotonic_count; | ||
186 | u32 stall; | ||
187 | u32 set_watchdog_timer; | ||
188 | u32 connect_controller; | ||
189 | u32 disconnect_controller; | ||
190 | u32 open_protocol; | ||
191 | u32 close_protocol; | ||
192 | u32 open_protocol_information; | ||
193 | u32 protocols_per_handle; | ||
194 | u32 locate_handle_buffer; | ||
195 | u32 locate_protocol; | ||
196 | u32 install_multiple_protocol_interfaces; | ||
197 | u32 uninstall_multiple_protocol_interfaces; | ||
198 | u32 calculate_crc32; | ||
199 | u32 copy_mem; | ||
200 | u32 set_mem; | ||
201 | u32 create_event_ex; | ||
202 | } __packed efi_boot_services_32_t; | ||
203 | |||
204 | typedef struct { | ||
205 | efi_table_hdr_t hdr; | ||
206 | u64 raise_tpl; | ||
207 | u64 restore_tpl; | ||
208 | u64 allocate_pages; | ||
209 | u64 free_pages; | ||
210 | u64 get_memory_map; | ||
211 | u64 allocate_pool; | ||
212 | u64 free_pool; | ||
213 | u64 create_event; | ||
214 | u64 set_timer; | ||
215 | u64 wait_for_event; | ||
216 | u64 signal_event; | ||
217 | u64 close_event; | ||
218 | u64 check_event; | ||
219 | u64 install_protocol_interface; | ||
220 | u64 reinstall_protocol_interface; | ||
221 | u64 uninstall_protocol_interface; | ||
222 | u64 handle_protocol; | ||
223 | u64 __reserved; | ||
224 | u64 register_protocol_notify; | ||
225 | u64 locate_handle; | ||
226 | u64 locate_device_path; | ||
227 | u64 install_configuration_table; | ||
228 | u64 load_image; | ||
229 | u64 start_image; | ||
230 | u64 exit; | ||
231 | u64 unload_image; | ||
232 | u64 exit_boot_services; | ||
233 | u64 get_next_monotonic_count; | ||
234 | u64 stall; | ||
235 | u64 set_watchdog_timer; | ||
236 | u64 connect_controller; | ||
237 | u64 disconnect_controller; | ||
238 | u64 open_protocol; | ||
239 | u64 close_protocol; | ||
240 | u64 open_protocol_information; | ||
241 | u64 protocols_per_handle; | ||
242 | u64 locate_handle_buffer; | ||
243 | u64 locate_protocol; | ||
244 | u64 install_multiple_protocol_interfaces; | ||
245 | u64 uninstall_multiple_protocol_interfaces; | ||
246 | u64 calculate_crc32; | ||
247 | u64 copy_mem; | ||
248 | u64 set_mem; | ||
249 | u64 create_event_ex; | ||
250 | } __packed efi_boot_services_64_t; | ||
251 | |||
156 | /* | 252 | /* |
157 | * EFI Boot Services table | 253 | * EFI Boot Services table |
158 | */ | 254 | */ |
@@ -231,6 +327,15 @@ typedef enum { | |||
231 | EfiPciIoAttributeOperationMaximum | 327 | EfiPciIoAttributeOperationMaximum |
232 | } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; | 328 | } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; |
233 | 329 | ||
330 | typedef struct { | ||
331 | u32 read; | ||
332 | u32 write; | ||
333 | } efi_pci_io_protocol_access_32_t; | ||
334 | |||
335 | typedef struct { | ||
336 | u64 read; | ||
337 | u64 write; | ||
338 | } efi_pci_io_protocol_access_64_t; | ||
234 | 339 | ||
235 | typedef struct { | 340 | typedef struct { |
236 | void *read; | 341 | void *read; |
@@ -238,6 +343,46 @@ typedef struct { | |||
238 | } efi_pci_io_protocol_access_t; | 343 | } efi_pci_io_protocol_access_t; |
239 | 344 | ||
240 | typedef struct { | 345 | typedef struct { |
346 | u32 poll_mem; | ||
347 | u32 poll_io; | ||
348 | efi_pci_io_protocol_access_32_t mem; | ||
349 | efi_pci_io_protocol_access_32_t io; | ||
350 | efi_pci_io_protocol_access_32_t pci; | ||
351 | u32 copy_mem; | ||
352 | u32 map; | ||
353 | u32 unmap; | ||
354 | u32 allocate_buffer; | ||
355 | u32 free_buffer; | ||
356 | u32 flush; | ||
357 | u32 get_location; | ||
358 | u32 attributes; | ||
359 | u32 get_bar_attributes; | ||
360 | u32 set_bar_attributes; | ||
361 | uint64_t romsize; | ||
362 | void *romimage; | ||
363 | } efi_pci_io_protocol_32; | ||
364 | |||
365 | typedef struct { | ||
366 | u64 poll_mem; | ||
367 | u64 poll_io; | ||
368 | efi_pci_io_protocol_access_64_t mem; | ||
369 | efi_pci_io_protocol_access_64_t io; | ||
370 | efi_pci_io_protocol_access_64_t pci; | ||
371 | u64 copy_mem; | ||
372 | u64 map; | ||
373 | u64 unmap; | ||
374 | u64 allocate_buffer; | ||
375 | u64 free_buffer; | ||
376 | u64 flush; | ||
377 | u64 get_location; | ||
378 | u64 attributes; | ||
379 | u64 get_bar_attributes; | ||
380 | u64 set_bar_attributes; | ||
381 | uint64_t romsize; | ||
382 | void *romimage; | ||
383 | } efi_pci_io_protocol_64; | ||
384 | |||
385 | typedef struct { | ||
241 | void *poll_mem; | 386 | void *poll_mem; |
242 | void *poll_io; | 387 | void *poll_io; |
243 | efi_pci_io_protocol_access_t mem; | 388 | efi_pci_io_protocol_access_t mem; |
@@ -292,6 +437,42 @@ typedef struct { | |||
292 | 437 | ||
293 | typedef struct { | 438 | typedef struct { |
294 | efi_table_hdr_t hdr; | 439 | efi_table_hdr_t hdr; |
440 | u32 get_time; | ||
441 | u32 set_time; | ||
442 | u32 get_wakeup_time; | ||
443 | u32 set_wakeup_time; | ||
444 | u32 set_virtual_address_map; | ||
445 | u32 convert_pointer; | ||
446 | u32 get_variable; | ||
447 | u32 get_next_variable; | ||
448 | u32 set_variable; | ||
449 | u32 get_next_high_mono_count; | ||
450 | u32 reset_system; | ||
451 | u32 update_capsule; | ||
452 | u32 query_capsule_caps; | ||
453 | u32 query_variable_info; | ||
454 | } efi_runtime_services_32_t; | ||
455 | |||
456 | typedef struct { | ||
457 | efi_table_hdr_t hdr; | ||
458 | u64 get_time; | ||
459 | u64 set_time; | ||
460 | u64 get_wakeup_time; | ||
461 | u64 set_wakeup_time; | ||
462 | u64 set_virtual_address_map; | ||
463 | u64 convert_pointer; | ||
464 | u64 get_variable; | ||
465 | u64 get_next_variable; | ||
466 | u64 set_variable; | ||
467 | u64 get_next_high_mono_count; | ||
468 | u64 reset_system; | ||
469 | u64 update_capsule; | ||
470 | u64 query_capsule_caps; | ||
471 | u64 query_variable_info; | ||
472 | } efi_runtime_services_64_t; | ||
473 | |||
474 | typedef struct { | ||
475 | efi_table_hdr_t hdr; | ||
295 | void *get_time; | 476 | void *get_time; |
296 | void *set_time; | 477 | void *set_time; |
297 | void *get_wakeup_time; | 478 | void *get_wakeup_time; |
@@ -485,6 +666,38 @@ struct efi_memory_map { | |||
485 | 666 | ||
486 | typedef struct { | 667 | typedef struct { |
487 | u32 revision; | 668 | u32 revision; |
669 | u32 parent_handle; | ||
670 | u32 system_table; | ||
671 | u32 device_handle; | ||
672 | u32 file_path; | ||
673 | u32 reserved; | ||
674 | u32 load_options_size; | ||
675 | u32 load_options; | ||
676 | u32 image_base; | ||
677 | __aligned_u64 image_size; | ||
678 | unsigned int image_code_type; | ||
679 | unsigned int image_data_type; | ||
680 | unsigned long unload; | ||
681 | } efi_loaded_image_32_t; | ||
682 | |||
683 | typedef struct { | ||
684 | u32 revision; | ||
685 | u64 parent_handle; | ||
686 | u64 system_table; | ||
687 | u64 device_handle; | ||
688 | u64 file_path; | ||
689 | u64 reserved; | ||
690 | u32 load_options_size; | ||
691 | u64 load_options; | ||
692 | u64 image_base; | ||
693 | __aligned_u64 image_size; | ||
694 | unsigned int image_code_type; | ||
695 | unsigned int image_data_type; | ||
696 | unsigned long unload; | ||
697 | } efi_loaded_image_64_t; | ||
698 | |||
699 | typedef struct { | ||
700 | u32 revision; | ||
488 | void *parent_handle; | 701 | void *parent_handle; |
489 | efi_system_table_t *system_table; | 702 | efi_system_table_t *system_table; |
490 | void *device_handle; | 703 | void *device_handle; |
@@ -511,6 +724,34 @@ typedef struct { | |||
511 | efi_char16_t filename[1]; | 724 | efi_char16_t filename[1]; |
512 | } efi_file_info_t; | 725 | } efi_file_info_t; |
513 | 726 | ||
727 | typedef struct { | ||
728 | u64 revision; | ||
729 | u32 open; | ||
730 | u32 close; | ||
731 | u32 delete; | ||
732 | u32 read; | ||
733 | u32 write; | ||
734 | u32 get_position; | ||
735 | u32 set_position; | ||
736 | u32 get_info; | ||
737 | u32 set_info; | ||
738 | u32 flush; | ||
739 | } efi_file_handle_32_t; | ||
740 | |||
741 | typedef struct { | ||
742 | u64 revision; | ||
743 | u64 open; | ||
744 | u64 close; | ||
745 | u64 delete; | ||
746 | u64 read; | ||
747 | u64 write; | ||
748 | u64 get_position; | ||
749 | u64 set_position; | ||
750 | u64 get_info; | ||
751 | u64 set_info; | ||
752 | u64 flush; | ||
753 | } efi_file_handle_64_t; | ||
754 | |||
514 | typedef struct _efi_file_handle { | 755 | typedef struct _efi_file_handle { |
515 | u64 revision; | 756 | u64 revision; |
516 | efi_status_t (*open)(struct _efi_file_handle *, | 757 | efi_status_t (*open)(struct _efi_file_handle *, |
@@ -809,6 +1050,17 @@ struct efivar_entry { | |||
809 | bool deleting; | 1050 | bool deleting; |
810 | }; | 1051 | }; |
811 | 1052 | ||
1053 | struct efi_simple_text_output_protocol_32 { | ||
1054 | u32 reset; | ||
1055 | u32 output_string; | ||
1056 | u32 test_string; | ||
1057 | }; | ||
1058 | |||
1059 | struct efi_simple_text_output_protocol_64 { | ||
1060 | u64 reset; | ||
1061 | u64 output_string; | ||
1062 | u64 test_string; | ||
1063 | }; | ||
812 | 1064 | ||
813 | struct efi_simple_text_output_protocol { | 1065 | struct efi_simple_text_output_protocol { |
814 | void *reset; | 1066 | void *reset; |