]> git.proxmox.com Git - grub2.git/blame - grub-core/commands/efi/lsefisystab.c
bump version to 2.06-13+pmx2
[grub2.git] / grub-core / commands / efi / lsefisystab.c
CommitLineData
6d3d698d 1/* lsefisystab.c - Display EFI systab. */
105de6a7
TG
2/*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008 Free Software Foundation, Inc.
5 *
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19#include <grub/types.h>
20#include <grub/mm.h>
e745cf0c 21#include <grub/dl.h>
105de6a7
TG
22#include <grub/misc.h>
23#include <grub/normal.h>
24#include <grub/charset.h>
25#include <grub/efi/api.h>
26#include <grub/efi/efi.h>
27
e745cf0c
VS
28GRUB_MOD_LICENSE ("GPLv3+");
29
105de6a7
TG
30struct guid_mapping
31{
32 grub_efi_guid_t guid;
33 const char *name;
34};
35
36static const struct guid_mapping guid_mappings[] =
37 {
38 { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
39 { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
7994077a
PB
40 { GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
41 "CRC32 GUIDED SECTION EXTRACTION"},
42 { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
15cfd02b 43 { GRUB_EFI_DEVICE_TREE_GUID, "DEVICE TREE"},
7994077a 44 { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
50d6f38f 45 { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"},
7994077a
PB
46 { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"},
47 { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
48 { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
49 { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
0860abe1 50 { GRUB_EFI_RT_PROPERTIES_TABLE_GUID, "RT PROPERTIES"},
105de6a7
TG
51 { GRUB_EFI_SAL_TABLE_GUID, "SAL"},
52 { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
261df54f 53 { GRUB_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
7994077a
PB
54 { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
55 { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
56 { GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
105de6a7
TG
57 };
58
59static grub_err_t
60grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
61 int argc __attribute__ ((unused)),
62 char **args __attribute__ ((unused)))
63{
64 const grub_efi_system_table_t *st = grub_efi_system_table;
65 grub_efi_configuration_table_t *t;
66 unsigned int i;
67
3f3ec8ef 68 grub_printf ("Address: %p\n", st);
105de6a7
TG
69 grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n",
70 st->hdr.signature, st->hdr.revision);
71 {
72 char *vendor;
73 grub_uint16_t *vendor_utf16;
74 grub_printf ("Vendor: ");
75
76 for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
f725fa7c
PJ
77 /* Allocate extra 3 bytes to simplify math. */
78 vendor = grub_calloc (4, vendor_utf16 - st->firmware_vendor + 1);
105de6a7
TG
79 if (!vendor)
80 return grub_errno;
81 *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor,
82 vendor_utf16 - st->firmware_vendor) = 0;
83 grub_printf ("%s", vendor);
48798b6a 84 grub_free (vendor);
105de6a7
TG
85 }
86
87 grub_printf (", Version=%x\n", st->firmware_revision);
88
d99af4f0 89 grub_printf ("%lld tables:\n", (long long) st->num_table_entries);
105de6a7
TG
90 t = st->configuration_table;
91 for (i = 0; i < st->num_table_entries; i++)
92 {
93 unsigned int j;
94
95 grub_printf ("%p ", t->vendor_table);
96
97 grub_printf ("%08x-%04x-%04x-",
98 t->vendor_guid.data1, t->vendor_guid.data2,
99 t->vendor_guid.data3);
100 for (j = 0; j < 8; j++)
101 grub_printf ("%02x", t->vendor_guid.data4[j]);
102
103 for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
104 if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
105 sizeof (grub_efi_guid_t)) == 0)
106 grub_printf (" %s", guid_mappings[j].name);
107
108 grub_printf ("\n");
109 t++;
110 }
111 return GRUB_ERR_NONE;
112}
113
114static grub_command_t cmd;
115
116GRUB_MOD_INIT(lsefisystab)
117{
118 cmd = grub_register_command ("lsefisystab", grub_cmd_lsefisystab,
119 "", "Display EFI system tables.");
120}
121
122GRUB_MOD_FINI(lsefisystab)
123{
124 grub_unregister_command (cmd);
125}