From c0be2c2099805c621f27d5b3ced224db437a582c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 22 Jul 2012 19:59:06 +0200 Subject: [PATCH 015/364] New command `lsefi'. * grub-core/Makefile.core.def (lsefi): New module. * grub-core/commands/efi/lsefi.c: New file. * include/grub/efi/api.h: Add more GUIDs. --- ChangeLog | 8 +++ grub-core/Makefile.core.def | 6 ++ grub-core/commands/efi/lsefi.c | 153 +++++++++++++++++++++++++++++++++++++++++ include/grub/efi/api.h | 142 +++++++++++++++++++++++++++++++++++++- 4 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 grub-core/commands/efi/lsefi.c diff --git a/ChangeLog b/ChangeLog index f514465..a21708c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2012-07-22 Vladimir Serbinenko + New command `lsefi'. + + * grub-core/Makefile.core.def (lsefi): New module. + * grub-core/commands/efi/lsefi.c: New file. + * include/grub/efi/api.h: Add more GUIDs. + +2012-07-22 Vladimir Serbinenko + * grub-core/loader/i386/bsd.c (grub_bsd_elf32_size_hook): Fix mask. (grub_bsd_elf32_hook): Likewise. (grub_bsd_elf64_size_hook): Likewise. diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 5c2fcc2..de702d6 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -569,6 +569,12 @@ module = { }; module = { + name = lsefi; + common = commands/efi/lsefi.c; + enable = efi; +}; + +module = { name = blocklist; common = commands/blocklist.c; }; diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c new file mode 100644 index 0000000..8dffbdc --- /dev/null +++ b/grub-core/commands/efi/lsefi.c @@ -0,0 +1,153 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2012 Free Software Foundation, Inc. + * + * GRUB 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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 GRUB. If not, see . + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +struct known_protocol +{ + grub_efi_guid_t guid; + const char *name; +} known_protocols[] = + { + { GRUB_EFI_DISK_IO_GUID, "disk" }, + { GRUB_EFI_BLOCK_IO_GUID, "block" }, + { GRUB_EFI_SERIAL_IO_GUID, "serial" }, + { GRUB_EFI_SIMPLE_NETWORK_GUID, "network" }, + { GRUB_EFI_PXE_GUID, "pxe" }, + { GRUB_EFI_DEVICE_PATH_GUID, "device path" }, + { GRUB_EFI_PCI_IO_GUID, "PCI" }, + { GRUB_EFI_PCI_ROOT_IO_GUID, "PCI root" }, + { GRUB_EFI_EDID_ACTIVE_GUID, "active EDID" }, + { GRUB_EFI_EDID_DISCOVERED_GUID, "discovered EDID" }, + { GRUB_EFI_EDID_OVERRIDE_GUID, "override EDID" }, + { GRUB_EFI_GOP_GUID, "GOP" }, + { GRUB_EFI_UGA_DRAW_GUID, "UGA draw" }, + { GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, "simple text output" }, + { GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, "simple text input" }, + { GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID, "simple pointer" }, + { GRUB_EFI_CONSOLE_CONTROL_GUID, "console control" }, + { GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" }, + { GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" }, + { GRUB_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" }, + { GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" }, + { GRUB_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" }, + { GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" }, + { GRUB_EFI_SCSI_IO_PROTOCOL_GUID, "SCSI I/O" }, + { GRUB_EFI_USB2_HC_PROTOCOL_GUID, "USB host" }, + { GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID, "debug support" }, + { GRUB_EFI_DEBUGPORT_PROTOCOL_GUID, "debug port" }, + { GRUB_EFI_DECOMPRESS_PROTOCOL_GUID, "decompress" }, + { GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID, "loaded image" }, + { GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, "device path to text" }, + { GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, "device path utilities" }, + { GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID, "device path from text" }, + { GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, "HII config routing" }, + { GRUB_EFI_HII_DATABASE_PROTOCOL_GUID, "HII database" }, + { GRUB_EFI_HII_STRING_PROTOCOL_GUID, "HII string" }, + { GRUB_EFI_HII_IMAGE_PROTOCOL_GUID, "HII image" }, + { GRUB_EFI_HII_FONT_PROTOCOL_GUID, "HII font" }, + { GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID, "component name 2" }, + { GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID, + "HII configuration access" }, + { GRUB_EFI_USB_IO_PROTOCOL_GUID, "USB I/O" }, + }; + +static grub_err_t +grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char **args __attribute__ ((unused))) +{ + grub_efi_handle_t *handles; + grub_efi_uintn_t num_handles; + unsigned i, j, k; + + handles = grub_efi_locate_handle (GRUB_EFI_ALL_HANDLES, + NULL, NULL, &num_handles); + + for (i = 0; i < num_handles; i++) + { + grub_efi_handle_t handle = handles[i]; + grub_efi_status_t status; + grub_efi_uintn_t num_protocols; + grub_efi_guid_t **protocols; + grub_efi_device_path_t *dp; + + grub_printf ("Handle %p\n", handle); + + dp = grub_efi_get_device_path (handle); + if (dp) + { + grub_printf (" "); + grub_efi_print_device_path (dp); + } + + status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle, + handle, &protocols, &num_protocols); + if (status != GRUB_EFI_SUCCESS) + grub_printf ("Unable to retrieve protocols\n"); + for (j = 0; j < num_protocols; j++) + { + for (k = 0; k < ARRAY_SIZE (known_protocols); k++) + if (grub_memcmp (protocols[j], &known_protocols[k].guid, + sizeof (known_protocols[k].guid)) == 0) + break; + if (k < ARRAY_SIZE (known_protocols)) + grub_printf (" %s\n", known_protocols[k].name); + else + grub_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", + protocols[j]->data1, + protocols[j]->data2, + protocols[j]->data3, + (unsigned) protocols[j]->data4[0], + (unsigned) protocols[j]->data4[1], + (unsigned) protocols[j]->data4[2], + (unsigned) protocols[j]->data4[3], + (unsigned) protocols[j]->data4[4], + (unsigned) protocols[j]->data4[5], + (unsigned) protocols[j]->data4[6], + (unsigned) protocols[j]->data4[7]); + } + + } + + return 0; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT(lsefi) +{ + cmd = grub_register_command ("lsefi", grub_cmd_lsefi, + NULL, "Display EFI handles."); +} + +GRUB_MOD_FINI(lsefi) +{ + grub_unregister_command (cmd); +} diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 26127de..9e7a8d8 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -104,9 +104,149 @@ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ } +#define GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ + { 0x387477c1, 0x69c7, 0x11d2, \ + { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ + } + +#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ + { 0xdd9e7534, 0x7762, 0x4698, \ + { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \ + } + +#define GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \ + { 0x387477c2, 0x69c7, 0x11d2, \ + { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ + } + +#define GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID \ + { 0x31878c87, 0xb75, 0x11d5, \ + { 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ + { 0x8D59D32B, 0xC655, 0x4AE9, \ + { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } \ + } + +#define GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID \ + { 0x18A031AB, 0xB443, 0x4D1A, \ + { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 } \ + } + +#define GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID \ + { 0x5B1B31A1, 0x9562, 0x11d2, \ + { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \ + } + +#define GRUB_EFI_LOAD_FILE_PROTOCOL_GUID \ + { 0x56EC3091, 0x954C, 0x11d2, \ + { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \ + } + +#define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + { 0x0964e5b22, 0x6459, 0x11d2, \ + { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ + } + +#define GRUB_EFI_TAPE_IO_PROTOCOL_GUID \ + { 0x1e93e633, 0xd65a, 0x459e, \ + { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \ + } + +#define GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID \ + { 0x1d85cd7f, 0xf43d, 0x11d2, \ + { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define GRUB_EFI_SCSI_IO_PROTOCOL_GUID \ + { 0x932f47e6, 0x2362, 0x4002, \ + { 0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \ + } + +#define GRUB_EFI_USB2_HC_PROTOCOL_GUID \ + { 0x3e745226, 0x9818, 0x45b6, \ + { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } \ + } + +#define GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID \ + { 0x2755590C, 0x6F3C, 0x42FA, \ + { 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \ + } + +#define GRUB_EFI_DEBUGPORT_PROTOCOL_GUID \ + { 0xEBA4E8D2, 0x3858, 0x41EC, \ + { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } \ + } + +#define GRUB_EFI_DECOMPRESS_PROTOCOL_GUID \ + { 0xd8117cfe, 0x94a6, 0x11d4, \ + { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ + { 0x8b843e20, 0x8132, 0x4852, \ + { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } \ + } + +#define GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ + { 0x379be4e, 0xd706, 0x437d, \ + { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \ + } + +#define GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ + { 0x5c99a21, 0xc70f, 0x4ad2, \ + { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } \ + } + +#define GRUB_EFI_ACPI_TABLE_PROTOCOL_GUID \ + { 0xffe06bdd, 0x6107, 0x46a6, \ + { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c} \ + } + +#define GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \ + { 0x587e72d7, 0xcc50, 0x4f79, \ + { 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f } \ + } + +#define GRUB_EFI_HII_DATABASE_PROTOCOL_GUID \ + { 0xef9fc172, 0xa1b2, 0x4693, \ + { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } \ + } + +#define GRUB_EFI_HII_STRING_PROTOCOL_GUID \ + { 0xfd96974, 0x23aa, 0x4cdc, \ + { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } \ + } + +#define GRUB_EFI_HII_IMAGE_PROTOCOL_GUID \ + { 0x31a6406a, 0x6bdf, 0x4e46, \ + { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } \ + } + +#define GRUB_EFI_HII_FONT_PROTOCOL_GUID \ + { 0xe9ca4775, 0x8657, 0x47fc, \ + { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } \ + } + +#define GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID \ + { 0x330d4706, 0xf2a0, 0x4e4f, \ + { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } \ + } + +#define GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID \ + { 0x6a7a5cff, 0xe8d9, 0x4f70, \ + { 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14} \ + } + +#define GRUB_EFI_USB_IO_PROTOCOL_GUID \ + { 0x2B2F68D6, 0x0CD2, 0x44cf, \ + { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \ + } + #define GRUB_EFI_MPS_TABLE_GUID \ { 0xeb9d2d2f, 0x2d88, 0x11d3, \ - { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } #define GRUB_EFI_ACPI_TABLE_GUID \ -- 1.8.1.4