[U-Boot] [PATCH 14/23] efi_loader: pass GUIDs as const efi_guid_t *

Heinrich Schuchardt xypron.glpk at gmx.de
Sat Aug 26 22:53:23 UTC 2017


We need to call some boottime services internally.
Our GUIDs are stored as const efi_guid_t *.

The boottime services never change GUIDs.
So we can define the parameters as const efi_guid_t *.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 include/efi_api.h             | 44 +++++++++++++++++++++----------------------
 include/efi_loader.h          |  4 ++--
 lib/efi_loader/efi_boottime.c | 37 ++++++++++++++++++------------------
 3 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index ec1b321e8e..8efc8dfab8 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -74,25 +74,25 @@ struct efi_boot_services {
 	efi_status_t (EFIAPI *close_event)(struct efi_event *event);
 	efi_status_t (EFIAPI *check_event)(struct efi_event *event);
 #define EFI_NATIVE_INTERFACE	0x00000000
-	efi_status_t (EFIAPI *install_protocol_interface)(
-			void **handle, efi_guid_t *protocol,
+	efi_status_t (EFIAPI * install_protocol_interface)(
+			void **handle, const efi_guid_t *protocol,
 			int protocol_interface_type, void *protocol_interface);
-	efi_status_t (EFIAPI *reinstall_protocol_interface)(
-			void *handle, efi_guid_t *protocol,
+	efi_status_t (EFIAPI * reinstall_protocol_interface)(
+			void *handle, const efi_guid_t *protocol,
 			void *old_interface, void *new_interface);
-	efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
-			efi_guid_t *protocol, void *protocol_interface);
-	efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
-					       void **);
+	efi_status_t (EFIAPI * uninstall_protocol_interface)(void *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;
-	efi_status_t (EFIAPI *register_protocol_notify)(
-			efi_guid_t *protocol, struct efi_event *event,
+	efi_status_t (EFIAPI * register_protocol_notify)(
+			const efi_guid_t *protocol, struct efi_event *event,
 			void **registration);
-	efi_status_t (EFIAPI *locate_handle)(
+	efi_status_t (EFIAPI * locate_handle)(
 			enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
+			const 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,
+	efi_status_t (EFIAPI * locate_device_path)(const efi_guid_t *protocol,
 			struct efi_device_path **device_path,
 			efi_handle_t *device);
 	efi_status_t (EFIAPI *install_configuration_table)(
@@ -128,25 +128,25 @@ struct efi_boot_services {
 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
-	efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
-			efi_guid_t *protocol, void **interface,
+	efi_status_t (EFIAPI * open_protocol)(efi_handle_t handle,
+			const efi_guid_t *protocol, void **interface,
 			efi_handle_t agent_handle,
 			efi_handle_t controller_handle, u32 attributes);
-	efi_status_t (EFIAPI *close_protocol)(void *handle,
-			efi_guid_t *protocol, void *agent_handle,
+	efi_status_t (EFIAPI * close_protocol)(void *handle,
+			const efi_guid_t *protocol, void *agent_handle,
 			void *controller_handle);
-	efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
-			efi_guid_t *protocol,
+	efi_status_t(EFIAPI * open_protocol_information)(efi_handle_t handle,
+			const efi_guid_t *protocol,
 			struct efi_open_protocol_info_entry **entry_buffer,
 			unsigned long *entry_count);
 	efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
 			efi_guid_t ***protocol_buffer,
 			unsigned long *protocols_buffer_count);
-	efi_status_t (EFIAPI *locate_handle_buffer) (
+	efi_status_t (EFIAPI * locate_handle_buffer) (
 			enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
+			const efi_guid_t *protocol, void *search_key,
 			unsigned long *no_handles, efi_handle_t **buffer);
-	efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol,
+	efi_status_t (EFIAPI * locate_protocol)(const efi_guid_t *protocol,
 			void *registration, void **protocol_interface);
 	efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
 			void **handle, ...);
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2a98bf66b8..9c68246c7c 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -182,12 +182,12 @@ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
 /* Call this to signal an event */
 void efi_signal_event(struct efi_event *event);
 /* Call this with EFI_CALL to close a protocol */
-efi_status_t EFIAPI efi_close_protocol(void *handle, efi_guid_t *protocol,
+efi_status_t EFIAPI efi_close_protocol(void *handle, const efi_guid_t *protocol,
 				       void *agent_handle,
 				       void *controller_handle);
 /* Call this with EFI_CALL to open a protocol */
 efi_status_t EFIAPI efi_open_protocol(
-			void *handle, efi_guid_t *protocol,
+			void *handle, const efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes);
 
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index ad8733d3e5..5a73ea5cd0 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -470,7 +470,8 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
 	return EFI_EXIT(EFI_INVALID_PARAMETER);
 }
 
-static efi_status_t efi_search_protocol(void *handle, efi_guid_t *protocol_guid,
+static efi_status_t efi_search_protocol(void *handle,
+					const efi_guid_t *protocol_guid,
 					struct efi_handler **handler)
 {
 	struct efi_object *efiobj;
@@ -496,7 +497,7 @@ static efi_status_t efi_search_protocol(void *handle, efi_guid_t *protocol_guid,
 }
 
 static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
-			efi_guid_t *protocol, int protocol_interface_type,
+			const efi_guid_t *protocol, int protocol_interface_type,
 			void *protocol_interface)
 {
 	int i;
@@ -551,7 +552,7 @@ out:
 }
 
 static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
-			efi_guid_t *protocol, void *old_interface,
+			const efi_guid_t *protocol, void *old_interface,
 			void *new_interface)
 {
 	EFI_ENTRY("%p, %p, %p, %p", handle, protocol, old_interface,
@@ -560,7 +561,7 @@ static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
 }
 
 static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
-			efi_guid_t *protocol, void *protocol_interface)
+			const efi_guid_t *protocol, void *protocol_interface)
 {
 	struct efi_handler *handler;
 	efi_status_t r;
@@ -589,16 +590,16 @@ out:
 	return EFI_EXIT(r);
 }
 
-static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol,
-							struct efi_event *event,
-							void **registration)
+static efi_status_t EFIAPI efi_register_protocol_notify(
+			const efi_guid_t *protocol, struct efi_event *event,
+			void **registration)
 {
 	EFI_ENTRY("%p, %p, %p", protocol, event, registration);
 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
 }
 
 static int efi_search(enum efi_locate_search_type search_type,
-		      efi_guid_t *protocol, void *search_key,
+		      const efi_guid_t *protocol, void *search_key,
 		      struct efi_object *efiobj)
 {
 	int i;
@@ -623,7 +624,7 @@ static int efi_search(enum efi_locate_search_type search_type,
 
 static efi_status_t efi_locate_handle(
 			enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
+			const efi_guid_t *protocol, void *search_key,
 			unsigned long *buffer_size, efi_handle_t *buffer)
 {
 	struct efi_object *efiobj;
@@ -680,7 +681,7 @@ static efi_status_t efi_locate_handle(
 
 static efi_status_t EFIAPI efi_locate_handle_ext(
 			enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
+			const efi_guid_t *protocol, void *search_key,
 			unsigned long *buffer_size, efi_handle_t *buffer)
 {
 	EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
@@ -690,7 +691,7 @@ static efi_status_t EFIAPI efi_locate_handle_ext(
 			buffer_size, buffer));
 }
 
-static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
+static efi_status_t EFIAPI efi_locate_device_path(const efi_guid_t *protocol,
 			struct efi_device_path **device_path,
 			efi_handle_t *device)
 {
@@ -939,7 +940,7 @@ static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,
 	return EFI_EXIT(EFI_INVALID_PARAMETER);
 }
 
-efi_status_t EFIAPI efi_close_protocol(void *handle, efi_guid_t *protocol,
+efi_status_t EFIAPI efi_close_protocol(void *handle, const efi_guid_t *protocol,
 				       void *agent_handle,
 				       void *controller_handle)
 {
@@ -980,7 +981,7 @@ out:
 }
 
 static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
-			efi_guid_t *protocol,
+			const efi_guid_t *protocol,
 			struct efi_open_protocol_info_entry **entry_buffer,
 			unsigned long *entry_count)
 {
@@ -1097,7 +1098,7 @@ static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
 
 static efi_status_t EFIAPI efi_locate_handle_buffer(
 			enum efi_locate_search_type search_type,
-			efi_guid_t *protocol, void *search_key,
+			const efi_guid_t *protocol, void *search_key,
 			unsigned long *no_handles, efi_handle_t **buffer)
 {
 	efi_status_t r;
@@ -1128,7 +1129,7 @@ out:
 	return EFI_EXIT(r);
 }
 
-static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
+static efi_status_t EFIAPI efi_locate_protocol(const efi_guid_t *protocol,
 					       void *registration,
 					       void **protocol_interface)
 {
@@ -1167,7 +1168,7 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
 	EFI_ENTRY("%p", handle);
 
 	va_list argptr;
-	efi_guid_t *protocol;
+	const efi_guid_t *protocol;
 	void *protocol_interface;
 	efi_status_t r = EFI_SUCCESS;
 	int i = 0;
@@ -1326,7 +1327,7 @@ static efi_status_t efi_protocol_open(
 }
 
 efi_status_t EFIAPI efi_open_protocol(
-			void *handle, efi_guid_t *protocol,
+			void *handle, const efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes)
 {
@@ -1372,7 +1373,7 @@ out:
 }
 
 static efi_status_t EFIAPI efi_handle_protocol(void *handle,
-					       efi_guid_t *protocol,
+					       const efi_guid_t *protocol,
 					       void **protocol_interface)
 {
 	return efi_open_protocol(handle, protocol, protocol_interface, NULL,
-- 
2.14.1



More information about the U-Boot mailing list