summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_debug.c
diff options
context:
space:
mode:
authorMichael Brown2013-03-15 20:09:45 +0100
committerMichael Brown2013-03-20 00:21:15 +0100
commit6b9b44319fa1c50d9c91c80cd266b15cbd173ada (patch)
treeb0c24419a3b7794cbb2698cce8da8e7cbeee97e2 /src/interface/efi/efi_debug.c
parent[efi] Fix minor typos in efi_image.c (diff)
downloadipxe-6b9b44319fa1c50d9c91c80cd266b15cbd173ada.tar.gz
ipxe-6b9b44319fa1c50d9c91c80cd266b15cbd173ada.tar.xz
ipxe-6b9b44319fa1c50d9c91c80cd266b15cbd173ada.zip
[efi] Add EFI-specific debugging macros
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_debug.c')
-rw-r--r--src/interface/efi/efi_debug.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c
new file mode 100644
index 00000000..7f3c115d
--- /dev/null
+++ b/src/interface/efi/efi_debug.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/**
+ * @file
+ *
+ * EFI debugging utilities
+ *
+ */
+
+#include <stdio.h>
+#include <ipxe/efi/efi.h>
+#include <ipxe/efi/efi_driver.h>
+#include <ipxe/efi/Protocol/DevicePath.h>
+#include <ipxe/efi/Protocol/DevicePathToText.h>
+
+/** Device path to text protocol */
+static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt;
+EFI_REQUIRE_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt );
+
+/**
+ * Print list of protocol handlers attached to a handle
+ *
+ * @v handle EFI handle
+ */
+void dbg_efi_protocols ( EFI_HANDLE handle ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ EFI_GUID **protocols;
+ UINTN count;
+ unsigned int i;
+ EFI_STATUS efirc;
+
+ /* Retrieve list of protocols */
+ if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
+ &count ) ) != 0 ) {
+ printf ( "EFI could not retrieve protocols for %p: %s\n",
+ handle, efi_strerror ( efirc ) );
+ return;
+ }
+
+ /* Dump list of protocols */
+ for ( i = 0 ; i < count ; i++ ) {
+ printf ( "%s\n", uuid_ntoa ( ( union uuid * ) protocols[i] ) );
+ }
+
+ /* Free list */
+ bs->FreePool ( protocols );
+}
+
+/**
+ * Print device path
+ *
+ * @v path Device path
+ */
+void dbg_efi_devpath ( EFI_DEVICE_PATH_PROTOCOL *path ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ EFI_DEVICE_PATH_PROTOCOL *end;
+ CHAR16 *text;
+ size_t len;
+
+ /* Convert path to a textual representation */
+ text = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
+ if ( ! text ) {
+ printf ( "<cannot convert>:\n" );
+ end = efi_devpath_end ( path );
+ len = ( ( ( void * ) end ) - ( ( void * ) path ) +
+ sizeof ( *end ) );
+ dbg_hex_dump_da ( 0, path, len );
+ return;
+ }
+
+ /* Print path */
+ printf ( "%ls", text );
+
+ /* Free path */
+ bs->FreePool ( text );
+}