[syslinux:master] hdt: Adding basic ACPI mode

syslinux-bot for Erwan Velu erwan.velu at free.fr
Sun Feb 6 14:06:35 PST 2011


Commit-ID:  403cee47ca49891640d857e331180994c9888b2b
Gitweb:     http://syslinux.zytor.com/commit/403cee47ca49891640d857e331180994c9888b2b
Author:     Erwan Velu <erwan.velu at free.fr>
AuthorDate: Wed, 2 Dec 2009 11:13:58 +0100
Committer:  Erwan Velu <erwan.velu at free.fr>
CommitDate: Fri, 4 Dec 2009 10:19:00 +0100

hdt: Adding basic ACPI mode

Impact: new acpi mode

Adding a new ACPI mode, still lots of work to do


---
 com32/hdt/hdt-cli-acpi.c |  102 ++++++++++++++++++++++++++++++++++++++++++++++
 com32/hdt/hdt-cli.c      |    8 ++-
 com32/hdt/hdt-cli.h      |    3 +
 com32/hdt/hdt-common.c   |   22 ++++++++++
 com32/hdt/hdt-common.h   |    5 ++
 5 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/com32/hdt/hdt-cli-acpi.c b/com32/hdt/hdt-cli-acpi.c
new file mode 100644
index 0000000..6667a14
--- /dev/null
+++ b/com32/hdt/hdt-cli-acpi.c
@@ -0,0 +1,102 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2009 Erwan Velu - All Rights Reserved
+ *
+ *   Permission is hereby granted, free of charge, to any person
+ *   obtaining a copy of this software and associated documentation
+ *   files (the "Software"), to deal in the Software without
+ *   restriction, including without limitation the rights to use,
+ *   copy, modify, merge, publish, distribute, sublicense, and/or
+ *   sell copies of the Software, and to permit persons to whom
+ *   the Software is furnished to do so, subject to the following
+ *   conditions:
+ *
+ *   The above copyright notice and this permission notice shall
+ *   be included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+*/
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+void main_show_acpi(int argc __unused, char **argv __unused,
+		    struct s_hardware *hardware)
+{
+    reset_more_printf();
+    detect_acpi(hardware);
+    if (hardware->is_acpi_valid == false) {
+	more_printf("No ACPI Tables detected\n");
+	return;
+    }
+
+//ACPI: XSDT (v001 DELL   PE_SC3   0x00000001 DELL 0x00000001) @ 0x00000000000f222c
+    more_printf(" Table (rev oem table_id oem_rev creator creator_rev address (\n");
+    more_printf("--------------------------------------------------------------\n");
+    if (hardware->acpi.rsdp.valid) {
+	s_rsdp *r = &hardware->acpi.rsdp;
+	more_printf("RSDP (v%03x %6s                         ) @ 0x%016llx",r->revision, r->oem_id,r->address);
+    }
+
+//	more_printf("XSDT (v%3x %6s %7s %08x %4s %08x) @ %08x",
+}
+
+static void show_acpi_modes(int argc __unused, char **argv __unused,
+			    struct s_hardware *hardware)
+{
+    detect_acpi(hardware);
+    reset_more_printf();
+    if (hardware->is_acpi_valid == false) {
+	more_printf("No ACPI Tables detected\n");
+	return;
+    }
+}
+
+struct cli_callback_descr list_acpi_show_modules[] = {
+    {
+     .name = CLI_MODES,
+     .exec = show_acpi_modes,
+     },
+    {
+     .name = NULL,
+     .exec = NULL,
+     },
+};
+
+struct cli_callback_descr list_acpi_commands[] = {
+    {
+     .name = NULL,
+     .exec = NULL,
+     },
+};
+
+struct cli_module_descr acpi_show_modules = {
+    .modules = list_acpi_show_modules,
+    .default_callback = main_show_acpi,
+};
+
+struct cli_module_descr acpi_commands = {
+    .modules = list_acpi_commands,
+    .default_callback = NULL,
+};
+
+struct cli_mode_descr acpi_mode = {
+    .mode = ACPI_MODE,
+    .name = CLI_ACPI,
+    .default_modules = &acpi_commands,
+    .show_modules = &acpi_show_modules,
+    .set_modules = NULL,
+};
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 146021b..7a4e24d 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -46,6 +46,7 @@ struct cli_mode_descr *list_modes[] = {
     &disk_mode,
     &vpd_mode,
     &memory_mode,
+    &acpi_mode,
     NULL,
 };
 
@@ -191,6 +192,10 @@ void set_mode(cli_mode_t mode, struct s_hardware *hardware)
 	hdt_cli.mode = mode;
 	snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_MEMORY);
 	break;
+    case ACPI_MODE:
+	hdt_cli.mode = mode;
+	snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_ACPI);
+	break;
     default:
 	/* Invalid mode */
 	printf("Unknown mode, please choose among:\n");
@@ -826,9 +831,6 @@ void start_cli_mode(struct s_hardware *hardware)
 
     reset_prompt();
 
