[PATCH v2 074/113] efi: flesh out EFI definitions in header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have a lot of function pointer members in the protocols, that were
defined as void pointers instead of properly prototyped function pointers.

Similarly, a lot of data types are defined to equivalent types that
aren't as descriptive, e.g. size_t vs ulong and s16 vs efi_char16_t.

Let's switch them over all at once. No functional change as the types
are either equivalent or were unused in the case of function pointers.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/clocksource/efi.c  |   4 +-
 drivers/serial/efi-stdio.c |   4 +-
 include/efi.h              | 115 ++++++++++++++++++++++---------------
 include/efi/efi-stdio.h    |   4 +-
 4 files changed, 74 insertions(+), 53 deletions(-)

diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi.c
index 11dbb6189786..1ac587a715f2 100644
--- a/drivers/clocksource/efi.c
+++ b/drivers/clocksource/efi.c
@@ -12,14 +12,14 @@
 #include <linux/err.h>
 
 static uint64_t ticks = 1;
-static void *efi_cs_evt;
+static struct efi_event *efi_cs_evt;
 
 static uint64_t efi_cs_read(void)
 {
 	return ticks;
 }
 
-static void efi_cs_inc(void *event, void *ctx)
+static void efi_cs_inc(struct efi_event *event, void *ctx)
 {
 	ticks++;
 }
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 235d67a303ed..92133f837838 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -79,9 +79,9 @@ static int xlate_keypress(struct efi_input_key *k)
 	return k->unicode_char & 0xff;
 }
 
-static void efi_wait_single_event(void *event)
+static void efi_wait_single_event(struct efi_event *event)
 {
-	unsigned long index;
+	size_t index;
 
 	/* wait until key is pressed */
 	BS->wait_for_event(1, &event, &index);
diff --git a/include/efi.h b/include/efi.h
index 7e8b7f0a49b8..08cb07c8b946 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -177,18 +177,20 @@ enum efi_timer_delay {
 	EFI_TIMER_RELATIVE = 2
 };
 
+struct efi_event;
+
 /*
  * EFI Boot Services table
  */
 struct efi_boot_services {
 	struct efi_table_hdr hdr;
-	void *raise_tpl;
-	void *restore_tpl;
+	efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
+	void (EFIAPI *restore_tpl)(unsigned long old_tpl);
 	efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
 				       efi_physical_addr_t *);
 	efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
-	efi_status_t (EFIAPI *get_memory_map)(unsigned long *, void *, unsigned long *,
-				       unsigned long *, u32 *);
+	efi_status_t (EFIAPI *get_memory_map)(size_t *, struct efi_memory_desc *,
+					      size_t *, size_t *, u32 *);
 	efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
 	efi_status_t (EFIAPI *free_pool)(void *);
 #define EFI_EVT_TIMER				0x80000000
@@ -203,33 +205,39 @@ struct efi_boot_services {
 #define EFI_TPL_NOTIFY		16
 #define EFI_TPL_HIGH_LEVEL	31
 	efi_status_t(EFIAPI *create_event)(u32 type , unsigned long tpl,
-			void (*fn) (void *event, void *ctx),
-			void *ctx, void **event);
-	efi_status_t(EFIAPI *set_timer)(void *event, enum efi_timer_delay type, uint64_t time);
-	efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events, void *event,
-			unsigned long *index);
-	void *signal_event;
-	efi_status_t(EFIAPI *close_event)(void *event);
-	void *check_event;
-	void *install_protocol_interface;
-	void *reinstall_protocol_interface;
-	void *uninstall_protocol_interface;
-	efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *, void **);
+			void (*fn) (struct efi_event *event, void *ctx),
+			void *ctx, struct efi_event **event);
+	efi_status_t(EFIAPI *set_timer)(struct efi_event *event, enum efi_timer_delay type, uint64_t time);
+	efi_status_t(EFIAPI *wait_for_event)(size_t number_of_events, struct efi_event **event,
+			size_t *index);
+	efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
+	efi_status_t(EFIAPI *close_event)(struct efi_event *event);
+#define EFI_NATIVE_INTERFACE	0x00000000
+	efi_status_t (EFIAPI *check_event)(struct efi_event *event);
+	efi_status_t (EFIAPI *install_protocol_interface)(efi_handle_t *handle, const efi_guid_t *protocol,
+			int protocol_interface_type, void *protocol_interface);
+	efi_status_t (EFIAPI *reinstall_protocol_interface)(efi_handle_t handle, const efi_guid_t *protocol,
+			void *old_interface, void *new_interface);
+	efi_status_t (EFIAPI *uninstall_protocol_interface)(efi_handle_t handle,
+			const efi_guid_t *protocol, void *protocol_interface);
+
+	efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, const efi_guid_t *, void **);
 	void *__reserved;
