}
}
+/**
+ * Convert EFI boolean to text
+ *
+ * @v boolean Boolean value
+ * @ret text Boolean value text
+ */
+static const char * efi_boolean ( BOOLEAN boolean ) {
+
+ return ( boolean ? "TRUE" : "FALSE" );
+}
+
+/**
+ * Wrap InstallProtocolInterface()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_install_protocol_interface_wrapper ( EFI_HANDLE *handle, EFI_GUID *protocol,
+ EFI_INTERFACE_TYPE interface_type,
+ VOID *interface ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "InstallProtocolInterface ( %s, %s, %d, %p ) ",
+ efi_handle_name ( *handle ), efi_guid_ntoa ( protocol ),
+ interface_type, interface );
+ efirc = bs->InstallProtocolInterface ( handle, protocol, interface_type,
+ interface );
+ DBGC ( colour, "= %s ( %s ) -> %p\n",
+ efi_status ( efirc ), efi_handle_name ( *handle ), retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap ReinstallProtocolInterface()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_reinstall_protocol_interface_wrapper ( EFI_HANDLE handle,
+ EFI_GUID *protocol,
+ VOID *old_interface,
+ VOID *new_interface ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "ReinstallProtocolInterface ( %s, %s, %p, %p ) ",
+ efi_handle_name ( handle ), efi_guid_ntoa ( protocol ),
+ old_interface, new_interface );
+ efirc = bs->ReinstallProtocolInterface ( handle, protocol,
+ old_interface, new_interface );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap UninstallProtocolInterface()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_uninstall_protocol_interface_wrapper ( EFI_HANDLE handle,
+ EFI_GUID *protocol,
+ VOID *interface ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "UninstallProtocolInterface ( %s, %s, %p ) ",
+ efi_handle_name ( handle ), efi_guid_ntoa ( protocol ),
+ interface );
+ efirc = bs->UninstallProtocolInterface ( handle, protocol, interface );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
/**
* Wrap HandleProtocol()
*
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
- DBGC ( colour, "HandleProtocol ( %s, %s, ... ) ",
+ DBGC ( colour, "HandleProtocol ( %s, %s ) ",
efi_handle_name ( handle ), efi_guid_ntoa ( protocol ) );
efirc = bs->HandleProtocol ( handle, protocol, interface );
DBGC ( colour, "= %s ( %p ) -> %p\n",
UINTN *buffer_size, EFI_HANDLE *buffer ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
void *retaddr = __builtin_return_address ( 0 );
+ unsigned int i;
EFI_STATUS efirc;
- DBGC ( colour, "LocateHandle ( %d, %s, ..., %zd, ... ) ", search_type,
- efi_guid_ntoa ( protocol ), ( ( size_t ) *buffer_size ) );
+ DBGC ( colour, "LocateHandle ( %s, %s, %p, %zd ) ",
+ efi_locate_search_type_name ( search_type ),
+ efi_guid_ntoa ( protocol ), search_key,
+ ( ( size_t ) *buffer_size ) );
efirc = bs->LocateHandle ( search_type, protocol, search_key,
buffer_size, buffer );
- DBGC ( colour, "= %s ( %zd ) -> %p\n",
- efi_status ( efirc ), ( ( size_t ) *buffer_size ), retaddr );
+ DBGC ( colour, "= %s ( %zd", efi_status ( efirc ),
+ ( ( size_t ) *buffer_size ) );
+ if ( efirc == 0 ) {
+ DBGC ( colour, ", {" );
+ for ( i = 0; i < ( *buffer_size / sizeof ( buffer[0] ) ); i++ ){
+ DBGC ( colour, "%s%s", ( i ? ", " : " " ),
+ efi_handle_name ( buffer[i] ) );
+ }
+ DBGC ( colour, " }" );
+ }
+ DBGC ( colour, " ) -> %p\n", retaddr );
return efirc;
}
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
- DBGC ( colour, "LocateDevicePath ( %s, %s, ... ) ",
+ DBGC ( colour, "LocateDevicePath ( %s, %s ) ",
efi_guid_ntoa ( protocol ), efi_devpath_text ( *device_path ) );
efirc = bs->LocateDevicePath ( protocol, device_path, device );
DBGC ( colour, "= %s ( %s, ",
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
- DBGC ( colour, "LoadImage ( %d, %s, ", boot_policy,
+ DBGC ( colour, "LoadImage ( %s, %s, ", efi_boolean ( boot_policy ),
efi_handle_name ( parent_image_handle ) );
- DBGC ( colour, "%s, %p, %#llx, ... ) ",
+ DBGC ( colour, "%s, %p, %#llx ) ",
efi_devpath_text ( device_path ), source_buffer,
( ( unsigned long long ) source_size ) );
efirc = bs->LoadImage ( boot_policy, parent_image_handle, device_path,
return efirc;
}
+/**
+ * Wrap StartImage()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_start_image_wrapper ( EFI_HANDLE image_handle, UINTN *exit_data_size,
+ CHAR16 **exit_data ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "StartImage ( %s ) ", efi_handle_name ( image_handle ) );
+ efirc = bs->StartImage ( image_handle, exit_data_size, exit_data );
+ DBGC ( colour, "= %s", efi_status ( efirc ) );
+ if ( ( efirc != 0 ) && exit_data && *exit_data_size )
+ DBGC ( colour, " ( \"%ls\" )", *exit_data );
+ DBGC ( colour, " -> %p\n", retaddr );
+ if ( ( efirc != 0 ) && exit_data && *exit_data_size )
+ DBGC_HD ( colour, *exit_data, *exit_data_size );
+ return efirc;
+}
+
+/**
+ * Wrap Exit()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_exit_wrapper ( EFI_HANDLE image_handle, EFI_STATUS exit_status,
+ UINTN exit_data_size, CHAR16 *exit_data ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ if ( ( exit_status != 0 ) && exit_data && exit_data_size )
+ DBGC_HD ( colour, exit_data, exit_data_size );
+ DBGC ( colour, "Exit ( %s, %s",
+ efi_handle_name ( image_handle ), efi_status ( exit_status ) );
+ if ( ( exit_status != 0 ) && exit_data && exit_data_size )
+ DBGC ( colour, ", \"%ls\"", exit_data );
+ DBGC ( colour, " ) " );
+ efirc = bs->Exit ( image_handle, exit_status, exit_data_size,
+ exit_data );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap UnloadImage()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_unload_image_wrapper ( EFI_HANDLE image_handle ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "UnloadImage ( %s ) ",
+ efi_handle_name ( image_handle ) );
+ efirc = bs->UnloadImage ( image_handle );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
/**
* Wrap ExitBootServices()
*
return efirc;
}
+/**
+ * Wrap ConnectController()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_connect_controller_wrapper ( EFI_HANDLE controller_handle,
+ EFI_HANDLE *driver_image_handle,
+ EFI_DEVICE_PATH_PROTOCOL *remaining_path,
+ BOOLEAN recursive ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_HANDLE *tmp;
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "ConnectController ( %s, {",
+ efi_handle_name ( controller_handle ) );
+ if ( driver_image_handle ) {
+ for ( tmp = driver_image_handle ; *tmp ; tmp++ ) {
+ DBGC ( colour, "%s%s",
+ ( ( tmp == driver_image_handle ) ? " " : ", " ),
+ efi_handle_name ( *tmp ) );
+ }
+ }
+ DBGC ( colour, " }, %s, %s ) ", efi_devpath_text ( remaining_path ),
+ efi_boolean ( recursive ) );
+ efirc = bs->ConnectController ( controller_handle, driver_image_handle,
+ remaining_path, recursive );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap DisconnectController()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_disconnect_controller_wrapper ( EFI_HANDLE controller_handle,
+ EFI_HANDLE driver_image_handle,
+ EFI_HANDLE child_handle ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "DisconnectController ( %s",
+ efi_handle_name ( controller_handle ) );
+ DBGC ( colour, ", %s", efi_handle_name ( driver_image_handle ) );
+ DBGC ( colour, ", %s ) ", efi_handle_name ( child_handle ) );
+ efirc = bs->DisconnectController ( controller_handle,
+ driver_image_handle,
+ child_handle );
+ DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
/**
* Wrap OpenProtocol()
*
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
- DBGC ( colour, "OpenProtocol ( %s, %s, ..., ",
+ DBGC ( colour, "OpenProtocol ( %s, %s, ",
efi_handle_name ( handle ), efi_guid_ntoa ( protocol ) );
DBGC ( colour, "%s, ", efi_handle_name ( agent_handle ) );
- DBGC ( colour, "%s, %#x ) ",
- efi_handle_name ( controller_handle ), attributes );
+ DBGC ( colour, "%s, %s ) ", efi_handle_name ( controller_handle ),
+ efi_open_attributes_name ( attributes ) );
efirc = bs->OpenProtocol ( handle, protocol, interface, agent_handle,
controller_handle, attributes );
DBGC ( colour, "= %s ( %p ) -> %p\n",
return efirc;
}
+/**
+ * Wrap CloseProtocol()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_close_protocol_wrapper ( EFI_HANDLE handle, EFI_GUID *protocol,
+ EFI_HANDLE agent_handle,
+ EFI_HANDLE controller_handle ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "CloseProtocol ( %s, %s, ",
+ efi_handle_name ( handle ), efi_guid_ntoa ( protocol ) );
+ DBGC ( colour, "%s, ", efi_handle_name ( agent_handle ) );
+ DBGC ( colour, "%s ) ", efi_handle_name ( controller_handle ) );
+ efirc = bs->CloseProtocol ( handle, protocol, agent_handle,
+ controller_handle );
+ DBGC ( colour, "= %s -> %p\n",
+ efi_status ( efirc ), retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap ProtocolsPerHandle()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_protocols_per_handle_wrapper ( EFI_HANDLE handle,
+ EFI_GUID ***protocol_buffer,
+ UINTN *protocol_buffer_count ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ unsigned int i;
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "ProtocolsPerHandle ( %s ) ",
+ efi_handle_name ( handle ) );
+ efirc = bs->ProtocolsPerHandle ( handle, protocol_buffer,
+ protocol_buffer_count );
+ DBGC ( colour, "= %s", efi_status ( efirc ) );
+ if ( efirc == 0 ) {
+ DBGC ( colour, " ( {" );
+ for ( i = 0 ; i < *protocol_buffer_count ; i++ ) {
+ DBGC ( colour, "%s%s", ( i ? ", " : " " ),
+ efi_guid_ntoa ( (*protocol_buffer)[i] ) );
+ }
+ DBGC ( colour, " } )" );
+ }
+ DBGC ( colour, " -> %p\n", retaddr );
+ return efirc;
+}
+
+/**
+ * Wrap LocateHandleBuffer()
+ *
+ */
+static EFI_STATUS EFIAPI
+efi_locate_handle_buffer_wrapper ( EFI_LOCATE_SEARCH_TYPE search_type,
+ EFI_GUID *protocol, VOID *search_key,
+ UINTN *no_handles, EFI_HANDLE **buffer ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ void *retaddr = __builtin_return_address ( 0 );
+ unsigned int i;
+ EFI_STATUS efirc;
+
+ DBGC ( colour, "LocateHandleBuffer ( %s, %s, %p ) ",
+ efi_locate_search_type_name ( search_type ),
+ efi_guid_ntoa ( protocol ), search_key );
+ efirc = bs->LocateHandleBuffer ( search_type, protocol, search_key,
+ no_handles, buffer );
+ DBGC ( colour, "= %s", efi_status ( efirc ) );
+ if ( efirc == 0 ) {
+ DBGC ( colour, " ( %d, {", ( ( unsigned int ) *no_handles ) );
+ for ( i = 0 ; i < *no_handles ; i++ ) {
+ DBGC ( colour, "%s%s", ( i ? ", " : " " ),
+ efi_handle_name ( (*buffer)[i] ) );
+ }
+ DBGC ( colour, " } )" );
+ }
+ DBGC ( colour, " -> %p\n", retaddr );
+ return efirc;
+}
+
/**
* Wrap LocateProtocol()
*
void *retaddr = __builtin_return_address ( 0 );
EFI_STATUS efirc;
- DBGC ( colour, "LocateProtocol ( %s, %p, ... ) ",
+ DBGC ( colour, "LocateProtocol ( %s, %p ) ",
efi_guid_ntoa ( protocol ), registration );
efirc = bs->LocateProtocol ( protocol, registration, interface );
DBGC ( colour, "= %s ( %p ) -> %p\n",
sizeof ( efi_systab_wrapper ) );
memcpy ( &efi_bs_wrapper, bs, sizeof ( efi_bs_wrapper ) );
efi_systab_wrapper.BootServices = &efi_bs_wrapper;
+ efi_bs_wrapper.InstallProtocolInterface
+ = efi_install_protocol_interface_wrapper;
+ efi_bs_wrapper.ReinstallProtocolInterface
+ = efi_reinstall_protocol_interface_wrapper;
+ efi_bs_wrapper.UninstallProtocolInterface
+ = efi_uninstall_protocol_interface_wrapper;
efi_bs_wrapper.HandleProtocol = efi_handle_protocol_wrapper;
efi_bs_wrapper.LocateHandle = efi_locate_handle_wrapper;
efi_bs_wrapper.LocateDevicePath = efi_locate_device_path_wrapper;
efi_bs_wrapper.LoadImage = efi_load_image_wrapper;
+ efi_bs_wrapper.StartImage = efi_start_image_wrapper;
+ efi_bs_wrapper.Exit = efi_exit_wrapper;
+ efi_bs_wrapper.UnloadImage = efi_unload_image_wrapper;
efi_bs_wrapper.ExitBootServices = efi_exit_boot_services_wrapper;
+ efi_bs_wrapper.ConnectController
+ = efi_connect_controller_wrapper;
+ efi_bs_wrapper.DisconnectController
+ = efi_disconnect_controller_wrapper;
efi_bs_wrapper.OpenProtocol = efi_open_protocol_wrapper;
+ efi_bs_wrapper.CloseProtocol = efi_close_protocol_wrapper;
+ efi_bs_wrapper.ProtocolsPerHandle
+ = efi_protocols_per_handle_wrapper;
+ efi_bs_wrapper.LocateHandleBuffer
+ = efi_locate_handle_buffer_wrapper;
efi_bs_wrapper.LocateProtocol = efi_locate_protocol_wrapper;
/* Open loaded image protocol */