-    s_acpi acpi;
-    parse_acpi(&acpi);
-
     while (hdt_cli.mode != EXIT_MODE) {
 
 	/* Display the cursor */
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 898b53f..fc7e000 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -68,6 +68,7 @@
 #define CLI_MODES "modes"
 #define CLI_VPD  "vpd"
 #define CLI_MEMORY  "memory"
+#define CLI_ACPI "acpi"
 #define CLI_ENABLE "enable"
 #define CLI_DISABLE "disable"
 
@@ -85,6 +86,7 @@ typedef enum {
     DISK_MODE,
     VPD_MODE,
     MEMORY_MODE,
+    ACPI_MODE,
 } cli_mode_t;
 
 #define PROMPT_SIZE 32
@@ -146,6 +148,7 @@ struct cli_mode_descr vesa_mode;
 struct cli_mode_descr disk_mode;
 struct cli_mode_descr vpd_mode;
 struct cli_mode_descr memory_mode;
+struct cli_mode_descr acpi_mode;
 
 /* cli helpers */
 void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found);
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 59175ce..aaf46bc 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -169,10 +169,12 @@ void init_hardware(struct s_hardware *hardware)
     hardware->vesa_detection = false;
     hardware->vpd_detection = false;
     hardware->memory_detection = false;
+    hardware->acpi_detection = false;
     hardware->nb_pci_devices = 0;
     hardware->is_dmi_valid = false;
     hardware->is_pxe_valid = false;
     hardware->is_vpd_valid = false;
+    hardware->is_acpi_valid = false;
     hardware->pci_domain = NULL;
     hardware->detected_memory_size = 0;
 
@@ -184,6 +186,7 @@ void init_hardware(struct s_hardware *hardware)
     memset(&hardware->pxe, 0, sizeof(struct s_pxe));
     memset(&hardware->vesa, 0, sizeof(struct s_vesa));
     memset(&hardware->vpd, 0, sizeof(s_vpd));
+    memset(&hardware->acpi, 0, sizeof(s_vpd));
     memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs);
     memset(hardware->pciids_path, 0, sizeof hardware->pciids_path);
     memset(hardware->modules_pcimap_path, 0,
@@ -222,6 +225,25 @@ int detect_dmi(struct s_hardware *hardware)
     return 0;
 }
 
+/*
+ * Detecting ACPI
+ * if yes, let's parse it
+ */
+int detect_acpi(struct s_hardware *hardware)
+{
+    int retval;
+    if (hardware->acpi_detection == true)
+	return -1;
+    hardware->acpi_detection = true;
+    if ((retval=parse_acpi(&hardware->acpi)) != ACPI_FOUND) {
+	hardware->is_acpi_valid = false;
+	return retval;
+    }
+
+    hardware->is_acpi_valid = true;
+    return retval;
+}
+
 /**
  * vpd_detection - populate the VPD structure
  *
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index d7a58e2..6d50b7b 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -51,6 +51,7 @@
 #include "../lib/sys/vesa/vesa.h"
 #include <vpd/vpd.h>
 #include <libansi.h>
+#include <acpi/acpi.h>
 
 /* Declare a variable or data structure as unused. */
 #define __unused __attribute__ (( unused ))
@@ -164,6 +165,7 @@ struct s_hardware {
     s_dmi dmi;			/* DMI table */
     s_cpu cpu;			/* CPU information */
     s_vpd vpd;			/* VPD information */
+    s_acpi acpi;
     struct pci_domain *pci_domain;	/* PCI Devices */
     struct driveinfo disk_info[256];	/* Disk Information */
     uint32_t mbr_ids[256];	/* MBR ids */
@@ -180,6 +182,7 @@ struct s_hardware {
     bool is_pxe_valid;
     bool is_vesa_valid;
     bool is_vpd_valid;
+    bool is_acpi_valid;
 
     bool dmi_detection;		/* Does the dmi stuff has already been detected? */
     bool pci_detection;		/* Does the pci stuff has already been detected? */
@@ -189,6 +192,7 @@ struct s_hardware {
     bool vesa_detection;	/* Does the vesa sutff have been already detected? */
     bool vpd_detection;		/* Does the vpd stuff has already been detected? */
     bool memory_detection;	/* Does the memory size got detected ?*/
+    bool acpi_detection;	/* Does the acpi got detected ?*/
 
     char syslinux_fs[22];
     const struct syslinux_version *sv;
@@ -216,6 +220,7 @@ int detect_pxe(struct s_hardware *hardware);
 void init_hardware(struct s_hardware *hardware);
 void clear_screen(void);
 void detect_syslinux(struct s_hardware *hardware);
+int detect_acpi(struct s_hardware *hardware);
 void detect_parameters(const int argc, const char *argv[],
 		       struct s_hardware *hardware);
 int detect_vesa(struct s_hardware *hardware);



More information about the Syslinux-commits mailing list