-	void *register_protocol_notify;
+	efi_status_t (EFIAPI *register_protocol_notify)(const efi_guid_t *protocol, struct efi_event *event,
+			void **registration);
 	efi_status_t (EFIAPI *locate_handle) (enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
-			unsigned long *buffer_size, efi_handle_t *buffer);
-	efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
+			const efi_guid_t *protocol, void *search_key,
+			size_t *buffer_size, efi_handle_t *buffer);
+	efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
 			struct efi_device_path **device_path, efi_handle_t *device);
-	void *install_configuration_table;
+	efi_status_t (EFIAPI *install_configuration_table)(const efi_guid_t *guid, void *table);
 	efi_status_t (EFIAPI *load_image)(bool boot_policiy, efi_handle_t parent_image,
 			struct efi_device_path *file_path, void *source_buffer,
 			unsigned long source_size, efi_handle_t *image);
 	efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
-			unsigned long *exitdata_size, s16 **exitdata);
+			size_t *exitdata_size, u16 **exitdata);
 	efi_status_t(EFIAPI *exit)(efi_handle_t handle,  efi_status_t exit_status,
-			unsigned long exitdata_size, s16 *exitdata);
+			unsigned long exitdata_size, u16 *exitdata);
 	efi_status_t (EFIAPI *unload_image)(efi_handle_t handle);
 	efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
 	void *get_next_monotonic_count;
@@ -237,12 +245,13 @@ struct efi_boot_services {
 	efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
 						  uint64_t watchdog_code,
 						  unsigned long data_size,
-						  s16 *watchdog_data);
+						  u16 *watchdog_data);
 	efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
 			efi_handle_t *driver_image_handle,
 			struct efi_device_path *remaining_device_path,
 			bool Recursive);
-	void *disconnect_controller;
+	efi_status_t (EFIAPI *disconnect_controller)(efi_handle_t controller_handle,
+			efi_handle_t driver_image_handle, efi_handle_t child_handle);
 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
@@ -264,12 +273,14 @@ struct efi_boot_services {
 			enum efi_locate_search_type search_type,
 			const efi_guid_t *protocol, void *search_key,
 			unsigned long *no_handles, efi_handle_t **buffer);
-	void *locate_protocol;
-	void *install_multiple_protocol_interfaces;
-	void *uninstall_multiple_protocol_interfaces;
-	void *calculate_crc32;
-	void *copy_mem;
-	void *set_mem;
+	efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
+			void *registration, void **protocol_interface);
+	efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(efi_handle_t *handle, ...);
+	efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(efi_handle_t handle, ...);
+	efi_status_t (EFIAPI *calculate_crc32)(const void *data,
+			unsigned long data_size, uint32_t *crc32);
+	void (EFIAPI *copy_mem)(void *destination, const void *source, unsigned long length);
+	void (EFIAPI *set_mem)(void *buffer, unsigned long size, uint8_t value);
 	void *create_event_ex;
 };
 
