Add memtest support.
[syslinux-debian/hramrach.git] / com32 / hdt / hdt-menu-acpi.c
blob8e0ba18f2a9c6cafec15bfc9e00bd144f9bbf349
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
12 * conditions:
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
29 #include "hdt-menu.h"
31 void compute_table(struct s_my_menu *menu, void *address, s_acpi_description_header * h) {
32 char buffer[SUBMENULEN + 1] = { 0 };
33 char statbuffer[STATLEN + 1] = { 0 };
35 snprintf(buffer, sizeof buffer, "%-4s v%03x %-6s %-8s %-7s %08x",
36 h->signature, h->revision, h->oem_id, h->oem_table_id, h->creator_id, h->creator_revision);
37 snprintf(statbuffer, sizeof statbuffer, "%-4s v%03x %-6s %-7s 0x%08x %-4s 0x%08x @ 0x%p",
38 h->signature, h->revision, h->oem_id, h->oem_table_id,
39 h->oem_revision, h->creator_id, h->creator_revision, address);
40 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
41 menu->items_count++;
45 /* Submenu for the vesa card */
46 static void compute_acpi_tables(struct s_my_menu *menu,
47 struct s_hardware *hardware)
49 menu->menu = add_menu(" ACPI Tables ", -1);
50 menu->items_count = 0;
51 set_menu_pos(SUBMENU_Y, SUBMENU_X);
53 char buffer[SUBMENULEN + 1] = { 0 };
55 snprintf(buffer, sizeof buffer, "%-4s %-4s %-6s %-8s %-7s %-8s",
56 "ACPI", "rev", "oem", "table_id", "creator", "creator_rev");
57 add_item(buffer, "Description", OPT_INACTIVE, NULL, 0);
58 menu->items_count++;
60 add_item("", "", OPT_SEP, "", 0);
62 if (hardware->acpi.rsdt.valid)
63 compute_table(menu,hardware->acpi.rsdt.address,
64 &hardware->acpi.rsdt.header);
66 if (hardware->acpi.xsdt.valid)
67 compute_table(menu,hardware->acpi.xsdt.address,
68 &hardware->acpi.xsdt.header);
70 if (hardware->acpi.fadt.valid)
71 compute_table(menu,hardware->acpi.fadt.address, &hardware->acpi.fadt.header);
73 if (hardware->acpi.dsdt.valid)
74 compute_table(menu,hardware->acpi.dsdt.address, &hardware->acpi.dsdt.header);
76 /* SSDT includes many optional tables, let's display them */
77 for (int i = 0; i < hardware->acpi.ssdt_count; i++) {
78 if ((hardware->acpi.ssdt[i] != NULL) && (hardware->acpi.ssdt[i]->valid))
79 compute_table(menu,hardware->acpi.ssdt[i]->address,
80 &hardware->acpi.ssdt[i]->header);
83 if (hardware->acpi.sbst.valid)
84 compute_table(menu,hardware->acpi.sbst.address, &hardware->acpi.sbst.header);
86 if (hardware->acpi.ecdt.valid)
87 compute_table(menu,hardware->acpi.ecdt.address, &hardware->acpi.ecdt.header);
89 if (hardware->acpi.hpet.valid)
90 compute_table(menu,hardware->acpi.hpet.address, &hardware->acpi.hpet.header);
92 if (hardware->acpi.tcpa.valid)
93 compute_table(menu,hardware->acpi.tcpa.address, &hardware->acpi.tcpa.header);
95 if (hardware->acpi.mcfg.valid)
96 compute_table(menu,hardware->acpi.mcfg.address, &hardware->acpi.mcfg.header);
98 if (hardware->acpi.slic.valid)
99 compute_table(menu,hardware->acpi.slic.address, &hardware->acpi.slic.header);
101 if (hardware->acpi.boot.valid)
102 compute_table(menu,hardware->acpi.boot.address, &hardware->acpi.boot.header);
104 /* FACS isn't having the same headers, let's use a dedicated rendering */
105 if (hardware->acpi.facs.valid) {
106 s_facs *fa = &hardware->acpi.facs;
107 char buffer[SUBMENULEN + 1] = { 0 };
108 char statbuffer[STATLEN + 1] = { 0 };
110 snprintf(buffer, sizeof buffer, "%-4s", fa->signature);
111 snprintf(statbuffer, sizeof statbuffer, "%-4s @ 0x%p", fa->signature, fa->address);
112 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
113 menu->items_count++;
116 if (hardware->acpi.madt.valid)
117 compute_table(menu,hardware->acpi.madt.address, &hardware->acpi.madt.header);
121 /* Main ACPI Menu*/
122 int compute_ACPI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
124 compute_acpi_tables(&hdt_menu->acpi_tables_menu, hardware);
125 hdt_menu->acpi_menu.menu = add_menu(" ACPI ", -1);
126 hdt_menu->acpi_menu.items_count = 0;
128 add_item("Tables", "Tables", OPT_SUBMENU, NULL,
129 hdt_menu->acpi_tables_menu.menu);
130 hdt_menu->acpi_menu.items_count++;
131 printf("MENU: ACPI menu done (%d items)\n",
132 hdt_menu->acpi_menu.items_count);
133 return 0;