Debian Codegraph @

grub-core/commands/i386/coreboot/cbls.c

raw
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2013 Free Software Foundation, Inc.
4 *
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <grub/dl.h>
20 #include <grub/misc.h>
21 #include <grub/command.h>
22 #include <grub/i18n.h>
23 #include <grub/coreboot/lbio.h>
24 #include <grub/i386/tsc.h>
25
26 GRUB_MOD_LICENSE ("GPLv3+");
27
28 static const char *console_descs[] = {
29 "8250 UART",
30 "VGA",
31 "BTEXT",
32 "log buffer console",
33 "SROM",
34 "EHCI debug",
35 "memory-mapped 8250 UART"
36 };
37
38 static const char *descs[] = {
39 [GRUB_LINUXBIOS_MEMBER_MEMORY] = "memory map (`lsmmap' to list)",
40 [GRUB_LINUXBIOS_MEMBER_MAINBOARD] = "mainboard",
41 [4] = "version",
42 [5] = "extra version",
43 [6] = "build",
44 [7] = "compile time",
45 [8] = "compile by",
46 [9] = "compile host",
47 [0xa] = "compile domain",
48 [0xb] = "compiler",
49 [0xc] = "linker",
50 [0xd] = "assembler",
51 [0xf] = "serial",
52 [GRUB_LINUXBIOS_MEMBER_CONSOLE] = "console",
53 [GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
54 [0x13] = "GPIO",
55 [0x15] = "VDAT",
56 [GRUB_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
57 [GRUB_LINUXBIOS_MEMBER_CBMEMC] = "CBMEM console (`cbmemc' to list)",
58 [0x18] = "MRC cache",
59 [0x19] = "VBNV",
60 [0xc8] = "CMOS option table",
61 [0xc9] = "CMOS option",
62 [0xca] = "CMOS option enum",
63 [0xcb] = "CMOS option defaults",
64 [0xcc] = "CMOS checksum",
65 };
66
67 static int
68 iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
69 void *data __attribute__ ((unused)))
70 {
71 if (table_item->tag < ARRAY_SIZE (descs) && descs[table_item->tag])
72 grub_printf ("tag=%02x size=%02x %s",
73 table_item->tag, table_item->size, descs[table_item->tag]);
74 else
75 grub_printf ("tag=%02x size=%02x",
76 table_item->tag, table_item->size);
77
78 switch (table_item->tag)
79 {
80 case GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER:
81 {
82 struct grub_linuxbios_table_framebuffer *fb;
83 fb = (struct grub_linuxbios_table_framebuffer *) (table_item + 1);
84
85 grub_printf (": %dx%dx%d pitch=%d lfb=0x%llx %d/%d/%d/%d %d/%d/%d/%d",
86 fb->width, fb->height,
87 fb->bpp, fb->pitch,
88 (unsigned long long) fb->lfb,
89 fb->red_mask_size, fb->green_mask_size,
90 fb->blue_mask_size, fb->reserved_mask_size,
91 fb->red_field_pos, fb->green_field_pos,
92 fb->blue_field_pos, fb->reserved_field_pos);
93 break;
94 }
95 case GRUB_LINUXBIOS_MEMBER_MAINBOARD:
96 {
97 struct grub_linuxbios_mainboard *mb;
98 mb = (struct grub_linuxbios_mainboard *) (table_item + 1);
99 grub_printf (": vendor=`%s' part_number=`%s'",
100 mb->strings + mb->vendor,
101 mb->strings + mb->part_number);
102 break;
103 }
104 case 0x04 ... 0x0d:
105 grub_printf (": `%s'", (char *) (table_item + 1));
106 break;
107 case GRUB_LINUXBIOS_MEMBER_CONSOLE:
108 {
109 grub_uint16_t *val = (grub_uint16_t *) (table_item + 1);
110 grub_printf (": id=%d", *val);
111 if (*val < ARRAY_SIZE (console_descs)
112 && console_descs[*val])
113 grub_printf (" %s", console_descs[*val]);
114 }
115 }
116 grub_printf ("\n");
117
118 return 0;
119 }
120
121
122 static grub_err_t
123 grub_cmd_lscoreboot (struct grub_command *cmd __attribute__ ((unused)),
124 int argc __attribute__ ((unused)),
125 char *argv[] __attribute__ ((unused)))
126 {
127 grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
128 return 0;
129 }
130
131 static grub_command_t cmd;
132
133 GRUB_MOD_INIT(cbls)
134 {
135 cmd =
136 grub_register_command ("lscoreboot", grub_cmd_lscoreboot,
137 0, N_("List coreboot tables."));
138 }
139
140 GRUB_MOD_FINI(cbls)
141 {
142 grub_unregister_command (cmd);
143 }