@@ -281,7 +292,8 @@ extern struct efi_boot_services *BS;
 enum efi_reset_type {
 	EFI_RESET_COLD = 0,
 	EFI_RESET_WARM = 1,
-	EFI_RESET_SHUTDOWN = 2
+	EFI_RESET_SHUTDOWN = 2,
+	EFI_RESET_PLATFORM_SPECIFIC = 3,
 };
 
 /*
@@ -292,19 +304,24 @@ enum efi_reset_type {
 
 struct efi_runtime_services {
 	struct efi_table_hdr hdr;
-	void *get_time;
-	void *set_time;
-	void *get_wakeup_time;
-	void *set_wakeup_time;
-	void *set_virtual_address_map;
-	void *convert_pointer;
-	efi_status_t (EFIAPI *get_variable)(s16 *variable_name, efi_guid_t *vendor,
+	efi_status_t (EFIAPI *get_time)(struct efi_time *time,
+					struct efi_time_cap *capabilities);
+	efi_status_t (EFIAPI *set_time)(struct efi_time *time);
+	efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
+				       struct efi_time *time);
+	efi_status_t (EFIAPI *set_wakeup_time)(char enabled, struct efi_time *time);
+	efi_status_t (EFIAPI *set_virtual_address_map)(size_t memory_map_size,
+				       size_t descriptor_size,
+				       uint32_t descriptor_version,
+				       struct efi_memory_desc *virtmap);
+	efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
+	efi_status_t (EFIAPI *get_variable)(efi_char16_t *variable_name, const efi_guid_t *vendor,
 			u32 *Attributes, unsigned long *data_size, void *data);
 	efi_status_t (EFIAPI *get_next_variable)(unsigned long *variable_name_size,
 			s16 *variable_name, efi_guid_t *vendor);
 	efi_status_t (EFIAPI *set_variable)(s16 *variable_name, efi_guid_t *vendor,
 			u32 Attributes, unsigned long data_size, void *data);
-	void *get_next_high_mono_count;
+	efi_status_t (EFIAPI *get_next_high_mono_count)(uint32_t *high_count);
 	void (EFIAPI *reset_system)(enum efi_reset_type reset_type, efi_status_t reset_status,
 			unsigned long data_size, void *reset_data);
 	void *update_capsule;
@@ -607,14 +624,14 @@ struct efi_config_table {
 
 struct efi_system_table {
 	struct efi_table_hdr hdr;
-	unsigned long fw_vendor;	/* physical addr of CHAR16 vendor string */
+	efi_char16_t *fw_vendor;	/* physical addr of CHAR16 vendor string */
 	u32 fw_revision;
 	efi_handle_t con_in_handle;
 	struct efi_simple_text_input_protocol *con_in;
 	efi_handle_t con_out_handle;
 	struct efi_simple_text_output_protocol *con_out;
 	efi_handle_t stderr_handle;
-	unsigned long std_err;
+	struct efi_simple_text_output_protocol *std_err;
 	struct efi_runtime_services *runtime;
 	struct efi_boot_services *boottime;
 	unsigned long nr_tables;
@@ -634,7 +651,7 @@ struct efi_loaded_image {
 	__aligned_u64 image_size;
 	unsigned int image_code_type;
 	unsigned int image_data_type;
-	unsigned long unload;
+	efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
 };
 
 __attribute__((noreturn)) void efi_main(efi_handle_t, struct efi_system_table *);
@@ -700,9 +717,12 @@ struct simple_text_output_mode {
 };
 
 struct efi_simple_text_output_protocol {
-	void *reset;
-	efi_status_t (EFIAPI *output_string)(void *, void *);
-	void *test_string;
+	efi_status_t (EFIAPI *reset)(
+			struct efi_simple_text_output_protocol *this,
+			char extended_verification);
+	efi_status_t (EFIAPI *output_string)(struct efi_simple_text_output_protocol *this, const efi_char16_t *str);
+	efi_status_t (EFIAPI *test_string)(struct efi_simple_text_output_protocol *this,
+			const efi_char16_t *str);
 
 	efi_status_t(EFIAPI *query_mode)(struct efi_simple_text_output_protocol *this,
 			unsigned long mode_number, unsigned long *columns, unsigned long *rows);
@@ -713,7 +733,8 @@ struct efi_simple_text_output_protocol {
 	efi_status_t(EFIAPI *clear_screen) (struct efi_simple_text_output_protocol *this);
 	efi_status_t(EFIAPI *set_cursor_position) (struct efi_simple_text_output_protocol *this,
 			unsigned long column, unsigned long row);
-	efi_status_t(EFIAPI *enable_cursor)(void *, bool enable);
+	efi_status_t(EFIAPI *enable_cursor)(struct efi_simple_text_output_protocol *this,
+			bool enable);
 	struct simple_text_output_mode *mode;
 };
 
diff --git a/include/efi/efi-stdio.h b/include/efi/efi-stdio.h
index 623b42c10f19..0b3a184a78a8 100644
--- a/include/efi/efi-stdio.h
+++ b/include/efi/efi-stdio.h
@@ -18,7 +18,7 @@ struct efi_key_state {
 
 struct efi_input_key {
 	u16 scan_code;
-	s16 unicode_char;
+	efi_char16_t unicode_char;
 };
 
 struct efi_key_data {
@@ -55,7 +55,7 @@ typedef efi_status_t (EFIAPI *efi_unregister_keystroke_notify)(
 struct efi_simple_text_input_ex_protocol {
 	efi_input_reset_ex reset;
 	efi_input_read_key_ex read_key_stroke_ex;
-	void *wait_for_key_ex;
+	struct efi_event *wait_for_key_ex;
 	efi_set_state set_state;
 	efi_register_keystroke_notify register_key_notify;
 	efi_unregister_keystroke_notify unregister_key_notify;
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux