vaseboot/VasEBoot-core/commands/efi/lsefisystab.c

132 lines
4.7 KiB
C

/* lsefisystab.c - Display EFI systab. */
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VAS_EBOOT 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.
*
* VAS_EBOOT 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 VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/dl.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/normal.h>
#include <VasEBoot/charset.h>
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/efi.h>
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
struct guid_mapping
{
VasEBoot_guid_t guid;
const char *name;
};
static const struct guid_mapping guid_mappings[] =
{
{ VAS_EBOOT_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
{ VAS_EBOOT_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
{ VAS_EBOOT_EFI_CONFORMANCE_PROFILES_TABLE_GUID, "CONFORMANCE PROFILES"},
{ VAS_EBOOT_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
"CRC32 GUIDED SECTION EXTRACTION"},
{ VAS_EBOOT_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
{ VAS_EBOOT_EFI_DEVICE_TREE_GUID, "DEVICE TREE"},
{ VAS_EBOOT_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
{ VAS_EBOOT_EFI_HCDP_TABLE_GUID, "HCDP"},
{ VAS_EBOOT_EFI_HOB_LIST_GUID, "HOB LIST"},
{ VAS_EBOOT_EFI_IMAGE_SECURITY_DATABASE_GUID, "IMAGE EXECUTION INFORMATION"},
{ VAS_EBOOT_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
{ VAS_EBOOT_EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMORY ATTRIBUTES TABLE"},
{ VAS_EBOOT_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
{ VAS_EBOOT_EFI_MPS_TABLE_GUID, "MPS"},
{ VAS_EBOOT_EFI_RT_PROPERTIES_TABLE_GUID, "RT PROPERTIES"},
{ VAS_EBOOT_EFI_SAL_TABLE_GUID, "SAL"},
{ VAS_EBOOT_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
{ VAS_EBOOT_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
{ VAS_EBOOT_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
{ VAS_EBOOT_EFI_TCG2_FINAL_EVENTS_TABLE_GUID, "TCG2 FINAL EVENTS TABLE"},
{ VAS_EBOOT_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
{ VAS_EBOOT_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
};
static VasEBoot_err_t
VasEBoot_cmd_lsefisystab (struct VasEBoot_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
const VasEBoot_efi_system_table_t *st = VasEBoot_efi_system_table;
const VasEBoot_efi_uint32_t major_rev = st->hdr.revision >> 16;
const VasEBoot_efi_uint32_t minor_rev_upper = (st->hdr.revision & 0xffff) / 10;
const VasEBoot_efi_uint32_t minor_rev_lower = (st->hdr.revision & 0xffff) % 10;
VasEBoot_efi_configuration_table_t *t;
unsigned int i;
VasEBoot_printf ("Address: %p\n", st);
VasEBoot_printf ("Signature: %016" PRIxVAS_EBOOT_UINT64_T " revision: %u.%u",
st->hdr.signature, major_rev, minor_rev_upper);
if (minor_rev_lower)
VasEBoot_printf (".%u", minor_rev_lower);
VasEBoot_printf ("\n");
{
char *vendor;
VasEBoot_uint16_t *vendor_utf16;
VasEBoot_printf ("Vendor: ");
for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
/* Allocate extra 3 bytes to simplify math. */
vendor = VasEBoot_calloc (4, vendor_utf16 - st->firmware_vendor + 1);
if (!vendor)
return VasEBoot_errno;
*VasEBoot_utf16_to_utf8 ((VasEBoot_uint8_t *) vendor, st->firmware_vendor,
vendor_utf16 - st->firmware_vendor) = 0;
VasEBoot_printf ("%s", vendor);
VasEBoot_free (vendor);
}
VasEBoot_printf (", Version=%x\n", st->firmware_revision);
VasEBoot_printf ("%lld tables:\n", (long long) st->num_table_entries);
t = st->configuration_table;
for (i = 0; i < st->num_table_entries; i++)
{
unsigned int j;
VasEBoot_printf ("%p ", t->vendor_table);
VasEBoot_printf ("%pG", &t->vendor_guid);
for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
if (VasEBoot_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
sizeof (VasEBoot_guid_t)) == 0)
VasEBoot_printf (" %s", guid_mappings[j].name);
VasEBoot_printf ("\n");
t++;
}
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VAS_EBOOT_MOD_INIT(lsefisystab)
{
cmd = VasEBoot_register_command ("lsefisystab", VasEBoot_cmd_lsefisystab,
"", "Display EFI system tables.");
}
VAS_EBOOT_MOD_FINI(lsefisystab)
{
VasEBoot_unregister_command (cmd);
}