Home | History | Annotate | Download | only in hdt
      1 /* ----------------------------------------------------------------------- *
      2  *
      3  *   Copyright 2009 Erwan Velu - All Rights Reserved
      4  *
      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:
     13  *
     14  *   The above copyright notice and this permission notice shall
     15  *   be included in all copies or substantial portions of the Software.
     16  *
     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.
     25  *
     26  * -----------------------------------------------------------------------
     27 */
     28 
     29 #include "hdt-menu.h"
     30 
     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 };
     34 
     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++;
     42 
     43 }
     44 
     45 /* Submenu for the vesa card */
     46 static void compute_acpi_tables(struct s_my_menu *menu,
     47 			      struct s_hardware *hardware)
     48 {
     49     menu->menu = add_menu(" ACPI Tables ", -1);
     50     menu->items_count = 0;
     51     set_menu_pos(SUBMENU_Y, SUBMENU_X);
     52 
     53     char buffer[SUBMENULEN + 1] = { 0 };
     54 
     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++;
     59 
     60     add_item("", "", OPT_SEP, "", 0);
     61 
     62     if (hardware->acpi.rsdt.valid)
     63         compute_table(menu,hardware->acpi.rsdt.address,
     64                        &hardware->acpi.rsdt.header);
     65 
     66     if (hardware->acpi.xsdt.valid)
     67         compute_table(menu,hardware->acpi.xsdt.address,
     68                        &hardware->acpi.xsdt.header);
     69 
     70     if (hardware->acpi.fadt.valid)
     71         compute_table(menu,hardware->acpi.fadt.address, &hardware->acpi.fadt.header);
     72 
     73     if (hardware->acpi.dsdt.valid)
     74         compute_table(menu,hardware->acpi.dsdt.address, &hardware->acpi.dsdt.header);
     75 
     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);
     81     }
     82 
     83     if (hardware->acpi.sbst.valid)
     84         compute_table(menu,hardware->acpi.sbst.address, &hardware->acpi.sbst.header);
     85 
     86     if (hardware->acpi.ecdt.valid)
     87         compute_table(menu,hardware->acpi.ecdt.address, &hardware->acpi.ecdt.header);
     88 
     89     if (hardware->acpi.hpet.valid)
     90         compute_table(menu,hardware->acpi.hpet.address, &hardware->acpi.hpet.header);
     91 
     92     if (hardware->acpi.tcpa.valid)
     93         compute_table(menu,hardware->acpi.tcpa.address, &hardware->acpi.tcpa.header);
     94 
     95     if (hardware->acpi.mcfg.valid)
     96         compute_table(menu,hardware->acpi.mcfg.address, &hardware->acpi.mcfg.header);
     97 
     98     if (hardware->acpi.slic.valid)
     99         compute_table(menu,hardware->acpi.slic.address, &hardware->acpi.slic.header);
    100 
    101     if (hardware->acpi.boot.valid)
    102         compute_table(menu,hardware->acpi.boot.address, &hardware->acpi.boot.header);
    103 
    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 };
    109 
    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++;
    114     }
    115 
    116     if (hardware->acpi.madt.valid)
    117         compute_table(menu,hardware->acpi.madt.address, &hardware->acpi.madt.header);
    118 
    119 }
    120 
    121 /* Main ACPI Menu*/
    122 int compute_ACPI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
    123 {
    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;
    127 
    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;
    134 }
    135