summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/com32/hdt
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/syslinux-4.02/com32/hdt')
-rw-r--r--contrib/syslinux-4.02/com32/hdt/Makefile126
-rw-r--r--contrib/syslinux-4.02/com32/hdt/README19
-rw-r--r--contrib/syslinux-4.02/com32/hdt/art/backgnd.pngbin0 -> 10155 bytes
-rw-r--r--contrib/syslinux-4.02/com32/hdt/art/hdt-black.pngbin0 -> 52537 bytes
-rw-r--r--contrib/syslinux-4.02/com32/hdt/art/hdt.pngbin0 -> 19732 bytes
-rw-r--r--contrib/syslinux-4.02/com32/hdt/floppy/hdt.cfg78
-rw-r--r--contrib/syslinux-4.02/com32/hdt/floppy/mtools.conf2
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-ata.c38
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-ata.h76
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-cpu.c227
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-disk.c253
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-dmi.c688
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-hdt.c375
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-kernel.c155
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-memory.c134
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-pci.c318
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-pxe.c98
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-syslinux.c62
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-vesa.c142
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli-vpd.c81
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli.c1121
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-cli.h204
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-common.c666
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-common.h226
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-about.c87
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-disk.c264
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-dmi.c381
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-kernel.c87
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-memory.c382
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-pci.c203
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-processor.c287
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-pxe.c125
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-summary.c195
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-syslinux.c82
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-vesa.c129
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu-vpd.c114
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu.c337
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-menu.h135
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-util.c93
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt-util.h34
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt.c86
-rw-r--r--contrib/syslinux-4.02/com32/hdt/hdt.h47
42 files changed, 8157 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/com32/hdt/Makefile b/contrib/syslinux-4.02/com32/hdt/Makefile
new file mode 100644
index 0000000..96af05f
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/Makefile
@@ -0,0 +1,126 @@
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+## Boston MA 02110-1301, USA; either version 2 of the License, or
+## (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+##
+## Hardware Detection Tool
+##
+
+topdir = ../..
+include ../MCONFIG
+
+LIBS = ../cmenu/libmenu/libmenu.a ../libutil/libutil_com.a \
+ ../lib/libcom32.a $(LIBGCC)
+CFLAGS += -I$(com32)/cmenu/libmenu
+
+MODULES = hdt.c32
+TESTFILES =
+
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+VERSION = $(shell $(SED) -n 's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h)
+CODENAME = $(shell $(SED) -n 's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h)
+VERSION_C32 = $(shell echo $(VERSION) | $(SED) -e 's/-/_/g' | $(SED) -e 's/\./_/g')
+
+MEMTEST_URL = http://memtest.org/download/4.10/memtest86+-4.10.bin
+MEMTEST = memtest.bin
+
+KERNEL_VERSION ?= $(shell uname -r)
+MODULES_ALIAS_FILE ?= /lib/modules/$(KERNEL_VERSION)/modules.alias
+GZ_MODULES_ALIAS_FILE ?= modules.alias.gz
+MODULES_PCIMAP_FILE ?= /lib/modules/$(KERNEL_VERSION)/modules.pcimap
+GZ_MODULES_PCIMAP_FILE ?= modules.pcimap.gz
+ISO_DIR ?= iso
+ISOLINUX_DIR ?= isolinux
+FLOPPY_DIR ?= floppy
+PCI_IDS_FILE ?= $(PWD)/$(FLOPPY_DIR)/pci.ids
+GZ_PCI_IDS_FILE ?= $(PCI_IDS_FILE).gz
+MENU_COM32 ?= $(com32)/menu/menu.c32
+ART_DIR ?= art/
+
+all: $(MODULES) $(TESTFILES)
+
+hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
+ $(LD) $(LDFLAGS) -o $@ $^
+
+memtest:
+ -[ ! -f $(FLOPPY_DIR)/$(MEMTEST) ] && $(WGET) $(MEMTEST_URL) -O $(FLOPPY_DIR)/$(MEMTEST)
+
+hdt.img: hdt.c32 $(FLOPPY_DIR)/hdt.cfg $(FLOPPY_DIR)/mtools.conf $(topdir)/mtools/syslinux $(MENU_COM32) memtest
+ rm -f hdt*.img
+ $(SED) -e 's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR)/hdt.cfg |\
+ $(SED) -e 's/%CODENAME%/$(CODENAME)/g' > $(FLOPPY_DIR)/syslinux.cfg
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MFORMAT) -v HDT_$(VERSION) -f 1440 -C a:
+ $(topdir)/mtools/syslinux hdt.img
+ -[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
+ -[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
+ -[ -f $(MODULES_ALIAS_FILE) ] && cat $(MODULES_ALIAS_FILE) | $(GZIPPROG) - -f | MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) - a:modules.alias
+ -[ -f $(MODULES_PCIMAP_FILE) ] && cat $(MODULES_PCIMAP_FILE) | $(GZIPPROG) - -f | MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) - a:modules.pcimap
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) hdt.c32 a:
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MENU_COM32) a:
+ @ [ -f $(GZ_PCI_IDS_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(GZ_PCI_IDS_FILE) a:pci.ids || printf "\nThe $(GZ_PCI_IDS_FILE) file is missing and can be downloaded from http://pciids.sourceforge.net and gzipped in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n"
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/syslinux.cfg a:
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/$(MEMTEST) a:
+ MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(ART_DIR)/backgnd.png a:
+ mv hdt.img hdt-$(VERSION).img
+ ln -sf hdt-$(VERSION).img hdt.img
+
+hdt.img.gz: hdt.img
+ rm -rf hdt*.img.gz
+ $(GZIPPROG) -c hdt-$(VERSION).img >hdt-$(VERSION).img.gz
+ ln -sf hdt-$(VERSION).img.gz hdt.img.gz
+
+hdt.iso: hdt.c32 $(topdir)/core/isolinux.bin $(FLOPPY_DIR)/hdt.cfg memtest
+ rm -rf $(ISO_DIR)
+ rm -f hdt.iso
+ mkdir -p $(ISO_DIR)/$(ISOLINUX_DIR)
+ cp $(topdir)/core/isolinux.bin $(ISO_DIR)/$(ISOLINUX_DIR)
+ $(SED) -e 's/%VERSION%/$(VERSION)/g' $(FLOPPY_DIR)/hdt.cfg |\
+ $(SED) -e 's/%CODENAME%/$(CODENAME)/g' > $(ISO_DIR)/$(ISOLINUX_DIR)/isolinux.cfg
+ cp hdt.c32 $(ISO_DIR)/$(ISOLINUX_DIR)
+ cp $(FLOPPY_DIR)/$(MEMTEST) $(ISO_DIR)/$(ISOLINUX_DIR)
+ cp $(MENU_COM32) $(ISO_DIR)/$(ISOLINUX_DIR)
+ cp -av $(ART_DIR)/backgnd.png $(ISO_DIR)/$(ISOLINUX_DIR)
+ -[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
+ -[ ! -f $(GZ_PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE) && $(GZIPPROG) $(PCI_IDS_FILE)
+ -[ -f $(MODULES_ALIAS_FILE) ] && cp $(MODULES_ALIAS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)\
+ && $(GZIPPROG) $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias\
+ && mv $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias.gz $(ISO_DIR)/$(ISOLINUX_DIR)/modules.alias
+ -[ -f $(MODULES_PCIMAP_FILE) ] && cp $(MODULES_PCIMAP_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)\
+ && $(GZIPPROG) $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap\
+ && mv $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap.gz $(ISO_DIR)/$(ISOLINUX_DIR)/modules.pcimap
+ -[ ! -f $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids.gz ] && cp $(GZ_PCI_IDS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids
+ -[ ! -f $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids ] && printf "\nThe $(FLOPPY_DIR)/pci.ids file is missing and can be downloaded from http://pciids.sourceforge.net and put in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n"
+ $(MKISOFS) -o hdt.iso -b $(ISOLINUX_DIR)/isolinux.bin -c $(ISOLINUX_DIR)/boot.cat \
+ -no-emul-boot -boot-load-size 4 -boot-info-table \
+ $(ISO_DIR)
+ mv hdt.iso hdt-$(VERSION).iso
+ ln -sf hdt-$(VERSION).iso hdt.iso
+
+release: spotless hdt.c32 hdt.img hdt.img.gz hdt.iso
+ mv hdt.c32 hdt_$(VERSION_C32).c32
+
+tidy dist:
+ rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
+
+clean: tidy
+ rm -f *.lnx
+
+spotless: clean
+ rm -f *.lss *.c32 *.com hdt*.img hdt*.iso hdt*.img.gz
+ rm -rf $(ISO_DIR)
+ rm -rf $(FLOPPY_DIR)/memtest
+ rm -rf $(FLOPPY_DIR)/pci.ids*
+ rm -f *~ \#*
+
+install:
+
+-include .*.d
diff --git a/contrib/syslinux-4.02/com32/hdt/README b/contrib/syslinux-4.02/com32/hdt/README
new file mode 100644
index 0000000..8e17161
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/README
@@ -0,0 +1,19 @@
+--------------
+Compiling HDT
+--------------
+To build HDT, you just have to do a "make" call in this directory.
+
+---------------------------
+Creating a bootable floppy
+--------------------------
+To build a bootable HDT floppy image, you can do a "make hdt.img" call.
+This will requires the mtools (http://mtools.linux.lu) to be installed.
+The script will try to pick several files from your system :
+- /lib/modules/`uname -r`/modules.alias
+- /lib/modules/`uname -r`/modules.pcimap
+- /usr/share/pci.ids or /usr/share/hwdata/pci.ids
+
+This paths can be overrided with the following command line:
+make MODULES_ALIAS_FILE=$(PWD)/floppy/modules.alias MODULES_PCIMAP_FILE=$(PWD)/floppy/modules.pcimap PCI_IDS_FILE=$(PWD)/floppy/pci.ids hdt.img
+
+If your system doesn't have pci.ids, please download it from http://pciids.sourceforge.net/ and put it into the floppy/ directory.
diff --git a/contrib/syslinux-4.02/com32/hdt/art/backgnd.png b/contrib/syslinux-4.02/com32/hdt/art/backgnd.png
new file mode 100644
index 0000000..a51efeb
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/art/backgnd.png
Binary files differ
diff --git a/contrib/syslinux-4.02/com32/hdt/art/hdt-black.png b/contrib/syslinux-4.02/com32/hdt/art/hdt-black.png
new file mode 100644
index 0000000..9bfdd94
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/art/hdt-black.png
Binary files differ
diff --git a/contrib/syslinux-4.02/com32/hdt/art/hdt.png b/contrib/syslinux-4.02/com32/hdt/art/hdt.png
new file mode 100644
index 0000000..3dad8e7
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/art/hdt.png
Binary files differ
diff --git a/contrib/syslinux-4.02/com32/hdt/floppy/hdt.cfg b/contrib/syslinux-4.02/com32/hdt/floppy/hdt.cfg
new file mode 100644
index 0000000..1350521
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/floppy/hdt.cfg
@@ -0,0 +1,78 @@
+UI menu.c32
+DEFAULT hdt
+PROMPT 0
+TIMEOUT 50
+MENU TITLE Hardware Detection Tool (HDT) version %VERSION% (%CODENAME%)
+MENU MARGIN 0
+MENU ROWS 15
+MENU TABMSG
+MENU TABMSGROW -3
+MENU CMDLINEROW -3
+MENU HELPMSGROW -4
+MENU HELPMSGENDROW -1
+
+MENU COLOR SCREEN 37;40
+MENU COLOR BORDER 34;40
+MENU COLOR TITLE 1;33;40
+MENU COLOR SCROLLBAR 34;46
+MENU COLOR SEL 30;47
+MENU COLOR UNSEL 36;40
+MENU COLOR CMDMARK 37;40
+MENU COLOR CMDLINE 37;40
+MENU COLOR TABMSG 37;40
+MENU COLOR DISABLED 37;40
+MENU COLOR HELP 32;40
+
+LABEL hdt
+MENU LABEL Menu mode
+MENU DEFAULT
+TEXT HELP
+ Starts HDT using the MENU mode
+ENDTEXT
+COM32 hdt.c32
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet
+
+LABEL cli
+MENU LABEL CLI (VESA mode)
+TEXT HELP
+ Starts HDT using the Command Line Interface (CLI)
+ VESA mode is enabled
+ENDTEXT
+COM32 hdt.c32
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet nomenu vesa
+
+LABEL vesa
+MENU LABEL CLI (Text mode)
+TEXT HELP
+ Starts HDT using the Command Line Interface (CLI)
+ VESA mode is disabled
+ENDTEXT
+COM32 hdt.c32
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet nomenu
+
+LABEL summary
+MENU LABEL CLI (Auto summary)
+TEXT HELP
+ Starts HDT using the Command Line Interface (CLI) and run 'show summary'
+ VESA mode is enabled
+ENDTEXT
+COM32 hdt.c32
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet vesa nomenu auto='show summary'
+
+LABEL verbose
+MENU LABEL CLI (Verbose)
+TEXT HELP
+ Starts HDT using the Command Line Interface (CLI) using the verbose mode
+ VESA mode is enabled
+ENDTEXT
+COM32 hdt.c32
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids vesa nomenu
+
+MENU SEPARATOR
+
+LABEL memtest
+MENU LABEL Memtest86+ 4.10
+TEXT HELP
+ Starts Memtest86+ 4.10
+ENDTEXT
+LINUX memtest.bin
diff --git a/contrib/syslinux-4.02/com32/hdt/floppy/mtools.conf b/contrib/syslinux-4.02/com32/hdt/floppy/mtools.conf
new file mode 100644
index 0000000..adbe2c8
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/floppy/mtools.conf
@@ -0,0 +1,2 @@
+# Floppy image for HDT
+drive a: file="hdt.img"
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-ata.c b/contrib/syslinux-4.02/com32/hdt/hdt-ata.c
new file mode 100644
index 0000000..9ba17ba
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-ata.c
@@ -0,0 +1,38 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <console.h>
+#include <disk/geom.h>
+#include <disk/util.h>
+
+#include "com32io.h"
+#include "hdt-common.h"
+#include "hdt-ata.h"
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-ata.h b/contrib/syslinux-4.02/com32/hdt/hdt-ata.h
new file mode 100644
index 0000000..ff35a59
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-ata.h
@@ -0,0 +1,76 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_ATA_H
+#define DEFINE_HDT_ATA_H
+#include <com32io.h>
+
+#include <disk/geom.h>
+#include "hdt.h"
+
+struct ata_identify_device {
+ unsigned short words000_009[10];
+ unsigned char serial_no[20];
+ unsigned short words020_022[3];
+ unsigned char fw_rev[8];
+ unsigned char model[40];
+ unsigned short words047_079[33];
+ unsigned short major_rev_num;
+ unsigned short minor_rev_num;
+ unsigned short command_set_1;
+ unsigned short command_set_2;
+ unsigned short command_set_extension;
+ unsigned short cfs_enable_1;
+ unsigned short word086;
+ unsigned short csf_default;
+ unsigned short words088_255[168];
+} ATTR_PACKED;
+
+struct ata_driveinfo {
+ struct ata_identify_device aid; /* IDENTIFY xxx DEVICE data */
+ char host_bus_type[5];
+ char interface_type[9];
+ char interface_port;
+} ATTR_PACKED;
+
+/* Useless stuff until I manage how to send ata packets */
+#ifdef ATA
+enum {
+ ATA_ID_FW_REV = 23,
+ ATA_ID_PROD = 27,
+ ATA_ID_FW_REV_LEN = 8,
+ ATA_ID_PROD_LEN = 40,
+};
+void ata_id_c_string(const uint16_t * id, unsigned char *s, unsigned int ofs,
+ unsigned int len);
+void ata_id_string(const uint16_t * id, unsigned char *s, unsigned int ofs,
+ unsigned int len);
+void printregs(const com32sys_t * r);
+#endif
+
+#endif
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-cpu.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-cpu.c
new file mode 100644
index 0000000..1695ccd
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-cpu.c
@@ -0,0 +1,227 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_cpu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char features[81];
+ cpu_detect(hardware);
+ detect_dmi(hardware);
+ more_printf("CPU\n");
+ more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
+ more_printf(" Product : %s \n", hardware->cpu.model);
+ more_printf(" CPU Cores : %d \n", hardware->cpu.num_cores);
+ more_printf(" L2 Cache : %dK\n", hardware->cpu.l2_cache_size);
+
+ memset(features, 0, sizeof(features));
+ snprintf(features, sizeof(features), " Features : %d Mhz : ",
+ hardware->dmi.processor.current_speed);
+ if (hardware->cpu.flags.lm)
+ strcat(features, "x86_64 64bit ");
+ else
+ strcat(features, "x86 32bit ");
+ if (hardware->cpu.flags.smp)
+ strcat(features, "SMP ");
+ if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm)
+ strcat(features, "HwVIRT ");
+
+ more_printf("%s\n", features);
+}
+
+static void show_flag(char *buffer, bool flag, char *flag_name, bool flush)
+{
+ char output_buffer[81];
+ if ((((strlen(buffer) + strlen(flag_name)) > 66) && flag) || flush) {
+ snprintf(output_buffer, sizeof output_buffer, "Flags : %s\n",
+ buffer);
+ more_printf("%s", output_buffer);
+ memset(buffer, 0, sizeof(buffer));
+ if (flush)
+ return;
+ }
+ if (flag)
+ strcat(buffer, flag_name);
+}
+
+static void show_cpu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char buffer[81];
+ reset_more_printf();
+ more_printf("CPU\n");
+ more_printf("Vendor : %s\n", hardware->cpu.vendor);
+ more_printf("Model : %s\n", hardware->cpu.model);
+ more_printf("CPU Cores : %d\n", hardware->cpu.num_cores);
+ more_printf("L1 Cache : %dK + %dK (I + D) \n",
+ hardware->cpu.l1_instruction_cache_size,
+ hardware->cpu.l1_data_cache_size);
+ more_printf("L2 Cache : %dK\n", hardware->cpu.l2_cache_size);
+ more_printf("Family ID : %d\n", hardware->cpu.family);
+ more_printf("Model ID : %d\n", hardware->cpu.model_id);
+ more_printf("Stepping : %d\n", hardware->cpu.stepping);
+ if (hardware->is_dmi_valid) {
+ more_printf("FSB : %d MHz\n",
+ hardware->dmi.processor.external_clock);
+ more_printf("Cur. Speed: %d MHz\n",
+ hardware->dmi.processor.current_speed);
+ more_printf("Max Speed : %d MHz\n", hardware->dmi.processor.max_speed);
+ more_printf("Upgrade : %s\n", hardware->dmi.processor.upgrade);
+ more_printf("Voltage : %d.%02d\n",
+ hardware->dmi.processor.voltage_mv / 1000,
+ hardware->dmi.processor.voltage_mv -
+ ((hardware->dmi.processor.voltage_mv / 1000) * 1000));
+ }
+ if (hardware->cpu.flags.smp) {
+ more_printf("SMP : yes\n");
+ } else {
+ more_printf("SMP : no\n");
+ }
+ if (hardware->cpu.flags.lm) {
+ more_printf("x86_64 : yes\n");
+ } else {
+ more_printf("x86_64 : no\n");
+ }
+
+ if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm) {
+ more_printf("HwVirt : yes\n");
+ } else {
+ more_printf("HwVirt : no\n");
+ }
+
+ memset(buffer, 0, sizeof(buffer));
+ show_flag(buffer, hardware->cpu.flags.fpu, "fpu ", false);
+ show_flag(buffer, hardware->cpu.flags.vme, "vme ", false);
+ show_flag(buffer, hardware->cpu.flags.de, "de ", false);
+ show_flag(buffer, hardware->cpu.flags.pse, "pse ", false);
+ show_flag(buffer, hardware->cpu.flags.tsc, "tsc ", false);
+ show_flag(buffer, hardware->cpu.flags.msr, "msr ", false);
+ show_flag(buffer, hardware->cpu.flags.pae, "pae ", false);
+ show_flag(buffer, hardware->cpu.flags.mce, "mce ", false);
+ show_flag(buffer, hardware->cpu.flags.cx8, "cx8 ", false);
+ show_flag(buffer, hardware->cpu.flags.apic, "apic ", false);
+ show_flag(buffer, hardware->cpu.flags.sep, "sep ", false);
+ show_flag(buffer, hardware->cpu.flags.mtrr, "mtrr ", false);
+ show_flag(buffer, hardware->cpu.flags.pge, "pge ", false);
+ show_flag(buffer, hardware->cpu.flags.mca, "mca ", false);
+ show_flag(buffer, hardware->cpu.flags.cmov, "cmov ", false);
+ show_flag(buffer, hardware->cpu.flags.pat, "pat ", false);
+ show_flag(buffer, hardware->cpu.flags.pse_36, "pse_36 ", false);
+ show_flag(buffer, hardware->cpu.flags.psn, "psn ", false);
+ show_flag(buffer, hardware->cpu.flags.clflsh, "clflsh ", false);
+ show_flag(buffer, hardware->cpu.flags.dts, "dts ", false);
+ show_flag(buffer, hardware->cpu.flags.acpi, "acpi ", false);
+ show_flag(buffer, hardware->cpu.flags.mmx, "mmx ", false);
+ show_flag(buffer, hardware->cpu.flags.sse, "sse ", false);
+ show_flag(buffer, hardware->cpu.flags.sse2, "sse2 ", false);
+ show_flag(buffer, hardware->cpu.flags.ss, "ss ", false);
+ show_flag(buffer, hardware->cpu.flags.htt, "ht ", false);
+ show_flag(buffer, hardware->cpu.flags.acc, "acc ", false);
+ show_flag(buffer, hardware->cpu.flags.syscall, "syscall ", false);
+ show_flag(buffer, hardware->cpu.flags.mp, "mp ", false);
+ show_flag(buffer, hardware->cpu.flags.nx, "nx ", false);
+ show_flag(buffer, hardware->cpu.flags.mmxext, "mmxext ", false);
+ show_flag(buffer, hardware->cpu.flags.lm, "lm ", false);
+ show_flag(buffer, hardware->cpu.flags.nowext, "3dnowext ", false);
+ show_flag(buffer, hardware->cpu.flags.now, "3dnow! ", false);
+ show_flag(buffer, hardware->cpu.flags.svm, "svm ", false);
+ show_flag(buffer, hardware->cpu.flags.vmx, "vmx ", false);
+ show_flag(buffer, hardware->cpu.flags.pbe, "pbe ", false);
+ show_flag(buffer, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
+ show_flag(buffer, hardware->cpu.flags.gbpages, "gbpages ", false);
+ show_flag(buffer, hardware->cpu.flags.rdtscp, "rdtscp ", false);
+ show_flag(buffer, hardware->cpu.flags.pni, "pni ", false);
+ show_flag(buffer, hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
+ show_flag(buffer, hardware->cpu.flags.dtes64, "dtes64 ", false);
+ show_flag(buffer, hardware->cpu.flags.smx, "smx ", false);
+ show_flag(buffer, hardware->cpu.flags.est, "est ", false);
+ show_flag(buffer, hardware->cpu.flags.tm2, "tm2 ", false);
+ show_flag(buffer, hardware->cpu.flags.sse3, "sse3 ", false);
+ show_flag(buffer, hardware->cpu.flags.fma, "fma ", false);
+ show_flag(buffer, hardware->cpu.flags.cx16, "cx16 ", false);
+ show_flag(buffer, hardware->cpu.flags.xtpr, "xtpr ", false);
+ show_flag(buffer, hardware->cpu.flags.pdcm, "pdcm ", false);
+ show_flag(buffer, hardware->cpu.flags.dca, "dca ", false);
+ show_flag(buffer, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
+ show_flag(buffer, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
+ show_flag(buffer, hardware->cpu.flags.x2apic, "x2apic ", false);
+ show_flag(buffer, hardware->cpu.flags.movbe, "movbe ", false);
+ show_flag(buffer, hardware->cpu.flags.popcnt, "popcnt ", false);
+ show_flag(buffer, hardware->cpu.flags.aes, "aes ", false);
+ show_flag(buffer, hardware->cpu.flags.xsave, "xsave ", false);
+ show_flag(buffer, hardware->cpu.flags.osxsave, "osxsave ", false);
+ show_flag(buffer, hardware->cpu.flags.avx, "avx ", false);
+ show_flag(buffer, hardware->cpu.flags.hypervisor, "hypervisor ", false);
+ show_flag(buffer, hardware->cpu.flags.ace2, "ace2 ", false);
+ show_flag(buffer, hardware->cpu.flags.ace2_en, "ace2_en ", false);
+ show_flag(buffer, hardware->cpu.flags.phe, "phe ", false);
+ show_flag(buffer, hardware->cpu.flags.phe_en, "phe_en ", false);
+ show_flag(buffer, hardware->cpu.flags.pmm, "pmm ", false);
+ show_flag(buffer, hardware->cpu.flags.pmm_en, "pmm_en ", false);
+ show_flag(buffer, hardware->cpu.flags.extapic, "extapic ", false);
+ show_flag(buffer, hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false);
+ show_flag(buffer, hardware->cpu.flags.abm, "abm ", false);
+ show_flag(buffer, hardware->cpu.flags.sse4a, "sse4a ", false);
+ show_flag(buffer, hardware->cpu.flags.misalignsse, "misalignsse ", false);
+ show_flag(buffer, hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false);
+ show_flag(buffer, hardware->cpu.flags.osvw, "osvw ", false);
+ show_flag(buffer, hardware->cpu.flags.ibs, "ibs ", false);
+ show_flag(buffer, hardware->cpu.flags.sse5, "sse5 ", false);
+ show_flag(buffer, hardware->cpu.flags.skinit, "skinit ", false);
+ show_flag(buffer, hardware->cpu.flags.wdt, "wdt ", false);
+ show_flag(buffer, hardware->cpu.flags.ida, "ida ", false);
+ show_flag(buffer, hardware->cpu.flags.arat, "arat ", false);
+ show_flag(buffer, hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false);
+ show_flag(buffer, hardware->cpu.flags.vnmi, "vnmi ", false);
+ show_flag(buffer, hardware->cpu.flags.flexpriority, "flexpriority ", false);
+ show_flag(buffer, hardware->cpu.flags.ept, "ept ", false);
+ show_flag(buffer, hardware->cpu.flags.vpid, "vpid ", false);
+
+ /* Let's flush the remaining flags */
+ show_flag(buffer, false, "", true);
+}
+
+struct cli_module_descr cpu_show_modules = {
+ .modules = NULL,
+ .default_callback = show_cpu,
+};
+
+struct cli_mode_descr cpu_mode = {
+ .mode = CPU_MODE,
+ .name = CLI_CPU,
+ .default_modules = NULL,
+ .show_modules = &cpu_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-disk.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-disk.c
new file mode 100644
index 0000000..c43b7ca
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-disk.c
@@ -0,0 +1,253 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+#include "hdt-util.h"
+
+/**
+ * show_partition_information - print information about a partition
+ * @ptab: part_entry describing the partition
+ * @i: Partition number (UI purposes only)
+ * @ptab_root: part_entry describing the root partition (extended only)
+ * @drive_info: driveinfo struct describing the drive on which the partition
+ * is
+ *
+ * Note on offsets (from hpa, see chain.c32):
+ *
+ * To make things extra confusing: data partition offsets are relative to where
+ * the data partition record is stored, whereas extended partition offsets
+ * are relative to the beginning of the extended partition all the way back
+ * at the MBR... but still not absolute!
+ **/
+static void show_partition_information(struct driveinfo *drive_info,
+ struct part_entry *ptab,
+ int partition_offset,
+ int nb_partitions_seen)
+{
+ char size[11];
+ char bootloader_name[9];
+ char *parttype;
+ unsigned int start, end;
+
+ int i = nb_partitions_seen;
+
+ reset_more_printf();
+
+ start = partition_offset;
+ end = start + ptab->length - 1;
+
+ if (ptab->length > 0)
+ sectors_to_size(ptab->length, size);
+ else
+ memset(size, 0, sizeof size);
+
+ if (i == 1)
+ more_printf(" # B Start End Size Id Type\n");
+
+ get_label(ptab->ostype, &parttype);
+ more_printf("%2d %s %11d %11d %s %02X %s",
+ i, (ptab->active_flag == 0x80) ? "x" : " ",
+ start, end, size, ptab->ostype, parttype);
+
+ /* Extra info */
+ if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab))
+ more_printf("%s", " (Swsusp sig. detected)");
+
+ if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0)
+ more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name);
+
+ more_printf("\n");
+
+ free(parttype);
+}
+
+void main_show_disk(int argc, char **argv, struct s_hardware *hardware)
+{
+ if (!argc) {
+ more_printf("Which disk?\n");
+ return;
+ }
+
+ int drive = strtol(argv[0], (char **)NULL, 16);
+
+ if (drive < 0x80 || drive >= 0xff) {
+ more_printf("Invalid disk: %d.\n", drive);
+ return;
+ }
+
+ int i = drive - 0x80;
+ struct driveinfo *d = &hardware->disk_info[i];
+ char disk_size[11];
+ char mbr_name[50];
+
+ detect_disks(hardware);
+ reset_more_printf();
+
+ if (!hardware->disk_info[i].cbios) {
+ more_printf("No disk found\n");
+ return; /* Invalid geometry */
+ }
+
+ get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50);
+
+ if ((int)d->edd_params.sectors > 0)
+ sectors_to_size((int)d->edd_params.sectors, disk_size);
+ else
+ memset(disk_size, 0, sizeof disk_size);
+
+ more_printf("DISK 0x%X:\n"
+ " C/H/S: %d cylinders, %d heads, %d sectors/track\n"
+ " EDD: Version: %X\n"
+ " Size: %s, %d bytes/sector, %d sectors/track\n"
+ " Host bus: %s, Interface type: %s\n"
+ " MBR: %s (id 0x%X)\n\n",
+ d->disk,
+ d->legacy_max_cylinder + 1, d->legacy_max_head + 1,
+ d->legacy_sectors_per_track, d->edd_version, disk_size,
+ (int)d->edd_params.bytes_per_sector,
+ (int)d->edd_params.sectors_per_track,
+ remove_spaces((char *)d->edd_params.host_bus_type),
+ remove_spaces((char *)d->edd_params.interface_type), mbr_name,
+ hardware->mbr_ids[i]);
+ display_line_nb += 6;
+
+ if (parse_partition_table(d, &show_partition_information)) {
+ if (errno_disk) {
+ fprintf(stderr, "I/O error parsing disk 0x%X\n", d->disk);
+ get_error("parse_partition_table");
+ } else {
+ fprintf(stderr, "Disk 0x%X: unrecognized partition layout\n",
+ d->disk);
+ }
+ fprintf(stderr, "\n");
+ }
+
+ more_printf("\n");
+}
+
+void main_show_disks(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ bool found = false;
+ reset_more_printf();
+ detect_disks(hardware);
+
+ int first_one = 0;
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ if (hardware->disk_info[drive - 0x80].cbios) {
+ found = true;
+ if (!first_one) {
+ first_one = 1;
+ } else {
+ pause_printf();
+ }
+ char buf[5] = "";
+ sprintf(buf, "0x%x", drive);
+ char *argv[1] = { buf };
+ main_show_disk(1, argv, hardware);
+ }
+ }
+
+ if (found == false)
+ more_printf("No disk found\n");
+}
+
+void disks_summary(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ int i = -1;
+ bool found = false;
+
+ detect_disks(hardware);
+ reset_more_printf();
+
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ i++;
+ if (!hardware->disk_info[i].cbios)
+ continue; /* Invalid geometry */
+
+ found = true;
+ struct driveinfo *d = &hardware->disk_info[i];
+ char disk_size[11];
+
+ if ((int)d->edd_params.sectors > 0)
+ sectors_to_size((int)d->edd_params.sectors, disk_size);
+ else
+ memset(disk_size, 0, sizeof disk_size);
+
+ more_printf("DISK 0x%X:\n", d->disk);
+ more_printf(" C/H/S: %d cylinders, %d heads, %d sectors/track\n",
+ d->legacy_max_cylinder + 1, d->legacy_max_head + 1,
+ d->legacy_sectors_per_track);
+ more_printf(" EDD: Version: %X, size: %s\n", d->edd_version,
+ disk_size);
+
+ /* Do not print Host Bus & Interface if EDD isn't 3.0 or more */
+ if (d->edd_version >= 0x30)
+ more_printf(" Host bus: %s, Interface type: %s\n\n",
+ remove_spaces((char *)d->edd_params.host_bus_type),
+ remove_spaces((char *)d->edd_params.interface_type));
+ }
+
+ if (found == false)
+ more_printf("No disk found\n");
+}
+
+struct cli_callback_descr list_disk_show_modules[] = {
+ {
+ .name = "disks",
+ .exec = main_show_disks,
+ },
+ {
+ .name = "disk",
+ .exec = main_show_disk,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr disk_show_modules = {
+ .modules = list_disk_show_modules,
+ .default_callback = disks_summary,
+};
+
+struct cli_mode_descr disk_mode = {
+ .mode = DISK_MODE,
+ .name = CLI_DISK,
+ .default_modules = NULL,
+ .show_modules = &disk_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-dmi.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-dmi.c
new file mode 100644
index 0000000..968308b
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-dmi.c
@@ -0,0 +1,688 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+static void show_dmi_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char available_dmi_commands[1024];
+ reset_more_printf();
+ memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
+
+ more_printf("Available DMI modules on your system:\n");
+ if (hardware->dmi.base_board.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BASE_BOARD);
+ if (hardware->dmi.battery.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BATTERY);
+ if (hardware->dmi.bios.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BIOS);
+ if (hardware->dmi.chassis.filled == true)
+ more_printf("\t%s\n", CLI_DMI_CHASSIS);
+ for (int i = 0; i < hardware->dmi.memory_count; i++) {
+ if (hardware->dmi.memory[i].filled == true) {
+ more_printf("\tbank <number>\n");
+ break;
+ }
+ }
+ for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
+ if (hardware->dmi.memory_module[i].filled == true) {
+ more_printf("\tmodule <number>\n");
+ break;
+ }
+ }
+ if (hardware->dmi.processor.filled == true)
+ more_printf("\t%s\n", CLI_DMI_PROCESSOR);
+ if (hardware->dmi.system.filled == true)
+ more_printf("\t%s\n", CLI_DMI_SYSTEM);
+ if (hardware->dmi.ipmi.filled == true)
+ more_printf("\t%s\n", CLI_DMI_IPMI);
+ if (hardware->dmi.cache_count)
+ more_printf("\t%s\n", CLI_DMI_CACHE);
+ if (strlen(hardware->dmi.oem_strings))
+ more_printf("\t%s\n", CLI_DMI_OEM);
+ if (hardware->dmi.hardware_security.filled)
+ more_printf("\t%s\n", CLI_DMI_SECURITY);
+}
+
+static void show_dmi_base_board(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.base_board.filled == false) {
+ more_printf("base_board information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("Base board\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.base_board.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.base_board.product_name);
+ more_printf(" Version : %s\n", hardware->dmi.base_board.version);
+ more_printf(" Serial : %s\n", hardware->dmi.base_board.serial);
+ more_printf(" Asset Tag : %s\n", hardware->dmi.base_board.asset_tag);
+ more_printf(" Location : %s\n", hardware->dmi.base_board.location);
+ more_printf(" Type : %s\n", hardware->dmi.base_board.type);
+ for (int i = 0; i < BASE_BOARD_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.base_board.features))[i] == true) {
+ more_printf(" %s\n", base_board_features_strings[i]);
+ }
+ }
+
+ for (unsigned int i = 0;
+ i <
+ sizeof hardware->dmi.base_board.devices_information /
+ sizeof *hardware->dmi.base_board.devices_information; i++) {
+ if (strlen(hardware->dmi.base_board.devices_information[i].type)) {
+ more_printf("On Board Device #%u Information\n", i)
+ more_printf(" Type : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ type);
+ more_printf(" Status : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ status ? "Enabled" : "Disabled");
+ more_printf(" Description : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ description);
+ }
+ }
+}
+
+static void show_dmi_system(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.system.filled == false) {
+ more_printf("system information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("System\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.system.product_name);
+ more_printf(" Version : %s\n", hardware->dmi.system.version);
+ more_printf(" Serial : %s\n", hardware->dmi.system.serial);
+ more_printf(" UUID : %s\n", hardware->dmi.system.uuid);
+ more_printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type);
+ more_printf(" SKU Number : %s\n", hardware->dmi.system.sku_number);
+ more_printf(" Family : %s\n", hardware->dmi.system.family);
+
+ if (strlen(hardware->dmi.system.configuration_options)) {
+ more_printf("System Configuration Options\n");
+ more_printf("%s\n", hardware->dmi.system.configuration_options);
+ }
+
+ if (hardware->dmi.system.system_reset.filled) {
+ more_printf("System Reset\n");
+ more_printf(" Status : %s\n",
+ (hardware->dmi.system.system_reset.
+ status ? "Enabled" : "Disabled"));
+ more_printf(" Watchdog Timer : %s\n",
+ (hardware->dmi.system.system_reset.
+ watchdog ? "Present" : "Not Present"));
+ if (strlen(hardware->dmi.system.system_reset.boot_option))
+ more_printf(" Boot Option : %s\n",
+ hardware->dmi.system.system_reset.boot_option);
+ if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit))
+ more_printf(" Boot Option On Limit : %s\n",
+ hardware->dmi.system.system_reset.boot_option_on_limit);
+ if (strlen(hardware->dmi.system.system_reset.reset_count))
+ more_printf(" Reset Count : %s\n",
+ hardware->dmi.system.system_reset.reset_count);
+ if (strlen(hardware->dmi.system.system_reset.reset_limit))
+ more_printf(" Reset Limit : %s\n",
+ hardware->dmi.system.system_reset.reset_limit);
+ if (strlen(hardware->dmi.system.system_reset.timer_interval))
+ more_printf(" Timer Interval : %s\n",
+ hardware->dmi.system.system_reset.timer_interval);
+ if (strlen(hardware->dmi.system.system_reset.timeout))
+ more_printf(" Timeout : %s\n",
+ hardware->dmi.system.system_reset.timeout);
+ }
+
+ more_printf("System Boot Information\n");
+ more_printf(" Status : %s\n",
+ hardware->dmi.system.system_boot_status);
+}
+
+static void show_dmi_bios(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.bios.filled == false) {
+ more_printf("bios information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("BIOS\n");
+ more_printf(" Vendor : %s\n", hardware->dmi.bios.vendor);
+ more_printf(" Version : %s\n", hardware->dmi.bios.version);
+ more_printf(" Release Date : %s\n", hardware->dmi.bios.release_date);
+ more_printf(" Bios Revision : %s\n", hardware->dmi.bios.bios_revision);
+ if (strlen(hardware->dmi.bios.firmware_revision))
+ more_printf(" Firmware Revision : %s\n",
+ hardware->dmi.bios.firmware_revision);
+ more_printf(" Address : 0x%04X0\n", hardware->dmi.bios.address);
+ more_printf(" Runtime address : %u %s\n",
+ hardware->dmi.bios.runtime_size,
+ hardware->dmi.bios.runtime_size_unit);
+ more_printf(" Rom size : %u %s\n", hardware->dmi.bios.rom_size,
+ hardware->dmi.bios.rom_size_unit);
+
+ for (int i = 0; i < BIOS_CHAR_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics))[i] == true) {
+ more_printf(" %s\n", bios_charac_strings[i]);
+ }
+ }
+ for (int i = 0; i < BIOS_CHAR_X1_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics_x1))[i] == true) {
+ more_printf(" %s\n", bios_charac_x1_strings[i]);
+ }
+ }
+
+ for (int i = 0; i < BIOS_CHAR_X2_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics_x2))[i] == true) {
+ more_printf(" %s\n", bios_charac_x2_strings[i]);
+ }
+ }
+
+}
+
+static void show_dmi_chassis(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.chassis.filled == false) {
+ more_printf("chassis information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("Chassis\n");
+ more_printf(" Manufacturer : %s\n",
+ hardware->dmi.chassis.manufacturer);
+ more_printf(" Type : %s\n", hardware->dmi.chassis.type);
+ more_printf(" Lock : %s\n", hardware->dmi.chassis.lock);
+ more_printf(" Version : %s\n", hardware->dmi.chassis.version);
+ more_printf(" Serial : %s\n", hardware->dmi.chassis.serial);
+ more_printf(" Asset Tag : %s\n",
+ del_multi_spaces(hardware->dmi.chassis.asset_tag));
+ more_printf(" Boot up state : %s\n",
+ hardware->dmi.chassis.boot_up_state);
+ more_printf(" Power supply state : %s\n",
+ hardware->dmi.chassis.power_supply_state);
+ more_printf(" Thermal state : %s\n",
+ hardware->dmi.chassis.thermal_state);
+ more_printf(" Security Status : %s\n",
+ hardware->dmi.chassis.security_status);
+ more_printf(" OEM Information : %s\n",
+ hardware->dmi.chassis.oem_information);
+ more_printf(" Height : %u\n", hardware->dmi.chassis.height);
+ more_printf(" NB Power Cords : %u\n",
+ hardware->dmi.chassis.nb_power_cords);
+}
+
+static void show_dmi_ipmi(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.ipmi.filled == false) {
+ more_printf("IPMI module not available\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("IPMI\n");
+ more_printf(" Interface Type : %s\n",
+ hardware->dmi.ipmi.interface_type);
+ more_printf(" Specification Ver. : %u.%u\n",
+ hardware->dmi.ipmi.major_specification_version,
+ hardware->dmi.ipmi.minor_specification_version);
+ more_printf(" I2C Slave Address : 0x%02x\n",
+ hardware->dmi.ipmi.I2C_slave_address);
+ more_printf(" Nv Storage Address : %u\n", hardware->dmi.ipmi.nv_address);
+ uint32_t high = hardware->dmi.ipmi.base_address >> 32;
+ uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF;
+ more_printf(" Base Address : %08X%08X\n", high, (low & ~1));
+ more_printf(" IRQ : %d\n", hardware->dmi.ipmi.irq);
+}
+
+static void show_dmi_battery(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.battery.filled == false) {
+ more_printf("battery information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("Battery \n");
+ more_printf(" Vendor : %s\n",
+ hardware->dmi.battery.manufacturer);
+ more_printf(" Manufacture Date : %s\n",
+ hardware->dmi.battery.manufacture_date);
+ more_printf(" Serial : %s\n", hardware->dmi.battery.serial);
+ more_printf(" Name : %s\n", hardware->dmi.battery.name);
+ more_printf(" Chemistry : %s\n", hardware->dmi.battery.chemistry);
+ more_printf(" Design Capacity : %s\n",
+ hardware->dmi.battery.design_capacity);
+ more_printf(" Design Voltage : %s\n",
+ hardware->dmi.battery.design_voltage);
+ more_printf(" SBDS : %s\n", hardware->dmi.battery.sbds);
+ more_printf(" SBDS Manuf. Date : %s\n",
+ hardware->dmi.battery.sbds_manufacture_date);
+ more_printf(" SBDS Chemistry : %s\n",
+ hardware->dmi.battery.sbds_chemistry);
+ more_printf(" Maximum Error : %s\n",
+ hardware->dmi.battery.maximum_error);
+ more_printf(" OEM Info : %s\n", hardware->dmi.battery.oem_info);
+}
+
+static void show_dmi_cpu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ if (hardware->dmi.processor.filled == false) {
+ more_printf("processor information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("CPU\n");
+ more_printf(" Socket Designation : %s\n",
+ hardware->dmi.processor.socket_designation);
+ more_printf(" Type : %s\n", hardware->dmi.processor.type);
+ more_printf(" Family : %s\n", hardware->dmi.processor.family);
+ more_printf(" Manufacturer : %s\n",
+ hardware->dmi.processor.manufacturer);
+ more_printf(" Version : %s\n", hardware->dmi.processor.version);
+ more_printf(" External Clock : %u\n",
+ hardware->dmi.processor.external_clock);
+ more_printf(" Max Speed : %u\n",
+ hardware->dmi.processor.max_speed);
+ more_printf(" Current Speed : %u\n",
+ hardware->dmi.processor.current_speed);
+ more_printf(" Cpu Type : %u\n",
+ hardware->dmi.processor.signature.type);
+ more_printf(" Cpu Family : %u\n",
+ hardware->dmi.processor.signature.family);
+ more_printf(" Cpu Model : %u\n",
+ hardware->dmi.processor.signature.model);
+ more_printf(" Cpu Stepping : %u\n",
+ hardware->dmi.processor.signature.stepping);
+ more_printf(" Cpu Minor Stepping : %u\n",
+ hardware->dmi.processor.signature.minor_stepping);
+// more_printf(" Voltage : %f\n",hardware->dmi.processor.voltage);
+ more_printf(" Status : %s\n", hardware->dmi.processor.status);
+ more_printf(" Upgrade : %s\n", hardware->dmi.processor.upgrade);
+ more_printf(" Cache L1 Handle : %s\n", hardware->dmi.processor.cache1);
+ more_printf(" Cache L2 Handle : %s\n", hardware->dmi.processor.cache2);
+ more_printf(" Cache L3 Handle : %s\n", hardware->dmi.processor.cache3);
+ more_printf(" Serial : %s\n", hardware->dmi.processor.serial);
+ more_printf(" Part Number : %s\n",
+ hardware->dmi.processor.part_number);
+ more_printf(" ID : %s\n", hardware->dmi.processor.id);
+ for (int i = 0; i < PROCESSOR_FLAGS_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.processor.cpu_flags))[i] == true) {
+ more_printf(" %s\n", cpu_flags_strings[i]);
+ }
+ }
+}
+
+void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware)
+{
+ int bank = -1;
+
+ /* Sanitize arguments */
+ if (argc > 0)
+ bank = strtol(argv[0], (char **)NULL, 10);
+
+ if (errno == ERANGE || bank < 0) {
+ more_printf("This bank number is incorrect\n");
+ return;
+ }
+
+ if ((bank >= hardware->dmi.memory_count) || (bank < 0)) {
+ more_printf("Bank %d number doesn't exist\n", bank);
+ return;
+ }
+ if (hardware->dmi.memory[bank].filled == false) {
+ more_printf("Bank %d doesn't contain any information\n", bank);
+ return;
+ }
+
+ reset_more_printf();
+ more_printf("Memory Bank %d\n", bank);
+ more_printf(" Form Factor : %s\n", hardware->dmi.memory[bank].form_factor);
+ more_printf(" Type : %s\n", hardware->dmi.memory[bank].type);
+ more_printf(" Type Detail : %s\n", hardware->dmi.memory[bank].type_detail);
+ more_printf(" Speed : %s\n", hardware->dmi.memory[bank].speed);
+ more_printf(" Size : %s\n", hardware->dmi.memory[bank].size);
+ more_printf(" Device Set : %s\n", hardware->dmi.memory[bank].device_set);
+ more_printf(" Device Loc. : %s\n",
+ hardware->dmi.memory[bank].device_locator);
+ more_printf(" Bank Locator : %s\n",
+ hardware->dmi.memory[bank].bank_locator);
+ more_printf(" Total Width : %s\n", hardware->dmi.memory[bank].total_width);
+ more_printf(" Data Width : %s\n", hardware->dmi.memory[bank].data_width);
+ more_printf(" Error : %s\n", hardware->dmi.memory[bank].error);
+ more_printf(" Vendor : %s\n",
+ hardware->dmi.memory[bank].manufacturer);
+ more_printf(" Serial : %s\n", hardware->dmi.memory[bank].serial);
+ more_printf(" Asset Tag : %s\n", hardware->dmi.memory[bank].asset_tag);
+ more_printf(" Part Number : %s\n", hardware->dmi.memory[bank].part_number);
+}
+
+static void show_dmi_cache(int argc, char **argv, struct s_hardware *hardware)
+{
+ if (!hardware->dmi.cache_count) {
+ more_printf("cache information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+
+ int cache = strtol(argv[0], NULL, 10);
+
+ if (argc != 1 || cache > hardware->dmi.cache_count) {
+ more_printf("show cache [0-%d]\n", hardware->dmi.cache_count - 1);
+ return;
+ }
+
+ reset_more_printf();
+
+ more_printf("Cache Information #%d\n", cache);
+ more_printf(" Socket Designation : %s\n",
+ hardware->dmi.cache[cache].socket_designation);
+ more_printf(" Configuration : %s\n",
+ hardware->dmi.cache[cache].configuration);
+ more_printf(" Operational Mode : %s\n",
+ hardware->dmi.cache[cache].mode);
+ more_printf(" Location : %s\n",
+ hardware->dmi.cache[cache].location);
+ more_printf(" Installed Size : %u KB",
+ hardware->dmi.cache[cache].installed_size);
+ more_printf("\n");
+ more_printf(" Maximum Size : %u KB",
+ hardware->dmi.cache[cache].max_size);
+ more_printf("\n");
+ more_printf(" Supported SRAM Types : %s",
+ hardware->dmi.cache[cache].supported_sram_types);
+ more_printf("\n");
+ more_printf(" Installed SRAM Type : %s",
+ hardware->dmi.cache[cache].installed_sram_types);
+ more_printf("\n");
+ more_printf(" Speed : %u ns",
+ hardware->dmi.cache[cache].speed);
+ more_printf("\n");
+ more_printf(" Error Correction Type : %s\n",
+ hardware->dmi.cache[cache].error_correction_type);
+ more_printf(" System Type : %s\n",
+ hardware->dmi.cache[cache].system_type);
+ more_printf(" Associativity : %s\n",
+ hardware->dmi.cache[cache].associativity);
+}
+
+void show_dmi_memory_module(int argc, char **argv, struct s_hardware *hardware)
+{
+ int module = -1;
+
+ /* Sanitize arguments */
+ if (argc > 0)
+ module = strtol(argv[0], (char **)NULL, 10);
+
+ if (errno == ERANGE || module < 0) {
+ more_printf("This module number is incorrect\n");
+ return;
+ }
+
+ if ((module >= hardware->dmi.memory_module_count) || (module < 0)) {
+ more_printf("Module number %d doesn't exist\n", module);
+ return;
+ }
+
+ if (hardware->dmi.memory_module[module].filled == false) {
+ more_printf("Module %d doesn't contain any information\n", module);
+ return;
+ }
+
+ reset_more_printf();
+ more_printf("Memory Module %d\n", module);
+ more_printf(" Socket Designation : %s\n",
+ hardware->dmi.memory_module[module].socket_designation);
+ more_printf(" Bank Connections : %s\n",
+ hardware->dmi.memory_module[module].bank_connections);
+ more_printf(" Current Speed : %s\n",
+ hardware->dmi.memory_module[module].speed);
+ more_printf(" Type : %s\n",
+ hardware->dmi.memory_module[module].type);
+ more_printf(" Installed Size : %s\n",
+ hardware->dmi.memory_module[module].installed_size);
+ more_printf(" Enabled Size : %s\n",
+ hardware->dmi.memory_module[module].enabled_size);
+ more_printf(" Error Status : %s\n",
+ hardware->dmi.memory_module[module].error_status);
+}
+
+void main_show_dmi(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+
+ detect_dmi(hardware);
+
+ if (hardware->is_dmi_valid == false) {
+ more_printf("No valid DMI table found, exiting.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("DMI Table version %u.%u found\n",
+ hardware->dmi.dmitable.major_version,
+ hardware->dmi.dmitable.minor_version);
+
+ show_dmi_modules(0, NULL, hardware);
+}
+
+void show_dmi_memory_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ /* Do we have so display unpopulated banks ? */
+ int show_free_banks = 1;
+
+ /* Needed, if called by the memory mode */
+ detect_dmi(hardware);
+
+ /* Detecting installed memory */
+ detect_memory(hardware);
+
+ more_printf("Memory Size : %lu MB (%lu KB)\n",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+
+ if ((hardware->dmi.memory_count <= 0)
+ && (hardware->dmi.memory_module_count <= 0)) {
+ more_printf("No memory bank found\n");
+ return;
+ }
+
+ /* Sanitize arguments */
+ if (argc > 0) {
+ /* When we display a summary, there is no need to show the unpopulated banks
+ * The first argv is set to define this behavior
+ */
+ show_free_banks = strtol(argv[0], NULL, 10);
+ if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1)
+ goto usage;
+ }
+
+ reset_more_printf();
+ /* If type 17 is available */
+ if (hardware->dmi.memory_count > 0) {
+ char bank_number[255];
+ more_printf("Memory Banks\n");
+ for (int i = 0; i < hardware->dmi.memory_count; i++) {
+ if (hardware->dmi.memory[i].filled == true) {
+ memset(bank_number, 0, sizeof(bank_number));
+ snprintf(bank_number, sizeof(bank_number), "%d ", i);
+ if (show_free_banks == false) {
+ if (strncmp(hardware->dmi.memory[i].size, "Free", 4))
+ more_printf(" bank %02d : %s %s@%s\n",
+ i, hardware->dmi.memory[i].size,
+ hardware->dmi.memory[i].type,
+ hardware->dmi.memory[i].speed);
+ } else {
+ more_printf(" bank %02d : %s %s@%s\n", i,
+ hardware->dmi.memory[i].size,
+ hardware->dmi.memory[i].type,
+ hardware->dmi.memory[i].speed);
+ }
+ }
+ }
+ } else if (hardware->dmi.memory_module_count > 0) {
+ /* Let's use type 6 as a fallback of type 17 */
+ more_printf("Memory Modules\n");
+ for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
+ if (hardware->dmi.memory_module[i].filled == true) {
+ more_printf(" module %02d : %s %s@%s\n", i,
+ hardware->dmi.memory_module[i].enabled_size,
+ hardware->dmi.memory_module[i].type,
+ hardware->dmi.memory_module[i].speed);
+ }
+ }
+ }
+
+ return;
+ //printf("Type 'show bank<bank_number>' for more details.\n");
+
+usage:
+ more_printf("show memory <clear screen? <show free banks?>>\n");
+ return;
+}
+
+void show_dmi_oem_strings(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ reset_more_printf();
+
+ if (strlen(hardware->dmi.oem_strings))
+ more_printf("OEM Strings\n%s", hardware->dmi.oem_strings);
+}
+
+void show_dmi_hardware_security(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ reset_more_printf();
+
+ if (!hardware->dmi.hardware_security.filled)
+ return;
+
+ more_printf("Hardware Security\n");
+ more_printf(" Power-On Password Status : %s\n",
+ hardware->dmi.hardware_security.power_on_passwd_status);
+ more_printf(" Keyboard Password Status : %s\n",
+ hardware->dmi.hardware_security.keyboard_passwd_status);
+ more_printf(" Administrator Password Status : %s\n",
+ hardware->dmi.hardware_security.administrator_passwd_status);
+ more_printf(" Front Panel Reset Status : %s\n",
+ hardware->dmi.hardware_security.front_panel_reset_status);
+}
+
+struct cli_callback_descr list_dmi_show_modules[] = {
+ {
+ .name = CLI_DMI_BASE_BOARD,
+ .exec = show_dmi_base_board,
+ },
+ {
+ .name = CLI_DMI_BIOS,
+ .exec = show_dmi_bios,
+ },
+ {
+ .name = CLI_DMI_BATTERY,
+ .exec = show_dmi_battery,
+ },
+ {
+ .name = CLI_DMI_CHASSIS,
+ .exec = show_dmi_chassis,
+ },
+ {
+ .name = CLI_DMI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
+ {
+ .name = "module",
+ .exec = show_dmi_memory_module,
+ },
+ {
+ .name = CLI_DMI_PROCESSOR,
+ .exec = show_dmi_cpu,
+ },
+ {
+ .name = CLI_DMI_SYSTEM,
+ .exec = show_dmi_system,
+ },
+ {
+ .name = CLI_DMI_OEM,
+ .exec = show_dmi_oem_strings,
+ },
+ {
+ .name = CLI_DMI_SECURITY,
+ .exec = show_dmi_hardware_security,
+ },
+ {
+ .name = CLI_DMI_IPMI,
+ .exec = show_dmi_ipmi,
+ },
+ {
+ .name = CLI_DMI_CACHE,
+ .exec = show_dmi_cache,
+ },
+ {
+ .name = CLI_DMI_LIST,
+ .exec = show_dmi_modules,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr dmi_show_modules = {
+ .modules = list_dmi_show_modules,
+ .default_callback = main_show_dmi,
+};
+
+struct cli_mode_descr dmi_mode = {
+ .mode = DMI_MODE,
+ .name = CLI_DMI,
+ .default_modules = NULL,
+ .show_modules = &dmi_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-hdt.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-hdt.c
new file mode 100644
index 0000000..f4854e3
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-hdt.c
@@ -0,0 +1,375 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <syslinux/config.h>
+#include <syslinux/reboot.h>
+
+#include "hdt-menu.h"
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+/**
+ * cli_clear_screen - clear (erase) the entire screen
+ **/
+static void cli_clear_screen(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ clear_screen();
+}
+
+/**
+ * main_show_modes - show availables modes
+ **/
+static void main_show_modes(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ int i = 0;
+
+ reset_more_printf();
+ printf("Available modes:\n");
+ while (list_modes[i]) {
+ printf("%s ", list_modes[i]->name);
+ i++;
+ }
+ printf("\n");
+}
+
+/**
+ * cli_set_mode - set the mode of the cli, in the cli
+ *
+ * The mode number must be supplied in argv, position 0.
+ **/
+static void cli_set_mode(int argc, char **argv, struct s_hardware *hardware)
+{
+ cli_mode_t new_mode;
+
+ reset_more_printf();
+ if (argc <= 0) {
+ more_printf("Which mode?\n");
+ return;
+ }
+
+ /*
+ * Note! argv[0] is a string representing the mode, we need the
+ * equivalent cli_mode_t to pass it to set_mode.
+ */
+ new_mode = mode_s_to_mode_t(argv[0]);
+ set_mode(new_mode, hardware);
+}
+
+/**
+ * do_exit - shared helper to exit a mode
+ **/
+static void do_exit(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ int new_mode = HDT_MODE;
+
+ switch (hdt_cli.mode) {
+ case HDT_MODE:
+ new_mode = EXIT_MODE;
+ break;
+ default:
+ new_mode = HDT_MODE;
+ break;
+ }
+
+ dprintf("CLI DEBUG: Switching from mode %d to mode %d\n", hdt_cli.mode,
+ new_mode);
+ set_mode(new_mode, hardware);
+}
+
+/**
+ * show_cli_help - shared helper to show available commands
+ **/
+static void show_cli_help(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ int j = 0;
+ struct cli_mode_descr *current_mode;
+ struct cli_callback_descr *associated_module = NULL;
+
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
+
+ printf("Available commands are:\n");
+
+ /* List first default modules of the mode */
+ if (current_mode->default_modules && current_mode->default_modules->modules) {
+ while (current_mode->default_modules->modules[j].name) {
+ printf("%s ", current_mode->default_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ /* List secondly the show modules of the mode */
+ if (current_mode->show_modules && current_mode->show_modules->modules) {
+ printf("\nshow commands:\n");
+ j = 0;
+ while (current_mode->show_modules->modules[j].name) {
+ printf("%s ", current_mode->show_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ /* List thirdly the set modules of the mode */
+ if (current_mode->set_modules && current_mode->set_modules->modules) {
+ printf("\nset commands:\n");
+ j = 0;
+ while (current_mode->set_modules->modules[j].name) {
+ printf("%s ", current_mode->set_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ /* List finally the default modules of the hdt mode */
+ if (current_mode->mode != hdt_mode.mode &&
+ hdt_mode.default_modules && hdt_mode.default_modules->modules) {
+ j = 0;
+ while (hdt_mode.default_modules->modules[j].name) {
+ /*
+ * Any default command that is present in hdt mode but
+ * not in the current mode is available. A default
+ * command can be redefined in the current mode though.
+ * This next call test this use case: if it is
+ * overwritten, do not print it again.
+ */
+ find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
+ current_mode->default_modules,
+ &associated_module);
+ if (associated_module == NULL)
+ printf("%s ", hdt_mode.default_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ printf("\n");
+ main_show_modes(argc, argv, hardware);
+}
+
+/**
+ * show_cli_help - shared helper to show available commands
+ **/
+static void goto_menu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char version_string[256];
+ snprintf(version_string, sizeof version_string, "%s %s (%s)",
+ PRODUCT_NAME, VERSION, CODENAME);
+ start_menu_mode(hardware, version_string);
+ return;
+}
+
+/**
+ * main_show_summary - give an overview of the system
+ **/
+void main_show_summary(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ detect_pci(hardware); /* pxe is detected in the pci */
+ detect_dmi(hardware);
+ cpu_detect(hardware);
+ detect_memory(hardware);
+ reset_more_printf();
+ clear_screen();
+ main_show_cpu(argc, argv, hardware);
+ if (hardware->is_dmi_valid) {
+ more_printf("System\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.system.product_name);
+ more_printf(" Serial : %s\n", hardware->dmi.system.serial);
+ more_printf("Bios\n");
+ more_printf(" Version : %s\n", hardware->dmi.bios.version);
+ more_printf(" Release : %s\n", hardware->dmi.bios.release_date);
+ more_printf("Memory Size : %lu MB (%lu KB)\n",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+ }
+ main_show_pci(argc, argv, hardware);
+
+ if (hardware->is_pxe_valid)
+ main_show_pxe(argc, argv, hardware);
+
+ main_show_kernel(argc, argv, hardware);
+}
+
+void main_show_hdt(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ reset_more_printf();
+ more_printf("HDT\n");
+ more_printf(" Product : %s\n", PRODUCT_NAME);
+ more_printf(" Version : %s (%s)\n", VERSION, CODENAME);
+ more_printf(" Website : %s\n", WEBSITE_URL);
+ more_printf(" Mailing List : %s\n", CONTACT);
+ more_printf(" Project Leader : %s\n", AUTHOR);
+ more_printf(" Core Developer : %s\n", CORE_DEVELOPER);
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c = 0; c < NB_CONTRIBUTORS; c++) {
+ more_printf(" Contributor : %s\n", contributors[c]);
+ }
+}
+
+/**
+ * do_reboot - reboot the system
+ **/
+static void do_reboot(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ (void) hardware;
+ /* Let's call the internal rebooting call */
+ syslinux_reboot(1);
+}
+
+/* Default hdt mode */
+struct cli_callback_descr list_hdt_default_modules[] = {
+ {
+ .name = CLI_CLEAR,
+ .exec = cli_clear_screen,
+ },
+ {
+ .name = CLI_EXIT,
+ .exec = do_exit,
+ },
+ {
+ .name = CLI_HELP,
+ .exec = show_cli_help,
+ },
+ {
+ .name = CLI_MENU,
+ .exec = goto_menu,
+ },
+ {
+ .name = CLI_REBOOT,
+ .exec = do_reboot,
+ },
+ {
+ .name = CLI_HISTORY,
+ .exec = print_history,
+ },
+ {
+ .name = NULL,
+ .exec = NULL},
+};
+
+struct cli_callback_descr list_hdt_show_modules[] = {
+ {
+ .name = CLI_SUMMARY,
+ .exec = main_show_summary,
+ },
+ {
+ .name = CLI_PCI,
+ .exec = main_show_pci,
+ },
+ {
+ .name = CLI_DMI,
+ .exec = main_show_dmi,
+ },
+ {
+ .name = CLI_CPU,
+ .exec = main_show_cpu,
+ },
+ {
+ .name = CLI_DISK,
+ .exec = disks_summary,
+ },
+ {
+ .name = CLI_PXE,
+ .exec = main_show_pxe,
+ },
+ {
+ .name = CLI_SYSLINUX,
+ .exec = main_show_syslinux,
+ },
+ {
+ .name = CLI_KERNEL,
+ .exec = main_show_kernel,
+ },
+ {
+ .name = CLI_VESA,
+ .exec = main_show_vesa,
+ },
+ {
+ .name = CLI_HDT,
+ .exec = main_show_hdt,
+ },
+ {
+ .name = CLI_VPD,
+ .exec = main_show_vpd,
+ },
+ {
+ .name = CLI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
+ {
+ .name = "modes",
+ .exec = main_show_modes,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_callback_descr list_hdt_set_modules[] = {
+ {
+ .name = CLI_MODE,
+ .exec = cli_set_mode,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr hdt_default_modules = {
+ .modules = list_hdt_default_modules,
+};
+
+struct cli_module_descr hdt_show_modules = {
+ .modules = list_hdt_show_modules,
+ .default_callback = main_show_summary,
+};
+
+struct cli_module_descr hdt_set_modules = {
+ .modules = list_hdt_set_modules,
+};
+
+struct cli_mode_descr hdt_mode = {
+ .mode = HDT_MODE,
+ .name = CLI_HDT,
+ .default_modules = &hdt_default_modules,
+ .show_modules = &hdt_show_modules,
+ .set_modules = &hdt_set_modules,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-kernel.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-kernel.c
new file mode 100644
index 0000000..f64771b
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-kernel.c
@@ -0,0 +1,155 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_kernel(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char buffer[1024] = {0};
+ struct pci_device *pci_device;
+ bool found = false;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ detect_pci(hardware);
+ reset_more_printf();
+ more_printf("Kernel modules\n");
+
+// more_printf(" PCI device no: %d \n", p->pci_device_pos);
+
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP)
+ && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ more_printf(" modules.pcimap and modules.alias files are missing\n");
+ return;
+ }
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+
+ if ((pci_device->dev_info->linux_kernel_module_count > 0)
+ && (!strstr(buffer, kernel_modules))) {
+ found = true;
+ if (pci_device->dev_info->linux_kernel_module_count > 1)
+ strncat(buffer, "(", 1);
+ strncat(buffer, kernel_modules, sizeof(kernel_modules));
+ if (pci_device->dev_info->linux_kernel_module_count > 1)
+ strncat(buffer, ")", 1);
+ strncat(buffer, " # ", 3);
+ }
+
+ }
+ if (found == true) {
+ strncat(buffer, "\n", 1);
+ more_printf("%s", buffer);
+ }
+}
+
+static void show_kernel_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ char modules[MAX_PCI_CLASSES][256] = {{0}};
+ char category_name[MAX_PCI_CLASSES][256] = {{0}};
+
+ detect_pci(hardware);
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ more_printf(" Missing pci.ids, we can't compute the list\n");
+ return;
+ }
+
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ more_printf(" Missing modules.pcimap, we can't compute the list\n");
+ return;
+ }
+
+ reset_more_printf();
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ strncat(kernel_modules, " ", 1);
+ }
+
+ if ((pci_device->dev_info->linux_kernel_module_count > 0)
+ && (!strstr(modules[pci_device->class[2]], kernel_modules))) {
+ strncat(modules[pci_device->class[2]], kernel_modules,
+ sizeof(kernel_modules));
+ snprintf(category_name[pci_device->class[2]],
+ sizeof(category_name[pci_device->class[2]]),
+ "%s", pci_device->dev_info->category_name);
+ }
+ }
+ /* Print the found items */
+ for (int i = 0; i < MAX_PCI_CLASSES; i++) {
+ if (strlen(category_name[i]) > 1) {
+ more_printf("%s : %s\n", category_name[i], modules[i]);
+ }
+ }
+}
+
+struct cli_module_descr kernel_show_modules = {
+ .modules = NULL,
+ .default_callback = show_kernel_modules,
+};
+
+struct cli_mode_descr kernel_mode = {
+ .mode = KERNEL_MODE,
+ .name = CLI_KERNEL,
+ .default_modules = NULL,
+ .show_modules = &kernel_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-memory.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-memory.c
new file mode 100644
index 0000000..51d087e
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-memory.c
@@ -0,0 +1,134 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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 <memory.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+static void show_memory_e820(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ struct e820entry map[E820MAX];
+ unsigned long memsize = 0;
+ int count = 0;
+ char type[14];
+
+ detect_memory_e820(map, E820MAX, &count);
+ memsize = memsize_e820(map, count);
+ reset_more_printf();
+ more_printf("Detected RAM : %lu MiB (%lu KiB)\n",
+ (memsize + (1 << 9)) >> 10, memsize);
+ more_printf("BIOS-provided physical RAM e820 map:\n");
+ for (int i = 0; i < count; i++) {
+ get_type(map[i].type, type, 14);
+ more_printf("%016llx - %016llx %016llx (%s)\n",
+ map[i].addr, map[i].size, map[i].addr + map[i].size,
+ remove_spaces(type));
+ }
+ struct e820entry nm[E820MAX];
+
+ /* Clean up, adjust and copy the BIOS-supplied E820-map. */
+ int nr = sanitize_e820_map(map, nm, count);
+
+ more_printf("\n");
+ more_printf("Sanitized e820 map:\n");
+ for (int i = 0; i < nr; i++) {
+ get_type(nm[i].type, type, 14);
+ more_printf("%016llx - %016llx %016llx (%s)\n",
+ nm[i].addr, nm[i].size, nm[i].addr + nm[i].size,
+ remove_spaces(type));
+ }
+}
+
+static void show_memory_e801(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ int mem_low, mem_high = 0;
+
+ reset_more_printf();
+ if (detect_memory_e801(&mem_low, &mem_high)) {
+ more_printf("e801 bogus!\n");
+ } else {
+ more_printf("Detected RAM : %d MiB(%d KiB)\n",
+ (mem_low >> 10) + (mem_high >> 4),
+ mem_low + (mem_high << 6));
+ more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n", mem_low,
+ mem_low >> 10, mem_high << 6, mem_high >> 4);
+ }
+}
+
+static void show_memory_88(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware __unused)
+{
+ int mem_size = 0;
+
+ reset_more_printf();
+ if (detect_memory_88(&mem_size)) {
+ more_printf("8800h bogus!\n");
+ } else {
+ more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size,
+ mem_size >> 10);
+ }
+}
+
+struct cli_callback_descr list_memory_show_modules[] = {
+ {
+ .name = "e820",
+ .exec = show_memory_e820,
+ },
+ {
+ .name = "e801",
+ .exec = show_memory_e801,
+ },
+ {
+ .name = "88",
+ .exec = show_memory_88,
+ },
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr memory_show_modules = {
+ .modules = list_memory_show_modules,
+ .default_callback = show_dmi_memory_modules,
+};
+
+struct cli_mode_descr memory_mode = {
+ .mode = MEMORY_MODE,
+ .name = CLI_MEMORY,
+ .default_modules = NULL,
+ .show_modules = &memory_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-pci.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-pci.c
new file mode 100644
index 0000000..e0b7830
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-pci.c
@@ -0,0 +1,318 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_pci(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ cli_detect_pci(hardware);
+ reset_more_printf();
+ more_printf("PCI\n");
+ more_printf(" NB Devices : %d\n", hardware->nb_pci_devices);
+}
+
+static void show_pci_device(int argc, char **argv, struct s_hardware *hardware)
+{
+ int i = 0;
+ struct pci_device *pci_device = NULL, *temp_pci_device;
+ int pcidev = -1;
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfiles = false;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ int bus = 0, slot = 0, func = 0;
+
+ reset_more_printf();
+ /* Sanitize arguments */
+ if (argc <= 0) {
+ more_printf("show device <number>\n");
+ return;
+ } else
+ pcidev = strtol(argv[0], (char **)NULL, 10);
+
+ if (errno == ERANGE) {
+ more_printf("This PCI device number is incorrect\n");
+ return;
+ }
+ if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) {
+ more_printf("PCI device %d doesn't exist\n", pcidev);
+ return;
+ }
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ }
+ if (hardware->modules_alias_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
+ nomodulesfiles = nomodulespcimap && nomodulesalias;
+ for_each_pci_func(temp_pci_device, hardware->pci_domain) {
+ i++;
+ if (i == pcidev) {
+ bus = __pci_bus;
+ slot = __pci_slot;
+ func = __pci_func;
+ pci_device = temp_pci_device;
+ }
+ }
+
+ if (pci_device == NULL) {
+ more_printf("We were enabled to find PCI device %d\n", pcidev);
+ return;
+ }
+
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
+
+ more_printf("PCI Device %d\n", pcidev);
+
+ if (nopciids == false) {
+ more_printf("Vendor Name : %s\n", pci_device->dev_info->vendor_name);
+ more_printf("Product Name : %s\n", pci_device->dev_info->product_name);
+ more_printf("Class Name : %s\n", pci_device->dev_info->class_name);
+ }
+
+ if (nomodulesfiles == false) {
+ more_printf("Kernel module : %s\n", kernel_modules);
+ }
+
+ more_printf("Vendor ID : %04x\n", pci_device->vendor);
+ more_printf("Product ID : %04x\n", pci_device->product);
+ more_printf("SubVendor ID : %04x\n", pci_device->sub_vendor);
+ more_printf("SubProduct ID : %04x\n", pci_device->sub_product);
+ more_printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2],
+ pci_device->class[1], pci_device->class[0]);
+ more_printf("Revision : %02x\n", pci_device->revision);
+ if ((pci_device->dev_info->irq > 0)
+ && (pci_device->dev_info->irq < 255))
+ more_printf("IRQ : %0d\n", pci_device->dev_info->irq);
+ more_printf("Latency : %0d\n", pci_device->dev_info->latency);
+ more_printf("PCI Bus : %02d\n", bus);
+ more_printf("PCI Slot : %02d\n", slot);
+ more_printf("PCI Func : %02d\n", func);
+
+ if (hardware->is_pxe_valid == true) {
+ if ((hardware->pxe.pci_device != NULL)
+ && (hardware->pxe.pci_device == pci_device)) {
+ more_printf("Mac Address : %s\n", hardware->pxe.mac_addr);
+ more_printf("PXE : Current boot device\n");
+ }
+ }
+}
+
+static void show_pci_devices(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ int i = 1;
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfile = false;
+ char first_line[81];
+ char second_line[81];
+
+ reset_more_printf();
+ more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
+
+ nomodulesfile = nomodulespcimap && nomodulesalias;
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
+
+ if (nopciids == false) {
+ snprintf(first_line, sizeof(first_line),
+ "%02d: %s %s \n", i,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ if (nomodulesfile == false)
+ snprintf(second_line, sizeof(second_line),
+ " # %-25s # Kmod: %s\n",
+ pci_device->dev_info->class_name, kernel_modules);
+ else
+ snprintf(second_line, sizeof(second_line),
+ " # %-25s # ID:%04x:%04x[%04x:%04x]\n",
+ pci_device->dev_info->class_name,
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+
+ more_printf("%s", first_line);
+ more_printf("%s", second_line);
+ more_printf("\n");
+ } else if (nopciids == true) {
+ if (nomodulesfile == true) {
+ more_printf("%02d: %04x:%04x [%04x:%04x] \n",
+ i, pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ } else {
+ more_printf
+ ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i,
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor,
+ pci_device->sub_product, kernel_modules);
+ }
+ }
+ i++;
+ }
+}
+
+static void show_pci_irq(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ struct pci_device *pci_device;
+ bool nopciids = false;
+
+ reset_more_printf();
+ more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
+ more_printf("IRQ : product\n");
+ more_printf("-------------\n");
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ /* Only display valid IRQs */
+ if ((pci_device->dev_info->irq > 0)
+ && (pci_device->dev_info->irq < 255)) {
+ if (nopciids == false) {
+ more_printf("%02d : %s %s \n",
+ pci_device->dev_info->irq,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ } else {
+ more_printf("%02d : %04x:%04x [%04x:%04x] \n",
+ pci_device->dev_info->irq,
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ }
+ }
+ }
+}
+
+struct cli_callback_descr list_pci_show_modules[] = {
+ {
+ .name = CLI_IRQ,
+ .exec = show_pci_irq,
+ },
+ {
+ .name = CLI_PCI_DEVICE,
+ .exec = show_pci_device,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr pci_show_modules = {
+ .modules = list_pci_show_modules,
+ .default_callback = show_pci_devices,
+};
+
+struct cli_mode_descr pci_mode = {
+ .mode = PCI_MODE,
+ .name = CLI_PCI,
+ .default_modules = NULL,
+ .show_modules = &pci_show_modules,
+ .set_modules = NULL,
+};
+
+void cli_detect_pci(struct s_hardware *hardware)
+{
+ bool error = false;
+ if (hardware->pci_detection == false) {
+ detect_pci(hardware);
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ more_printf
+ ("The pci.ids file is missing, device names can't be computed.\n");
+ more_printf("Please put one in same dir as hdt\n");
+ error = true;
+ }
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ more_printf
+ ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n");
+ more_printf("Please put one of them in same dir as hdt\n");
+ error = true;
+ }
+ if (error == true) {
+ char tempbuf[10];
+ more_printf("Press enter to continue\n");
+ fgets(tempbuf, sizeof(tempbuf), stdin);
+ }
+ }
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-pxe.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-pxe.c
new file mode 100644
index 0000000..29e760a
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-pxe.c
@@ -0,0 +1,98 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <syslinux/pxe.h>
+#include <syslinux/config.h>
+#include <sys/gpxe.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_pxe(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ char buffer[81];
+ memset(buffer, 0, sizeof(81));
+ reset_more_printf();
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ more_printf("You are not currently using PXELINUX\n");
+ return;
+ }
+
+ detect_pxe(hardware);
+ more_printf("PXE\n");
+ if (hardware->is_pxe_valid == false) {
+ more_printf(" No valid PXE ROM found\n");
+ return;
+ }
+
+ struct s_pxe *p = &hardware->pxe;
+ more_printf(" PCI device no: %d \n", p->pci_device_pos);
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS || (p->pci_device == NULL)) {
+ snprintf(buffer, sizeof(buffer),
+ " PCI ID : %04x:%04x[%04x:%04X] rev(%02x)\n",
+ p->vendor_id, p->product_id, p->subvendor_id,
+ p->subproduct_id, p->rev);
+ snprintf(buffer, sizeof(buffer),
+ " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ more_printf("%s", buffer);
+ } else {
+ snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
+ p->pci_device->dev_info->vendor_name);
+ more_printf("%s", buffer);
+ snprintf(buffer, sizeof(buffer), " Product : %s \n",
+ p->pci_device->dev_info->product_name);
+ more_printf("%s", buffer);
+ }
+ more_printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0],
+ p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr);
+
+ if (is_gpxe())
+ more_printf(" gPXE Detected: Yes\n")
+ else
+ more_printf(" gPXE Detected: No\n");
+}
+
+struct cli_module_descr pxe_show_modules = {
+ .modules = NULL,
+ .default_callback = main_show_pxe,
+};
+
+struct cli_mode_descr pxe_mode = {
+ .mode = PXE_MODE,
+ .name = CLI_PXE,
+ .default_modules = NULL,
+ .show_modules = &pxe_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-syslinux.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-syslinux.c
new file mode 100644
index 0000000..302ca24
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-syslinux.c
@@ -0,0 +1,62 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <syslinux/pxe.h>
+#include <syslinux/config.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_syslinux(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ reset_more_printf();
+ more_printf("SYSLINUX\n");
+ more_printf(" Bootloader : %s\n", hardware->syslinux_fs);
+ more_printf(" Version : %s\n", hardware->sv->version_string);
+ more_printf(" Version : %u\n", hardware->sv->version);
+ more_printf(" Max API : %u\n", hardware->sv->max_api);
+ more_printf(" Copyright : %s\n", hardware->sv->copyright_string);
+}
+
+struct cli_module_descr syslinux_show_modules = {
+ .modules = NULL,
+ .default_callback = main_show_syslinux,
+};
+
+struct cli_mode_descr syslinux_mode = {
+ .mode = SYSLINUX_MODE,
+ .name = CLI_SYSLINUX,
+ .default_modules = NULL,
+ .show_modules = &syslinux_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-vesa.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-vesa.c
new file mode 100644
index 0000000..a4a80fa
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-vesa.c
@@ -0,0 +1,142 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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_vesa(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ reset_more_printf();
+ detect_vesa(hardware);
+ if (hardware->is_vesa_valid == false) {
+ more_printf("No VESA BIOS detected\n");
+ return;
+ }
+ more_printf("VESA\n");
+ more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version,
+ hardware->vesa.minor_version);
+ more_printf(" Vendor : %s\n", hardware->vesa.vendor);
+ more_printf(" Product : %s\n", hardware->vesa.product);
+ more_printf(" Product rev. : %s\n", hardware->vesa.product_revision);
+ more_printf(" Software rev.: %d\n", hardware->vesa.software_rev);
+ more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64);
+ more_printf(" Modes : %d\n", hardware->vesa.vmi_count);
+}
+
+static void show_vesa_modes(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ detect_vesa(hardware);
+ reset_more_printf();
+ if (hardware->is_vesa_valid == false) {
+ more_printf("No VESA BIOS detected\n");
+ return;
+ }
+ more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n");
+ more_printf("----------------------------------------\n");
+
+ for (int i = 0; i < hardware->vesa.vmi_count; i++) {
+ struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
+ /*
+ * Sometimes, vesa bios reports 0x0 modes.
+ * We don't need to display that ones.
+ */
+ if ((mi->h_res == 0) || (mi->v_res == 0))
+ continue;
+ more_printf("%5u %5u %3u %3d 0x%04x\n",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200,
+ hardware->vesa.vmi[i].mode);
+ }
+}
+
+static void enable_vesa(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ vesamode = true;
+ max_console_lines = MAX_VESA_CLI_LINES;
+ init_console(hardware);
+}
+
+static void disable_vesa(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ vesamode = false;
+ max_console_lines = MAX_CLI_LINES;
+ init_console(hardware);
+}
+
+struct cli_callback_descr list_vesa_show_modules[] = {
+ {
+ .name = CLI_MODES,
+ .exec = show_vesa_modes,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_callback_descr list_vesa_commands[] = {
+ {
+ .name = CLI_ENABLE,
+ .exec = enable_vesa,
+ },
+ {
+ .name = CLI_DISABLE,
+ .exec = disable_vesa,
+ },
+
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
+};
+
+struct cli_module_descr vesa_show_modules = {
+ .modules = list_vesa_show_modules,
+ .default_callback = main_show_vesa,
+};
+
+struct cli_module_descr vesa_commands = {
+ .modules = list_vesa_commands,
+ .default_callback = enable_vesa,
+};
+
+struct cli_mode_descr vesa_mode = {
+ .mode = VESA_MODE,
+ .name = CLI_VESA,
+ .default_modules = &vesa_commands,
+ .show_modules = &vesa_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli-vpd.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli-vpd.c
new file mode 100644
index 0000000..c2f1c4e
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli-vpd.c
@@ -0,0 +1,81 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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 <string.h>
+#include <vpd/vpd.h>
+
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+void main_show_vpd(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ reset_more_printf();
+ detect_vpd(hardware);
+
+ if (!hardware->is_vpd_valid) {
+ more_printf("No VPD structure detected.\n");
+ return;
+ }
+
+ more_printf("VPD present at address : %s\n", hardware->vpd.base_address);
+ if (strlen(hardware->vpd.bios_build_id) > 0)
+ more_printf("Bios Build ID : %s\n",
+ hardware->vpd.bios_build_id);
+ if (strlen(hardware->vpd.bios_release_date) > 0)
+ more_printf("Bios Release Date : %s\n",
+ hardware->vpd.bios_release_date);
+ if (strlen(hardware->vpd.bios_version) > 0)
+ more_printf("Bios Version : %s\n",
+ hardware->vpd.bios_version);
+ if (strlen(hardware->vpd.default_flash_filename) > 0)
+ more_printf("Default Flash Filename : %s\n",
+ hardware->vpd.default_flash_filename);
+ if (strlen(hardware->vpd.box_serial_number) > 0)
+ more_printf("Box Serial Number : %s\n",
+ hardware->vpd.box_serial_number);
+ if (strlen(hardware->vpd.motherboard_serial_number) > 0)
+ more_printf("Motherboard Serial Number : %s\n",
+ hardware->vpd.motherboard_serial_number);
+ if (strlen(hardware->vpd.machine_type_model) > 0)
+ more_printf("Machine Type/Model : %s\n",
+ hardware->vpd.machine_type_model);
+}
+
+struct cli_module_descr vpd_show_modules = {
+ .modules = NULL,
+ .default_callback = main_show_vpd,
+};
+
+struct cli_mode_descr vpd_mode = {
+ .mode = VPD_MODE,
+ .name = CLI_VPD,
+ .default_modules = NULL,
+ .show_modules = &vpd_show_modules,
+ .set_modules = NULL,
+};
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli.c b/contrib/syslinux-4.02/com32/hdt/hdt-cli.c
new file mode 100644
index 0000000..639bcdb
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli.c
@@ -0,0 +1,1121 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <syslinux/config.h>
+#include <getkey.h>
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+struct cli_mode_descr *list_modes[] = {
+ &hdt_mode,
+ &dmi_mode,
+ &syslinux_mode,
+ &pxe_mode,
+ &kernel_mode,
+ &cpu_mode,
+ &pci_mode,
+ &vesa_mode,
+ &disk_mode,
+ &vpd_mode,
+ &memory_mode,
+ NULL,
+};
+
+/*
+ * .aliases = {"q", "quit"} won't work since it is an array of pointers, not an
+ * array of variables. There is no easy way around it besides declaring the arrays of
+ * strings first.
+ */
+const char *exit_aliases[] = { "q", "quit" };
+const char *help_aliases[] = { "h", "?" };
+
+/* List of aliases */
+struct cli_alias hdt_aliases[] = {
+ {
+ .command = CLI_EXIT,
+ .nb_aliases = 2,
+ .aliases = exit_aliases,
+ },
+ {
+ .command = CLI_HELP,
+ .nb_aliases = 2,
+ .aliases = help_aliases,
+ },
+};
+
+struct cli_mode_descr *current_mode;
+int autocomplete_backlog;
+
+struct autocomplete_list {
+ char autocomplete_token[MAX_LINE_SIZE];
+ struct autocomplete_list *next;
+};
+struct autocomplete_list *autocomplete_head = NULL;
+struct autocomplete_list *autocomplete_tail = NULL;
+struct autocomplete_list *autocomplete_last_seen = NULL;
+
+static void autocomplete_add_token_to_list(const char *token)
+{
+ struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list));
+
+ strlcpy(new->autocomplete_token, token, sizeof(new->autocomplete_token));
+ new->next = NULL;
+ autocomplete_backlog++;
+
+ if (autocomplete_tail != NULL)
+ autocomplete_tail->next = new;
+ if (autocomplete_head == NULL)
+ autocomplete_head = new;
+ autocomplete_tail = new;
+}
+
+static void autocomplete_destroy_list(void)
+{
+ struct autocomplete_list *tmp = NULL;
+
+ while (autocomplete_head != NULL) {
+ tmp = autocomplete_head->next;
+ free(autocomplete_head);
+ autocomplete_head = tmp;
+ }
+ autocomplete_backlog = 0;
+ autocomplete_tail = NULL;
+ autocomplete_last_seen = NULL;
+}
+
+/**
+ * set_mode - set the current mode of the cli
+ * @mode: mode to set
+ *
+ * Unlike cli_set_mode, this function is not used by the cli directly.
+ **/
+void set_mode(cli_mode_t mode, struct s_hardware *hardware)
+{
+ int i = 0;
+
+ switch (mode) {
+ case EXIT_MODE:
+ hdt_cli.mode = mode;
+ break;
+ case HDT_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_HDT);
+ break;
+ case PXE_MODE:
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ printf("You are not currently using PXELINUX\n");
+ break;
+ }
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PXE);
+ break;
+ case KERNEL_MODE:
+ detect_pci(hardware);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_KERNEL);
+ break;
+ case SYSLINUX_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_SYSLINUX);
+ break;
+ case VESA_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VESA);
+ break;
+ case PCI_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PCI);
+ if (!hardware->pci_detection)
+ cli_detect_pci(hardware);
+ break;
+ case CPU_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_CPU);
+ if (!hardware->dmi_detection)
+ detect_dmi(hardware);
+ if (!hardware->cpu_detection)
+ cpu_detect(hardware);
+ break;
+ case DMI_MODE:
+ detect_dmi(hardware);
+ if (!hardware->is_dmi_valid) {
+ printf("No valid DMI table found, exiting.\n");
+ break;
+ }
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DMI);
+ break;
+ case DISK_MODE:
+ detect_disks(hardware);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DISK);
+ break;
+ case VPD_MODE:
+ detect_vpd(hardware);
+ if (!hardware->is_vpd_valid) {
+ printf("No valid VPD table found, exiting.\n");
+ break;
+ }
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VPD);
+ break;
+ case MEMORY_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_MEMORY);
+ break;
+ default:
+ /* Invalid mode */
+ printf("Unknown mode, please choose among:\n");
+ while (list_modes[i]) {
+ printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
+ }
+
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
+ /* There is not cli_mode_descr struct for the exit mode */
+ if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) {
+ /* Shouldn't get here... */
+ printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
+ }
+}
+
+/**
+ * mode_s_to_mode_t - given a mode string, return the cli_mode_t representation
+ **/
+cli_mode_t mode_s_to_mode_t(char *name)
+{
+ int i = 0;
+
+ while (list_modes[i]) {
+ if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name)))
+ break;
+ i++;
+ }
+
+ if (!list_modes[i])
+ return INVALID_MODE;
+ else
+ return list_modes[i]->mode;
+}
+
+/**
+ * find_cli_mode_descr - find the cli_mode_descr struct associated to a mode
+ * @mode: mode to look for
+ * @mode_found: store the mode if found, NULL otherwise
+ *
+ * Given a mode name, return a pointer to the associated cli_mode_descr
+ * structure.
+ * Note: the current mode name is stored in hdt_cli.mode.
+ **/
+void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
+{
+ int i = 0;
+
+ while (list_modes[i] && list_modes[i]->mode != mode)
+ i++;
+
+ /* Shouldn't get here... */
+ if (!list_modes[i])
+ *mode_found = NULL;
+ else
+ *mode_found = list_modes[i];
+}
+
+/**
+ * expand_aliases - resolve aliases mapping
+ * @line: command line to parse
+ * @command: first token in the line
+ * @module: second token in the line
+ * @argc: number of arguments
+ * @argv: array of arguments
+ *
+ * We maintain a small list of static alises to enhance user experience.
+ * Only commands can be aliased (first token). Otherwise it can become really hairy...
+ **/
+static void expand_aliases(char *line __unused, char **command, char **module,
+ int *argc, char **argv)
+{
+ struct cli_mode_descr *mode;
+ int i, j;
+
+ find_cli_mode_descr(mode_s_to_mode_t(*command), &mode);
+ if (mode != NULL && *module == NULL) {
+ /*
+ * The user specified a mode instead of `set mode...', e.g.
+ * `dmi' instead of `set mode dmi'
+ */
+
+ /* *argv is NULL since *module is NULL */
+ *argc = 1;
+ *argv = malloc(*argc * sizeof(char *));
+ argv[0] = malloc((sizeof(*command) + 1) * sizeof(char));
+ strlcpy(argv[0], *command, sizeof(*command) + 1);
+ dprintf("CLI DEBUG: ALIAS %s ", *command);
+
+ strlcpy(*command, CLI_SET, sizeof(CLI_SET)); /* set */
+
+ *module = malloc(sizeof(CLI_MODE) * sizeof(char));
+ strlcpy(*module, CLI_MODE, sizeof(CLI_MODE)); /* mode */
+
+ dprintf("--> %s %s %s\n", *command, *module, argv[0]);
+ goto out;
+ }
+
+ /* Simple aliases mapping a single command to another one */
+ for (i = 0; i < MAX_ALIASES; i++) {
+ for (j = 0; j < hdt_aliases[i].nb_aliases; j++) {
+ if (!strncmp(*command, hdt_aliases[i].aliases[j],
+ sizeof(hdt_aliases[i].aliases[j]))) {
+ dprintf("CLI DEBUG: ALIAS %s ", *command);
+ strlcpy(*command, hdt_aliases[i].command,
+ sizeof(hdt_aliases[i].command) + 1);
+ dprintf("--> %s\n", *command);
+ goto out; /* Don't allow chaining aliases */
+ }
+ }
+ }
+ return;
+
+out:
+ dprintf("CLI DEBUG: New parameters:\n");
+ dprintf("CLI DEBUG: command = %s\n", *command);
+ dprintf("CLI DEBUG: module = %s\n", *module);
+ dprintf("CLI DEBUG: argc = %d\n", *argc);
+ for (i = 0; i < *argc; i++)
+ dprintf("CLI DEBUG: argv[%d] = %s\n", i, argv[0]);
+ return;
+}
+
+/**
+ * parse_command_line - low level parser for the command line
+ * @line: command line to parse
+ * @command: first token in the line
+ * @module: second token in the line
+ * @argc: number of arguments
+ * @argv: array of arguments
+ *
+ * The format of the command line is:
+ * <main command> [<module on which to operate> [<args>]]
+ * command is always malloc'ed (even for an empty line)
+ **/
+static void parse_command_line(char *line, char **command, char **module,
+ int *argc, char **argv)
+{
+ int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0;
+ int args_len = 0;
+ char *pch = NULL, *pch_next = NULL, *tmp_pch_next = NULL;
+
+ *command = NULL;
+ *module = NULL;
+ *argc = 0;
+
+ pch = line;
+ while (pch != NULL) {
+ pch_next = strchr(pch + 1, ' ');
+ tmp_pch_next = pch_next;
+
+ /*
+ * Skip whitespaces if the user entered
+ * 'set mode foo' for 'set mode foo'
+ * ^ ^
+ * |___|___ pch
+ * |___ pch_next <- wrong!
+ *
+ * We still keep the position into tmp_pch_next to compute
+ * the lenght of the current token.
+ */
+ while (pch_next != NULL && !strncmp(pch_next, CLI_SPACE, 1))
+ pch_next++;
+
+ /* End of line guaranteed to be zeroed */
+ if (pch_next == NULL) {
+ token_len = (int)(strchr(pch + 1, '\0') - pch);
+ args_len = token_len;
+ } else {
+ token_len = (int)(tmp_pch_next - pch);
+ args_len = (int)(pch_next - pch);
+ }
+
+ if (token_found == 0) {
+ /* Main command to execute */
+ *command = malloc((token_len + 1) * sizeof(char));
+ strlcpy(*command, pch, token_len);
+ (*command)[token_len] = '\0';
+ dprintf("CLI DEBUG: command = %s\n", *command);
+ args_pos += args_len;
+ } else if (token_found == 1) {
+ /* Module */
+ *module = malloc((token_len + 1) * sizeof(char));
+ strlcpy(*module, pch, token_len);
+ (*module)[token_len] = '\0';
+ dprintf("CLI DEBUG: module = %s\n", *module);
+ args_pos += args_len;
+ } else
+ (*argc)++;
+
+ token_found++;
+ pch = pch_next;
+ }
+ dprintf("CLI DEBUG: argc = %d\n", *argc);
+
+ /* Skip arguments handling if none is supplied */
+ if (!*argc)
+ return;
+
+ /* Transform the arguments string into an array */
+ *argv = malloc(*argc * sizeof(char *));
+ pch = strtok(line + args_pos, CLI_SPACE);
+ while (pch != NULL) {
+ dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch);
+ argv[argc_iter] = malloc(sizeof(pch) * sizeof(char));
+ strlcpy(argv[argc_iter], pch, sizeof(pch));
+ argc_iter++;
+ pch = strtok(NULL, CLI_SPACE);
+ /*
+ * strtok(NULL, CLI_SPACE) over a stream of spaces
+ * will return an empty string
+ */
+ while (pch != NULL && !strncmp(pch, "", 1))
+ pch = strtok(NULL, CLI_SPACE);
+ }
+}
+
+/**
+ * find_cli_callback_descr - find a callback in a list of modules
+ * @module_name: Name of the module to find
+ * @modules_list: Lits of modules among which to find @module_name
+ * @module_found: Pointer to the matched module, NULL if not found
+ *
+ * Given a module name and a list of possible modules, find the corresponding
+ * module structure that matches the module name and store it in @module_found.
+ **/
+void find_cli_callback_descr(const char *module_name,
+ struct cli_module_descr *modules_list,
+ struct cli_callback_descr **module_found)
+{
+ int modules_iter = 0;
+
+ if (modules_list == NULL)
+ goto not_found;
+
+ /* Find the callback to execute */
+ while (modules_list->modules[modules_iter].name &&
+ strcmp(module_name, modules_list->modules[modules_iter].name) != 0)
+ modules_iter++;
+
+ if (modules_list->modules[modules_iter].name) {
+ *module_found = &(modules_list->modules[modules_iter]);
+ dprintf("CLI DEBUG: module %s found\n", (*module_found)->name);
+ return;
+ }
+
+not_found:
+ *module_found = NULL;
+ return;
+}
+
+/**
+ * autocomplete_command - print matching commands
+ * @command: Beginning of the command
+ *
+ * Given a string @command, print all availables commands starting with
+ * @command. Commands are found within the list of commands for the current
+ * mode and the hdt mode (if the current mode is not hdt).
+ **/
+static void autocomplete_command(char *command)
+{
+ int j = 0;
+ struct cli_callback_descr *associated_module = NULL;
+
+ /* First take care of the two special commands: 'show' and 'set' */
+ if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
+ printf("%s\n", CLI_SHOW);
+ autocomplete_add_token_to_list(CLI_SHOW);
+ }
+ if (strncmp(CLI_SET, command, strlen(command)) == 0) {
+ printf("%s\n", CLI_SET);
+ autocomplete_add_token_to_list(CLI_SET);
+ }
+
+ /*
+ * Then, go through the modes for the special case
+ * '<mode>' -> 'set mode <mode>'
+ */
+ while (list_modes[j]) {
+ if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) {
+ printf("%s\n", list_modes[j]->name);
+ autocomplete_add_token_to_list(list_modes[j]->name);
+ }
+ j++;
+ }
+
+ /*
+ * Let's go now through the list of default_modules for the current mode
+ * (single token commands for the current_mode)
+ */
+ j = 0;
+ if (current_mode->default_modules && current_mode->default_modules->modules) {
+ while (current_mode->default_modules->modules[j].name) {
+ if (strncmp(current_mode->default_modules->modules[j].name,
+ command, strlen(command)) == 0) {
+ printf("%s\n", current_mode->default_modules->modules[j].name);
+ autocomplete_add_token_to_list(current_mode->default_modules->
+ modules[j].name);
+ }
+ j++;
+ }
+ }
+
+ /*
+ * Finally, if the current_mode is not hdt, list the available
+ * default_modules of hdt (these are always available from any mode).
+ */
+ if (current_mode->mode == HDT_MODE)
+ return;
+
+ if (!hdt_mode.default_modules || !hdt_mode.default_modules->modules)
+ return;
+
+ j = 0;
+ while (hdt_mode.default_modules &&
+ hdt_mode.default_modules->modules[j].name) {
+ /*
+ * Any default command that is present in hdt mode but
+ * not in the current mode is available. A default
+ * command can be redefined in the current mode though.
+ * This next call tests this use case: if it is
+ * overwritten, do not print it again.
+ */
+ find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
+ current_mode->default_modules,
+ &associated_module);
+ if (associated_module == NULL &&
+ strncmp(command,
+ hdt_mode.default_modules->modules[j].name,
+ strlen(command)) == 0) {
+ printf("%s\n", hdt_mode.default_modules->modules[j].name);
+ autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].
+ name);
+ }
+ j++;
+ }
+}
+
+/**
+ * autocomplete_module - print matching modules
+ * @command: Command on the command line (not NULL)
+ * @module: Beginning of the module
+ *
+ * Given a command @command and a string @module, print all availables modules
+ * starting with @module for command @command. Commands are found within the
+ * list of commands for the current mode and the hdt mode (if the current mode
+ * is not hdt).
+ **/
+static void autocomplete_module(char *command, char *module)
+{
+ int j = 0;
+ char autocomplete_full_line[MAX_LINE_SIZE];
+
+ if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
+ if (!current_mode->show_modules || !current_mode->show_modules->modules)
+ return;
+
+ while (current_mode->show_modules->modules[j].name) {
+ if (strncmp(current_mode->show_modules->modules[j].name,
+ module, strlen(module)) == 0) {
+ printf("%s\n", current_mode->show_modules->modules[j].name);
+ sprintf(autocomplete_full_line, "%s %s",
+ CLI_SHOW, current_mode->show_modules->modules[j].name);
+ autocomplete_add_token_to_list(autocomplete_full_line);
+ }
+ j++;
+ }
+ } else if (strncmp(CLI_SET, command, strlen(command)) == 0) {
+ j = 0;
+ if (!current_mode->set_modules || !current_mode->set_modules->modules)
+ return;
+
+ while (current_mode->set_modules->modules[j].name) {
+ if (strncmp(current_mode->set_modules->modules[j].name,
+ module, strlen(module)) == 0) {
+ printf("%s\n", current_mode->set_modules->modules[j].name);
+ sprintf(autocomplete_full_line, "%s %s",
+ CLI_SET, current_mode->set_modules->modules[j].name);
+ autocomplete_add_token_to_list(autocomplete_full_line);
+ }
+ j++;
+ }
+ }
+}
+
+/**
+ * autocomplete - find possible matches for a command line
+ * @line: command line to parse
+ **/
+static void autocomplete(char *line)
+{
+ int i;
+ int argc = 0;
+ char *command = NULL, *module = NULL;
+ char **argv = NULL;
+
+ parse_command_line(line, &command, &module, &argc, argv);
+
+ /* If the user specified arguments, there is nothing we can complete */
+ if (argc != 0)
+ goto out;
+
+ /* No argument, (the start of) a module has been specified */
+ if (module != NULL) {
+ autocomplete_module(command, module);
+ free(module);
+ goto out;
+ }
+
+ /* No argument, no module, (the start of) a command has been specified */
+ if (command != NULL) {
+ autocomplete_command(command);
+ free(command);
+ goto out;
+ }
+
+out:
+ /* Let's not forget to clean ourselves */
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ if (argc > 0)
+ free(argv);
+ return;
+}
+
+/**
+ * exec_command - main logic to map the command line to callbacks
+ **/
+static void exec_command(char *line, struct s_hardware *hardware)
+{
+ int argc, i = 0;
+ char *command = NULL, *module = NULL;
+ char **argv = NULL;
+ struct cli_callback_descr *current_module = NULL;
+
+ /* This will allocate memory for command and module */
+ parse_command_line(line, &command, &module, &argc, argv);
+
+ /*
+ * Expand shortcuts, if needed
+ * This will allocate memory for argc/argv
+ */
+ expand_aliases(line, &command, &module, &argc, argv);
+
+ if (module == NULL) {
+ dprintf("CLI DEBUG: single command detected\n");
+ /*
+ * A single word was specified: look at the list of default
+ * commands in the current mode to see if there is a match.
+ * If not, it may be a generic function (exit, help, ...). These
+ * are stored in the list of default commands of the hdt mode.
+ */
+ find_cli_callback_descr(command, current_mode->default_modules,
+ &current_module);
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) &&
+ current_mode->show_modules != NULL &&
+ current_mode->show_modules->default_callback != NULL)
+ current_mode->show_modules->default_callback(argc, argv, hardware);
+ else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1) &&
+ current_mode->set_modules != NULL &&
+ current_mode->set_modules->default_callback != NULL)
+ current_mode->set_modules->default_callback(argc, argv, hardware);
+ else {
+ find_cli_callback_descr(command, hdt_mode.default_modules,
+ &current_module);
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown command: '%s'\n", command);
+ }
+ } else {
+ /*
+ * A module has been specified! We now need to find the type of command.
+ *
+ * The syntax of the cli is the following:
+ * <type of command> <module on which to operate> <args>
+ * e.g.
+ * dmi> show system
+ * dmi> show bank 1
+ * dmi> show memory 0 1
+ * pci> show device 12
+ * hdt> set mode dmi
+ */
+ if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
+ dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW);
+ /* Look first for a 'show' callback in the current mode */
+ find_cli_callback_descr(module, current_mode->show_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else {
+ /* Look now for a 'show' callback in the hdt mode */
+ find_cli_callback_descr(module, hdt_mode.show_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown module: '%s'\n", module);
+ }
+ } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) {
+ dprintf("CLI DEBUG: %s command detected\n", CLI_SET);
+ /* Look now for a 'set' callback in the hdt mode */
+ find_cli_callback_descr(module, current_mode->set_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else {
+ /* Look now for a 'set' callback in the hdt mode */
+ find_cli_callback_descr(module, hdt_mode.set_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown module: '%s'\n", module);
+ }
+ }
+ }
+
+ /* Let's not forget to clean ourselves */
+ if (command != NULL)
+ free(command);
+ if (module != NULL)
+ free(module);
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ if (argc > 0)
+ free(argv);
+}
+
+static void reset_prompt(void)
+{
+ /* No need to display the prompt if we exit */
+ if (hdt_cli.mode != EXIT_MODE) {
+ printf("%s", hdt_cli.prompt);
+ /* Reset the line */
+ hdt_cli.cursor_pos = 0;
+ }
+}
+
+void start_auto_mode(struct s_hardware *hardware)
+{
+ char *mypch;
+ int nb_commands = 0;
+ char *commands[MAX_NB_AUTO_COMMANDS];
+
+ if (!quiet)
+ more_printf("\nEntering Auto mode\n");
+
+ /* Protecting the auto_label from the strtok modifications */
+ char *temp = strdup(hardware->auto_label);
+
+ /* Searching & saving all commands */
+ mypch = strtok(temp, AUTO_SEPARATOR);
+ while (mypch != NULL) {
+ if ((strlen(remove_spaces(mypch)) > 0) &&
+ (remove_spaces(mypch)[0] != AUTO_SEPARATOR[0])) {
+ nb_commands++;
+ if ((commands[nb_commands] = malloc(AUTO_COMMAND_SIZE)) != NULL) {
+ sprintf(commands[nb_commands], "%s", remove_spaces(mypch));
+ } else
+ nb_commands--;
+ }
+ mypch = strtok(NULL, AUTO_SEPARATOR);
+ }
+
+ /* Executing found commands */
+ for (int i = 1; i <= nb_commands; i++) {
+ if (commands[i]) {
+ if (!quiet)
+ more_printf("%s%s\n", hdt_cli.prompt, commands[i]);
+ exec_command(commands[i], hardware);
+ free(commands[i]);
+ }
+ }
+
+ if (!quiet)
+ more_printf("\nExiting Auto mode\n");
+
+ more_printf("\n");
+}
+
+void print_history(int argc, char **argv, struct s_hardware * hardware)
+{
+ (void)argc;
+ (void)argv;
+ (void)hardware;
+
+ reset_more_printf();
+ for (int i = 1; i <= MAX_HISTORY_SIZE; i++) {
+ if (i == hdt_cli.history_pos) {
+ more_printf("*%d:'%s'\n", i, hdt_cli.history[i]);
+ continue;
+ }
+ if (strlen(hdt_cli.history[i]) == 0)
+ continue;
+ more_printf(" %d:'%s'\n", i, hdt_cli.history[i]);
+ }
+}
+
+/* Code that manages the cli mode */
+void start_cli_mode(struct s_hardware *hardware)
+{
+ int current_key = 0;
+ int future_history_pos = 1; /* position of the next position in the history */
+ int current_future_history_pos = 1; /* Temp variable */
+ bool display_history = true; /* Temp Variable */
+ char temp_command[MAX_LINE_SIZE];
+
+ hdt_cli.cursor_pos = 0;
+ memset(hdt_cli.history, 0, sizeof(hdt_cli.history));
+ hdt_cli.history_pos = 1;
+ hdt_cli.max_history_pos = 1;
+
+ /* Find the mode selected */
+ set_mode(HDT_MODE, hardware);
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
+ if (current_mode == NULL) {
+ /* Shouldn't get here... */
+ printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
+ return;
+ }
+
+ /* Start the auto mode if the command line is set */
+ if (strlen(hardware->auto_label) > 0) {
+ start_auto_mode(hardware);
+ }
+
+ printf("Entering CLI mode\n");
+
+ reset_prompt();
+
+ while (hdt_cli.mode != EXIT_MODE) {
+
+ /* Display the cursor */
+ display_cursor(true);
+
+ /* Let's put the cursor blinking until we get an input */
+ set_cursor_blink(true);
+
+ /* We wait endlessly for a keyboard input */
+ current_key = get_key(stdin, 0);
+
+ /* We have to cancel the blinking mode to prevent
+ * input text to blink */
+ set_cursor_blink(false);
+
+ /* Reset autocomplete buffer unless TAB is pressed */
+ if (current_key != KEY_TAB)
+ autocomplete_destroy_list();
+
+ switch (current_key) {
+ /* clear until then end of line */
+ case KEY_CTRL('k'):
+ /* Clear the end of the line */
+ clear_end_of_line();
+ memset(&INPUT[hdt_cli.cursor_pos], 0,
+ strlen(INPUT) - hdt_cli.cursor_pos);
+ break;
+
+ case KEY_CTRL('c'):
+ printf("\n");
+ reset_prompt();
+ break;
+
+ case KEY_LEFT:
+ if (hdt_cli.cursor_pos > 0) {
+ move_cursor_left(1);
+ hdt_cli.cursor_pos--;
+ }
+ break;
+
+ case KEY_RIGHT:
+ if (hdt_cli.cursor_pos < (int)strlen(INPUT)) {
+ move_cursor_right(1);
+ hdt_cli.cursor_pos++;
+ }
+ break;
+
+ case KEY_CTRL('e'):
+ case KEY_END:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if ((strlen(INPUT) - hdt_cli.cursor_pos) > 0) {
+ /* Return to the begining of line */
+ move_cursor_right(strlen(INPUT) - hdt_cli.cursor_pos);
+ hdt_cli.cursor_pos = strlen(INPUT);
+ }
+ break;
+
+ case KEY_CTRL('a'):
+ case KEY_HOME:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if (hdt_cli.cursor_pos > 0) {
+ /* Return to the begining of line */
+ move_cursor_left(hdt_cli.cursor_pos);
+ hdt_cli.cursor_pos = 0;
+ }
+ break;
+
+ case KEY_UP:
+
+ /* Saving future position */
+ current_future_history_pos = future_history_pos;
+
+ /* We have to compute the next position */
+ if (future_history_pos == 1) {
+ future_history_pos = MAX_HISTORY_SIZE;
+ } else {
+ future_history_pos--;
+ }
+
+ /* Does the next position is valid */
+ if (strlen(hdt_cli.history[future_history_pos]) == 0) {
+ /* Position is invalid, restoring position */
+ future_history_pos = current_future_history_pos;
+ break;
+ }
+
+ /* Let's make that future position the one we use */
+ memset(INPUT, 0, sizeof(INPUT));
+ strlcpy(INPUT, hdt_cli.history[future_history_pos], sizeof(INPUT));
+
+ /* Clear the line */
+ clear_line();
+
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+
+ reset_prompt();
+ printf("%s", INPUT);
+ hdt_cli.cursor_pos = strlen(INPUT);
+ break;
+
+ case KEY_DOWN:
+ display_history = true;
+
+ /* Saving future position */
+ current_future_history_pos = future_history_pos;
+
+ if (future_history_pos == MAX_HISTORY_SIZE) {
+ future_history_pos = 1;
+ } else {
+ future_history_pos++;
+ }
+
+ /* Does the next position is valid */
+ if (strlen(hdt_cli.history[future_history_pos]) == 0)
+ display_history = false;
+
+ /* An exception is made to reach the last empty line */
+ if (future_history_pos == hdt_cli.max_history_pos)
+ display_history = true;
+
+ if (display_history == false) {
+ /* Position is invalid, restoring position */
+ future_history_pos = current_future_history_pos;
+ break;
+ }
+
+ /* Let's make that future position the one we use */
+ memset(INPUT, 0, sizeof(INPUT));
+ strlcpy(INPUT, hdt_cli.history[future_history_pos], sizeof(INPUT));
+
+ /* Clear the line */
+ clear_line();
+
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+
+ reset_prompt();
+ printf("%s", INPUT);
+ hdt_cli.cursor_pos = strlen(INPUT);
+ break;
+
+ case KEY_TAB:
+ if (autocomplete_backlog) {
+ clear_line();
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+ reset_prompt();
+ printf("%s", autocomplete_last_seen->autocomplete_token);
+ strlcpy(INPUT,
+ autocomplete_last_seen->autocomplete_token,
+ sizeof(INPUT));
+ hdt_cli.cursor_pos = strlen(INPUT);
+
+ /* Cycle through the list */
+ autocomplete_last_seen = autocomplete_last_seen->next;
+ if (autocomplete_last_seen == NULL)
+ autocomplete_last_seen = autocomplete_head;
+ } else {
+ printf("\n");
+ autocomplete(skip_spaces(INPUT));
+ autocomplete_last_seen = autocomplete_head;
+
+ printf("%s%s", hdt_cli.prompt, INPUT);
+ }
+ break;
+
+ case KEY_ENTER:
+ printf("\n");
+ if (strlen(remove_spaces(INPUT)) < 1) {
+ reset_prompt();
+ break;
+ }
+ exec_command(remove_spaces(INPUT), hardware);
+ hdt_cli.history_pos++;
+
+ /* Did we reach the end of the history ?*/
+ if (hdt_cli.history_pos > MAX_HISTORY_SIZE) {
+ /* Let's return at the beginning */
+ hdt_cli.history_pos = 1;
+ }
+
+ /* Does the next position is already used ?
+ * If yes, we are cycling in history */
+ if (strlen(INPUT) > 0) {
+ /* Let's clean that entry */
+ memset(&INPUT,0,sizeof(INPUT));
+ }
+
+ future_history_pos = hdt_cli.history_pos;
+ if (hdt_cli.history_pos > hdt_cli.max_history_pos)
+ hdt_cli.max_history_pos = hdt_cli.history_pos;
+ reset_prompt();
+ break;
+
+ case KEY_CTRL('d'):
+ case KEY_DELETE:
+ /* No need to delete when input is empty */
+ if (strlen(INPUT) == 0)
+ break;
+ /* Don't delete when cursor is at the end of the line */
+ if (hdt_cli.cursor_pos >= strlen(INPUT))
+ break;
+
+ for (int c = hdt_cli.cursor_pos; c < (int)strlen(INPUT) - 1; c++)
+ INPUT[c] = INPUT[c + 1];
+ INPUT[strlen(INPUT) - 1] = '\0';
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", INPUT + hdt_cli.cursor_pos);
+
+ /* Replace the cursor at the proper place */
+ if (strlen(INPUT + hdt_cli.cursor_pos) > 0)
+ move_cursor_left(strlen(INPUT + hdt_cli.cursor_pos));
+ break;
+
+ case KEY_DEL:
+ case KEY_BACKSPACE:
+ /* Don't delete prompt */
+ if (hdt_cli.cursor_pos == 0)
+ break;
+
+ for (int c = hdt_cli.cursor_pos - 1;
+ c < (int)strlen(INPUT) - 1; c++)
+ INPUT[c] = INPUT[c + 1];
+ INPUT[strlen(INPUT) - 1] = '\0';
+
+ /* Get one char back */
+ move_cursor_left(1);
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", INPUT + hdt_cli.cursor_pos - 1);
+
+ /* Realing to a char before the place we were */
+ hdt_cli.cursor_pos--;
+ move_cursor_to_column(strlen(hdt_cli.prompt) + hdt_cli.cursor_pos +
+ 1);
+
+ break;
+
+ case KEY_F1:
+ printf("\n");
+ exec_command(CLI_HELP, hardware);
+ reset_prompt();
+ break;
+
+ default:
+ if ((current_key < 0x20) || (current_key > 0x7e))
+ break;
+ /* Prevent overflow */
+ if (hdt_cli.cursor_pos > MAX_LINE_SIZE - 2)
+ break;
+ /* If we aren't at the end of the input line, let's insert */
+ if (hdt_cli.cursor_pos < (int)strlen(INPUT)) {
+ char key[2];
+ int trailing_chars = strlen(INPUT) - hdt_cli.cursor_pos;
+ memset(temp_command, 0, sizeof(temp_command));
+ strlcpy(temp_command, INPUT, hdt_cli.cursor_pos);
+ sprintf(key, "%c", current_key);
+ strncat(temp_command, key, 1);
+ strncat(temp_command,
+ INPUT + hdt_cli.cursor_pos, trailing_chars);
+ memset(INPUT, 0, sizeof(INPUT));
+ snprintf(INPUT, sizeof(INPUT), "%s", temp_command);
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", INPUT + hdt_cli.cursor_pos);
+
+ /* Return where we must put the new char */
+ move_cursor_left(trailing_chars);
+
+ } else {
+ putchar(current_key);
+ INPUT[hdt_cli.cursor_pos] = current_key;
+ }
+ hdt_cli.cursor_pos++;
+ break;
+ }
+ }
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-cli.h b/contrib/syslinux-4.02/com32/hdt/hdt-cli.h
new file mode 100644
index 0000000..98246b4
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-cli.h
@@ -0,0 +1,204 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_CLI_H
+#define DEFINE_HDT_CLI_H
+#include <stdio.h>
+#include <getkey.h>
+#include <dprintf.h>
+
+#include "hdt-common.h"
+
+#define MAX_LINE_SIZE 256
+
+#define CLI_SPACE " "
+#define CLI_LF "\n"
+#define CLI_MENU "menu"
+#define CLI_CLEAR "clear"
+#define CLI_EXIT "exit"
+#define CLI_HELP "help"
+#define CLI_REBOOT "reboot"
+#define CLI_SHOW "show"
+#define CLI_SET "set"
+#define CLI_MODE "mode"
+#define CLI_HDT "hdt"
+#define CLI_PCI "pci"
+#define CLI_PXE "pxe"
+#define CLI_KERNEL "kernel"
+#define CLI_SYSLINUX "syslinux"
+#define CLI_VESA "vesa"
+#define CLI_SUMMARY "summary"
+#define CLI_COMMANDS "commands"
+#define CLI_DMI "dmi"
+#define CLI_CPU "cpu"
+#define CLI_DISK "disk"
+#define CLI_SHOW_LIST "list"
+#define CLI_IRQ "irq"
+#define CLI_MODES "modes"
+#define CLI_VPD "vpd"
+#define CLI_MEMORY "memory"
+#define CLI_ENABLE "enable"
+#define CLI_DISABLE "disable"
+
+typedef enum {
+ INVALID_MODE,
+ EXIT_MODE,
+ HDT_MODE,
+ PCI_MODE,
+ DMI_MODE,
+ CPU_MODE,
+ PXE_MODE,
+ KERNEL_MODE,
+ SYSLINUX_MODE,
+ VESA_MODE,
+ DISK_MODE,
+ VPD_MODE,
+ MEMORY_MODE,
+} cli_mode_t;
+
+#define PROMPT_SIZE 32
+#define MAX_HISTORY_SIZE 32
+#define INPUT hdt_cli.history[hdt_cli.history_pos]
+struct s_cli {
+ cli_mode_t mode;
+ char prompt[PROMPT_SIZE];
+ uint8_t cursor_pos;
+ char history[MAX_HISTORY_SIZE+1][MAX_LINE_SIZE];
+ int history_pos;
+ int max_history_pos;
+};
+struct s_cli hdt_cli;
+
+/* Describe a cli mode */
+struct cli_mode_descr {
+ const unsigned int mode;
+ const char *name;
+ /* Handle 1-token commands */
+ struct cli_module_descr *default_modules;
+ /* Handle show <module> <args> */
+ struct cli_module_descr *show_modules;
+ /* Handle set <module> <args> */
+ struct cli_module_descr *set_modules;
+};
+
+/* Describe a subset of commands in a module (default, show, set, ...) */
+struct cli_module_descr {
+ struct cli_callback_descr *modules;
+ void (*default_callback) (int argc, char **argv,
+ struct s_hardware * hardware);
+};
+
+/* Describe a callback (belongs to a mode and a module) */
+struct cli_callback_descr {
+ const char *name;
+ void (*exec) (int argc, char **argv, struct s_hardware * hardware);
+};
+
+/* Manage aliases */
+#define MAX_ALIASES 2
+struct cli_alias {
+ const char *command; /* Original command */
+ const int nb_aliases; /* Size of aliases array */
+ const char **aliases; /* List of aliases */
+};
+
+/* List of implemented modes */
+extern struct cli_mode_descr *list_modes[];
+struct cli_mode_descr hdt_mode;
+struct cli_mode_descr dmi_mode;
+struct cli_mode_descr syslinux_mode;
+struct cli_mode_descr pxe_mode;
+struct cli_mode_descr kernel_mode;
+struct cli_mode_descr cpu_mode;
+struct cli_mode_descr pci_mode;
+struct cli_mode_descr vesa_mode;
+struct cli_mode_descr disk_mode;
+struct cli_mode_descr vpd_mode;
+struct cli_mode_descr memory_mode;
+
+/* cli helpers */
+void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found);
+void find_cli_callback_descr(const char *module_name,
+ struct cli_module_descr *modules_list,
+ struct cli_callback_descr **module_found);
+cli_mode_t mode_s_to_mode_t(char *name);
+
+void set_mode(cli_mode_t mode, struct s_hardware *hardware);
+void start_cli_mode(struct s_hardware *hardware);
+void start_auto_mode(struct s_hardware *hardware);
+void main_show(char *item, struct s_hardware *hardware);
+
+#define CLI_HISTORY "history"
+void print_history(int argc, char **argv, struct s_hardware * hardware);
+
+// DMI STUFF
+#define CLI_DMI_BASE_BOARD "base_board"
+#define CLI_DMI_BATTERY "battery"
+#define CLI_DMI_BIOS "bios"
+#define CLI_DMI_CHASSIS "chassis"
+#define CLI_DMI_MEMORY "memory"
+#define CLI_DMI_MEMORY_BANK "bank"
+#define CLI_DMI_PROCESSOR "cpu"
+#define CLI_DMI_SYSTEM "system"
+#define CLI_DMI_IPMI "ipmi"
+#define CLI_DMI_CACHE "cache"
+#define CLI_DMI_OEM "oem"
+#define CLI_DMI_SECURITY "security"
+#define CLI_DMI_LIST CLI_SHOW_LIST
+void main_show_dmi(int argc, char **argv, struct s_hardware *hardware);
+void show_dmi_memory_modules(int argc, char **argv,
+ struct s_hardware *hardware);
+void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware);
+
+// PCI STUFF
+#define CLI_PCI_DEVICE "device"
+void main_show_pci(int argc, char **argv, struct s_hardware *hardware);
+void cli_detect_pci(struct s_hardware *hardware);
+
+// CPU STUFF
+void main_show_cpu(int argc, char **argv, struct s_hardware *hardware);
+
+// DISK STUFF
+void disks_summary(int argc, char **argv, struct s_hardware *hardware);
+
+// PXE STUFF
+void main_show_pxe(int argc, char **argv, struct s_hardware *hardware);
+
+// KERNEL STUFF
+void main_show_kernel(int argc, char **argv, struct s_hardware *hardware);
+
+// SYSLINUX STUFF
+void main_show_syslinux(int argc, char **argv, struct s_hardware *hardware);
+
+// VESA STUFF
+void main_show_vesa(int argc, char **argv, struct s_hardware *hardware);
+
+// VPD STUFF
+void main_show_vpd(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware);
+#endif
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-common.c b/contrib/syslinux-4.02/com32/hdt/hdt-common.c
new file mode 100644
index 0000000..5a187f2
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-common.c
@@ -0,0 +1,666 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <getkey.h>
+#include "syslinux/config.h"
+#include "../lib/sys/vesa/vesa.h"
+#include "hdt-common.h"
+#include <disk/util.h>
+#include <disk/mbrs.h>
+#include <memory.h>
+
+/* ISOlinux requires a 8.3 format */
+void convert_isolinux_filename(char *filename, struct s_hardware *hardware)
+{
+ /* Exit if we are not running ISOLINUX */
+ if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX)
+ return;
+ /* Searching the dot */
+ char *dot = strchr(filename, '.');
+ /* Exiting if no dot exists in that string */
+ if (dot == NULL)
+ return;
+ /* Exiting if the extension is 3 char or less */
+ if (strlen(dot) <= 4)
+ return;
+
+ /* We have an extension bigger than .blah
+ * so we have to shorten it to 3*/
+ dot[4] = '\0';
+}
+
+void detect_parameters(const int argc, const char *argv[],
+ struct s_hardware *hardware)
+{
+ /* Quiet mode - make the output more quiet */
+ quiet = false;
+
+ /* Vesa mode isn't set until we explictly call it */
+ vesamode = false;
+
+ for (int i = 1; i < argc; i++) {
+ if (!strncmp(argv[i], "quiet", 5)) {
+ quiet = true;
+ } else if (!strncmp(argv[i], "modules_pcimap=", 15)) {
+ strlcpy(hardware->modules_pcimap_path, argv[i] + 15,
+ sizeof(hardware->modules_pcimap_path));
+ convert_isolinux_filename(hardware->modules_pcimap_path, hardware);
+ } else if (!strncmp(argv[i], "pciids=", 7)) {
+ strlcpy(hardware->pciids_path, argv[i] + 7,
+ sizeof(hardware->pciids_path));
+ convert_isolinux_filename(hardware->pciids_path, hardware);
+ } else if (!strncmp(argv[i], "modules_alias=", 14)) {
+ strlcpy(hardware->modules_alias_path, argv[i] + 14,
+ sizeof(hardware->modules_alias_path));
+ convert_isolinux_filename(hardware->modules_alias_path, hardware);
+ } else if (!strncmp(argv[i], "memtest=", 8)) {
+ strlcpy(hardware->memtest_label, argv[i] + 8,
+ sizeof(hardware->memtest_label));
+ convert_isolinux_filename(hardware->memtest_label, hardware);
+ } else if (!strncmp(argv[i], "vesa", 4)) {
+ vesamode = true;
+ max_console_lines = MAX_CLI_LINES;
+ /* If the user defines a background image */
+ if (!strncmp(argv[i], "vesa=", 5)) {
+ strlcpy(hardware->vesa_background, argv[i] + 5,
+ sizeof(hardware->vesa_background));
+ }
+ } else if (!strncmp(argv[i], "novesa", 6)) {
+ vesamode = false;
+ max_console_lines = MAX_VESA_CLI_LINES;
+ } else if (!strncmp(argv[i], "auto=", 5)) {
+ /* The auto= parameter is separated in several argv[]
+ * as it can contains spaces.
+ * We use the AUTO_DELIMITER char to define the limits
+ * of this parameter.
+ * i.e auto='show dmi; show pci'
+ */
+
+ /* Extracting the first parameter */
+ strcpy(hardware->auto_label, argv[i] + 6);
+ strcat(hardware->auto_label, " ");
+ char *pos;
+ i++;
+
+ /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
+ while (((pos = strstr(argv[i], AUTO_DELIMITER)) == NULL)
+ && (i < argc)) {
+ strcat(hardware->auto_label, argv[i]);
+ strcat(hardware->auto_label, " ");
+ i++;
+ }
+
+ /* If we didn't reach the end of the line, let's grab the last item */
+ if (i < argc) {
+ strcat(hardware->auto_label, argv[i]);
+ hardware->auto_label[strlen(hardware->auto_label) - 1] = 0;
+ }
+ }
+ }
+}
+
+void detect_syslinux(struct s_hardware *hardware)
+{
+ hardware->sv = syslinux_version();
+ switch (hardware->sv->filesystem) {
+ case SYSLINUX_FS_SYSLINUX:
+ strlcpy(hardware->syslinux_fs, "SYSlinux", 9);
+ break;
+ case SYSLINUX_FS_PXELINUX:
+ strlcpy(hardware->syslinux_fs, "PXElinux", 9);
+ break;
+ case SYSLINUX_FS_ISOLINUX:
+ strlcpy(hardware->syslinux_fs, "ISOlinux", 9);
+ break;
+ case SYSLINUX_FS_EXTLINUX:
+ strlcpy(hardware->syslinux_fs, "EXTlinux", 9);
+ break;
+ case SYSLINUX_FS_UNKNOWN:
+ default:
+ strlcpy(hardware->syslinux_fs, "Unknown Bootloader",
+ sizeof hardware->syslinux_fs);
+ break;
+ }
+}
+
+void init_hardware(struct s_hardware *hardware)
+{
+ hardware->pci_ids_return_code = 0;
+ hardware->modules_pcimap_return_code = 0;
+ hardware->modules_alias_return_code = 0;
+ hardware->cpu_detection = false;
+ hardware->pci_detection = false;
+ hardware->disk_detection = false;
+ hardware->disks_count = 0;
+ hardware->dmi_detection = false;
+ hardware->pxe_detection = false;
+ hardware->vesa_detection = false;
+ hardware->vpd_detection = false;
+ hardware->memory_detection = false;
+ hardware->nb_pci_devices = 0;
+ hardware->is_dmi_valid = false;
+ hardware->is_pxe_valid = false;
+ hardware->is_vpd_valid = false;
+ hardware->pci_domain = NULL;
+ hardware->detected_memory_size = 0;
+
+ /* Cleaning structures */
+ memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
+ memset(hardware->mbr_ids, 0, sizeof(hardware->mbr_ids));
+ memset(&hardware->dmi, 0, sizeof(s_dmi));
+ memset(&hardware->cpu, 0, sizeof(s_cpu));
+ 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->syslinux_fs, 0, sizeof hardware->syslinux_fs);
+ memset(hardware->pciids_path, 0, sizeof hardware->pciids_path);
+ memset(hardware->modules_pcimap_path, 0,
+ sizeof hardware->modules_pcimap_path);
+ memset(hardware->modules_alias_path, 0,
+ sizeof hardware->modules_alias_path);
+ memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
+ memset(hardware->auto_label, 0, sizeof hardware->auto_label);
+ memset(hardware->vesa_background, 0, sizeof hardware->vesa_background);
+ strcat(hardware->pciids_path, "pci.ids");
+ strcat(hardware->modules_pcimap_path, "modules.pcimap");
+ strcat(hardware->modules_alias_path, "modules.alias");
+ strcat(hardware->memtest_label, "memtest");
+ strlcpy(hardware->vesa_background, CLI_DEFAULT_BACKGROUND,
+ sizeof(hardware->vesa_background));
+}
+
+/*
+ * Detecting if a DMI table exist
+ * if yes, let's parse it
+ */
+int detect_dmi(struct s_hardware *hardware)
+{
+ if (hardware->dmi_detection == true)
+ return -1;
+ hardware->dmi_detection = true;
+ if (dmi_iterate(&hardware->dmi) == -ENODMITABLE) {
+ hardware->is_dmi_valid = false;
+ return -ENODMITABLE;
+ }
+
+ parse_dmitable(&hardware->dmi);
+ hardware->is_dmi_valid = true;
+ return 0;
+}
+
+/**
+ * vpd_detection - populate the VPD structure
+ *
+ * VPD is a structure available on IBM machines.
+ * It is documented at:
+ * http://www.pc.ibm.com/qtechinfo/MIGR-45120.html
+ * (XXX the page seems to be gone)
+ **/
+int detect_vpd(struct s_hardware *hardware)
+{
+ if (hardware->vpd_detection)
+ return -1;
+ else
+ hardware->vpd_detection = true;
+
+ if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) {
+ hardware->is_vpd_valid = false;
+ return -ENOVPDTABLE;
+ } else {
+ hardware->is_vpd_valid = true;
+ return 0;
+ }
+}
+
+/* Detection vesa stuff*/
+int detect_vesa(struct s_hardware *hardware)
+{
+ static com32sys_t rm;
+ struct vesa_general_info *gi;
+ struct vesa_mode_info *mi;
+ uint16_t mode, *mode_ptr;
+ char *oem_ptr;
+
+ if (hardware->vesa_detection == true)
+ return -1;
+
+ hardware->vesa_detection = true;
+ hardware->is_vesa_valid = false;
+
+ /* Allocate space in the bounce buffer for these structures */
+ gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
+ mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
+
+ gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
+ rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
+ rm.edi.w[0] = OFFS(gi);
+ rm.es = SEG(gi);
+ __intcall(0x10, &rm, &rm);
+
+ if (rm.eax.w[0] != 0x004F) {
+ return -1;
+ };
+
+ mode_ptr = GET_PTR(gi->video_mode_ptr);
+ oem_ptr = GET_PTR(gi->oem_vendor_name_ptr);
+ strlcpy(hardware->vesa.vendor, oem_ptr, sizeof(hardware->vesa.vendor));
+ oem_ptr = GET_PTR(gi->oem_product_name_ptr);
+ strlcpy(hardware->vesa.product, oem_ptr, sizeof(hardware->vesa.product));
+ oem_ptr = GET_PTR(gi->oem_product_rev_ptr);
+ strlcpy(hardware->vesa.product_revision, oem_ptr,
+ sizeof(hardware->vesa.product_revision));
+
+ hardware->vesa.major_version = (gi->version >> 8) & 0xff;
+ hardware->vesa.minor_version = gi->version & 0xff;
+ hardware->vesa.total_memory = gi->total_memory;
+ hardware->vesa.software_rev = gi->oem_software_rev;
+
+ hardware->vesa.vmi_count = 0;
+
+ while ((mode = *mode_ptr++) != 0xFFFF) {
+
+ rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
+ rm.ecx.w[0] = mode;
+ rm.edi.w[0] = OFFS(mi);
+ rm.es = SEG(mi);
+ __intcall(0x10, &rm, &rm);
+
+ /* Must be a supported mode */
+ if (rm.eax.w[0] != 0x004f)
+ continue;
+
+ /* Saving detected values */
+ memcpy(&hardware->vesa.vmi[hardware->vesa.vmi_count].mi, mi,
+ sizeof(struct vesa_mode_info));
+ hardware->vesa.vmi[hardware->vesa.vmi_count].mode = mode;
+
+ hardware->vesa.vmi_count++;
+ }
+ hardware->is_vesa_valid = true;
+ return 0;
+}
+
+/* Try to detect disks from port 0x80 to 0xff */
+void detect_disks(struct s_hardware *hardware)
+{
+ int i = -1;
+ int err;
+
+ if (hardware->disk_detection)
+ return;
+
+ hardware->disk_detection = true;
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ i++;
+ hardware->disk_info[i].disk = drive;
+ err = get_drive_parameters(&hardware->disk_info[i]);
+
+ /*
+ * Do not print output when drive does not exist or
+ * doesn't support int13 (cdrom, ...)
+ */
+ if (err == -1 || !hardware->disk_info[i].cbios)
+ continue;
+
+ /* Detect MBR */
+ hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]);
+
+ hardware->disks_count++;
+ }
+}
+
+int detect_pxe(struct s_hardware *hardware)
+{
+ void *dhcpdata;
+
+ size_t dhcplen;
+ t_PXENV_UNDI_GET_NIC_TYPE gnt;
+
+ if (hardware->pxe_detection == true)
+ return -1;
+ hardware->pxe_detection = true;
+ hardware->is_pxe_valid = false;
+ memset(&gnt, 0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
+ memset(&hardware->pxe, 0, sizeof(struct s_pxe));
+
+ /* This code can only work if pxelinux is loaded */
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ return -1;
+ }
+// printf("PXE: PXElinux detected\n");
+ if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
+ pxe_bootp_t *dhcp = &hardware->pxe.dhcpdata;
+ memcpy(&hardware->pxe.dhcpdata, dhcpdata,
+ sizeof(hardware->pxe.dhcpdata));
+ snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr),
+ "%02x:%02x:%02x:%02x:%02x:%02x", dhcp->CAddr[0],
+ dhcp->CAddr[1], dhcp->CAddr[2], dhcp->CAddr[3],
+ dhcp->CAddr[4], dhcp->CAddr[5]);
+
+ /* Saving our IP address in a easy format */
+ hardware->pxe.ip_addr[0] = hardware->pxe.dhcpdata.yip & 0xff;
+ hardware->pxe.ip_addr[1] = hardware->pxe.dhcpdata.yip >> 8 & 0xff;
+ hardware->pxe.ip_addr[2] = hardware->pxe.dhcpdata.yip >> 16 & 0xff;
+ hardware->pxe.ip_addr[3] = hardware->pxe.dhcpdata.yip >> 24 & 0xff;
+
+ if (!pxe_get_nic_type(&gnt)) {
+ switch (gnt.NicType) {
+ case PCI_NIC:
+ hardware->is_pxe_valid = true;
+ hardware->pxe.vendor_id = gnt.info.pci.Vendor_ID;
+ hardware->pxe.product_id = gnt.info.pci.Dev_ID;
+ hardware->pxe.subvendor_id = gnt.info.pci.SubVendor_ID;
+ hardware->pxe.subproduct_id =
+ gnt.info.pci.SubDevice_ID,
+ hardware->pxe.rev = gnt.info.pci.Rev;
+ hardware->pxe.pci_bus = (gnt.info.pci.BusDevFunc >> 8) & 0xff;
+ hardware->pxe.pci_dev = (gnt.info.pci.BusDevFunc >> 3) & 0x7;
+ hardware->pxe.pci_func = gnt.info.pci.BusDevFunc & 0x03;
+ hardware->pxe.base_class = gnt.info.pci.Base_Class;
+ hardware->pxe.sub_class = gnt.info.pci.Sub_Class;
+ hardware->pxe.prog_intf = gnt.info.pci.Prog_Intf;
+ hardware->pxe.nictype = gnt.NicType;
+ break;
+ case CardBus_NIC:
+ hardware->is_pxe_valid = true;
+ hardware->pxe.vendor_id = gnt.info.cardbus.Vendor_ID;
+ hardware->pxe.product_id = gnt.info.cardbus.Dev_ID;
+ hardware->pxe.subvendor_id = gnt.info.cardbus.SubVendor_ID;
+ hardware->pxe.subproduct_id =
+ gnt.info.cardbus.SubDevice_ID,
+ hardware->pxe.rev = gnt.info.cardbus.Rev;
+ hardware->pxe.pci_bus =
+ (gnt.info.cardbus.BusDevFunc >> 8) & 0xff;
+ hardware->pxe.pci_dev =
+ (gnt.info.cardbus.BusDevFunc >> 3) & 0x7;
+ hardware->pxe.pci_func = gnt.info.cardbus.BusDevFunc & 0x03;
+ hardware->pxe.base_class = gnt.info.cardbus.Base_Class;
+ hardware->pxe.sub_class = gnt.info.cardbus.Sub_Class;
+ hardware->pxe.prog_intf = gnt.info.cardbus.Prog_Intf;
+ hardware->pxe.nictype = gnt.NicType;
+ break;
+ case PnP_NIC:
+ default:
+ return -1;
+ break;
+ }
+ /* Let's try to find the associated pci device */
+ detect_pci(hardware);
+
+ /* The firt pass try to find the exact pci device */
+ hardware->pxe.pci_device = NULL;
+ hardware->pxe.pci_device_pos = 0;
+ struct pci_device *pci_device;
+ int pci_number = 0;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ pci_number++;
+ if ((__pci_bus == hardware->pxe.pci_bus) &&
+ (__pci_slot == hardware->pxe.pci_dev) &&
+ (__pci_func == hardware->pxe.pci_func) &&
+ (pci_device->vendor == hardware->pxe.vendor_id)
+ && (pci_device->product == hardware->pxe.product_id)) {
+ hardware->pxe.pci_device = pci_device;
+ hardware->pxe.pci_device_pos = pci_number;
+ return 0;
+ }
+ }
+
+ /* If we reach that part, it means the pci device pointed by
+ * the pxe rom wasn't found in our list.
+ * Let's try to find the device only by its pci ids.
+ * The pci device we'll match is maybe not exactly the good one
+ * as we can have the same pci id several times.
+ * At least, the pci id, the vendor/product will be right.
+ * That's clearly a workaround for some weird cases.
+ * This should happend very unlikely */
+ hardware->pxe.pci_device = NULL;
+ hardware->pxe.pci_device_pos = 0;
+ pci_number = 0;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ pci_number++;
+ if ((pci_device->vendor == hardware->pxe.vendor_id)
+ && (pci_device->product == hardware->pxe.product_id)) {
+ hardware->pxe.pci_device = pci_device;
+ hardware->pxe.pci_device_pos = pci_number;
+ return 0;
+ }
+ }
+
+ }
+ }
+ return 0;
+}
+
+void detect_memory(struct s_hardware *hardware) {
+ if (hardware->memory_detection == false) {
+ hardware->memory_detection = true;
+ hardware->detected_memory_size = detect_memsize();
+ }
+}
+
+void detect_pci(struct s_hardware *hardware)
+{
+ if (hardware->pci_detection == true)
+ return;
+ hardware->pci_detection = true;
+
+ hardware->nb_pci_devices = 0;
+
+ /* Scanning to detect pci buses and devices */
+ hardware->pci_domain = pci_scan();
+
+ if (!hardware->pci_domain)
+ return;
+
+ /* Gathering addtional information */
+ gather_additional_pci_config(hardware->pci_domain);
+
+ struct pci_device *pci_device;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ hardware->nb_pci_devices++;
+ }
+
+ if (!quiet) {
+ more_printf("PCI: %d devices detected\n", hardware->nb_pci_devices);
+ more_printf("PCI: Resolving names\n");
+ }
+ /* Assigning product & vendor name for each device */
+ hardware->pci_ids_return_code =
+ get_name_from_pci_ids(hardware->pci_domain, hardware->pciids_path);
+
+ if (!quiet)
+ more_printf("PCI: Resolving class names\n");
+ /* Assigning class name for each device */
+ hardware->pci_ids_return_code =
+ get_class_name_from_pci_ids(hardware->pci_domain,
+ hardware->pciids_path);
+
+ if (!quiet)
+ more_printf("PCI: Resolving module names\n");
+ /* Detecting which kernel module should match each device using modules.pcimap */
+ hardware->modules_pcimap_return_code =
+ get_module_name_from_pcimap(hardware->pci_domain,
+ hardware->modules_pcimap_path);
+
+ /* Detecting which kernel module should match each device using modules.alias */
+ hardware->modules_alias_return_code =
+ get_module_name_from_alias(hardware->pci_domain,
+ hardware->modules_alias_path);
+
+ /* We try to detect the pxe stuff to populate the PXE: field of pci devices */
+ detect_pxe(hardware);
+}
+
+void cpu_detect(struct s_hardware *hardware)
+{
+ if (hardware->cpu_detection == true)
+ return;
+ detect_cpu(&hardware->cpu);
+ /* Old processors doesn't manage the identify commands
+ * Let's use the dmi value in that case */
+ if (strlen(remove_spaces(hardware->cpu.model)) == 0)
+ strlcpy(hardware->cpu.model, hardware->dmi.processor.version,
+ sizeof(hardware->cpu.model));
+
+ /* Some CPUs like to put many spaces in the model name
+ * That makes some weird display in console/menu
+ * Let's remove that mulitple spaces */
+ strlcpy(hardware->cpu.model,del_multi_spaces(hardware->cpu.model),sizeof(hardware->cpu.model));
+ hardware->cpu_detection = true;
+}
+
+/*
+ * Find the last instance of a particular command line argument
+ * (which should include the final =; do not use for boolean arguments)
+ */
+const char *find_argument(const char **argv, const char *argument)
+{
+ int la = strlen(argument);
+ const char **arg;
+ const char *ptr = NULL;
+
+ for (arg = argv; *arg; arg++) {
+ if (!memcmp(*arg, argument, la))
+ ptr = *arg + la;
+ }
+
+ return ptr;
+}
+
+void clear_screen(void)
+{
+ move_cursor_to_next_line();
+ disable_utf8();
+ set_g1_special_char();
+ set_us_g0_charset();
+ display_cursor(false);
+ clear_entire_screen();
+ gotoxy(0,0);
+ reset_more_printf();
+}
+
+/* remove begining spaces */
+char *skip_spaces(char *p)
+{
+ while (*p && *p <= ' ') {
+ p++;
+ }
+
+ return p;
+}
+
+/* remove trailing & begining spaces */
+char *remove_spaces(char *p)
+{
+ char *save = p;
+ p += strlen(p) - 1;
+ while (*p && *p <= ' ') {
+ *p = '\0';
+ p--;
+ }
+ p = save;
+ while (*p && *p <= ' ') {
+ p++;
+ }
+
+ return p;
+}
+
+/* remove trailing LF */
+char *remove_trailing_lf(char *p)
+{
+ char *save = p;
+ p += strlen(p) - 1;
+ while (*p && *p == 10) {
+ *p = '\0';
+ p--;
+ }
+ p = save;
+
+ return p;
+}
+
+/* delete multiple spaces, one is enough */
+char *del_multi_spaces(char *p)
+{
+ /* Saving the original pointer */
+ char *save = p;
+
+ /* Let's parse the complete string
+ * As we search for a double spacing
+ * we have to be sure then string is
+ * long enough to be processed */
+ while (*p && *p + 1) {
+
+ /* If we have two consecutive spaces */
+ if ((*p == ' ') && (*(p + 1) == ' ')) {
+
+ /* Let's copy to the current position
+ * the content from the second space*/
+ strlcpy(p, p + 1, strlen(p + 1));
+
+ /* The string is 1 char smaller */
+ *(p + strlen(p) - 1) = '\0';
+
+ /* Don't increment the pointer as we
+ * changed the content of the current position*/
+ continue;
+ }
+
+ /* Nothing as been found, let's see on the next char */
+ p++;
+ }
+ /* Returning the original pointer */
+ return save;
+}
+
+/* Reset the more_printf counter */
+void reset_more_printf(void)
+{
+ display_line_nb = 0;
+}
+
+int draw_background(const char *what)
+{
+ if (!what)
+ return vesacon_default_background();
+ else
+ return vesacon_load_background(what);
+}
+
+void init_console(struct s_hardware *hardware)
+{
+ if (vesamode) {
+ openconsole(&dev_rawcon_r, &dev_vesaserial_w);
+ draw_background(hardware->vesa_background);
+ } else
+ console_ansi_raw();
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-common.h b/contrib/syslinux-4.02/com32/hdt/hdt-common.h
new file mode 100644
index 0000000..fd9d785
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-common.h
@@ -0,0 +1,226 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_COMMON_H
+#define DEFINE_HDT_COMMON_H
+#include <stdio.h>
+#include <syslinux/pxe.h>
+#include <console.h>
+#include <consoles.h>
+#include <syslinux/vesacon.h>
+#include "sys/pci.h"
+
+#include <disk/bootloaders.h>
+#include <disk/errno_disk.h>
+#include <disk/error.h>
+#include <disk/geom.h>
+#include <disk/mbrs.h>
+#include <disk/msdos.h>
+#include <disk/partition.h>
+#include <disk/swsusp.h>
+#include <disk/read.h>
+
+#include "cpuid.h"
+#include "dmi/dmi.h"
+#include "hdt-ata.h"
+#include "../lib/sys/vesa/vesa.h"
+#include <vpd/vpd.h>
+#include <libansi.h>
+
+/* Declare a variable or data structure as unused. */
+#define __unused __attribute__ (( unused ))
+
+/* This two values are used for switching for the menu to the CLI mode */
+#define HDT_SWITCH_TO_CLI "hdt_switch_to_cli"
+#define HDT_RETURN_TO_CLI 100
+#define MAX_VESA_MODES 255
+
+/* This value is used for rebooting from the menu mode */
+#define HDT_REBOOT "hdt_reboot"
+
+/* The maximum number of commands we can process */
+#define MAX_NB_AUTO_COMMANDS 255
+/* The maximum size of a command */
+#define AUTO_COMMAND_SIZE 255
+/* The char that separate two commands */
+#define AUTO_SEPARATOR ";"
+/* The char that surround the list of commands */
+#define AUTO_DELIMITER "'"
+
+/* Graphic to load in background when using the vesa mode */
+#define CLI_DEFAULT_BACKGROUND "backgnd.png"
+
+/* The maximum number of lines */
+#define MAX_CLI_LINES 20
+#define MAX_VESA_CLI_LINES 24
+
+/* Defines if the cli is quiet*/
+bool quiet;
+
+/* Defines if we must use the vesa mode */
+bool vesamode;
+
+/* Defines the number of lines in the console
+ * Default is 20 for a std console */
+extern int max_console_lines;
+
+extern int display_line_nb;
+extern bool disable_more_printf;
+
+#define pause_printf() do {\
+ printf("--More--");\
+ get_key(stdin, 0);\
+ printf("\033[2K\033[1G\033[1F\n");\
+} while (0);
+
+/* The brokeness of that macro is that
+ * it assumes that __VA_ARGS__ contains
+ * one \n (and only one)
+ */
+#define more_printf(...) do {\
+ if (__likely(!disable_more_printf)) {\
+ if (display_line_nb == max_console_lines) {\
+ display_line_nb=0;\
+ printf("\n--More--");\
+ get_key(stdin, 0);\
+ printf("\033[2K\033[1G\033[1F");\
+ }\
+ display_line_nb++;\
+ }\
+ printf(__VA_ARGS__);\
+} while (0);
+
+/* Display CPU registers for debugging purposes */
+static inline void printregs(const com32sys_t * r)
+{
+ printf("eflags = %08x ds = %04x es = %04x fs = %04x gs = %04x\n"
+ "eax = %08x ebx = %08x ecx = %08x edx = %08x\n"
+ "ebp = %08x esi = %08x edi = %08x esp = %08x\n",
+ r->eflags.l, r->ds, r->es, r->fs, r->gs,
+ r->eax.l, r->ebx.l, r->ecx.l, r->edx.l,
+ r->ebp.l, r->esi.l, r->edi.l, r->_unused_esp.l);
+}
+
+struct s_pxe {
+ uint16_t vendor_id;
+ uint16_t product_id;
+ uint16_t subvendor_id;
+ uint16_t subproduct_id;
+ uint8_t rev;
+ uint8_t pci_bus;
+ uint8_t pci_dev;
+ uint8_t pci_func;
+ uint8_t base_class;
+ uint8_t sub_class;
+ uint8_t prog_intf;
+ uint8_t nictype;
+ char mac_addr[18]; /* The current mac address */
+ uint8_t ip_addr[4];
+ pxe_bootp_t dhcpdata; /* The dhcp answer */
+ struct pci_device *pci_device; /* The matching pci device */
+ uint8_t pci_device_pos; /* It position in our pci sorted list */
+};
+
+struct s_vesa_mode_info {
+ struct vesa_mode_info mi;
+ uint16_t mode;
+};
+
+struct s_vesa {
+ uint8_t major_version;
+ uint8_t minor_version;
+ struct s_vesa_mode_info vmi[MAX_VESA_MODES];
+ uint8_t vmi_count;
+ uint16_t total_memory;
+ char vendor[256];
+ char product[256];
+ char product_revision[256];
+ uint16_t software_rev;
+};
+
+struct s_hardware {
+ s_dmi dmi; /* DMI table */
+ s_cpu cpu; /* CPU information */
+ s_vpd vpd; /* VPD information */
+ struct pci_domain *pci_domain; /* PCI Devices */
+ struct driveinfo disk_info[256]; /* Disk Information */
+ uint32_t mbr_ids[256]; /* MBR ids */
+ int disks_count; /* Number of detected disks */
+ struct s_pxe pxe;
+ struct s_vesa vesa;
+ unsigned long detected_memory_size; /* The detected memory size (in KB) */
+
+ int pci_ids_return_code;
+ int modules_pcimap_return_code;
+ int modules_alias_return_code;
+ int nb_pci_devices;
+ bool is_dmi_valid;
+ bool is_pxe_valid;
+ bool is_vesa_valid;
+ bool is_vpd_valid;
+
+ bool dmi_detection; /* Does the dmi stuff has already been detected? */
+ bool pci_detection; /* Does the pci stuff has already been detected? */
+ bool cpu_detection; /* Does the cpu stuff has already been detected? */
+ bool disk_detection; /* Does the disk stuff has already been detected? */
+ bool pxe_detection; /* Does the pxe stuff has already been detected? */
+ 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 ?*/
+
+ char syslinux_fs[22];
+ const struct syslinux_version *sv;
+ char modules_pcimap_path[255];
+ char modules_alias_path[255];
+ char pciids_path[255];
+ char memtest_label[255];
+ char auto_label[AUTO_COMMAND_SIZE];
+ char vesa_background[255];
+};
+
+void reset_more_printf(void);
+const char *find_argument(const char **argv, const char *argument);
+char *remove_spaces(char *p);
+char *remove_trailing_lf(char *p);
+char *skip_spaces(char *p);
+char *del_multi_spaces(char *p);
+int detect_dmi(struct s_hardware *hardware);
+int detect_vpd(struct s_hardware *hardware);
+void detect_disks(struct s_hardware *hardware);
+void detect_pci(struct s_hardware *hardware);
+void cpu_detect(struct s_hardware *hardware);
+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);
+void detect_parameters(const int argc, const char *argv[],
+ struct s_hardware *hardware);
+int detect_vesa(struct s_hardware *hardware);
+void detect_memory(struct s_hardware *hardware);
+void init_console(struct s_hardware *hardware);
+#endif
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-about.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-about.c
new file mode 100644
index 0000000..1e8a6ff
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-about.c
@@ -0,0 +1,87 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Computing About menu*/
+void compute_aboutmenu(struct s_my_menu *menu)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" About ", -1);
+ menu->items_count = 0;
+
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Product : %s", PRODUCT_NAME);
+ snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s (%s)", VERSION,
+ CODENAME);
+ snprintf(statbuffer, sizeof statbuffer, "Version : %s (%s)", VERSION,
+ CODENAME);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Website : %s", WEBSITE_URL);
+ snprintf(statbuffer, sizeof statbuffer, "Website : %s",WEBSITE_URL);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Mailing List : %s", CONTACT);
+ snprintf(statbuffer, sizeof statbuffer, "Mailing List: %s", CONTACT);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "Project Leader : %s", AUTHOR);
+ snprintf(statbuffer, sizeof statbuffer, "Project Leader : %s", AUTHOR);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Core Developer : %s", CORE_DEVELOPER);
+ snprintf(statbuffer, sizeof statbuffer, "Core Developer : %s",
+ CORE_DEVELOPER);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c = 0; c < NB_CONTRIBUTORS; c++) {
+ snprintf(buffer, sizeof buffer, "Contributor : %s", contributors[c]);
+ snprintf(statbuffer, sizeof statbuffer, "Contributor : %s",
+ contributors[c]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ printf("MENU: About menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-disk.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-disk.c
new file mode 100644
index 0000000..b0b4a5a
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-disk.c
@@ -0,0 +1,264 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <stdlib.h>
+
+#include "hdt-menu.h"
+#include "hdt-util.h"
+
+static int dn;
+
+static void show_partition_information(struct driveinfo *drive_info,
+ struct part_entry *ptab __unused,
+ int partition_offset __unused,
+ int nb_partitions_seen)
+{
+ char menu_title[MENULEN + 1];
+ char menu_title_ref[MENULEN + 1];
+
+ if (nb_partitions_seen == 1)
+ add_sep();
+
+ memset(menu_title, 0, sizeof menu_title);
+ memset(menu_title_ref, 0, sizeof menu_title_ref);
+ snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
+ drive_info[dn].disk, nb_partitions_seen);
+ snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
+
+ add_item(menu_title,
+ "Partition information (start, end, length, type, ...)",
+ OPT_SUBMENU, menu_title_ref, 0);
+}
+
+/**
+ * compute_partition_information - print information about a partition
+ * @ptab: part_entry describing the partition
+ * @i: Partition number (UI purposes only)
+ * @ptab_root: part_entry describing the root partition (extended only)
+ * @drive_info: driveinfo struct describing the drive on which the partition
+ * is
+ *
+ * Note on offsets (from hpa, see chain.c32):
+ *
+ * To make things extra confusing: data partition offsets are relative to where
+ * the data partition record is stored, whereas extended partition offsets
+ * are relative to the beginning of the extended partition all the way back
+ * at the MBR... but still not absolute!
+ **/
+static void compute_partition_information(struct driveinfo *drive_info,
+ struct part_entry *ptab,
+ int partition_offset,
+ int nb_partitions_seen)
+{
+ char size[11];
+ char bootloader_name[9];
+ char *parttype;
+ unsigned int start, end;
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ char menu_title[MENULEN + 1];
+ char menu_title_ref[MENULEN + 1];
+
+ memset(buffer, 0, sizeof buffer);
+ memset(statbuffer, 0, sizeof statbuffer);
+ memset(menu_title, 0, sizeof menu_title);
+ memset(menu_title_ref, 0, sizeof menu_title_ref);
+ snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
+ drive_info[dn].disk, nb_partitions_seen);
+ snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
+
+ add_named_menu(menu_title_ref, menu_title, -1);
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ start = partition_offset;
+ end = start + ptab->length - 1;
+
+ if (ptab->length > 0)
+ sectors_to_size(ptab->length, size);
+ else
+ memset(size, 0, sizeof size);
+
+ get_label(ptab->ostype, &parttype);
+
+ snprintf(buffer, sizeof buffer, "Size : %s", remove_spaces(size));
+ snprintf(statbuffer, sizeof statbuffer, "Size : %s", remove_spaces(size));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "Type : %s", parttype);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", parttype);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) {
+ snprintf(buffer, sizeof buffer, "Bootloader : %s", bootloader_name);
+ snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
+ bootloader_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+
+ snprintf(buffer, sizeof buffer, "Bootable : %s",
+ (ptab->active_flag == 0x80) ? "Yes" : "No");
+ snprintf(statbuffer, sizeof statbuffer, "Bootable: %s",
+ (ptab->active_flag == 0x80) ? "Yes" : "No");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "Start : %d", start);
+ snprintf(statbuffer, sizeof statbuffer, "Start: %d", start);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "End : %d", end);
+ snprintf(statbuffer, sizeof statbuffer, "End: %d", end);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "Id : %X", ptab->ostype);
+ snprintf(statbuffer, sizeof statbuffer, "Id: %X", ptab->ostype);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ free(parttype);
+
+ /* Extra info */
+ if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) {
+ snprintf(buffer, sizeof buffer, "%s", "Swsusp sig : detected");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "Swsusp sig : detected");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+}
+
+/* Compute the disk submenu */
+static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
+ const struct s_hardware *hardware,
+ int disk_number)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ char mbr_name[50];
+ struct driveinfo *d = (struct driveinfo *)hardware->disk_info;
+
+ snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)",
+ d[disk_number].disk, d[disk_number].edd_version);
+ menu[nb_sub_disk_menu].menu = add_menu(buffer, -1);
+ menu[nb_sub_disk_menu].items_count = 0;
+
+ int previous_size, size;
+ char previous_unit[3], unit[3]; // GB
+ char size_iec[11]; // GiB
+ char size_dec[11]; // GB
+ sectors_to_size_dec(previous_unit, &previous_size, unit, &size,
+ d[disk_number].edd_params.sectors);
+ sectors_to_size(d[disk_number].edd_params.sectors, size_iec);
+ sectors_to_size_dec2(d[disk_number].edd_params.sectors, size_dec);
+
+ snprintf(buffer, sizeof buffer, "Size : %s/%s (%d %s)",
+ remove_spaces(size_iec), remove_spaces(size_dec), previous_size,
+ previous_unit);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s/%s (%d %s)",
+ remove_spaces(size_iec), remove_spaces(size_dec), previous_size,
+ previous_unit);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ /* Do not print Host Bus & Interface if EDD isn't 3.0 or more */
+ if (d[disk_number].edd_version >= 0x30) {
+ snprintf(buffer, sizeof buffer, "Host Bus/Interface: %s / %s",
+ remove_spaces((char *)d[disk_number].edd_params.host_bus_type),
+ d[disk_number].edd_params.interface_type);
+ snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s",
+ remove_spaces((char *)d[disk_number].edd_params.host_bus_type),
+ d[disk_number].edd_params.interface_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+ }
+
+ snprintf(buffer, sizeof buffer, "C / H / S : %d / %d / %d",
+ d[disk_number].legacy_max_cylinder + 1,
+ d[disk_number].legacy_max_head + 1,
+ (int)d[disk_number].edd_params.sectors);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Cylinders / Heads / Sectors: %d / %d / %d",
+ d[disk_number].legacy_max_cylinder + 1,
+ d[disk_number].legacy_max_head + 1,
+ (int)d[disk_number].edd_params.sectors);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ snprintf(buffer, sizeof buffer, "Sectors/Track : %d",
+ d[disk_number].legacy_sectors_per_track);
+ snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d",
+ d[disk_number].legacy_sectors_per_track);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50);
+
+ snprintf(buffer, sizeof buffer, "MBR : %s (0x%X)",
+ remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
+ snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)",
+ remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ dn = disk_number;
+
+ parse_partition_table(&d[disk_number], &show_partition_information);
+ if (!parse_partition_table(&d[disk_number], &compute_partition_information)) {
+ get_error("parse_partition_table");
+ menu[nb_sub_disk_menu].items_count++;
+ }
+
+ return 0;
+}
+
+/* Compute the Disks menu */
+void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[MENULEN + 1];
+ int nb_sub_disk_menu = 0;
+
+ /* No need to compute that menu if no disks were detected */
+ menu->disk_menu.items_count = 0;
+ if (hardware->disks_count == 0)
+ return;
+
+ for (int i = 0; i < hardware->disks_count; i++) {
+ if (!hardware->disk_info[i].cbios)
+ continue; /* Invalid geometry */
+ compute_disk_module
+ ((struct s_my_menu *)&(menu->disk_sub_menu), nb_sub_disk_menu,
+ hardware, i);
+ nb_sub_disk_menu++;
+ }
+
+ menu->disk_menu.menu = add_menu(" Disks ", -1);
+
+ for (int i = 0; i < nb_sub_disk_menu; i++) {
+ snprintf(buffer, sizeof buffer, " Disk <%d> ", i + 1);
+ add_item(buffer, "Disk", OPT_SUBMENU, NULL,
+ menu->disk_sub_menu[i].menu);
+ menu->disk_menu.items_count++;
+ }
+ printf("MENU: Disks menu done (%d items)\n", menu->disk_menu.items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-dmi.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-dmi.c
new file mode 100644
index 0000000..7a413a1
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-dmi.c
@@ -0,0 +1,381 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Compute System main menu */
+void compute_system(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" System ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->system.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->system.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s", dmi->system.product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ dmi->system.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->system.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->system.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->system.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->system.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "UUID : %s", dmi->system.uuid);
+ snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Wakeup : %s", dmi->system.wakeup_type);
+ snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s",
+ dmi->system.wakeup_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SKU Number: %s", dmi->system.sku_number);
+ snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s",
+ dmi->system.sku_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Family : %s", dmi->system.family);
+ snprintf(statbuffer, sizeof statbuffer, "Family: %s", dmi->system.family);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: System menu done (%d items)\n", menu->items_count);
+}
+
+/* Compute Chassis menu */
+void compute_chassis(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" Chassis ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->chassis.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->chassis.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->chassis.type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->chassis.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ dmi->chassis.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->chassis.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->chassis.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ del_multi_spaces(dmi->chassis.asset_tag));
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ del_multi_spaces(dmi->chassis.asset_tag));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Lock : %s", dmi->chassis.lock);
+ snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Chassis menu done (%d items)\n", menu->items_count);
+}
+
+/* Compute BIOS menu */
+void compute_bios(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" BIOS ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->bios.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->bios.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->bios.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Release : %s", dmi->bios.release_date);
+ snprintf(statbuffer, sizeof statbuffer, "Release Date: %s",
+ dmi->bios.release_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bios Rev. : %s", dmi->bios.bios_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s",
+ dmi->bios.bios_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Fw. Rev. : %s",
+ dmi->bios.firmware_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s",
+ dmi->bios.firmware_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ printf("MENU: BIOS menu done (%d items)\n", menu->items_count);
+}
+
+/* Compute Motherboard main menu */
+void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" Motherboard ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->base_board.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->base_board.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ dmi->base_board.product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ dmi->base_board.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->base_board.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ dmi->base_board.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->base_board.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->base_board.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ dmi->base_board.asset_tag);
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ dmi->base_board.asset_tag);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Location : %s", dmi->base_board.location);
+ snprintf(statbuffer, sizeof statbuffer, "Location: %s",
+ dmi->base_board.location);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->base_board.type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->base_board.type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Motherboard menu done (%d items)\n", menu->items_count);
+}
+
+/* Compute Main IPMI menu */
+void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" IPMI ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Interface Type : %s",
+ dmi->ipmi.interface_type);
+ snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s",
+ dmi->ipmi.interface_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Spec. Version : %u.%u",
+ dmi->ipmi.major_specification_version,
+ dmi->ipmi.minor_specification_version);
+ snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u",
+ dmi->ipmi.major_specification_version,
+ dmi->ipmi.minor_specification_version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "I2C Slave @ : 0x%02x",
+ dmi->ipmi.I2C_slave_address);
+ snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x",
+ dmi->ipmi.I2C_slave_address);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "NV Storage @ : %u",
+ dmi->ipmi.nv_address);
+ snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u",
+ dmi->ipmi.nv_address);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ uint32_t high = dmi->ipmi.base_address >> 32;
+ uint32_t low = dmi->ipmi.base_address & 0xFFFF;
+
+ snprintf(buffer, sizeof buffer, "Base Address : %08X%08X",
+ high, (low & ~1));
+ snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X",
+ high, (low & ~1));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "IRQ : %d", dmi->ipmi.irq);
+ snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", dmi->ipmi.irq);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: IPMI menu done (%d items)\n", menu->items_count);
+}
+
+/* Compute Main Battery menu */
+void compute_battery(struct s_my_menu *menu, s_dmi * dmi)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" Battery ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->battery.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->battery.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Manufacture Date: %s",
+ dmi->battery.manufacture_date);
+ snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s",
+ dmi->battery.manufacture_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s",
+ dmi->battery.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial: %s", dmi->battery.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Name : %s", dmi->battery.name);
+ snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Chemistry : %s",
+ dmi->battery.chemistry);
+ snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s",
+ dmi->battery.chemistry);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Design Capacity : %s",
+ dmi->battery.design_capacity);
+ snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s",
+ dmi->battery.design_capacity);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Design Voltage : %s",
+ dmi->battery.design_voltage);
+ snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s",
+ dmi->battery.design_voltage);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS : %s", dmi->battery.sbds);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s",
+ dmi->battery.sbds_manufacture_date);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s",
+ dmi->battery.sbds_manufacture_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS Chemistry : %s",
+ dmi->battery.sbds_chemistry);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s",
+ dmi->battery.sbds_chemistry);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Maximum Error : %s",
+ dmi->battery.maximum_error);
+ snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s",
+ dmi->battery.maximum_error);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "OEM Info : %s",
+ dmi->battery.oem_info);
+ snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s",
+ dmi->battery.oem_info);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Battery menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-kernel.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-kernel.c
new file mode 100644
index 0000000..98e5209
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-kernel.c
@@ -0,0 +1,87 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Main Kernel menu */
+void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char infobar[STATLEN + 1];
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ struct pci_device *pci_device;
+
+ menu->menu = add_menu(" Kernel Modules ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ add_item("The modules.{pcimap|alias} file is missing",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("Kernel modules can't be computed.",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("Please put one of them in same dir as hdt",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+ } else {
+ /*
+ * For every detected pci device, grab its kernel module to
+ * compute this submenu
+ */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ /* No need to add unknown kernel modules */
+ if (strlen(kernel_modules) > 0) {
+ snprintf(buffer, sizeof buffer, "%s (%s)",
+ kernel_modules, pci_device->dev_info->class_name);
+ snprintf(infobar, sizeof infobar,
+ "%04x:%04x %s : %s",
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+ }
+ }
+
+ printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-memory.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-memory.c
new file mode 100644
index 0000000..6c82b11
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-memory.c
@@ -0,0 +1,382 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <memory.h>
+#include "hdt-menu.h"
+#define E820MAX 128
+
+/* Compute the e820 submenu */
+static void compute_e820(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e820 Physical RAM map ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ struct e820entry map[E820MAX];
+ int count = 0;
+ char type[14];
+
+ detect_memory_e820(map, E820MAX, &count);
+ unsigned long memory_size = memsize_e820(map, count);
+ snprintf(buffer, sizeof buffer, "Detected Memory - %lu MiB (%lu KiB)",
+ memory_size >> 10, memory_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %lu MiB (%lu KiB)", memory_size >> 10,
+ memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+
+ for (int j = 0; j < count; j++) {
+ get_type(map[j].type, type, 14);
+ snprintf(buffer, sizeof buffer,
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size, remove_spaces(type));
+ snprintf(statbuffer, sizeof statbuffer,
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size, remove_spaces(type));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+}
+
+/* Compute the e801 submenu */
+static void compute_e801(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e801 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ int mem_low, mem_high = 0;
+ if (detect_memory_e801(&mem_low, &mem_high)) {
+ snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
+ snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
+ (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6));
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %d MiB (%d KiB)",
+ (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ add_item("", "", OPT_SEP, "", 0);
+ snprintf(buffer, sizeof buffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "High Memory : %d KiB (%d MiB)",
+ mem_high << 6, mem_high >> 4);
+ snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)",
+ mem_high << 6, mem_high >> 4);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ }
+ menu->items_count++;
+}
+
+/* Compute the 88 submenu */
+static void compute_88(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " 88 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ int mem_size = 0;
+ if (detect_memory_88(&mem_size)) {
+ snprintf(buffer, sizeof buffer, "%s", "88 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "88 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
+ snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
+ mem_size >> 10, mem_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %d MiB (%d KiB)", mem_size >> 10, mem_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+ menu->items_count++;
+}
+
+/* Compute the Memory submenu */
+static void compute_memory_module(struct s_my_menu *menu, s_dmi * dmi,
+ int slot_number)
+{
+ int i = slot_number;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " Bank <%d> ", i);
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ snprintf(buffer, sizeof buffer, "Form Factor : %s",
+ dmi->memory[i].form_factor);
+ snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s",
+ dmi->memory[i].form_factor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->memory[i].type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->memory[i].type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type Details : %s",
+ dmi->memory[i].type_detail);
+ snprintf(statbuffer, sizeof statbuffer, "Type Details: %s",
+ dmi->memory[i].type_detail);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Speed : %s", dmi->memory[i].speed);
+ snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s",
+ dmi->memory[i].speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Size : %s", dmi->memory[i].size);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s", dmi->memory[i].size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Set : %s",
+ dmi->memory[i].device_set);
+ snprintf(statbuffer, sizeof statbuffer, "Device Set: %s",
+ dmi->memory[i].device_set);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Loc. : %s",
+ dmi->memory[i].device_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Device Location: %s",
+ dmi->memory[i].device_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bank Locator : %s",
+ dmi->memory[i].bank_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s",
+ dmi->memory[i].bank_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Total Width : %s",
+ dmi->memory[i].total_width);
+ snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s",
+ dmi->memory[i].total_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Data Width : %s",
+ dmi->memory[i].data_width);
+ snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s",
+ dmi->memory[i].data_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Error : %s", dmi->memory[i].error);
+ snprintf(statbuffer, sizeof statbuffer, "Error: %s", dmi->memory[i].error);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->memory[i].manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->memory[i].manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->memory[i].serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
+ dmi->memory[i].serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ dmi->memory[i].asset_tag);
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ dmi->memory[i].asset_tag);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Part Number : %s",
+ dmi->memory[i].part_number);
+ snprintf(statbuffer, sizeof statbuffer, "Part Number: %s",
+ dmi->memory[i].part_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+}
+
+/* Compute the Memory submenu when type 6 is used*/
+static void compute_memory_module_type6(struct s_my_menu *menu, s_dmi * dmi,
+ int slot_number)
+{
+ int i = slot_number;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " Bank <%d> ", i);
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ snprintf(buffer, sizeof buffer, "Socket Designation : %s",
+ dmi->memory_module[i].socket_designation);
+ snprintf(statbuffer, sizeof statbuffer, "Socket Designation : %s",
+ dmi->memory_module[i].socket_designation);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bank Connections : %s",
+ dmi->memory_module[i].bank_connections);
+ snprintf(statbuffer, sizeof statbuffer, "Bank Connections: %s",
+ dmi->memory_module[i].bank_connections);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s",
+ dmi->memory_module[i].type);
+ snprintf(statbuffer, sizeof statbuffer, "Type : %s",
+ dmi->memory_module[i].type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Current Speed : %s",
+ dmi->memory_module[i].speed);
+ snprintf(statbuffer, sizeof statbuffer, "Current Speed : %s",
+ dmi->memory_module[i].speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Installed Size : %s",
+ dmi->memory_module[i].installed_size);
+ snprintf(statbuffer, sizeof statbuffer, "Installed Size : %s",
+ dmi->memory_module[i].installed_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Enabled Size : %s",
+ dmi->memory_module[i].enabled_size);
+ snprintf(statbuffer, sizeof statbuffer, "Enabled Size : %s",
+ dmi->memory_module[i].enabled_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Error Status : %s",
+ dmi->memory_module[i].error_status);
+ snprintf(statbuffer, sizeof statbuffer, "Error Status : %s",
+ dmi->memory_module[i].error_status);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+}
+
+/* Compute the Memory menu */
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi,
+ struct s_hardware *hardware)
+{
+ char buffer[MENULEN + 1];
+ int i = 0;
+ int memory_count = 0;
+
+ /* If memory type 17 is available */
+ if (dmi->memory_count > 0) {
+ memory_count = dmi->memory_count;
+ for (i = 0; i < dmi->memory_count; i++) {
+ compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
+ }
+ } else if (dmi->memory_module_count > 0) {
+ memory_count = dmi->memory_module_count;
+ /* Memory Type 17 isn't available, let's fallback on type 6 */
+ for (i = 0; i < dmi->memory_module_count; i++) {
+ compute_memory_module_type6(&(menu->memory_sub_menu[i]), dmi, i);
+ }
+ }
+
+ compute_e820(&(menu->memory_sub_menu[++i]));
+ compute_e801(&(menu->memory_sub_menu[++i]));
+ compute_88(&(menu->memory_sub_menu[++i]));
+
+ menu->memory_menu.menu = add_menu(" Memory ", -1);
+ menu->memory_menu.items_count = 0;
+
+ snprintf(buffer, sizeof(buffer), " %lu MB detected ",
+ (hardware->detected_memory_size + (1 << 9)) >> 10);
+ add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL,
+ menu->memory_sub_menu[0].menu);
+ menu->memory_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ if (memory_count == 0) {
+ snprintf(buffer, sizeof buffer, " No memory bank detected ");
+ add_item(buffer, "Memory Bank", OPT_INACTIVE, NULL,
+ menu->memory_sub_menu[1].menu);
+ menu->memory_menu.items_count++;
+ } else
+ for (i = 0; i < memory_count; i++) {
+ snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
+ add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[i].menu);
+ menu->memory_menu.items_count++;
+ }
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, " e820 ");
+ add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " e801 ");
+ add_item(buffer, "e801 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " 88 ");
+ add_item(buffer, "88 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+ printf("MENU: Memory menu done (%d items)\n",
+ menu->memory_menu.items_count);
+ add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-pci.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-pci.c
new file mode 100644
index 0000000..734b744
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-pci.c
@@ -0,0 +1,203 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Dynamic submenu for pci devices */
+static void compute_pci_device(struct s_my_menu *menu,
+ struct pci_device *pci_device,
+ int pci_bus, int pci_slot, int pci_func,
+ struct s_hardware *hardware)
+{
+ char buffer[56];
+ char statbuffer[STATLEN];
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ menu->menu = add_menu(" Details ", -1);
+ menu->items_count = 0;
+ set_menu_pos(5, 17);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ pci_device->dev_info->vendor_name);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
+ pci_device->dev_info->vendor_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ pci_device->dev_info->product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name %s",
+ pci_device->dev_info->product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Class : %s",
+ pci_device->dev_info->class_name);
+ snprintf(statbuffer, sizeof statbuffer, "Class Name: %s",
+ pci_device->dev_info->class_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Location: %02x:%02x.%01x", pci_bus,
+ pci_slot, pci_func);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Location on the PCI Bus: %02x:%02x.%01x", pci_bus, pci_slot,
+ pci_func);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI ID : %04x:%04x[%04x:%04x]",
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ snprintf(statbuffer, sizeof statbuffer,
+ "vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]",
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if ((pci_device->dev_info->irq > 0) && (pci_device->dev_info->irq < 255)) {
+ snprintf(buffer, sizeof buffer, "IRQ : %d",
+ pci_device->dev_info->irq);
+ snprintf(statbuffer, sizeof statbuffer, "IRQ : %d",
+ pci_device->dev_info->irq);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ snprintf(buffer, sizeof buffer, "Latency : %d",
+ pci_device->dev_info->latency);
+ snprintf(statbuffer, sizeof statbuffer, "Latency : %d",
+ pci_device->dev_info->latency);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ memset(kernel_modules, 0, sizeof(kernel_modules));
+
+ if (pci_device->dev_info->linux_kernel_module_count > 1) {
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ snprintf(buffer, sizeof buffer, "Modules : %s", kernel_modules);
+ snprintf(statbuffer, sizeof statbuffer, "Kernel Modules: %s",
+ kernel_modules);
+ } else {
+ snprintf(buffer, sizeof buffer, "Module : %s",
+ pci_device->dev_info->linux_kernel_module[0]);
+ snprintf(statbuffer, sizeof statbuffer, "Kernel Module: %s",
+ pci_device->dev_info->linux_kernel_module[0]);
+ }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (hardware->is_pxe_valid == true) {
+ if ((hardware->pxe.pci_device != NULL)
+ && (hardware->pxe.pci_device == pci_device)) {
+
+ snprintf(buffer, sizeof buffer, "MAC Addr: %s",
+ hardware->pxe.mac_addr);
+ snprintf(statbuffer, sizeof statbuffer, "MAC Address : %s",
+ hardware->pxe.mac_addr);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PXE : %s",
+ "Current Boot device");
+ snprintf(statbuffer, sizeof statbuffer, "PXE : %s",
+ "Current Boot device");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+ }
+}
+
+/* Main PCI menu */
+int compute_PCI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
+{
+ int i = 0;
+ char menuname[255][MENULEN + 1];
+ char infobar[255][STATLEN + 1];
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
+
+ compute_pci_device(&(hdt_menu->pci_sub_menu[i]), pci_device,
+ __pci_bus, __pci_slot, __pci_func, hardware);
+ snprintf(menuname[i], 59, "%s|%s",
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ snprintf(infobar[i], STATLEN,
+ "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s",
+ __pci_bus, __pci_slot, __pci_func,
+ pci_device->dev_info->class_name, pci_device->vendor,
+ pci_device->product, pci_device->sub_vendor,
+ pci_device->sub_product, kernel_modules);
+ i++;
+ }
+
+ hdt_menu->pci_menu.menu = add_menu(" PCI Devices ", -1);
+ hdt_menu->pci_menu.items_count = 0;
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ add_item("The pci.ids file is missing", "Missing pci.ids file",
+ OPT_INACTIVE, NULL, 0);
+ add_item("PCI Device names can't be computed.",
+ "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
+ add_item("Please put one in same dir as hdt",
+ "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+ }
+ for (int j = 0; j < i; j++) {
+ add_item(menuname[j], infobar[j], OPT_SUBMENU, NULL,
+ hdt_menu->pci_sub_menu[j].menu);
+ hdt_menu->pci_menu.items_count++;
+ }
+ printf("MENU: PCI menu done (%d items)\n", hdt_menu->pci_menu.items_count);
+ return 0;
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-processor.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-processor.c
new file mode 100644
index 0000000..f303eb6
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-processor.c
@@ -0,0 +1,287 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+static void show_flag(struct s_my_menu *menu, char *buffer, bool flag,
+ char *flag_name, bool flush)
+{
+ char output_buffer[SUBMENULEN + 1];
+ char statbuffer[SUBMENULEN + 1];
+ if ((((strlen(buffer) + strlen(flag_name)) > 35) && flag) || flush) {
+ snprintf(output_buffer, sizeof output_buffer, "Flags : %s", buffer);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer);
+ add_item(output_buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ memset(buffer, 0, sizeof(buffer));
+ if (flush)
+ return;
+ }
+ if (flag)
+ strcat(buffer, flag_name);
+}
+
+/* Compute Processor menu */
+void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char buffer1[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" Main Processor ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->cpu.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", hardware->cpu.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Model : %s", hardware->cpu.model);
+ snprintf(statbuffer, sizeof statbuffer, "Model: %s", hardware->cpu.model);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "CPU Cores : %d", hardware->cpu.num_cores);
+ snprintf(statbuffer, sizeof statbuffer, "Number of CPU cores: %d",
+ hardware->cpu.num_cores);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "L1 Cache : %dK + %dK (I+D)",
+ hardware->cpu.l1_instruction_cache_size,
+ hardware->cpu.l1_data_cache_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "L1 Cache Size: %dK + %dK (Instruction + Data)",
+ hardware->cpu.l1_instruction_cache_size,
+ hardware->cpu.l1_data_cache_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "L2 Cache : %dK",
+ hardware->cpu.l2_cache_size);
+ snprintf(statbuffer, sizeof statbuffer, "L2 Cache Size: %dK",
+ hardware->cpu.l2_cache_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family);
+ snprintf(statbuffer, sizeof statbuffer, "Family ID: %d",
+ hardware->cpu.family);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Model ID : %d", hardware->cpu.model_id);
+ snprintf(statbuffer, sizeof statbuffer, "Model ID: %d",
+ hardware->cpu.model_id);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Stepping : %d", hardware->cpu.stepping);
+ snprintf(statbuffer, sizeof statbuffer, "Stepping: %d",
+ hardware->cpu.stepping);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (hardware->is_dmi_valid) {
+ snprintf(buffer, sizeof buffer, "FSB : %d",
+ hardware->dmi.processor.external_clock);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Front Side Bus (MHz): %d",
+ hardware->dmi.processor.external_clock);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Cur. Speed: %d",
+ hardware->dmi.processor.current_speed);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Current Speed (MHz): %d",
+ hardware->dmi.processor.current_speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Max Speed : %d",
+ hardware->dmi.processor.max_speed);
+ snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d",
+ hardware->dmi.processor.max_speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Upgrade : %s",
+ hardware->dmi.processor.upgrade);
+ snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s",
+ hardware->dmi.processor.upgrade);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Voltage : %d.%02d",
+ hardware->dmi.processor.voltage_mv / 1000,
+ hardware->dmi.processor.voltage_mv -
+ ((hardware->dmi.processor.voltage_mv / 1000) * 1000));
+ snprintf(statbuffer, sizeof statbuffer, "Voltage (V) : %d.%02d",
+ hardware->dmi.processor.voltage_mv / 1000,
+ hardware->dmi.processor.voltage_mv -
+ ((hardware->dmi.processor.voltage_mv / 1000) * 1000));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (hardware->cpu.flags.smp) {
+ snprintf(buffer, sizeof buffer, "SMP : Yes");
+ snprintf(statbuffer, sizeof statbuffer, "SMP: Yes");
+ } else {
+ snprintf(buffer, sizeof buffer, "SMP : No");
+ snprintf(statbuffer, sizeof statbuffer, "SMP: No");
+ }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (hardware->cpu.flags.lm) {
+ snprintf(buffer, sizeof buffer, "x86_64 : Yes");
+ snprintf(statbuffer, sizeof statbuffer,
+ "x86_64 compatible processor: Yes");
+ } else {
+ snprintf(buffer, sizeof buffer, "X86_64 : No");
+ snprintf(statbuffer, sizeof statbuffer,
+ "X86_64 compatible processor: No");
+ }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if ((hardware->cpu.flags.vmx) || (hardware->cpu.flags.svm)) {
+ snprintf(buffer, sizeof buffer, "Hw Virt. : Yes");
+ snprintf(statbuffer, sizeof statbuffer,
+ "Hardware Virtualisation Capable: Yes");
+ } else {
+ snprintf(buffer, sizeof buffer, "Hw Virt. : No");
+ snprintf(statbuffer, sizeof statbuffer,
+ "Hardware Virtualisation Capabable : No");
+ }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ memset(buffer1, 0, sizeof(buffer1));
+ show_flag(menu, buffer1, hardware->cpu.flags.fpu, "fpu ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.vme, "vme ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.de, "de ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pse, "pse ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.tsc, "tsc ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.msr, "msr ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pae, "pae ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mce, "mce ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.cx8, "cx8 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.apic, "apic ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sep, "sep ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mtrr, "mtrr ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pge, "pge ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mca, "mca ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.cmov, "cmov ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pat, "pat ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pse_36, "pse_36 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.psn, "psn ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.clflsh, "clflsh ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.dts, "dts ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.acpi, "acpi ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mmx, "mmx ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sse, "sse ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sse2, "sse2 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ss, "ss ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.htt, "ht ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.acc, "acc ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.syscall, "syscall ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mp, "mp ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.nx, "nx ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.mmxext, "mmxext ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.lm, "lm ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.nowext, "3dnowext ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.now, "3dnow! ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.svm, "svm ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.vmx, "vmx ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pbe, "pbe ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.gbpages, "gbpages ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.rdtscp, "rdtscp ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pni, "pni ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.dtes64, "dtes64 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.smx, "smx ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.est, "est ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.tm2, "tm2 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sse3, "sse3 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.fma, "fma ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.cx16, "cx16 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.xtpr, "xtpr ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pdcm, "pdcm ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.dca, "dca ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.x2apic, "x2apic ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.movbe, "movbe ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.popcnt, "popcnt ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.aes, "aes ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.xsave, "xsave ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.osxsave, "osxsave ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.avx, "avx ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.hypervisor, "hypervisor ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ace2, "ace2 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ace2_en, "ace2_en ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.phe, "phe ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.phe_en, "phe_en ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pmm, "pmm ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.pmm_en, "pmm_en ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.extapic, "extapic ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.cr8_legacy, "cr8_legacy ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.abm, "abm ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sse4a, "sse4a ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.misalignsse, "misalignsse ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.nowprefetch, "3dnowprefetch ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.osvw, "osvw ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ibs, "ibs ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.sse5, "sse5 ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.skinit, "skinit ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.wdt, "wdt ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ida, "ida ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.arat, "arat ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.tpr_shadow, "tpr_shadow ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.vnmi, "vnmi ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.flexpriority, "flexpriority ",
+ false);
+ show_flag(menu, buffer1, hardware->cpu.flags.ept, "ept ", false);
+ show_flag(menu, buffer1, hardware->cpu.flags.vpid, "vpid ", false);
+
+ /* Let's flush the remaining flags */
+ show_flag(menu, buffer1, false, "", true);
+
+ printf("MENU: Processor menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-pxe.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-pxe.c
new file mode 100644
index 0000000..426bfe0
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-pxe.c
@@ -0,0 +1,125 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+#include <sys/gpxe.h>
+
+/* Main Kernel menu */
+void compute_PXE(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char infobar[STATLEN + 1];
+ char gpxe[4];
+
+ if (hardware->is_pxe_valid == false)
+ return;
+
+ menu->menu = add_menu(" PXE ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ struct s_pxe *p = &hardware->pxe;
+
+ if ((hardware->pci_ids_return_code == -ENOPCIIDS)
+ || (p->pci_device == NULL)) {
+ snprintf(buffer, sizeof buffer, "PCI Vendor : %d", p->vendor_id);
+ snprintf(infobar, sizeof infobar, "PCI Vendor : %d", p->vendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI Product : %d", p->vendor_id);
+ snprintf(infobar, sizeof infobar, "PCI Product : %d", p->vendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI SubVendor : %d", p->subvendor_id);
+ snprintf(infobar, sizeof infobar, "PCI SubVendor : %d",
+ p->subvendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI SubProduct : %d",
+ p->subproduct_id);
+ snprintf(infobar, sizeof infobar, "PCI SubProduct : %d",
+ p->subproduct_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI Revision : %d", p->rev);
+ snprintf(infobar, sizeof infobar, "PCI Revision : %d", p->rev);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer,
+ "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ snprintf(infobar, sizeof infobar,
+ "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ } else {
+
+ snprintf(buffer, sizeof buffer, "Manufacturer : %s",
+ p->pci_device->dev_info->vendor_name);
+ snprintf(infobar, sizeof infobar, "Manufacturer : %s",
+ p->pci_device->dev_info->vendor_name);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ p->pci_device->dev_info->product_name);
+ snprintf(infobar, sizeof infobar, "Product : %s",
+ p->pci_device->dev_info->product_name);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ snprintf(buffer, sizeof buffer, "MAC Address : %s", p->mac_addr);
+ snprintf(infobar, sizeof infobar, "MAC Address : %s", p->mac_addr);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ snprintf(infobar, sizeof infobar, "IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (is_gpxe()) strcat(gpxe,"Yes");
+ else strcat (gpxe,"No");
+
+ snprintf(buffer, sizeof buffer, "gPXE Detected: %s", gpxe);
+ snprintf(infobar, sizeof infobar, "gPXE Detected: %s", gpxe);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: PXE menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-summary.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-summary.c
new file mode 100644
index 0000000..e9d56ca
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-summary.c
@@ -0,0 +1,195 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Computing Summary menu */
+void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" Summary ", -1);
+ menu->items_count = 0;
+
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "CPU Vendor : %s", hardware->cpu.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s",
+ hardware->cpu.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "CPU Model : %s", hardware->cpu.model);
+ snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s",
+ hardware->cpu.model);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ char features[SUBMENULEN + 1];
+ memset(features, 0, sizeof(features));
+ sprintf(features, "%d cores, %dK L2 Cache", hardware->cpu.num_cores,
+ hardware->cpu.l2_cache_size);
+ if (hardware->cpu.flags.lm)
+ strcat(features, ", 64bit");
+ else
+ strcat(features, ", 32bit");
+ if (hardware->cpu.flags.smp)
+ strcat(features, ", SMP ");
+ if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm)
+ strcat(features, ", HwVIRT ");
+ snprintf(buffer, sizeof buffer, "%s", features);
+ snprintf(statbuffer, sizeof statbuffer, "Features : %s", features);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+ if (hardware->is_dmi_valid == true) {
+
+ snprintf(buffer, sizeof buffer, "System Vendor : %s",
+ hardware->dmi.system.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s",
+ hardware->dmi.system.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "System Product: %s",
+ hardware->dmi.system.product_name);
+ snprintf(statbuffer, sizeof statbuffer,
+ "System Product Name: %s", hardware->dmi.system.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "System Serial : %s",
+ hardware->dmi.system.serial);
+ snprintf(statbuffer, sizeof statbuffer,
+ "System Serial Number: %s", hardware->dmi.system.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "Bios Version : %s",
+ hardware->dmi.bios.version);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
+ hardware->dmi.bios.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bios Release : %s",
+ hardware->dmi.bios.release_date);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
+ hardware->dmi.bios.release_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory Size: %lu MiB (%lu KiB)",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
+ hardware->nb_pci_devices);
+ snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
+ hardware->nb_pci_devices);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (hardware->is_pxe_valid == true) {
+ add_item("", "", OPT_SEP, "", 0);
+
+ struct s_pxe *p = &hardware->pxe;
+
+ snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", p->mac_addr);
+ snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s",
+ p->mac_addr);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ snprintf(statbuffer, sizeof statbuffer,
+ "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0],
+ p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
+ add_item("", "", OPT_SEP, "", 0);
+
+ bool kmod = false;
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ /*
+ * For every detected pci device, grab its kernel module to compute
+ * this submenu
+ */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ /* No need to add unknown kernel modules */
+ if (strlen(kernel_modules) > 0) {
+ snprintf(buffer, sizeof buffer, "%s (%s)",
+ kernel_modules, pci_device->dev_info->class_name);
+ snprintf(statbuffer, sizeof statbuffer,
+ "%04x:%04x %s : %s",
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ kmod = true;
+ }
+ }
+ }
+
+ printf("MENU: Summary menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-syslinux.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-syslinux.c
new file mode 100644
index 0000000..aaddf17
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-syslinux.c
@@ -0,0 +1,82 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 "syslinux/config.h"
+#include "hdt-menu.h"
+
+/* Computing Syslinux menu */
+void compute_syslinuxmenu(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char syslinux_fs_menu[24];
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu);
+
+ snprintf(syslinux_fs_menu, sizeof syslinux_fs_menu, " %s ",
+ hardware->syslinux_fs);
+ menu->menu = add_menu(syslinux_fs_menu, -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Bootloader : %s", hardware->syslinux_fs);
+ snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
+ hardware->syslinux_fs);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s",
+ hardware->sv->version_string);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ hardware->sv->version_string);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %u", hardware->sv->version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %u",
+ hardware->sv->version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Max API : %u", hardware->sv->max_api);
+ snprintf(statbuffer, sizeof statbuffer, "Max API: %u",
+ hardware->sv->max_api);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "%s", hardware->sv->copyright_string);
+ /* Remove the trailing LF in the copyright string to avoid scrolling */
+ snprintf(statbuffer, sizeof statbuffer, "%s",
+ remove_trailing_lf((char *)hardware->sv->copyright_string));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Syslinux menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-vesa.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-vesa.c
new file mode 100644
index 0000000..0fe06ab
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-vesa.c
@@ -0,0 +1,129 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-menu.h"
+
+/* Submenu for the vesa card */
+static void compute_vesa_card(struct s_my_menu *menu,
+ struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" VESA Bios ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "VESA Version: %d.%d",
+ hardware->vesa.major_version, hardware->vesa.minor_version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %d.%d",
+ hardware->vesa.major_version, hardware->vesa.minor_version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->vesa.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
+ hardware->vesa.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s", hardware->vesa.product);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ hardware->vesa.product);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product Rev.: %s",
+ hardware->vesa.product_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Produt Revision: %s",
+ hardware->vesa.product_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Software Rev: %d",
+ hardware->vesa.software_rev);
+ snprintf(statbuffer, sizeof statbuffer, "Software Revision: %d",
+ hardware->vesa.software_rev);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Memory (KB) : %d",
+ hardware->vesa.total_memory * 64);
+ snprintf(statbuffer, sizeof statbuffer, "Memory (KB): %d",
+ hardware->vesa.total_memory * 64);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+}
+
+/* Submenu for the vesa card */
+void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[56];
+ char statbuffer[STATLEN];
+
+ menu->menu = add_menu(" VESA Modes ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ for (int i = 0; i < hardware->vesa.vmi_count; i++) {
+ struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
+ /* Sometimes, vesa bios reports 0x0 modes
+ * We don't need to display that ones */
+ if ((mi->h_res == 0) || (mi->v_res == 0))
+ continue;
+ snprintf(buffer, sizeof buffer, "%4u x %4u x %2ubits vga=%3d",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200);
+ snprintf(statbuffer, sizeof statbuffer, "%4ux%4ux%2ubits vga=%3d",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+}
+
+/* Main VESA Menu*/
+int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
+{
+ char buffer[15];
+ compute_vesa_card(&hdt_menu->vesa_card_menu, hardware);
+ compute_vesa_modes(&hdt_menu->vesa_modes_menu, hardware);
+ hdt_menu->vesa_menu.menu = add_menu(" VESA ", -1);
+ hdt_menu->vesa_menu.items_count = 0;
+
+ add_item("VESA Bios", "VESA Bios", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_card_menu.menu);
+ hdt_menu->vesa_menu.items_count++;
+ snprintf(buffer, sizeof buffer, "%s (%d)", "Modes",
+ hardware->vesa.vmi_count);
+ add_item(buffer, "VESA Modes", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_modes_menu.menu);
+ hdt_menu->vesa_menu.items_count++;
+ printf("MENU: VESA menu done (%d items)\n",
+ hdt_menu->vesa_menu.items_count);
+ return 0;
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu-vpd.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu-vpd.c
new file mode 100644
index 0000000..d77a823
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu-vpd.c
@@ -0,0 +1,114 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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-menu.h"
+
+/**
+ * compute_vpd - generate vpd menu
+ **/
+void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1]; /* Status bar */
+
+ menu->menu = add_menu(" VPD ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Address : %s",
+ hardware->vpd.base_address);
+ snprintf(statbuffer, sizeof statbuffer, "Address: %s",
+ hardware->cpu.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (strlen(hardware->vpd.bios_build_id) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Build ID : %s",
+ hardware->vpd.bios_build_id);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s",
+ hardware->vpd.bios_build_id);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.bios_release_date) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Release Date : %s",
+ hardware->vpd.bios_release_date);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
+ hardware->vpd.bios_release_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.bios_version) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Version : %s",
+ hardware->vpd.bios_version);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
+ hardware->vpd.bios_version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.default_flash_filename) > 0) {
+ snprintf(buffer, sizeof buffer, "Default Flash Filename : %s",
+ hardware->vpd.default_flash_filename);
+ snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s",
+ hardware->vpd.default_flash_filename);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.box_serial_number) > 0) {
+ snprintf(buffer, sizeof buffer, "Box Serial Number : %s",
+ hardware->vpd.box_serial_number);
+ snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s",
+ hardware->vpd.box_serial_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.motherboard_serial_number) > 0) {
+ snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s",
+ hardware->vpd.motherboard_serial_number);
+ snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s",
+ hardware->vpd.motherboard_serial_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (strlen(hardware->vpd.machine_type_model) > 0) {
+ snprintf(buffer, sizeof buffer, "Machine Type/Model : %s",
+ hardware->vpd.machine_type_model);
+ snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s",
+ hardware->vpd.machine_type_model);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ printf("MENU: VPD menu done (%d items)\n", menu->items_count);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu.c b/contrib/syslinux-4.02/com32/hdt/hdt-menu.c
new file mode 100644
index 0000000..219f698
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu.c
@@ -0,0 +1,337 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <unistd.h>
+#include <memory.h>
+#include <syslinux/reboot.h>
+#include "hdt-menu.h"
+
+int start_menu_mode(struct s_hardware *hardware, char *version_string)
+{
+ struct s_hdt_menu hdt_menu;
+
+ memset(&hdt_menu, 0, sizeof(hdt_menu));
+
+ /* Detect every kind of hardware */
+ detect_hardware(hardware);
+
+ /* Setup the menu system */
+ setup_menu(version_string);
+
+ /* Compute all submenus */
+ compute_submenus(&hdt_menu, hardware);
+
+ /* Compute the main menu */
+ compute_main_menu(&hdt_menu, hardware);
+
+#ifdef WITH_MENU_DISPLAY
+ t_menuitem *curr;
+ char cmd[160];
+
+ if (!quiet)
+ more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count);
+ curr = showmenus(hdt_menu.main_menu.menu);
+ /* When we exit the menu, do we have something to do? */
+ if (curr) {
+ /* When want to execute something */
+ if (curr->action == OPT_RUN) {
+ /* Tweak, we want to switch to the cli */
+ if (!strncmp
+ (curr->data, HDT_SWITCH_TO_CLI, sizeof(HDT_SWITCH_TO_CLI))) {
+ return HDT_RETURN_TO_CLI;
+ }
+ if (!strncmp
+ (curr->data, HDT_REBOOT, sizeof(HDT_REBOOT))) {
+ syslinux_reboot(1);
+ }
+ strcpy(cmd, curr->data);
+
+ /* Use specific syslinux call if needed */
+ if (issyslinux())
+ runsyslinuxcmd(cmd);
+ else
+ csprint(cmd, 0x07);
+ return 1; // Should not happen when run from SYSLINUX
+ }
+ }
+#endif
+ return 0;
+}
+
+/* In the menu system, what to do on keyboard timeout */
+TIMEOUTCODE ontimeout(void)
+{
+ // beep();
+ return CODE_WAIT;
+}
+
+/* Keyboard handler for the menu system */
+void keys_handler(t_menusystem * ms
+ __attribute__ ((unused)), t_menuitem * mi, int scancode)
+{
+ int nr, nc;
+
+ /* 0xFFFF is an invalid helpid */
+ if (scancode == KEY_F1 && mi->helpid != 0xFFFF) {
+ runhelpsystem(mi->helpid);
+ }
+
+ /*
+ * If user hit TAB, and item is an "executable" item
+ * and user has privileges to edit it, edit it in place.
+ */
+ if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) {
+//(isallowed(username,"editcmd") || isallowed(username,"root"))) {
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ /* User typed TAB and has permissions to edit command line */
+ gotoxy(EDITPROMPT, 1);
+ csprint("Command line:", 0x07);
+ editstring(mi->data, ACTIONLEN);
+ gotoxy(EDITPROMPT, 1);
+ cprint(' ', 0x07, nc - 1);
+ }
+}
+
+/* Setup the Menu system */
+void setup_menu(char *version)
+{
+ /* Creating the menu */
+ init_menusystem(version);
+ set_window_size(0, 0, 25, 80);
+
+ /* Do not use inactive attributes - they make little sense for HDT */
+ set_normal_attr(-1, -1, 0x17, 0x1F);
+
+ /* Register the menusystem handler */
+ // reg_handler(HDLR_SCREEN,&msys_handler);
+ reg_handler(HDLR_KEYS, &keys_handler);
+
+ /* Register the ontimeout handler, with a time out of 10 seconds */
+ reg_ontimeout(ontimeout, 1000, 0);
+}
+
+/* Compute Main' submenus */
+void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
+{
+
+ /* Compute this menu if a DMI table exists */
+ if (hardware->is_dmi_valid) {
+ if (hardware->dmi.ipmi.filled == true)
+ compute_ipmi(&hdt_menu->ipmi_menu, &hardware->dmi);
+ if (hardware->dmi.base_board.filled == true)
+ compute_motherboard(&(hdt_menu->mobo_menu), &(hardware->dmi));
+ if (hardware->dmi.chassis.filled == true)
+ compute_chassis(&(hdt_menu->chassis_menu), &(hardware->dmi));
+ if (hardware->dmi.system.filled == true)
+ compute_system(&(hdt_menu->system_menu), &(hardware->dmi));
+ compute_memory(hdt_menu, &(hardware->dmi), hardware);
+ if (hardware->dmi.bios.filled == true)
+ compute_bios(&(hdt_menu->bios_menu), &(hardware->dmi));
+ if (hardware->dmi.battery.filled == true)
+ compute_battery(&(hdt_menu->battery_menu), &(hardware->dmi));
+ }
+
+ compute_processor(&(hdt_menu->cpu_menu), hardware);
+ compute_vpd(&(hdt_menu->vpd_menu), hardware);
+ compute_disks(hdt_menu, hardware);
+
+#ifdef WITH_PCI
+ compute_PCI(hdt_menu, hardware);
+ compute_PXE(&(hdt_menu->pxe_menu), hardware);
+ compute_kernel(&(hdt_menu->kernel_menu), hardware);
+#endif
+ compute_summarymenu(&(hdt_menu->summary_menu), hardware);
+ compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware);
+ compute_VESA(hdt_menu, hardware);
+ compute_aboutmenu(&(hdt_menu->about_menu));
+}
+
+void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
+{
+ char menu_item[64];
+ /* Let's count the number of menus we have */
+ hdt_menu->total_menu_count = 0;
+ hdt_menu->main_menu.items_count = 0;
+
+ hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1);
+ set_item_options(-1, 24);
+
+#ifdef WITH_PCI
+ snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n",
+ hardware->nb_pci_devices);
+ add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL,
+ hdt_menu->pci_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count;
+#endif
+ if (hdt_menu->disk_menu.items_count > 0) {
+ snprintf(menu_item, sizeof(menu_item), "<D>isks (%2d)\n",
+ hdt_menu->disk_menu.items_count);
+ add_item(menu_item, "Disks Menu", OPT_SUBMENU, NULL,
+ hdt_menu->disk_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ hdt_menu->total_menu_count += hdt_menu->disk_menu.items_count;
+ }
+
+ snprintf(menu_item, sizeof(menu_item), "<M>emory\n");
+ add_item(menu_item, "Memory Menu", OPT_SUBMENU, NULL,
+ hdt_menu->memory_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ hdt_menu->total_menu_count += hdt_menu->memory_menu.items_count;
+
+ add_item("<P>rocessor", "Main Processor Menu", OPT_SUBMENU, NULL,
+ hdt_menu->cpu_menu.menu);
+ hdt_menu->main_menu.items_count++;
+
+ if (hardware->is_dmi_valid) {
+ if (hardware->dmi.base_board.filled == true) {
+ add_item("M<o>therboard", "Motherboard Menu",
+ OPT_SUBMENU, NULL, hdt_menu->mobo_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.bios.filled == true) {
+ add_item("<B>ios", "Bios Menu", OPT_SUBMENU, NULL,
+ hdt_menu->bios_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.chassis.filled == true) {
+ add_item("<C>hassis", "Chassis Menu", OPT_SUBMENU, NULL,
+ hdt_menu->chassis_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.system.filled == true) {
+ add_item("<S>ystem", "System Menu", OPT_SUBMENU, NULL,
+ hdt_menu->system_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.battery.filled == true) {
+ add_item("Ba<t>tery", "Battery Menu", OPT_SUBMENU, NULL,
+ hdt_menu->battery_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+ if (hardware->dmi.ipmi.filled == true) {
+ add_item("I<P>MI", "IPMI Menu", OPT_SUBMENU, NULL,
+ hdt_menu->ipmi_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+ }
+
+ if (hardware->is_vpd_valid == true) {
+ add_item("<V>PD", "VPD Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->vpd_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->is_pxe_valid == true) {
+ add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->pxe_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->is_vesa_valid == true) {
+ add_item("<V>ESA", "VESA Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ add_item("", "", OPT_SEP, "", 0);
+#ifdef WITH_PCI
+ if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) ||
+ (hardware->modules_alias_return_code != -ENOMODULESALIAS)) {
+ add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU,
+ NULL, hdt_menu->kernel_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+#endif
+ add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->syslinux_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ add_item("S<u>mmary", "Summary Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->summary_menu.menu);
+ hdt_menu->main_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ add_item("S<w>itch to CLI", "Switch to Command Line", OPT_RUN,
+ HDT_SWITCH_TO_CLI, 0);
+ add_item("<A>bout", "About Menu", OPT_SUBMENU, NULL,
+ hdt_menu->about_menu.menu);
+ add_item("<R>eboot", "Reboot", OPT_RUN, HDT_REBOOT, 0);
+ add_item("E<x>it", "Exit", OPT_EXITMENU, NULL, 0);
+ hdt_menu->main_menu.items_count++;
+
+ hdt_menu->total_menu_count += hdt_menu->main_menu.items_count;
+}
+
+void detect_hardware(struct s_hardware *hardware)
+{
+ if (!quiet)
+ more_printf("MEMORY: Detecting\n");
+ detect_memory(hardware);
+
+ if (!quiet)
+ more_printf("DMI: Detecting Table\n");
+ if (detect_dmi(hardware) == -ENODMITABLE) {
+ printf("DMI: ERROR ! Table not found ! \n");
+ printf("DMI: Many hardware components will not be detected ! \n");
+ } else {
+ if (!quiet)
+ more_printf("DMI: Table found ! (version %u.%u)\n",
+ hardware->dmi.dmitable.major_version,
+ hardware->dmi.dmitable.minor_version);
+ }
+
+ if (!quiet)
+ more_printf("CPU: Detecting\n");
+ cpu_detect(hardware);
+
+ if (!quiet)
+ more_printf("DISKS: Detecting\n");
+ detect_disks(hardware);
+
+ if (!quiet)
+ more_printf("VPD: Detecting\n");
+ detect_vpd(hardware);
+
+#ifdef WITH_PCI
+ detect_pci(hardware);
+ if (!quiet)
+ more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices);
+#endif
+ if (!quiet)
+ more_printf("VESA: Detecting\n");
+ detect_vesa(hardware);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-menu.h b/contrib/syslinux-4.02/com32/hdt/hdt-menu.h
new file mode 100644
index 0000000..c8c9124
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-menu.h
@@ -0,0 +1,135 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_MENU_H
+#define DEFINE_HDT_MENU_H
+#include <stdio.h>
+#include <getkey.h>
+
+#include "menu.h"
+#include "help.h"
+//#include "cpuid.h"
+#include "sys/pci.h"
+#include "hdt-common.h"
+#include "dmi/dmi.h"
+#include "hdt-ata.h"
+
+#define EDITPROMPT 21
+
+#define SUBMENULEN 46
+
+#define SUBMENU_Y 3
+#define SUBMENU_X 29
+
+#define MAX_PCI_SUB_MENU 128
+#define MAX_MEMORY_SUB_MENU 32
+#define MAX_DISK_SUB_MENU 32
+
+struct s_my_menu {
+ unsigned char menu;
+ int items_count;
+};
+
+struct s_hdt_menu {
+ struct s_my_menu main_menu;
+ struct s_my_menu cpu_menu;
+ struct s_my_menu mobo_menu;
+ struct s_my_menu chassis_menu;
+ struct s_my_menu bios_menu;
+ struct s_my_menu ipmi_menu;
+ struct s_my_menu system_menu;
+ struct s_my_menu pci_menu;
+ struct s_my_menu pci_sub_menu[MAX_PCI_SUB_MENU];
+ struct s_my_menu kernel_menu;
+ struct s_my_menu memory_menu;
+ struct s_my_menu memory_sub_menu[MAX_MEMORY_SUB_MENU];
+ struct s_my_menu disk_menu;
+ struct s_my_menu disk_sub_menu[MAX_DISK_SUB_MENU];
+ struct s_my_menu battery_menu;
+ struct s_my_menu syslinux_menu;
+ struct s_my_menu about_menu;
+ struct s_my_menu summary_menu;
+ struct s_my_menu pxe_menu;
+ struct s_my_menu vesa_menu;
+ struct s_my_menu vesa_card_menu;
+ struct s_my_menu vesa_modes_menu;
+ struct s_my_menu vpd_menu;
+ int total_menu_count; // Sum of all menus we have
+};
+
+TIMEOUTCODE ontimeout(void);
+void keys_handler(t_menusystem * ms
+ __attribute__ ((unused)), t_menuitem * mi, int scancode);
+
+// PCI Stuff
+int compute_PCI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
+
+// KERNEL Stuff
+void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware);
+
+// Disk Stuff
+void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware);
+
+// DMI Stuff
+void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi);
+void compute_battery(struct s_my_menu *menu, s_dmi * dmi);
+void compute_system(struct s_my_menu *menu, s_dmi * dmi);
+void compute_chassis(struct s_my_menu *menu, s_dmi * dmi);
+void compute_bios(struct s_my_menu *menu, s_dmi * dmi);
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi,
+ struct s_hardware *hardware);
+void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi);
+
+// VPD Stuff
+void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware);
+
+// Processor Stuff
+void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware);
+
+// Syslinux stuff
+void compute_syslinuxmenu(struct s_my_menu *menu, struct s_hardware *hardware);
+
+// About menu
+void compute_aboutmenu(struct s_my_menu *menu);
+
+// Summary menu
+void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware);
+
+// PXE menu
+void compute_PXE(struct s_my_menu *menu, struct s_hardware *hardware);
+
+//VESA menu
+int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
+
+int start_menu_mode(struct s_hardware *hardware, char *version_string);
+void setup_menu(char *version);
+void compute_main_menu(struct s_hdt_menu *hdt_menu,
+ struct s_hardware *hardware);
+void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
+void detect_hardware(struct s_hardware *hardware);
+#endif
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-util.c b/contrib/syslinux-4.02/com32/hdt/hdt-util.c
new file mode 100644
index 0000000..3b41a91
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-util.c
@@ -0,0 +1,93 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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 <stdio.h>
+#include <string.h>
+
+/* Computing div(x,y) */
+#define sub(val) (((val%1024)*100)>>10)
+#define sub_dec(val) (((val%1000)*100)/1000)
+
+void sectors_to_size(int sectors, char *buffer)
+{
+ int b = (sectors / 2);
+ int mib = b >> 10;
+ int gib = mib >> 10;
+ int tib = gib >> 10;
+
+ if (tib > 0)
+ sprintf(buffer, "%3d.%02d TiB", tib,sub(gib));
+ else if (gib > 0)
+ sprintf(buffer, "%3d.%02d GiB", gib,sub(mib));
+ else if (mib > 0)
+ sprintf(buffer, "%3d.%02d MiB", mib,sub(b));
+ else
+ sprintf(buffer, "%d B", b);
+}
+
+void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit,
+ int *size, int sectors)
+{
+ *size = sectors / 2; // Converting to bytes
+ strlcpy(unit, "KB", 2);
+ strlcpy(previous_unit, unit, 2);
+ *previous_size = *size;
+ if (*size > 1000) {
+ *size = *size / 1000;
+ strlcpy(unit, "MB", 2);
+ if (*size > 1000) {
+ *previous_size = *size;
+ *size = *size / 1000;
+ strlcpy(previous_unit, unit, 2);
+ strlcpy(unit, "GB", 2);
+ if (*size > 1000) {
+ *previous_size = *size;
+ *size = *size / 1000;
+ strlcpy(previous_unit, unit, 2);
+ strlcpy(unit, "TB", 2);
+ }
+ }
+ }
+}
+
+void sectors_to_size_dec2(int sectors, char *buffer)
+{
+ int b = (sectors / 2);
+ int mib = b / 1000;
+ int gib = mib / 1000;
+ int tib = gib / 1000;
+
+ if (tib > 0)
+ sprintf(buffer, "%3d.%02d TB", tib,sub_dec(gib));
+ else if (gib > 0)
+ sprintf(buffer, "%3d.%02d GB", gib,sub_dec(mib));
+ else if (mib > 0)
+ sprintf(buffer, "%3d.%02d MB", mib,sub_dec(b));
+ else
+ sprintf(buffer, "%d B", b);
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt-util.h b/contrib/syslinux-4.02/com32/hdt/hdt-util.h
new file mode 100644
index 0000000..9e3769e
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt-util.h
@@ -0,0 +1,34 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Pierre-Alexandre Meyer - 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_UTIL_H
+#define DEFINE_HDT_UTIL_H
+void sectors_to_size(int, char *);
+void sectors_to_size_dec(char *, int *, char *, int *, int);
+void sectors_to_size_dec2(int sectors, char *buffer);
+#endif
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt.c b/contrib/syslinux-4.02/com32/hdt/hdt.c
new file mode 100644
index 0000000..1a438a3
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt.c
@@ -0,0 +1,86 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+/*
+ * hdt.c
+ *
+ * An Hardware Detection Tool
+ */
+
+#include <stdio.h>
+#include "hdt.h"
+#include "hdt-cli.h"
+#include "hdt-menu.h"
+#include "hdt-common.h"
+
+int display_line_nb = 0;
+bool disable_more_printf = false;
+
+/* Defines the number of lines in the console
+ * Default is 20 for a std console */
+int max_console_lines = MAX_CLI_LINES;
+
+int main(const int argc, const char *argv[])
+{
+ char version_string[256];
+ const char *arg;
+ struct s_hardware hardware;
+
+ snprintf(version_string, sizeof version_string, "%s %s (%s)",
+ PRODUCT_NAME, VERSION, CODENAME);
+
+ /* Cleaning structures */
+ init_hardware(&hardware);
+
+ /* Detecting Syslinux version */
+ detect_syslinux(&hardware);
+
+ /* Detecting parameters */
+ detect_parameters(argc, argv, &hardware);
+
+ /* Opening the Syslinux console */
+ init_console(&hardware);
+
+ /* Clear the screen and reset position of the cursor */
+ clear_screen();
+ printf("\033[1;1H");
+
+ printf("%s\n", version_string);
+
+ if ((arg = find_argument(argv + 1, "nomenu"))
+ || (find_argument(argv + 1, "auto")))
+ start_cli_mode(&hardware);
+ else {
+ int return_code = start_menu_mode(&hardware, version_string);
+ if (return_code == HDT_RETURN_TO_CLI)
+ start_cli_mode(&hardware);
+ else
+ return return_code;
+ }
+ return 0;
+}
diff --git a/contrib/syslinux-4.02/com32/hdt/hdt.h b/contrib/syslinux-4.02/com32/hdt/hdt.h
new file mode 100644
index 0000000..0c7535d
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/hdt/hdt.h
@@ -0,0 +1,47 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#ifndef DEFINE_HDT_H
+#define DEFINE_HDT_H
+
+#define PRODUCT_NAME "Hardware Detection Tool"
+#define AUTHOR "Erwan Velu"
+#define CORE_DEVELOPER "Pierre-Alexandre Meyer"
+#define CONTACT "hdt@zytor.com"
+#define VERSION "0.3.6.1"
+#define CODENAME "cachaca"
+#define NB_CONTRIBUTORS 3
+#define CONTRIBUTORS {"Sebastien Gonzalve (Patches)", "Gert Hulselmans (Tests)", "Alexander Andino (Design)"}
+#define WEBSITE_URL "http://hdt-project.org"
+
+#define ATTR_PACKED __attribute__((packed))
+
+#define WITH_PCI 1
+#define WITH_MENU_DISPLAY 1
+
+#endif