2N/A/* lsefisystab.c - Display EFI systab. */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2008 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A#include <grub/types.h>
2N/A#include <grub/mm.h>
2N/A#include <grub/dl.h>
2N/A#include <grub/misc.h>
2N/A#include <grub/normal.h>
2N/A#include <grub/charset.h>
2N/A#include <grub/efi/api.h>
2N/A#include <grub/efi/efi.h>
2N/A
2N/AGRUB_MOD_LICENSE ("GPLv3+");
2N/A
2N/Astruct guid_mapping
2N/A{
2N/A grub_efi_guid_t guid;
2N/A const char *name;
2N/A};
2N/A
2N/Astatic const struct guid_mapping guid_mappings[] =
2N/A {
2N/A { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
2N/A { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
2N/A { GRUB_EFI_SAL_TABLE_GUID, "SAL"},
2N/A { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
2N/A { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
2N/A { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}
2N/A };
2N/A
2N/Astatic grub_err_t
2N/Agrub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
2N/A int argc __attribute__ ((unused)),
2N/A char **args __attribute__ ((unused)))
2N/A{
2N/A const grub_efi_system_table_t *st = grub_efi_system_table;
2N/A grub_efi_configuration_table_t *t;
2N/A unsigned int i;
2N/A
2N/A grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n",
2N/A st->hdr.signature, st->hdr.revision);
2N/A {
2N/A char *vendor;
2N/A grub_uint16_t *vendor_utf16;
2N/A grub_printf ("Vendor: ");
2N/A
2N/A for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
2N/A vendor = grub_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1);
2N/A if (!vendor)
2N/A return grub_errno;
2N/A *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor,
2N/A vendor_utf16 - st->firmware_vendor) = 0;
2N/A grub_printf ("%s", vendor);
2N/A grub_free (vendor);
2N/A }
2N/A
2N/A grub_printf (", Version=%x\n", st->firmware_revision);
2N/A
2N/A grub_printf ("%ld tables:\n", st->num_table_entries);
2N/A t = st->configuration_table;
2N/A for (i = 0; i < st->num_table_entries; i++)
2N/A {
2N/A unsigned int j;
2N/A
2N/A grub_printf ("%p ", t->vendor_table);
2N/A
2N/A grub_printf ("%08x-%04x-%04x-",
2N/A t->vendor_guid.data1, t->vendor_guid.data2,
2N/A t->vendor_guid.data3);
2N/A for (j = 0; j < 8; j++)
2N/A grub_printf ("%02x", t->vendor_guid.data4[j]);
2N/A
2N/A for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
2N/A if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
2N/A sizeof (grub_efi_guid_t)) == 0)
2N/A grub_printf (" %s", guid_mappings[j].name);
2N/A
2N/A grub_printf ("\n");
2N/A t++;
2N/A }
2N/A return GRUB_ERR_NONE;
2N/A}
2N/A
2N/Astatic grub_command_t cmd;
2N/A
2N/AGRUB_MOD_INIT(lsefisystab)
2N/A{
2N/A cmd = grub_register_command ("lsefisystab", grub_cmd_lsefisystab,
2N/A "", "Display EFI system tables.");
2N/A}
2N/A
2N/AGRUB_MOD_FINI(lsefisystab)
2N/A{
2N/A grub_unregister_command (cmd);
2N/A}