aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-12-22 09:38:43 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-12-22 09:38:43 -0800
commit2b164fd1078bc9640836f15598ed901cc7a31ae2 (patch)
tree05c661adf5920b2408fbd1961b3bd855c75732d8
parent8492da661cc77e26cd18e4cf307b78e50661ea29 (diff)
parente535becb865292360e808996409c1513df7d2be7 (diff)
downloadsyslinux-devel-2b164fd1078bc9640836f15598ed901cc7a31ae2.tar.gz
syslinux-devel-2b164fd1078bc9640836f15598ed901cc7a31ae2.tar.xz
syslinux-devel-2b164fd1078bc9640836f15598ed901cc7a31ae2.zip
Merge branch 'master' into fsc
Resolved Conflicts: com32/Makefile com32/lib/sys/open.c com32/modules/Makefile dos/Makefile dos/com16.ld dos/syslinux.c version Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--MCONFIG2
-rw-r--r--Makefile2
-rw-r--r--NEWS19
-rw-r--r--com32/Makefile2
-rw-r--r--com32/cmenu/libmenu/menu.h4
-rw-r--r--com32/gfxboot/Makefile44
-rw-r--r--com32/gfxboot/gfxboot.c806
-rw-r--r--com32/gfxboot/realmode_callback.asm190
-rw-r--r--com32/gplinclude/cpuid.h61
-rw-r--r--com32/gplinclude/disk/bootloaders.h3
-rw-r--r--com32/gplinclude/disk/common.h10
-rw-r--r--com32/gplinclude/disk/errno_disk.h64
-rw-r--r--com32/gplinclude/disk/error.h2
-rw-r--r--com32/gplinclude/disk/geom.h287
-rw-r--r--com32/gplinclude/disk/msdos.h2
-rw-r--r--com32/gplinclude/disk/partition.h24
-rw-r--r--com32/gplinclude/disk/read.h6
-rw-r--r--com32/gplinclude/disk/swsusp.h14
-rw-r--r--com32/gplinclude/disk/util.h2
-rw-r--r--com32/gplinclude/disk/write.h12
-rw-r--r--com32/gplinclude/dmi/dmi.h46
-rw-r--r--com32/gplinclude/dmi/dmi_base_board.h38
-rw-r--r--com32/gplinclude/dmi/dmi_cache.h28
-rw-r--r--com32/gplinclude/dmi/dmi_memory.h26
-rw-r--r--com32/gplinclude/dmi/dmi_processor.h2
-rw-r--r--com32/gplinclude/dmi/dmi_system.h10
-rw-r--r--com32/gplinclude/memory.h32
-rw-r--r--com32/gpllib/cpuid.c128
-rw-r--r--com32/gpllib/disk/ata.c38
-rw-r--r--com32/gpllib/disk/bootloaders.c34
-rw-r--r--com32/gpllib/disk/error.c4
-rw-r--r--com32/gpllib/disk/geom.c213
-rw-r--r--com32/gpllib/disk/labels.c772
-rw-r--r--com32/gpllib/disk/mbrs.c146
-rw-r--r--com32/gpllib/disk/msdos.c175
-rw-r--r--com32/gpllib/disk/read.c130
-rw-r--r--com32/gpllib/disk/swsusp.c22
-rw-r--r--com32/gpllib/disk/util.c23
-rw-r--r--com32/gpllib/disk/write.c127
-rw-r--r--com32/gpllib/dmi/dmi.c773
-rw-r--r--com32/gpllib/dmi/dmi_cache.c167
-rw-r--r--com32/gpllib/dmi/dmi_chassis.c8
-rw-r--r--com32/gpllib/dmi/dmi_memory.c133
-rw-r--r--com32/gpllib/dmi/dmi_processor.c55
-rw-r--r--com32/gpllib/memory.c405
-rw-r--r--com32/hdt/Makefile77
-rw-r--r--com32/hdt/art/backgnd.pngbin0 -> 10155 bytes
-rw-r--r--com32/hdt/art/hdt-black.pngbin0 -> 52537 bytes
-rw-r--r--com32/hdt/art/hdt.pngbin0 -> 19732 bytes
-rw-r--r--com32/hdt/floppy/hdt.cfg75
-rw-r--r--com32/hdt/hdt-ata.h50
-rw-r--r--com32/hdt/hdt-cli-cpu.c305
-rw-r--r--com32/hdt/hdt-cli-disk.c284
-rw-r--r--com32/hdt/hdt-cli-dmi.c1106
-rw-r--r--com32/hdt/hdt-cli-hdt.c493
-rw-r--r--com32/hdt/hdt-cli-kernel.c188
-rw-r--r--com32/hdt/hdt-cli-memory.c132
-rw-r--r--com32/hdt/hdt-cli-pci.c465
-rw-r--r--com32/hdt/hdt-cli-pxe.c87
-rw-r--r--com32/hdt/hdt-cli-syslinux.c30
-rw-r--r--com32/hdt/hdt-cli-vesa.c136
-rw-r--r--com32/hdt/hdt-cli-vpd.c63
-rw-r--r--com32/hdt/hdt-cli.c1688
-rw-r--r--com32/hdt/hdt-cli.h84
-rw-r--r--com32/hdt/hdt-common.c1016
-rw-r--r--com32/hdt/hdt-common.h164
-rw-r--r--com32/hdt/hdt-menu-about.c77
-rw-r--r--com32/hdt/hdt-menu-disk.c367
-rw-r--r--com32/hdt/hdt-menu-dmi.c662
-rw-r--r--com32/hdt/hdt-menu-kernel.c101
-rw-r--r--com32/hdt/hdt-menu-memory.c539
-rw-r--r--com32/hdt/hdt-menu-pci.c312
-rw-r--r--com32/hdt/hdt-menu-processor.c439
-rw-r--r--com32/hdt/hdt-menu-pxe.c157
-rw-r--r--com32/hdt/hdt-menu-summary.c288
-rw-r--r--com32/hdt/hdt-menu-syslinux.c80
-rw-r--r--com32/hdt/hdt-menu-vesa.c144
-rw-r--r--com32/hdt/hdt-menu-vpd.c108
-rw-r--r--com32/hdt/hdt-menu.c460
-rw-r--r--com32/hdt/hdt-menu.h60
-rw-r--r--com32/hdt/hdt-util.c82
-rw-r--r--com32/hdt/hdt-util.h1
-rw-r--r--com32/hdt/hdt.c63
-rw-r--r--com32/hdt/hdt.h9
-rw-r--r--com32/include/cpufeature.h56
-rw-r--r--com32/include/dprintf.h22
-rw-r--r--com32/include/sys/gpxe.h16
-rw-r--r--com32/include/syslinux/vesacon.h4
-rw-r--r--com32/lib/Makefile7
-rw-r--r--com32/lib/dprintf.c19
-rw-r--r--com32/lib/jpeg/bgr24.c135
-rw-r--r--com32/lib/jpeg/bgra32.c158
-rw-r--r--com32/lib/jpeg/grey.c87
-rw-r--r--com32/lib/jpeg/jidctflt.c22
-rw-r--r--com32/lib/jpeg/rgb24.c135
-rw-r--r--com32/lib/jpeg/rgba32.c155
-rw-r--r--com32/lib/jpeg/tinyjpeg-internal.h45
-rw-r--r--com32/lib/jpeg/tinyjpeg.c243
-rw-r--r--com32/lib/jpeg/yuv420p.c133
-rw-r--r--com32/lib/pci/scan.c63
-rw-r--r--com32/lib/sys/ansi.c4
-rw-r--r--com32/lib/sys/ansi.h9
-rw-r--r--com32/lib/sys/ansicon_write.c18
-rw-r--r--com32/lib/sys/gpxe.c45
-rw-r--r--com32/lib/sys/open.c3
-rw-r--r--com32/lib/sys/vesa/background.c56
-rw-r--r--com32/lib/sys/vesa/drawtxt.c50
-rw-r--r--com32/lib/sys/vesa/initvesa.c47
-rw-r--r--com32/lib/sys/vesa/video.h26
-rw-r--r--com32/lib/sys/vesacon_write.c32
-rw-r--r--com32/lib/vdprintf.c46
-rw-r--r--com32/mboot/Makefile2
-rw-r--r--com32/mboot/initvesa.c226
-rw-r--r--com32/mboot/map.c32
-rw-r--r--com32/mboot/mboot.c7
-rw-r--r--com32/mboot/mboot.h6
-rw-r--r--com32/mboot/vesa.h100
-rw-r--r--com32/menu/menu.c14
-rw-r--r--com32/menu/menu.h10
-rw-r--r--com32/menu/menumain.c14
-rw-r--r--com32/menu/readconfig.c9
-rw-r--r--com32/menu/vesamenu.c14
-rw-r--r--com32/modules/Makefile3
-rw-r--r--com32/modules/dmitest.c2
-rw-r--r--com32/modules/gpxecmd.c53
-rw-r--r--com32/modules/ifcpu.c165
-rw-r--r--com32/modules/ifcpu64.c2
-rw-r--r--com32/modules/pcitest.c9
-rw-r--r--com32/modules/sanboot.c53
-rw-r--r--doc/comboot.txt11
-rw-r--r--doc/memdisk.txt41
-rw-r--r--doc/menu.txt16
-rw-r--r--dos/Makefile4
-rw-r--r--dos/int2526.S76
-rw-r--r--dos/mystuff.h10
-rw-r--r--dos/syslinux.c216
-rw-r--r--dosutil/Makefile19
-rw-r--r--dosutil/README10
-rw-r--r--dosutil/eltorito.asm1096
-rw-r--r--dosutil/eltorito.txt50
-rw-r--r--memdisk/Makefile10
-rw-r--r--memdisk/acpi.h54
-rw-r--r--memdisk/bda.h56
-rw-r--r--memdisk/dskprobe.c114
-rw-r--r--memdisk/dskprobe.h21
-rw-r--r--memdisk/eltorito.c58
-rw-r--r--memdisk/eltorito.h83
-rw-r--r--memdisk/memdisk.inc127
-rw-r--r--memdisk/memdisk_chs.asm3
-rw-r--r--memdisk/memdisk_chs_512.asm5
-rw-r--r--memdisk/memdisk_edd.asm3
-rw-r--r--memdisk/memdisk_edd_512.asm5
-rw-r--r--memdisk/memdisk_iso_2048.asm5
-rw-r--r--memdisk/memdisk_iso_512.asm5
-rw-r--r--memdisk/setup.c317
-rw-r--r--utils/isohybrid.in4
156 files changed, 12859 insertions, 7400 deletions
diff --git a/MCONFIG b/MCONFIG
index 0d70a33e..b84e6c56 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -57,6 +57,8 @@ PNGTOPNM = pngtopnm
MCOPY = mcopy
MFORMAT = mformat
MKISOFS = mkisofs
+SED = sed
+WGET = wget
com32 = $(topdir)/com32
diff --git a/Makefile b/Makefile
index de0d2fda..37dc3e9b 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ include $(topdir)/MCONFIG
# List of module objects that should be installed for all derivatives
MODULES = memdisk/memdisk memdump/memdump.com modules/*.com \
com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
- com32/hdt/*.c32 com32/rosh/*.c32
+ com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32
# syslinux.exe is BTARGET so as to not require everyone to have the
# mingw suite installed
diff --git a/NEWS b/NEWS
index c934a3e3..3f028ad7 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,25 @@ Starting with 1.47, changes marked with SYSLINUX, PXELINUX, ISOLINUX
or EXTLINUX apply to that specific program only; other changes apply
to all derivatives.
+Changes in 3.84:
+ * SYSLINUX: make the DOS installer work for MS-DOS 7.x/8.x
+ (Win9x/ME) again.
+ * HDT: updated to version 0.3.6 (numerous changes.)
+ * mboot.c32: now supports video mode setting if requested by
+ the image.
+ * MEMDISK: Fix floppy images of PC-DOS.
+ * MEMDISK: Add support for emulation of CD-ROM images; patch
+ by Shao Miller.
+ * MEMDISK: Comply with the Win9x "safe hook" standard,
+ allowing a protected-mode driver.
+ * MEMDISK: New "mBFT" ACPI table, by analogy with the iSCSI
+ iBFT table. This allows detection from a protected-mode
+ operating system without EDD support.
+ * 32-bit version of the gfxboot loader (gfxboot.c32), so far
+ experimental. This will replace gfxboot.com in the future.
+ * vesamenu.c32: new MENU RESOLUTION directive to set a screen
+ resolution other than 640x480.
+
Changes in 3.83:
* PXELINUX: clear memory before handing over to a chainloaded
NBP. This may help avoid a bug in Windows RIS.
diff --git a/com32/Makefile b/com32/Makefile
index e9608a58..89d0694e 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -1,3 +1,3 @@
-SUBDIRS = tools lib gpllib libutil modules mboot menu samples rosh cmenu hdt
+SUBDIRS = tools lib gpllib libutil modules mboot menu samples rosh cmenu hdt gfxboot
all tidy dist clean spotless install:
set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
diff --git a/com32/cmenu/libmenu/menu.h b/com32/cmenu/libmenu/menu.h
index 44acb122..a1356020 100644
--- a/com32/cmenu/libmenu/menu.h
+++ b/com32/cmenu/libmenu/menu.h
@@ -76,8 +76,8 @@
#define MOREBELOW 'v' // more items available below
// Attributes of the menu system
-#define MAXMENUS 150 // Maximum number of menu's allowed
-#define MAXMENUSIZE 60 // Default value for max num of entries in each menu
+#define MAXMENUS 250 // Maximum number of menu's allowed
+#define MAXMENUSIZE 100 // Default value for max num of entries in each menu
#define MAXMENUHEIGHT 20 // Maximum number of entries displayed
#define MENUBOXTYPE BOX_SINSIN // Default box type Look at tui.h for other values
diff --git a/com32/gfxboot/Makefile b/com32/gfxboot/Makefile
new file mode 100644
index 00000000..2affcdea
--- /dev/null
+++ b/com32/gfxboot/Makefile
@@ -0,0 +1,44 @@
+## -----------------------------------------------------------------------
+##
+## Copyright 2001-2009 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., 53 Temple Place Ste 330,
+## Boston MA 02111-1307, USA; either version 2 of the License, or
+## (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+topdir = ../..
+include ../MCONFIG
+
+MODULES = gfxboot.c32
+
+all: $(MODULES)
+
+gfxboot.elf : gfxboot.o realmode_callback.o $(LIBS) $(C_LIBS)
+ $(LD) $(LDFLAGS) -o $@ $^
+
+realmode_callback.o: realmode_callback.asm
+ nasm -f bin -O99 -o $*.tmp -l $*.lst $<
+ objcopy -B i386 -I binary -O elf32-i386 \
+ --redefine-sym _binary_$*_tmp_start=$*_start \
+ --redefine-sym _binary_$*_tmp_end=$*_end \
+ --strip-symbol _binary_$*_tmp_size \
+ $*.tmp $@
+
+tidy dist:
+ rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
+
+clean: tidy
+ rm -f *.lnx
+
+spotless: clean
+ rm -f *.lss *.c32 *.com
+ rm -f *~ \#*
+
+install:
+
+-include .*.d
diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
new file mode 100644
index 00000000..e1b865a1
--- /dev/null
+++ b/com32/gfxboot/gfxboot.c
@@ -0,0 +1,806 @@
+/*
+ *
+ * gfxboot.c
+ *
+ * A com32 module to load gfxboot graphics.
+ *
+ * Copyright (c) 2009 Steffen Winterfeldt.
+ *
+ * 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., 53 Temple Place Ste 330, Boston MA
+ * 02111-1307, USA; either version 2 of the License, or (at your option) any
+ * later version; incorporated herein by reference.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <syslinux/loadfile.h>
+#include <syslinux/config.h>
+#include <syslinux/linux.h>
+#include <syslinux/boot.h>
+#include <console.h>
+#include <com32.h>
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+#define MAX_CONFIG_LINE_LEN 2048
+#define MAX_CMDLINE_LEN 2048
+
+// buffer for realmode callback
+// must be at least block size; can in theory be larger than 4k, but there's
+// not enough space left
+#define REALMODE_BUF_SIZE 4096
+
+// gfxboot working memory in MB
+#define GFX_MEMORY_SIZE 7
+
+// read chunk size for progress bar
+#define CHUNK_SIZE (64 << 10)
+
+// callback function numbers
+#define GFX_CB_INIT 0
+#define GFX_CB_DONE 1
+#define GFX_CB_INPUT 2
+#define GFX_CB_MENU_INIT 3
+#define GFX_CB_INFOBOX_INIT 4
+#define GFX_CB_INFOBOX_DONE 5
+#define GFX_CB_PROGRESS_INIT 6
+#define GFX_CB_PROGRESS_DONE 7
+#define GFX_CB_PROGRESS_UPDATE 8
+#define GFX_CB_PROGRESS_LIMIT 9 // unused
+#define GFX_CB_PASSWORD_INIT 10
+#define GFX_CB_PASSWORD_DONE 11
+
+// real mode code chunk, will be placed into bounce buffer
+extern void realmode_callback_start, realmode_callback_end;
+
+// gets in the way
+#undef linux
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// gfxboot config data (64 bytes)
+typedef struct __attribute__ ((packed)) {
+ uint8_t bootloader; // 0: boot loader type (0: lilo, 1: syslinux, 2: grub)
+ uint8_t sector_shift; // 1: sector shift
+ uint8_t media_type; // 2: media type (0: disk, 1: floppy, 2: cdrom)
+ uint8_t failsafe; // 3: turn on failsafe mode (bitmask)
+ // 0: SHIFT pressed
+ // 1: skip gfxboot
+ // 2: skip monitor detection
+ uint8_t sysconfig_size; // 4: size of sysconfig data
+ uint8_t boot_drive; // 5: BIOS boot drive
+ uint16_t callback; // 6: offset to callback handler
+ uint16_t bootloader_seg; // 8: code/data segment used by bootloader; must follow gfx_callback
+ uint16_t serial_port; // 10: syslinux initialized serial port from 'serial' option
+ uint32_t user_info_0; // 12: data for info box
+ uint32_t user_info_1; // 16: data for info box
+ uint32_t bios_mem_size; // 20: BIOS memory size (in bytes)
+ uint16_t xmem_0; // 24: extended mem area 0 (start:size in MB; 12:4 bits) - obsolete
+ uint16_t xmem_1; // 26: extended mem area 1 - obsolete
+ uint16_t xmem_2; // 28: extended mem area 2 - obsolete
+ uint16_t xmem_3; // 30: extended mem area 3 - obsolete
+ uint32_t file; // 32: start of gfx file
+ uint32_t archive_start; // 36: start of cpio archive
+ uint32_t archive_end; // 40: end of cpio archive
+ uint32_t mem0_start; // 44: low free memory start
+ uint32_t mem0_end; // 48: low free memory end
+ uint32_t xmem_start; // 52: extended mem start
+ uint32_t xmem_end; // 56: extended mem end
+ uint16_t features; // 60: feature flags returned by GFX_CB_INIT
+ // 0: GFX_CB_MENU_INIT accepts 32 bit addresses
+ // 1: knows about xmem_start, xmem_end
+ uint16_t reserved_1; // 62:
+} gfx_config_t;
+
+
+// gfxboot menu description (18 bytes)
+typedef struct __attribute__ ((packed)) {
+ uint16_t entries;
+ char *default_entry;
+ char *label_list;
+ uint16_t label_size;
+ char *arg_list;
+ uint16_t arg_size;
+} gfx_menu_t;
+
+
+// menu description
+typedef struct menu_s {
+ struct menu_s *next;
+ char *label;
+ char *kernel;
+ char *linux;
+ char *localboot;
+ char *initrd;
+ char *append;
+ char *ipappend;
+} menu_t;
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+gfx_config_t gfx_config;
+gfx_menu_t gfx_menu;
+
+menu_t *menu;
+menu_t *menu_default;
+
+struct {
+ uint32_t jmp_table[12];
+ uint16_t code_seg;
+ char fname_buf[64];
+} gfx;
+
+void *lowmem_buf;
+unsigned lowmem_buf_size;
+
+int timeout;
+
+char cmdline[MAX_CMDLINE_LEN];
+
+void *save_buf;
+unsigned save_buf_size;
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void show_message(char *file);
+char *get_config_file_name(void);
+char *skip_spaces(char *s);
+char *skip_nonspaces(char *s);
+void chop_line(char *s);
+int read_config_file(void);
+unsigned magic_ok(unsigned char *buf, unsigned *code_size);
+unsigned find_file(unsigned char *buf, unsigned len, unsigned *gfx_file_start, unsigned *file_len, unsigned *code_size);
+int gfx_init(char *file);
+int gfx_menu_init(void);
+void gfx_done(void);
+int gfx_input(void);
+ssize_t save_read(int fd, void *buf, size_t size);
+void *load_one(char *file, ssize_t *file_size);
+void boot(void);
+void boot_entry(menu_t *menu_ptr, char *arg);
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+int main(int argc, char **argv)
+{
+ int menu_index;
+ enum syslinux_filesystem syslinux_id;
+ com32sys_t r;
+
+ openconsole(&dev_stdcon_r, &dev_stdcon_w);
+
+ syslinux_id = syslinux_version()->filesystem;
+
+ lowmem_buf = __com32.cs_bounce;
+ lowmem_buf_size = __com32.cs_bounce_size;
+
+ r.eax.l = 0x0a; // Get Derivative-Specific Information
+ r.ecx.l = 9;
+ __intcall(0x22, &r, &r);
+ gfx_config.sector_shift = (uint8_t) r.ecx.l;
+ gfx_config.boot_drive = (uint8_t) r.edx.l;
+
+ if(syslinux_id == SYSLINUX_FS_PXELINUX) {
+ gfx_config.sector_shift = 11;
+ gfx_config.boot_drive = 0;
+ }
+
+ gfx_config.bootloader = 1;
+ gfx_config.sysconfig_size = sizeof gfx_config;
+ gfx_config.bootloader_seg = 0; // apparently not needed
+
+ save_buf_size = lowmem_buf_size;
+ save_buf = malloc(save_buf_size);
+
+ if(argc < 2) {
+ printf("Usage: gfxboot.c32 bootlogo_file [message_file]\n");
+ if(argc > 2) show_message(argv[2]);
+
+ return 0;
+ }
+
+ if(read_config_file()) {
+ printf("Error reading config file\n");
+ if(argc > 2) show_message(argv[2]);
+
+ return 0;
+ }
+
+ if(gfx_init(argv[1])) {
+ printf("Error setting up gfxboot\n");
+ if(argc > 2) show_message(argv[2]);
+
+ return 0;
+ }
+
+ gfx_menu_init();
+
+ for(;;) {
+ menu_index = gfx_input();
+
+ // abort gfx, return to text mode prompt
+ if(menu_index == -1) {
+ gfx_done();
+ break;
+ }
+
+ // does not return if it succeeds
+ boot();
+ }
+
+ if(argc > 2) show_message(argv[2]);
+
+ return 0;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void show_message(char *file)
+{
+ int c;
+ FILE *f;
+
+ if(!(f = fopen(file, "r"))) return;
+
+ while((c = getc(f)) != EOF) {
+ if(c < ' ' && c != '\n' && c != '\t') continue;
+ printf("%c", c);
+ }
+
+ fclose(f);
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+char *skip_spaces(char *s)
+{
+ while(*s && (*s == ' ' || *s == '\t')) s++;
+
+ return s;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+char *skip_nonspaces(char *s)
+{
+ while(*s && *s != ' ' && *s != '\t') s++;
+
+ return s;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void chop_line(char *s)
+{
+ int i = strlen(s);
+
+ if(!i) return;
+
+ while(--i >= 0) {
+ if(s[i] == ' ' || s[i] == '\t' || s[i] == '\n') {
+ s[i] = 0;
+ }
+ else {
+ break;
+ }
+ }
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Read and parse syslinux config file.
+//
+// return:
+// 0: ok, 1: error
+//
+int read_config_file(void)
+{
+ FILE *f;
+ char *s, *t, buf[MAX_CONFIG_LINE_LEN];
+ unsigned u, menu_idx = 0, label_size = 0, append_size = 0;
+ menu_t *menu_ptr = NULL, **menu_next = &menu;
+
+ menu_default = calloc(1, sizeof *menu_default);
+
+ if(!(f = fopen(syslinux_config_file(), "r"))) return 1;
+
+ while((s = fgets(buf, sizeof buf, f))) {
+ chop_line(s);
+ s = skip_spaces(s);
+ if(!*s || *s == '#') continue;
+ t = skip_nonspaces(s);
+ if(*t) *t++ = 0;
+ t = skip_spaces(t);
+
+ if(!strcmp(s, "timeout")) {
+ timeout = atoi(t);
+ continue;
+ }
+
+ if(!strcmp(s, "default")) {
+ menu_default->label = strdup(t);
+ u = strlen(t);
+ if(u > label_size) label_size = u;
+ continue;
+ }
+
+ if(!strcmp(s, "label")) {
+ menu_ptr = *menu_next = calloc(1, sizeof **menu_next);
+ menu_next = &menu_ptr->next;
+ menu_idx++;
+ menu_ptr->label = strdup(t);
+ u = strlen(t);
+ if(u > label_size) label_size = u;
+ continue;
+ }
+
+ if(!strcmp(s, "kernel") && menu_ptr) {
+ menu_ptr->kernel = strdup(t);
+ continue;
+ }
+
+ if(!strcmp(s, "linux") && menu_ptr) {
+ menu_ptr->linux = strdup(t);
+ continue;
+ }
+
+ if(!strcmp(s, "localboot") && menu_ptr) {
+ menu_ptr->localboot = strdup(t);
+ continue;
+ }
+
+ if(!strcmp(s, "initrd") && menu_ptr) {
+ menu_ptr->initrd = strdup(t);
+ continue;
+ }
+
+ if(!strcmp(s, "append")) {
+ (menu_ptr ?: menu_default)->append = strdup(t);
+ u = strlen(t);
+ if(u > append_size) append_size = u;
+ continue;
+ }
+
+ if(!strcmp(s, "ipappend")) {
+ (menu_ptr ?: menu_default)->ipappend = strdup(t);
+ continue;
+ }
+ }
+
+ fclose(f);
+
+ // final '\0'
+ label_size++;
+ append_size++;
+
+ gfx_menu.entries = menu_idx;
+ gfx_menu.label_size = label_size;
+ gfx_menu.arg_size = append_size;
+
+ gfx_menu.default_entry = menu_default->label;
+ if(!gfx_menu.default_entry && menu) {
+ gfx_menu.default_entry = menu->label;
+ }
+
+ gfx_menu.label_list = calloc(menu_idx, label_size);
+ gfx_menu.arg_list = calloc(menu_idx, append_size);
+
+ for(u = 0, menu_ptr = menu; menu_ptr; menu_ptr = menu_ptr->next, u++) {
+ if(!menu_ptr->append) menu_ptr->append = menu_default->append;
+ if(!menu_ptr->ipappend) menu_ptr->ipappend = menu_default->ipappend;
+
+ if(menu_ptr->label) strcpy(gfx_menu.label_list + u * label_size, menu_ptr->label);
+ if(menu_ptr->append) strcpy(gfx_menu.arg_list + u * append_size, menu_ptr->append);
+ }
+
+ return 0;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Check header and return code start offset.
+//
+unsigned magic_ok(unsigned char *buf, unsigned *code_size)
+{
+ if(
+ *(unsigned *) buf == 0x0b2d97f00 && // magic id
+ (buf[4] == 8) // version 8
+ ) {
+ *code_size = *(unsigned *) (buf + 12);
+ return *(unsigned *) (buf + 8);
+ }
+
+ return 0;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Search cpio archive for gfx file.
+//
+unsigned find_file(unsigned char *buf, unsigned len, unsigned *gfx_file_start, unsigned *file_len, unsigned *code_size)
+{
+ unsigned i, fname_len, code_start = 0;
+
+ *gfx_file_start = 0;
+ *code_size = 0;
+
+ for(i = 0; i < len;) {
+ if((len - i) >= 0x1a && (buf[i] + (buf[i + 1] << 8)) == 0x71c7) {
+ fname_len = *(unsigned short *) (buf + i + 20);
+ *file_len = *(unsigned short *) (buf + i + 24) + (*(unsigned short *) (buf + i + 22) << 16);
+ i += 26 + fname_len;
+ i = ((i + 1) & ~1);
+ if((code_start = magic_ok(buf + i, code_size))) {
+ *gfx_file_start = i;
+ return code_start;
+ }
+ i += *file_len;
+ i = ((i + 1) & ~1);
+ }
+ else {
+ break;
+ }
+ }
+
+ return code_start;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Initialize gfxboot code.
+//
+// return:
+// 0: ok, 1: error
+//
+int gfx_init(char *file)
+{
+ size_t archive_size = 0;
+ void *archive;
+ unsigned code_start, code_size, file_start, file_len, u;
+ com32sys_t r;
+ void *lowmem = lowmem_buf;
+ unsigned lowmem_size = lowmem_buf_size;
+
+ printf("Loading %s...\n", file);
+ if(loadfile(file, &archive, &archive_size)) return 1;
+
+ if(!archive_size) return 1;
+
+ // printf("%s: %d\n", file, archive_size);
+
+ gfx_config.archive_start = (uint32_t) archive;
+ gfx_config.archive_end = gfx_config.archive_start + archive_size;
+
+ // locate file inside cpio archive
+ if(!(code_start = find_file(archive, archive_size, &file_start, &file_len, &code_size))) {
+ printf("%s: invalid file format\n", file);
+ return 1;
+ }
+
+#if 0
+ printf(
+ "code_start = 0x%x, code_size = 0x%x\n"
+ "archive_start = 0x%x, archive size = 0x%x\n"
+ "file_start = 0x%x, file_len = 0x%x\n",
+ code_start, code_size,
+ gfx_config.archive_start, archive_size,
+ file_start, file_len
+ );
+#endif
+
+ gfx_config.file = gfx_config.archive_start + file_start;
+
+ u = &realmode_callback_end - &realmode_callback_start;
+ u = (u + REALMODE_BUF_SIZE + 0xf) & ~0xf;
+
+ if(u + code_size > lowmem_size) {
+ printf("bounce buffer too small: size %u, needed %u\n", lowmem_size, u + code_size);
+ return 1;
+ }
+
+ memcpy(lowmem + REALMODE_BUF_SIZE, &realmode_callback_start, &realmode_callback_end - &realmode_callback_start);
+
+ // fill in buffer size and location
+ *(uint16_t *) (lowmem + REALMODE_BUF_SIZE) = REALMODE_BUF_SIZE;
+ *(uint16_t *) (lowmem + REALMODE_BUF_SIZE + 2) = (uint32_t) lowmem >> 4;
+
+ gfx_config.bootloader_seg = ((uint32_t) lowmem + REALMODE_BUF_SIZE) >> 4;
+ gfx_config.callback = 4; // start address
+
+ lowmem += u;
+ lowmem_size -= u;
+
+ memcpy(lowmem, archive + file_start + code_start, code_size);
+
+ gfx_config.mem0_start = (uint32_t) lowmem + code_size;
+ gfx_config.mem0_end = (uint32_t) lowmem + lowmem_size;
+ // align a bit
+ gfx_config.mem0_start = (gfx_config.mem0_start + 0xf) & ~0xf;
+
+ gfx_config.xmem_start = (uint32_t) malloc(GFX_MEMORY_SIZE << 20);
+ if(gfx_config.xmem_start) {
+ gfx_config.xmem_end = gfx_config.xmem_start + (GFX_MEMORY_SIZE << 20);
+ }
+
+ // fake; not used anyway
+ gfx_config.bios_mem_size = 256 << 20;
+
+ gfx.code_seg = (uint32_t) lowmem >> 4;
+
+ for(u = 0; u < sizeof gfx.jmp_table / sizeof *gfx.jmp_table; u++) {
+ gfx.jmp_table[u] = (gfx.code_seg << 16) + *(uint16_t *) (lowmem + 2 * u);
+ }
+
+#if 0
+ for(u = 0; u < sizeof gfx.jmp_table / sizeof *gfx.jmp_table; u++) {
+ printf("%d: 0x%08x\n", u, gfx.jmp_table[u]);
+ }
+#endif
+
+ // we are ready to start
+
+ r.esi.l = (uint32_t) &gfx_config;
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_INIT], &r, &r);
+
+ if((r.eflags.l & EFLAGS_CF)) {
+ printf("graphics initialization failed\n");
+
+ return 1;
+ }
+
+ if((gfx_config.features & 3) != 3) {
+ gfx_done();
+
+ printf("%s: boot graphics code too old, please use newer version\n", file);
+
+ return 1;
+ }
+
+
+ return 0;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+int gfx_menu_init()
+{
+ com32sys_t r;
+
+ r.esi.l = (uint32_t) &gfx_menu;
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_MENU_INIT], &r, &r);
+
+ return 0;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void gfx_done()
+{
+ com32sys_t r;
+
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_DONE], &r, &r);
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Run gfxboot main loop.
+//
+// return:
+// boot menu index (-1: go to text mode prompt)
+//
+int gfx_input()
+{
+ com32sys_t r;
+
+ r.edi.l = (uint32_t) cmdline;
+ r.ecx.l = sizeof cmdline;
+ r.eax.l = timeout * 182 / 100;
+ timeout = 0; // use timeout only first time
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_INPUT], &r, &r);
+ if((r.eflags.l & EFLAGS_CF)) r.eax.l = 1;
+
+ if(r.eax.l == 1) return -1;
+
+ return r.ebx.l;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Like read(2) but preserve bounce buffer.
+//
+ssize_t save_read(int fd, void *buf, size_t size)
+{
+ ssize_t i;
+
+ memcpy(save_buf, lowmem_buf, save_buf_size);
+ i = read(fd, buf, size);
+ memcpy(lowmem_buf, save_buf, save_buf_size);
+
+ return i;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Read file and update progress bar.
+//
+void *load_one(char *file, ssize_t *file_size)
+{
+ int fd;
+ void *buf = NULL;
+ struct stat sbuf;
+ ssize_t size = 0, cur, i;
+ com32sys_t r;
+
+ *file_size = 0;
+
+ if((fd = open(file, O_RDONLY)) == -1) {
+ printf("%s: file not found\n", file);
+ return buf;
+ }
+
+ if(!fstat(fd, &sbuf) && S_ISREG(sbuf.st_mode)) size = sbuf.st_size;
+
+ i = 0;
+
+ if(size) {
+ buf = malloc(size);
+ for(i = 1, cur = 0 ; cur < size && i > 0; cur += i) {
+ i = save_read(fd, buf + cur, CHUNK_SIZE);
+ r.eax.l = i >> gfx_config.sector_shift;
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_UPDATE], &r, &r);
+ }
+ }
+ else {
+ do {
+ buf = realloc(buf, size + CHUNK_SIZE);
+ i = save_read(fd, buf + size, CHUNK_SIZE);
+ size += i;
+ r.eax.l = i >> gfx_config.sector_shift;
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_UPDATE], &r, &r);
+ } while(i > 0);
+ }
+
+ close(fd);
+
+ if(i == -1) {
+ free(buf);
+ buf = NULL;
+ size = 0;
+ }
+
+ *file_size = size;
+
+ return buf;
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Locate menu entry and boot.
+//
+void boot()
+{
+ char *label, *arg, *s;
+ menu_t *menu_ptr;
+
+ label = skip_spaces(cmdline);
+ arg = skip_spaces(s = skip_nonspaces(label));
+ *s = 0;
+
+ for(menu_ptr = menu; menu_ptr; menu_ptr = menu_ptr->next) {
+ if(menu_ptr->label && !strcmp(menu_ptr->label, label)) break;
+ }
+
+ boot_entry(menu_ptr, arg);
+}
+
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Load & run kernel.
+//
+// Returns only on error.
+//
+void boot_entry(menu_t *menu_ptr, char *arg)
+{
+ void *kernel, *initrd_buf;
+ ssize_t kernel_size = 0, initrd_size = 0;
+ struct initramfs *initrd = NULL;
+ char *file, *cmd_buf;
+ int fd;
+ struct stat sbuf;
+ com32sys_t r;
+ char *s, *s0, *t, *initrd_arg;
+
+ if(!menu_ptr) return;
+
+ if(menu_ptr->localboot) {
+ gfx_done();
+ syslinux_local_boot(atoi(arg));
+
+ return;
+ }
+
+ file = menu_ptr->kernel;
+ if(!file) file = menu_ptr->linux;
+ if(!file) return;
+
+ // first, load kernel
+
+ r.eax.l = 0; // kernel size in sectors
+
+ if((fd = open(file, O_RDONLY)) >= 0) {
+ if(!fstat(fd, &sbuf) && S_ISREG(sbuf.st_mode)) r.eax.l = sbuf.st_size >> gfx_config.sector_shift;
+ close(fd);
+ }
+
+ r.esi.l = (uint32_t) file;
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_INIT], &r, &r);
+
+ kernel = load_one(file, &kernel_size);
+
+ if(!kernel) {
+ gfx_done();
+ printf("%s: read error\n", file);
+ return;
+ }
+
+ if(kernel_size < 1024 || *(uint32_t *) (kernel + 0x202) != 0x53726448) {
+ // not a linux kernel
+ gfx_done();
+ asprintf(&cmd_buf, "%s %s", menu_ptr->label, arg);
+ syslinux_run_command(cmd_buf);
+ return;
+ }
+
+ // printf("kernel = %p, size = %d\n", kernel, kernel_size);
+
+ // parse cmdline for "initrd" option
+
+ initrd_arg = menu_ptr->initrd;
+
+ s = s0 = strdup(arg);
+
+ while(*s && strncmp(s, "initrd=", sizeof "initrd=" - 1)) {
+ s = skip_spaces(skip_nonspaces(s));
+ }
+
+ if(*s) {
+ s += sizeof "initrd=" - 1;
+ *skip_nonspaces(s) = 0;
+ initrd_arg = s;
+ }
+
+ if(initrd_arg) {
+ initrd = initramfs_init();
+
+ while((t = strsep(&s, ","))) {
+ initrd_buf = load_one(t, &initrd_size);
+
+ if(!initrd_buf) {
+ printf("%s: read error\n", t);
+ free(s0);
+ return;
+ }
+
+ initramfs_add_data(initrd, initrd_buf, initrd_size, initrd_size, 4);
+
+ // printf("initrd = %p, size = %d\n", initrd_buf, initrd_size);
+ }
+ }
+
+ free(s0);
+
+ __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_DONE], &r, &r);
+
+ syslinux_boot_linux(kernel, kernel_size, initrd, arg);
+}
+
+
diff --git a/com32/gfxboot/realmode_callback.asm b/com32/gfxboot/realmode_callback.asm
new file mode 100644
index 00000000..fb5461d9
--- /dev/null
+++ b/com32/gfxboot/realmode_callback.asm
@@ -0,0 +1,190 @@
+ bits 16
+
+ section .text
+
+ ; must be filled in
+f_buf_size dw 0
+f_buf_seg dw 0
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+gfx_cb:
+ push cs
+ pop ds
+
+ cmp al,cb_len
+ jae gfx_cb_80
+
+ movzx bx,al
+ add bx,bx
+ call word [bx+cb_table]
+ jmp gfx_cb_90
+
+gfx_cb_80:
+ mov al,0ffh
+gfx_cb_90:
+ retf
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Return status info.
+;
+; return:
+; edx filename buffer (64 bytes)
+;
+cb_status:
+ mov edx,cs
+ shl edx,4
+ add edx,f_name
+ xor al,al
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Open file.
+;
+; return:
+; al 0: ok, 1: file not found
+; ecx file length (al = 0)
+;
+cb_fopen:
+ mov si,f_name
+ push ds
+ pop es
+ mov ax,6
+ int 22h
+ xchg edx,eax
+ mov al,1
+ jc cb_fopen_90
+ cmp cx,[f_buf_size]
+ ja cb_fopen_90
+ or cx,cx
+ jz cb_fopen_90
+ mov [f_block_size],cx
+ or edx,edx
+ jz cb_fopen_90
+ mov [f_handle],si
+ mov [f_size],edx
+ mov ecx,edx
+ mov ax,[f_buf_size]
+ cwd
+ div word [f_block_size]
+ mov [f_blocks],ax
+
+ xor al,al
+cb_fopen_90:
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Read next chunk.
+;
+; return:
+; edx buffer address (linear)
+; ecx data length (< 64k)
+;
+cb_fread:
+ xor ecx,ecx
+ mov si,[f_handle]
+ or si,si
+ jz cb_fread_80
+ mov cx,[f_blocks]
+ mov es,[f_buf_seg]
+ xor bx,bx
+ mov ax,7
+ int 22h
+ mov [f_handle],si
+ mov al,1
+ jc cb_fread_90
+cb_fread_80:
+ xor al,al
+cb_fread_90:
+ movzx edx,word [f_buf_seg]
+ shl edx,4
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Return current working directory.
+;
+; return:
+; edx filename
+;
+cb_getcwd:
+ mov ax,15h
+ int 22h
+ mov edx,es
+ shl edx,4
+ movzx ebx,bx
+ add edx,ebx
+ xor al,al
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Set current working directory.
+;
+cb_chdir:
+ mov bx,f_name
+ push ds
+ pop es
+ mov ax,25h
+ int 22h
+ xor al,al
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; read sector
+;
+; edx sector
+;
+; return:
+; edx buffer (linear address)
+;
+; Note: does not return on error!
+;
+cb_readsector:
+ xor edi,edi
+ xor esi,esi
+ mov cx,1
+ mov es,[f_buf_seg]
+ xor bx,bx
+ mov ax,19h
+ int 22h
+ movzx edx,word [f_buf_seg]
+ shl edx,4
+ xor al,al
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+; Re-read fs structures.
+;
+cb_mount:
+ mov ax,26h
+ int 22h
+ setc al
+ ret
+
+
+; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+;
+ align 2, db 0
+
+cb_table dw cb_status
+ dw cb_fopen
+ dw cb_fread
+ dw cb_getcwd
+ dw cb_chdir
+ dw cb_readsector
+ dw cb_mount
+cb_len equ ($-cb_table)/2
+
+f_handle dw 0
+f_block_size dw 0
+f_blocks dw 0
+f_size dd 0
+f_name times 64 db 0
+f_name_len equ $ - f_name
+
diff --git a/com32/gplinclude/cpuid.h b/com32/gplinclude/cpuid.h
index f85e6ab3..bc9df171 100644
--- a/com32/gplinclude/cpuid.h
+++ b/com32/gplinclude/cpuid.h
@@ -49,6 +49,7 @@ typedef struct {
bool clflsh; /* Supports the CLFLUSH instruction */
bool dts; /* Debug Trace Store */
bool acpi; /* ACPI via MSR */
+ bool pbe; /* Pending Break Enable */
bool mmx; /* Multimedia Extensions */
bool fxsr; /* FXSAVE and FXRSTOR instructions (fast save and restore */
/* of FPU context), and CR4.OSFXSR available */
@@ -61,12 +62,62 @@ typedef struct {
bool mp; /* MP Capable. */
bool nx; /* Execute Disable */
bool mmxext; /* AMD MMX extensions */
+ bool fxsr_opt; /* FXSAVE/FXRSTOR optimizations */
+ bool gbpages; /* "pdpe1gb" GB pages */
+ bool rdtscp; /* RDTSCP */
bool lm; /* Long Mode (x86-64) */
bool nowext; /* AMD 3DNow! extensions */
bool now; /* 3DNow! */
bool smp; /* A smp configuration has been found */
+ bool pni; /* Streaming SIMD Extensions-3 */
+ bool pclmulqd; /* PCLMULQDQ instruction */
+ bool dtes64; /* 64-bit Debug Store */
bool vmx; /* Hardware virtualization */
+ bool smx; /* Safer Mode */
+ bool est; /* Enhanced SpeedStep */
+ bool tm2; /* Thermal Monitor 2 */
+ bool sse3; /* Supplemental SSE-3 */
+ bool cid; /* Context ID */
+ bool fma; /* Fused multiply-add */
+ bool cx16; /* CMPXCHG16B */
+ bool xtpr; /* Send Task Priority Messages */
+ bool pdcm; /* Performance Capabilities */
+ bool dca; /* Direct Cache Access */
+ bool xmm4_1; /* "sse4_1" SSE-4.1 */
+ bool xmm4_2; /* "sse4_2" SSE-4.2 */
+ bool x2apic; /* x2APIC */
+ bool movbe; /* MOVBE instruction */
+ bool popcnt; /* POPCNT instruction */
+ bool aes; /* AES Instruction */
+ bool xsave; /* XSAVE/XRSTOR/XSETBV/XGETBV */
+ bool osxsave; /* XSAVE enabled in the OS */
+ bool avx; /* Advanced Vector Extensions */
+ bool hypervisor; /* Running on a hypervisor */
+ bool ace2; /* Advanced Cryptography Engine v2 */
+ bool ace2_en; /* ACE v2 enabled */
+ bool phe; /* PadLock Hash Engine */
+ bool phe_en; /* PadLock Hash Engine Enabled */
+ bool pmm; /* PadLock Montgomery Multiplier */
+ bool pmm_en; /* PadLock Montgomery Multiplier enabled */
bool svm; /* Secure virtual machine */
+ bool extapic; /* Extended APIC space */
+ bool cr8_legacy; /* CR8 in 32-bit mode */
+ bool abm; /* Advanced bit manipulation */
+ bool sse4a; /* SSE4-A */
+ bool misalignsse; /* Misaligned SSE mode */
+ bool nowprefetch; /* 3DNow prefetch instructions */
+ bool osvw; /* OS Visible Workaround */
+ bool ibs; /* Instruction Based Sampling */
+ bool sse5; /* SSE5 */
+ bool skinit; /* SKINIT/STGI instructions */
+ bool wdt; /* Watchdog Timer */
+ bool ida; /* Intel Dynamic Acceleration */
+ bool arat; /* Always Running APIC Timer */
+ bool tpr_shadow; /* Intel TPR Shadow */
+ bool vnmi; /* Intel Virtual NMI */
+ bool flexpriority; /* Intel FlexPriority */
+ bool ept; /* Intel Extended Page Table */
+ bool vpid; /* Intel Virtual Processor ID */
} s_cpu_flags;
typedef struct {
@@ -76,6 +127,10 @@ typedef struct {
char model[CPU_MODEL_SIZE];
uint8_t model_id;
uint8_t stepping;
+ uint8_t num_cores;
+ uint16_t l1_data_cache_size;
+ uint16_t l1_instruction_cache_size;
+ uint16_t l2_cache_size;
s_cpu_flags flags;
} s_cpu;
@@ -144,7 +199,9 @@ struct cpuinfo_x86 {
uint32_t x86_capability[NCAPINTS];
char x86_vendor_id[16];
char x86_model_id[64];
- int x86_cache_size; /* in KB, if available */
+ uint16_t x86_l1_data_cache_size; /* in KB, if available */
+ uint16_t x86_l1_instruction_cache_size; /* in KB, if available */
+ uint16_t x86_l2_cache_size; /* in KB, if available */
int x86_cache_alignment; /* in bytes */
char fdiv_bug;
char f00f_bug;
@@ -155,7 +212,7 @@ struct cpuinfo_x86 {
#ifdef CONFIG_SMP
cpumask_t llc_shared_map; /* cpus sharing the last level cache */
#endif
- unsigned char x86_max_cores; /* cpuid returned max cores value */
+ unsigned char x86_num_cores; /* cpuid returned the number of cores */
unsigned char booted_cores; /* number of cores as seen by OS */
unsigned char apicid;
unsigned char x86_clflush_size;
diff --git a/com32/gplinclude/disk/bootloaders.h b/com32/gplinclude/disk/bootloaders.h
index 6aec9b3d..5a6ff9d9 100644
--- a/com32/gplinclude/disk/bootloaders.h
+++ b/com32/gplinclude/disk/bootloaders.h
@@ -14,5 +14,6 @@
#include <disk/geom.h>
#include <disk/partition.h>
-int get_bootloader_string(const struct driveinfo *, const struct part_entry *, char*, const int);
+int get_bootloader_string(const struct driveinfo *, const struct part_entry *,
+ char *, const int);
#endif /* __BOOTLOADERS_H_ */
diff --git a/com32/gplinclude/disk/common.h b/com32/gplinclude/disk/common.h
index 627e94ec..4e415c11 100644
--- a/com32/gplinclude/disk/common.h
+++ b/com32/gplinclude/disk/common.h
@@ -23,11 +23,11 @@
#define SECTOR 512 /* bytes/sector */
struct ebios_dapa {
- uint16_t len;
- uint16_t count;
- uint16_t off;
- uint16_t seg;
- uint64_t lba;
+ uint16_t len;
+ uint16_t count;
+ uint16_t off;
+ uint16_t seg;
+ uint64_t lba;
};
#endif /* _COMMON_H_ */
diff --git a/com32/gplinclude/disk/errno_disk.h b/com32/gplinclude/disk/errno_disk.h
index 60b511fc..68bd89d9 100644
--- a/com32/gplinclude/disk/errno_disk.h
+++ b/com32/gplinclude/disk/errno_disk.h
@@ -13,38 +13,38 @@
extern int errno_disk;
/* Prefix with ED to avoid confusion with errno */
-#define EDINV 0x01 /* Invalid function in AH or invalid parameter */
-#define EDADDR 0x02 /* Address mark not found */
-#define EDRO 0x03 /* Disk write-protected */
-#define EDNOFND 0x04 /* Sector not found/read error */
-#define EDRFAIL 0x05 /* Reset failed (hard disk) */
-#define EDCHANG 0x06 /* Disk changed (floppy) */
-#define EDFAIL 0x07 /* Drive parameter activity failed (hard disk) */
-#define EDDMA 0x08 /* DMA overrun */
-#define EDBOUND 0x09 /* Data boundary error (attempted DMA across 64K boundary or >80h sectors) */
-#define EDBADS 0x0A /* Bad sector detected (hard disk) */
-#define EDBADT 0x0B /* Bad track detected (hard disk) */
-#define EDINVM 0x0C /* Unsupported track or invalid media */
-#define EDINVS 0x0D /* Invalid number of sectors on format (PS/2 hard disk) */
-#define EDADDRM 0x0E /* Control data address mark detected (hard disk) */
-#define EDDMARG 0x0F /* DMA arbitration level out of range (hard disk) */
-#define EDCRCF 0x10 /* Uncorrectable CRC or ECC error on read */
-#define EDCRCV 0x11 /* Data ECC corrected (hard disk) */
-#define EDCTRL 0x20 /* Controller failure */
-#define EDMEDIA 0x31 /* No media in drive (IBM/MS INT 13 extensions) */
-#define EDCMOS 0x32 /* Incorrect drive type stored in CMOS (Compaq) */
-#define EDSEEKF 0x40 /* Seek failed */
-#define EDTIME 0x80 /* Timeout (not ready) */
-#define EDREADY 0xAA /* Drive not ready (hard disk) */
-#define EDNLOCK 0xB0 /* Volume not locked in drive (INT 13 extensions) */
-#define EDLOCK 0xB1 /* Volume locked in drive (INT 13 extensions) */
-#define EDREMOV 0xB2 /* Volume not removable (INT 13 extensions) */
-#define EDUSED 0xB3 /* Volume in use (INT 13 extensions) */
-#define EDCOUNT 0xB4 /* Lock count exceeded (INT 13 extensions) */
-#define EDEJF 0xB5 /* Valid eject request failed (INT 13 extensions) */
+#define EDINV 0x01 /* Invalid function in AH or invalid parameter */
+#define EDADDR 0x02 /* Address mark not found */
+#define EDRO 0x03 /* Disk write-protected */
+#define EDNOFND 0x04 /* Sector not found/read error */
+#define EDRFAIL 0x05 /* Reset failed (hard disk) */
+#define EDCHANG 0x06 /* Disk changed (floppy) */
+#define EDFAIL 0x07 /* Drive parameter activity failed (hard disk) */
+#define EDDMA 0x08 /* DMA overrun */
+#define EDBOUND 0x09 /* Data boundary error (attempted DMA across 64K boundary or >80h sectors) */
+#define EDBADS 0x0A /* Bad sector detected (hard disk) */
+#define EDBADT 0x0B /* Bad track detected (hard disk) */
+#define EDINVM 0x0C /* Unsupported track or invalid media */
+#define EDINVS 0x0D /* Invalid number of sectors on format (PS/2 hard disk) */
+#define EDADDRM 0x0E /* Control data address mark detected (hard disk) */
+#define EDDMARG 0x0F /* DMA arbitration level out of range (hard disk) */
+#define EDCRCF 0x10 /* Uncorrectable CRC or ECC error on read */
+#define EDCRCV 0x11 /* Data ECC corrected (hard disk) */
+#define EDCTRL 0x20 /* Controller failure */
+#define EDMEDIA 0x31 /* No media in drive (IBM/MS INT 13 extensions) */
+#define EDCMOS 0x32 /* Incorrect drive type stored in CMOS (Compaq) */
+#define EDSEEKF 0x40 /* Seek failed */
+#define EDTIME 0x80 /* Timeout (not ready) */
+#define EDREADY 0xAA /* Drive not ready (hard disk) */
+#define EDNLOCK 0xB0 /* Volume not locked in drive (INT 13 extensions) */
+#define EDLOCK 0xB1 /* Volume locked in drive (INT 13 extensions) */
+#define EDREMOV 0xB2 /* Volume not removable (INT 13 extensions) */
+#define EDUSED 0xB3 /* Volume in use (INT 13 extensions) */
+#define EDCOUNT 0xB4 /* Lock count exceeded (INT 13 extensions) */
+#define EDEJF 0xB5 /* Valid eject request failed (INT 13 extensions) */
#define EDUNKOWN 0xBB /* Undefined error (hard disk) */
-#define EDWF 0xCC /* Write fault (hard disk) */
-#define EDRF 0xE0 /* Status register error (hard disk) */
-#define EDSF 0xFF /* Sense operation failed (hard disk) */
+#define EDWF 0xCC /* Write fault (hard disk) */
+#define EDRF 0xE0 /* Status register error (hard disk) */
+#define EDSF 0xFF /* Sense operation failed (hard disk) */
#endif /* _ERRNO_DISK_H */
diff --git a/com32/gplinclude/disk/error.h b/com32/gplinclude/disk/error.h
index 27683572..e00266fe 100644
--- a/com32/gplinclude/disk/error.h
+++ b/com32/gplinclude/disk/error.h
@@ -9,5 +9,5 @@
#ifndef _ERROR_H_
#define _ERROR_H_
-void get_error(const char*);
+void get_error(const char *);
#endif /* _ERROR_H_ */
diff --git a/com32/gplinclude/disk/geom.h b/com32/gplinclude/disk/geom.h
index 0d3eed57..359c7cf9 100644
--- a/com32/gplinclude/disk/geom.h
+++ b/com32/gplinclude/disk/geom.h
@@ -29,7 +29,7 @@
* returned by a v2.x implementation; similarly for the Device Path info
**/
struct edd_device_parameters {
- uint16_t len; /* size of returned data */
+ uint16_t len; /* size of returned data */
/**
* Bitfields for IBM/MS INT 13 Extensions information flags:
* Bit(s) Description (Table 00274)
@@ -42,28 +42,28 @@ struct edd_device_parameters {
* 6 CHS information set to maximum supported values, not current media
* 15-7 reserved (0)
**/
- uint16_t info; /* information flags */
- uint32_t cylinders; /* number of physical cylinders on drive */
- uint32_t heads; /* number of physical heads on drive */
- uint32_t sectors_per_track; /* number of physical sectors per track */
- uint64_t sectors; /* total number of sectors on drive */
- uint16_t bytes_per_sector; /* bytes per sector */
- /* --- v2.0+ --- */
- uint32_t dpte_pointer; /* EDD configuration parameters, FFFFh:FFFFh if not available */
- /* --- v3.0 --- */
- uint16_t device_path_information; /* signature BEDDh to indicate presence of Device Path info */
- uint8_t device_path_length; /* length of Device Path information, including signature and this byte (24h for v3.0) */
- uint8_t device_path_reserved; /* reserved (0) */
- uint16_t device_path_reserved_2; /* reserved (0) */
- uint8_t host_bus_type[4]; /* ASCIZ name of host bus ("ISA" or "PCI") */
- uint8_t interface_type[8]; /* ASCIZ name of interface type
- * "ATA"
- * "ATAPI"
- * "SCSI"
- * "USB"
- * "1394" IEEE 1394 (FireWire)
- * "FIBRE" Fibre Channel
- */
+ uint16_t info; /* information flags */
+ uint32_t cylinders; /* number of physical cylinders on drive */
+ uint32_t heads; /* number of physical heads on drive */
+ uint32_t sectors_per_track; /* number of physical sectors per track */
+ uint64_t sectors; /* total number of sectors on drive */
+ uint16_t bytes_per_sector; /* bytes per sector */
+ /* --- v2.0+ --- */
+ uint32_t dpte_pointer; /* EDD configuration parameters, FFFFh:FFFFh if not available */
+ /* --- v3.0 --- */
+ uint16_t device_path_information; /* signature BEDDh to indicate presence of Device Path info */
+ uint8_t device_path_length; /* length of Device Path information, including signature and this byte (24h for v3.0) */
+ uint8_t device_path_reserved; /* reserved (0) */
+ uint16_t device_path_reserved_2; /* reserved (0) */
+ uint8_t host_bus_type[4]; /* ASCIZ name of host bus ("ISA" or "PCI") */
+ uint8_t interface_type[8]; /* ASCIZ name of interface type
+ * "ATA"
+ * "ATAPI"
+ * "SCSI"
+ * "USB"
+ * "1394" IEEE 1394 (FireWire)
+ * "FIBRE" Fibre Channel
+ */
/**
* Format of EDD v3.0 Interface Path:
* Offset Size Description (Table 00275)
@@ -76,33 +76,33 @@ struct edd_device_parameters {
* 02h BYTE PCI function number
* 03h 5 BYTEs reserved (0)
**/
- union {
- struct {
- uint16_t base_address;
- uint16_t reserved1;
- uint32_t reserved2;
- } __attribute__ ((packed)) isa;
- struct {
- uint8_t bus;
- uint8_t slot;
- uint8_t function;
- uint8_t channel;
- uint32_t reserved;
- } __attribute__ ((packed)) pci;
- /* pcix is same as pci */
- struct {
- uint64_t reserved;
- } __attribute__ ((packed)) ibnd;
- struct {
- uint64_t reserved;
- } __attribute__ ((packed)) xprs;
- struct {
- uint64_t reserved;
- } __attribute__ ((packed)) htpt;
- struct {
- uint64_t reserved;
- } __attribute__ ((packed)) unknown;
- } interface_path;
+ union {
+ struct {
+ uint16_t base_address;
+ uint16_t reserved1;
+ uint32_t reserved2;
+ } __attribute__ ((packed)) isa;
+ struct {
+ uint8_t bus;
+ uint8_t slot;
+ uint8_t function;
+ uint8_t channel;
+ uint32_t reserved;
+ } __attribute__ ((packed)) pci;
+ /* pcix is same as pci */
+ struct {
+ uint64_t reserved;
+ } __attribute__ ((packed)) ibnd;
+ struct {
+ uint64_t reserved;
+ } __attribute__ ((packed)) xprs;
+ struct {
+ uint64_t reserved;
+ } __attribute__ ((packed)) htpt;
+ struct {
+ uint64_t reserved;
+ } __attribute__ ((packed)) unknown;
+ } interface_path;
/**
* Format of EDD v3.0 Device Path:
* Offset Size Description (Table 00276)
@@ -124,83 +124,83 @@ struct edd_device_parameters {
* ---FibreChannel---
* 00h QWORD Word Wide Number (WWN)
**/
- union {
- struct {
- uint8_t device;
- uint8_t reserved1;
- uint16_t reserved2;
- uint32_t reserved3;
- uint64_t reserved4;
- } __attribute__ ((packed)) ata;
- struct {
- uint8_t device;
- uint8_t lun;
- uint8_t reserved1;
- uint8_t reserved2;
- uint32_t reserved3;
- uint64_t reserved4;
- } __attribute__ ((packed)) atapi;
- struct {
- uint16_t id;
- uint64_t lun;
- uint16_t reserved1;
- uint32_t reserved2;
- } __attribute__ ((packed)) scsi;
- struct {
- uint64_t serial_number;
- uint64_t reserved;
- } __attribute__ ((packed)) usb;
- struct {
- uint64_t eui;
- uint64_t reserved;
- } __attribute__ ((packed)) i1394;
- struct {
- uint64_t wwid;
- uint64_t lun;
- } __attribute__ ((packed)) fibre;
- struct {
- uint64_t identity_tag;
- uint64_t reserved;
- } __attribute__ ((packed)) i2o;
- struct {
- uint32_t array_number;
- uint32_t reserved1;
- uint64_t reserved2;
- } __attribute__ ((packed)) raid;
- struct {
- uint8_t device;
- uint8_t reserved1;
- uint16_t reserved2;
- uint32_t reserved3;
- uint64_t reserved4;
- } __attribute__ ((packed)) sata;
- struct {
- uint64_t reserved1;
- uint64_t reserved2;
- } __attribute__ ((packed)) unknown;
- } device_path;
- uint8_t reserved; /* reserved (0) */
- uint8_t checksum; /* checksum of bytes 1Eh-40h (two's complement of sum, which makes
- * the 8-bit sum of bytes 1Eh-41h equal 00h) */
+ union {
+ struct {
+ uint8_t device;
+ uint8_t reserved1;
+ uint16_t reserved2;
+ uint32_t reserved3;
+ uint64_t reserved4;
+ } __attribute__ ((packed)) ata;
+ struct {
+ uint8_t device;
+ uint8_t lun;
+ uint8_t reserved1;
+ uint8_t reserved2;
+ uint32_t reserved3;
+ uint64_t reserved4;
+ } __attribute__ ((packed)) atapi;
+ struct {
+ uint16_t id;
+ uint64_t lun;
+ uint16_t reserved1;
+ uint32_t reserved2;
+ } __attribute__ ((packed)) scsi;
+ struct {
+ uint64_t serial_number;
+ uint64_t reserved;
+ } __attribute__ ((packed)) usb;
+ struct {
+ uint64_t eui;
+ uint64_t reserved;
+ } __attribute__ ((packed)) i1394;
+ struct {
+ uint64_t wwid;
+ uint64_t lun;
+ } __attribute__ ((packed)) fibre;
+ struct {
+ uint64_t identity_tag;
+ uint64_t reserved;
+ } __attribute__ ((packed)) i2o;
+ struct {
+ uint32_t array_number;
+ uint32_t reserved1;
+ uint64_t reserved2;
+ } __attribute__ ((packed)) raid;
+ struct {
+ uint8_t device;
+ uint8_t reserved1;
+ uint16_t reserved2;
+ uint32_t reserved3;
+ uint64_t reserved4;
+ } __attribute__ ((packed)) sata;
+ struct {
+ uint64_t reserved1;
+ uint64_t reserved2;
+ } __attribute__ ((packed)) unknown;
+ } device_path;
+ uint8_t reserved; /* reserved (0) */
+ uint8_t checksum; /* checksum of bytes 1Eh-40h (two's complement of sum, which makes
+ * the 8-bit sum of bytes 1Eh-41h equal 00h) */
} __attribute__ ((packed));
/*
* Disk parameters
*/
struct driveinfo {
- int disk; /* Disk port (0x80 - 0xff) */
- /* Legacy C/H/S */
- int cbios; /* CHS geometry is valid */
- int legacy_max_head;
- int legacy_max_cylinder;
- int legacy_sectors_per_track;
- int legacy_max_drive;
- int legacy_type; /* Drive type (AT/PS2 floppies only) */
- /* EDD support */
- int ebios; /* EBIOS supported on this disk */
- int edd_version; /* EBIOS major version */
- int edd_functionality_subset;
- struct edd_device_parameters edd_params;/* EDD parameters */
+ int disk; /* Disk port (0x80 - 0xff) */
+ /* Legacy C/H/S */
+ int cbios; /* CHS geometry is valid */
+ int legacy_max_head;
+ int legacy_max_cylinder;
+ int legacy_sectors_per_track;
+ int legacy_max_drive;
+ int legacy_type; /* Drive type (AT/PS2 floppies only) */
+ /* EDD support */
+ int ebios; /* EBIOS supported on this disk */
+ int edd_version; /* EBIOS major version */
+ int edd_functionality_subset;
+ struct edd_device_parameters edd_params; /* EDD parameters */
};
/**
@@ -290,36 +290,37 @@ struct driveinfo {
* 10h ATAPI Removable Media Device
*/
enum diskette_drive_types {
- DISKETTE_360K = 1,
- DISKETTE_1_2M = 2,
- DISKETTE_720K = 3,
- DISKETTE_1_44M = 4,
- DISKETTE_2_88M = 6,
- DISKETTE_ATAPI = 10,
+ DISKETTE_360K = 1,
+ DISKETTE_1_2M = 2,
+ DISKETTE_720K = 3,
+ DISKETTE_1_44M = 4,
+ DISKETTE_2_88M = 6,
+ DISKETTE_ATAPI = 10,
};
/**
* chs_to_lba - compute lba value from cylinder, head and sector number
**/
-static inline int chs_to_lba(const struct driveinfo* drive_info,
- const unsigned int cylinder, const unsigned int head,
- const unsigned int sector)
+static inline int chs_to_lba(const struct driveinfo *drive_info,
+ const unsigned int cylinder,
+ const unsigned int head, const unsigned int sector)
{
- /* Use EDD, if valid */
- if (drive_info->edd_params.sectors_per_track > 0 &&
- drive_info->edd_params.heads > 0)
- return (sector - 1) + (head * drive_info->edd_params.sectors_per_track) +
- (cylinder * (drive_info->edd_params.heads) *
- drive_info->edd_params.sectors_per_track);
- else if (drive_info->cbios)
- return (sector - 1) + (head * drive_info->legacy_sectors_per_track) +
- (cylinder * (drive_info->legacy_max_head + 1) *
- drive_info->legacy_sectors_per_track);
+ /* Use EDD, if valid */
+ if (drive_info->edd_params.sectors_per_track > 0 &&
+ drive_info->edd_params.heads > 0)
+ return (sector - 1) +
+ (head * drive_info->edd_params.sectors_per_track) +
+ (cylinder * (drive_info->edd_params.heads) *
+ drive_info->edd_params.sectors_per_track);
+ else if (drive_info->cbios)
+ return (sector - 1) + (head * drive_info->legacy_sectors_per_track) +
+ (cylinder * (drive_info->legacy_max_head + 1) *
+ drive_info->legacy_sectors_per_track);
}
-void lba_to_chs(const struct driveinfo* drive_info, const int lba,
- unsigned int* cylinder, unsigned int* head,
- unsigned int* sector);
+void lba_to_chs(const struct driveinfo *drive_info, const int lba,
+ unsigned int *cylinder, unsigned int *head,
+ unsigned int *sector);
int get_drive_parameters(struct driveinfo *drive_info);
#endif /* _GEOM_H */
diff --git a/com32/gplinclude/disk/msdos.h b/com32/gplinclude/disk/msdos.h
index 405b9b99..cb39dad2 100644
--- a/com32/gplinclude/disk/msdos.h
+++ b/com32/gplinclude/disk/msdos.h
@@ -13,7 +13,7 @@
#include <disk/geom.h>
#include <disk/partition.h>
-typedef void (*p_callback)(struct driveinfo *, struct part_entry *, int, int);
+typedef void (*p_callback) (struct driveinfo *, struct part_entry *, int, int);
int parse_partition_table(struct driveinfo *, p_callback);
#endif /* _MSDOS_H_ */
diff --git a/com32/gplinclude/disk/partition.h b/com32/gplinclude/disk/partition.h
index be6bfaab..5edf8281 100644
--- a/com32/gplinclude/disk/partition.h
+++ b/com32/gplinclude/disk/partition.h
@@ -21,17 +21,17 @@
/* A DOS partition table entry */
struct part_entry {
- uint8_t active_flag; /* 0x80 if "active" */
- uint8_t start_head;
- uint8_t start_sect;
- uint8_t start_cyl;
- uint8_t ostype;
- uint8_t end_head;
- uint8_t end_sect;
- uint8_t end_cyl;
- uint32_t start_lba;
- uint32_t length;
-} __attribute__((packed));
+ uint8_t active_flag; /* 0x80 if "active" */
+ uint8_t start_head;
+ uint8_t start_sect;
+ uint8_t start_cyl;
+ uint8_t ostype;
+ uint8_t end_head;
+ uint8_t end_sect;
+ uint8_t end_cyl;
+ uint32_t start_lba;
+ uint32_t length;
+} __attribute__ ((packed));
-void get_label(int label, char** buffer_label);
+void get_label(int label, char **buffer_label);
#endif /* _PARTITION_H_ */
diff --git a/com32/gplinclude/disk/read.h b/com32/gplinclude/disk/read.h
index 43762a68..08a9dd3e 100644
--- a/com32/gplinclude/disk/read.h
+++ b/com32/gplinclude/disk/read.h
@@ -12,7 +12,7 @@
#include <disk/geom.h>
-int read_mbr(int, void*);
-int dev_read(int, void*, unsigned int, int);
-int read_sectors(struct driveinfo*, void*, const unsigned int, const int);
+int read_mbr(int, void *);
+int dev_read(int, void *, unsigned int, int);
+int read_sectors(struct driveinfo *, void *, const unsigned int, const int);
#endif /* _READ_H */
diff --git a/com32/gplinclude/disk/swsusp.h b/com32/gplinclude/disk/swsusp.h
index 1d77c878..3e9acacf 100644
--- a/com32/gplinclude/disk/swsusp.h
+++ b/com32/gplinclude/disk/swsusp.h
@@ -8,12 +8,12 @@
#define SWSUSP_SIG "S1SUSPEND"
struct swsusp_header {
- char reserved[PAGE_SIZE - 20 - sizeof(unsigned long) - sizeof(int)];
- unsigned long image;
- unsigned int flags; /* Flags to pass to the "boot" kernel */
- char orig_sig[10];
- char sig[10];
-} __attribute__((packed));
+ char reserved[PAGE_SIZE - 20 - sizeof(unsigned long) - sizeof(int)];
+ unsigned long image;
+ unsigned int flags; /* Flags to pass to the "boot" kernel */
+ char orig_sig[10];
+ char sig[10];
+} __attribute__ ((packed));
-int swsusp_check(struct driveinfo*, struct part_entry*);
+int swsusp_check(struct driveinfo *, struct part_entry *);
#endif /* _SWSUSP_H */
diff --git a/com32/gplinclude/disk/util.h b/com32/gplinclude/disk/util.h
index 20a9428f..52f085a7 100644
--- a/com32/gplinclude/disk/util.h
+++ b/com32/gplinclude/disk/util.h
@@ -17,5 +17,5 @@
#include <com32.h>
-int int13_retry(const com32sys_t *inreg, com32sys_t *outreg);
+int int13_retry(const com32sys_t * inreg, com32sys_t * outreg);
#endif /* _UTIL_H_ */
diff --git a/com32/gplinclude/disk/write.h b/com32/gplinclude/disk/write.h
index faa80c7d..89d26fc6 100644
--- a/com32/gplinclude/disk/write.h
+++ b/com32/gplinclude/disk/write.h
@@ -17,12 +17,10 @@
#include <disk/geom.h>
-int write_sectors(const struct driveinfo*, const unsigned int,
+int write_sectors(const struct driveinfo *, const unsigned int,
const void *, const int);
-int write_verify_sector(struct driveinfo* drive_info,
- const unsigned int,
- const void *);
-int write_verify_sectors(struct driveinfo*,
- const unsigned int,
- const void *, const int);
+int write_verify_sector(struct driveinfo *drive_info,
+ const unsigned int, const void *);
+int write_verify_sectors(struct driveinfo *,
+ const unsigned int, const void *, const int);
#endif
diff --git a/com32/gplinclude/dmi/dmi.h b/com32/gplinclude/dmi/dmi.h
index 72bc8dc4..dba2229b 100644
--- a/com32/gplinclude/dmi/dmi.h
+++ b/com32/gplinclude/dmi/dmi.h
@@ -13,7 +13,7 @@
#ifndef DMI_H
#define DMI_H
#include <inttypes.h>
-#define DMI_BUFFER_SIZE 16
+#define DMI_BUFFER_SIZE 16
#define MAX_DMI_MEMORY_ITEMS 32
#define MAX_DMI_CACHE_ITEMS 32
#define OEM_STRINGS_SIZE 512
@@ -60,28 +60,28 @@ struct dmi_header {
};
typedef struct {
- s_bios bios;
- s_system system;
- s_base_board base_board;
- s_chassis chassis;
- s_processor processor;
- s_battery battery;
- s_memory_module memory_module[MAX_DMI_MEMORY_ITEMS];
- s_memory memory[MAX_DMI_MEMORY_ITEMS];
- s_ipmi ipmi;
- s_cache cache[MAX_DMI_CACHE_ITEMS];
- int memory_module_count;
- int memory_count;
- int cache_count;
- dmi_table dmitable;
- char oem_strings[OEM_STRINGS_SIZE];
- struct {
- char power_on_passwd_status[HARDWARE_SECURITY_SIZE];
- char keyboard_passwd_status[HARDWARE_SECURITY_SIZE];
- char administrator_passwd_status[HARDWARE_SECURITY_SIZE];
- char front_panel_reset_status[HARDWARE_SECURITY_SIZE];
- bool filled;
- } hardware_security;
+ s_bios bios;
+ s_system system;
+ s_base_board base_board;
+ s_chassis chassis;
+ s_processor processor;
+ s_battery battery;
+ s_memory_module memory_module[MAX_DMI_MEMORY_ITEMS];
+ s_memory memory[MAX_DMI_MEMORY_ITEMS];
+ s_ipmi ipmi;
+ s_cache cache[MAX_DMI_CACHE_ITEMS];
+ int memory_module_count;
+ int memory_count;
+ int cache_count;
+ dmi_table dmitable;
+ char oem_strings[OEM_STRINGS_SIZE];
+ struct {
+ char power_on_passwd_status[HARDWARE_SECURITY_SIZE];
+ char keyboard_passwd_status[HARDWARE_SECURITY_SIZE];
+ char administrator_passwd_status[HARDWARE_SECURITY_SIZE];
+ char front_panel_reset_status[HARDWARE_SECURITY_SIZE];
+ bool filled;
+ } hardware_security;
} s_dmi;
void to_dmi_header(struct dmi_header *h, uint8_t * data);
diff --git a/com32/gplinclude/dmi/dmi_base_board.h b/com32/gplinclude/dmi/dmi_base_board.h
index ff4dd8a9..3d5fb557 100644
--- a/com32/gplinclude/dmi/dmi_base_board.h
+++ b/com32/gplinclude/dmi/dmi_base_board.h
@@ -30,29 +30,29 @@ extern const char *base_board_features_strings[];
/* this struct have BASE_BOARD_NB_ELEMENTS */
/* each bool is associated to the relevant message above */
typedef struct {
- bool hosting;
- bool board_needs_daughter;
- bool removable;
- bool replaceable;
- bool hot_swappable;
+ bool hosting;
+ bool board_needs_daughter;
+ bool removable;
+ bool replaceable;
+ bool hot_swappable;
} __attribute__ ((__packed__)) s_base_board_features;
typedef struct {
- char manufacturer[BASE_BOARD_MANUFACTURER_SIZE];
- char product_name[BASE_BOARD_PRODUCT_NAME_SIZE];
- char version[BASE_BOARD_VERSION_SIZE];
- char serial[BASE_BOARD_SERIAL_SIZE];
- char asset_tag[BASE_BOARD_ASSET_TAG_SIZE];
- char location[BASE_BOARD_LOCATION_SIZE];
- char type[BASE_BOARD_TYPE_SIZE];
- s_base_board_features features;
+ char manufacturer[BASE_BOARD_MANUFACTURER_SIZE];
+ char product_name[BASE_BOARD_PRODUCT_NAME_SIZE];
+ char version[BASE_BOARD_VERSION_SIZE];
+ char serial[BASE_BOARD_SERIAL_SIZE];
+ char asset_tag[BASE_BOARD_ASSET_TAG_SIZE];
+ char location[BASE_BOARD_LOCATION_SIZE];
+ char type[BASE_BOARD_TYPE_SIZE];
+ s_base_board_features features;
/* The filled field have to be set to true when the dmitable implement that item */
- bool filled;
- struct {
- char type[16];
- uint8_t status;
- char description[10];
- } devices_information[10];
+ bool filled;
+ struct {
+ char type[16];
+ uint8_t status;
+ char description[10];
+ } devices_information[10];
} s_base_board;
#endif
diff --git a/com32/gplinclude/dmi/dmi_cache.h b/com32/gplinclude/dmi/dmi_cache.h
index 50f93afd..cfd7114e 100644
--- a/com32/gplinclude/dmi/dmi_cache.h
+++ b/com32/gplinclude/dmi/dmi_cache.h
@@ -23,24 +23,24 @@
#include "stdbool.h"
typedef struct {
- char socket_designation[32];
- char configuration[32];
- char mode[32];
- char location[8];
- uint16_t installed_size;
- uint16_t max_size;
- char supported_sram_types[32];
- char installed_sram_types[32];
- uint16_t speed;
- char error_correction_type[32];
- char system_type[16];
- char associativity[32];
-} __attribute__((__packed__)) s_cache;
+ char socket_designation[32];
+ char configuration[32];
+ char mode[32];
+ char location[8];
+ uint16_t installed_size;
+ uint16_t max_size;
+ char supported_sram_types[32];
+ char installed_sram_types[32];
+ uint16_t speed;
+ char error_correction_type[32];
+ char system_type[16];
+ char associativity[32];
+} __attribute__ ((__packed__)) s_cache;
const char *dmi_cache_mode(uint8_t code);
const char *dmi_cache_location(uint8_t code);
uint16_t dmi_cache_size(uint16_t code);
-void dmi_cache_types(uint16_t code, const char *sep, char* array);
+void dmi_cache_types(uint16_t code, const char *sep, char *array);
const char *dmi_cache_ec_type(uint8_t code);
const char *dmi_cache_type(uint8_t code);
const char *dmi_cache_associativity(uint8_t code);
diff --git a/com32/gplinclude/dmi/dmi_memory.h b/com32/gplinclude/dmi/dmi_memory.h
index f9c2b561..47ad7fcd 100644
--- a/com32/gplinclude/dmi/dmi_memory.h
+++ b/com32/gplinclude/dmi/dmi_memory.h
@@ -50,14 +50,14 @@ typedef struct {
} s_memory;
typedef struct {
-char socket_designation[8];
-char bank_connections[8];
-char speed[8];
-char type[16];
-char installed_size[8];
-char enabled_size[8];
-char error_status[8];
-bool filled;
+ char socket_designation[8];
+ char bank_connections[8];
+ char speed[8];
+ char type[48];
+ char installed_size[48];
+ char enabled_size[48];
+ char error_status[8];
+ bool filled;
} s_memory_module;
void dmi_memory_array_error_handle(uint16_t code, char *array);
@@ -69,9 +69,9 @@ const char *dmi_memory_device_type(uint8_t code);
void dmi_memory_device_type_detail(uint16_t code, char *type_detail);
void dmi_memory_device_speed(uint16_t code, char *speed);
-void dmi_memory_module_connections(uint8_t, char*);
-void dmi_memory_module_speed(uint8_t, char*);
-void dmi_memory_module_types(uint16_t, const char*, char*);
-void dmi_memory_module_size(uint8_t, char*);
-void dmi_memory_module_error(uint8_t, const char*, char*);
+void dmi_memory_module_connections(uint8_t, char *);
+void dmi_memory_module_speed(uint8_t, char *);
+void dmi_memory_module_types(uint16_t, const char *, char *);
+void dmi_memory_module_size(uint8_t, char *);
+void dmi_memory_module_error(uint8_t, const char *, char *);
#endif
diff --git a/com32/gplinclude/dmi/dmi_processor.h b/com32/gplinclude/dmi/dmi_processor.h
index de2f4e4f..63b8767f 100644
--- a/com32/gplinclude/dmi/dmi_processor.h
+++ b/com32/gplinclude/dmi/dmi_processor.h
@@ -84,7 +84,7 @@ typedef struct {
char family[PROCESSOR_FAMILY_SIZE];
char manufacturer[PROCESSOR_MANUFACTURER_SIZE];
char version[PROCESSOR_VERSION_SIZE];
- float voltage;
+ uint16_t voltage_mv;
uint16_t external_clock;
uint16_t max_speed;
uint16_t current_speed;
diff --git a/com32/gplinclude/dmi/dmi_system.h b/com32/gplinclude/dmi/dmi_system.h
index 28a562de..6bb053ff 100644
--- a/com32/gplinclude/dmi/dmi_system.h
+++ b/com32/gplinclude/dmi/dmi_system.h
@@ -35,10 +35,10 @@ typedef struct {
char sku_number[SYSTEM_SKU_NUMBER_SIZE];
char family[SYSTEM_FAMILY_SIZE];
/* The filled field have to be set to true when the dmitable implement that item */
-bool filled;
-char system_boot_status[SYSTEM_BOOT_STATUS_SIZE];
-char configuration_options[SYSTEM_CONFIGURATION_OPTIONS_SIZE];
-struct {
+ bool filled;
+ char system_boot_status[SYSTEM_BOOT_STATUS_SIZE];
+ char configuration_options[SYSTEM_CONFIGURATION_OPTIONS_SIZE];
+ struct {
bool filled;
uint8_t status;
uint8_t watchdog;
@@ -48,6 +48,6 @@ struct {
char reset_limit[8];
char timer_interval[8];
char timeout[8];
-} system_reset;
+ } system_reset;
} s_system;
#endif
diff --git a/com32/gplinclude/memory.h b/com32/gplinclude/memory.h
index c9f386d4..fe33c18d 100644
--- a/com32/gplinclude/memory.h
+++ b/com32/gplinclude/memory.h
@@ -22,16 +22,32 @@
#define _MEMORY_H_
#include <stdint.h>
+#define E820MAX 128
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */
+#define E820_NVS 4
+
+#define RES_START 0xa0000
+#define RES_END 0x100000
+
struct e820entry {
- uint64_t addr; /* start of memory segment */
- uint64_t size; /* size of memory segment */
- uint64_t type; /* type of memory segment */
-} __attribute__((packed));
+ uint64_t addr; /* start of memory segment */
+ uint64_t size; /* size of memory segment */
+ uint64_t type; /* type of memory segment */
+} __attribute__ ((packed));
-const char * const e820_types[5];
+const char *const e820_types[5];
-void get_type(int, char*, int);
+void get_type(int, char *, int);
void detect_memory_e820(struct e820entry *desc, int size_map, int *size_found);
-int detect_memory_e801(int*, int*);
-int detect_memory_88(int*);
+int detect_memory_e801(int *, int *);
+int detect_memory_88(int *);
+
+/* The following stuff could be merge once the addr_t will be set to 64bits.
+ * syslinux_scan_memory can be used for that purpose */
+unsigned long memsize_e820(struct e820entry *e820, int e820_nr);
+int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios,
+ short old_nr);
+unsigned long detect_memsize(void);
#endif
diff --git a/com32/gpllib/cpuid.c b/com32/gpllib/cpuid.c
index fb69cef6..fa212045 100644
--- a/com32/gpllib/cpuid.c
+++ b/com32/gpllib/cpuid.c
@@ -133,10 +133,54 @@ int get_model_name(struct cpuinfo_x86 *c)
return 1;
}
+void detect_cache(uint32_t xlvl, struct cpuinfo_x86 *c)
+{
+ uint32_t eax, ebx, ecx, edx, l2size;
+ /* Detecting L1 cache */
+ if (xlvl >= 0x80000005) {
+ cpuid(0x80000005, &eax, &ebx, &ecx, &edx);
+ c->x86_l1_data_cache_size = ecx >> 24;
+ c->x86_l1_instruction_cache_size = edx >> 24;
+ }
+
+ /* Detecting L2 cache */
+ c->x86_l2_cache_size = 0;
+
+ if (xlvl < 0x80000006) /* Some chips just has a large L1. */
+ return;
+
+ cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
+ l2size = ecx >> 16;
+
+ /* Vendor based fixes */
+ switch (c->x86_vendor) {
+ case X86_VENDOR_INTEL:
+ /*
+ * Intel PIII Tualatin. This comes in two flavours.
+ * One has 256kb of cache, the other 512. We have no way
+ * to determine which, so we use a boottime override
+ * for the 512kb model, and assume 256 otherwise.
+ */
+ if ((c->x86 == 6) && (c->x86_model == 11) && (l2size == 0))
+ l2size = 256;
+ break;
+ case X86_VENDOR_AMD:
+ /* AMD errata T13 (order #21922) */
+ if ((c->x86 == 6)) {
+ if (c->x86_model == 3 && c->x86_mask == 0) /* Duron Rev A0 */
+ l2size = 64;
+ if (c->x86_model == 4 && (c->x86_mask == 0 || c->x86_mask == 1)) /* Tbird rev A1/A2 */
+ l2size = 256;
+ }
+ break;
+ }
+ c->x86_l2_cache_size = l2size;
+}
+
void generic_identify(struct cpuinfo_x86 *c)
{
uint32_t tfms, xlvl;
- unsigned int ebx;
+ uint32_t eax, ebx, ecx, edx;
/* Get vendor name */
cpuid(0x00000000,
@@ -146,6 +190,7 @@ void generic_identify(struct cpuinfo_x86 *c)
(uint32_t *) & c->x86_vendor_id[4]);
get_cpu_vendor(c);
+
/* Intel-defined flags: level 0x00000001 */
if (c->cpuid_level >= 0x00000001) {
uint32_t capability, excap;
@@ -176,6 +221,26 @@ void generic_identify(struct cpuinfo_x86 *c)
if (xlvl >= 0x80000004)
get_model_name(c); /* Default name */
}
+
+ /* Detecting the number of cores */
+ switch (c->x86_vendor) {
+ case X86_VENDOR_AMD:
+ if (xlvl >= 0x80000008) {
+ c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
+ if (c->x86_num_cores & (c->x86_num_cores - 1))
+ c->x86_num_cores = 1;
+ }
+ break;
+ case X86_VENDOR_INTEL:
+ cpuid(0x4, &eax, &ebx, &ecx, &edx);
+ c->x86_num_cores = ((eax & 0xfc000000) >> 26) + 1;
+ break;
+ default:
+ c->x86_num_cores = 1;
+ break;
+ }
+
+ detect_cache(xlvl, c);
}
/*
@@ -280,6 +345,7 @@ void set_cpu_flags(struct cpuinfo_x86 *c, s_cpu * cpu)
cpu->flags.clflsh = cpu_has(c, X86_FEATURE_CLFLSH);
cpu->flags.dts = cpu_has(c, X86_FEATURE_DTES);
cpu->flags.acpi = cpu_has(c, X86_FEATURE_ACPI);
+ cpu->flags.pbe = cpu_has(c, X86_FEATURE_PBE);
cpu->flags.mmx = cpu_has(c, X86_FEATURE_MMX);
cpu->flags.fxsr = cpu_has(c, X86_FEATURE_FXSR);
cpu->flags.sse = cpu_has(c, X86_FEATURE_XMM);
@@ -291,11 +357,61 @@ void set_cpu_flags(struct cpuinfo_x86 *c, s_cpu * cpu)
cpu->flags.mp = cpu_has(c, X86_FEATURE_MP);
cpu->flags.nx = cpu_has(c, X86_FEATURE_NX);
cpu->flags.mmxext = cpu_has(c, X86_FEATURE_MMXEXT);
+ cpu->flags.fxsr_opt = cpu_has(c, X86_FEATURE_FXSR_OPT);
+ cpu->flags.gbpages = cpu_has(c, X86_FEATURE_GBPAGES);
+ cpu->flags.rdtscp = cpu_has(c, X86_FEATURE_RDTSCP);
cpu->flags.lm = cpu_has(c, X86_FEATURE_LM);
cpu->flags.nowext = cpu_has(c, X86_FEATURE_3DNOWEXT);
cpu->flags.now = cpu_has(c, X86_FEATURE_3DNOW);
cpu->flags.smp = find_smp_config();
+ cpu->flags.pni = cpu_has(c, X86_FEATURE_XMM3);
+ cpu->flags.pclmulqd = cpu_has(c, X86_FEATURE_PCLMULQDQ);
+ cpu->flags.dtes64 = cpu_has(c, X86_FEATURE_DTES64);
cpu->flags.vmx = cpu_has(c, X86_FEATURE_VMX);
+ cpu->flags.smx = cpu_has(c, X86_FEATURE_SMX);
+ cpu->flags.est = cpu_has(c, X86_FEATURE_EST);
+ cpu->flags.tm2 = cpu_has(c, X86_FEATURE_TM2);
+ cpu->flags.sse3 = cpu_has(c, X86_FEATURE_SSE3);
+ cpu->flags.cid = cpu_has(c, X86_FEATURE_CID);
+ cpu->flags.fma = cpu_has(c, X86_FEATURE_FMA);
+ cpu->flags.cx16 = cpu_has(c, X86_FEATURE_CX16);
+ cpu->flags.xtpr = cpu_has(c, X86_FEATURE_XTPR);
+ cpu->flags.pdcm = cpu_has(c, X86_FEATURE_PDCM);
+ cpu->flags.dca = cpu_has(c, X86_FEATURE_DCA);
+ cpu->flags.xmm4_1 = cpu_has(c, X86_FEATURE_XMM4_1);
+ cpu->flags.xmm4_2 = cpu_has(c, X86_FEATURE_XMM4_2);
+ cpu->flags.x2apic = cpu_has(c, X86_FEATURE_X2APIC);
+ cpu->flags.movbe = cpu_has(c, X86_FEATURE_MOVBE);
+ cpu->flags.popcnt = cpu_has(c, X86_FEATURE_POPCNT);
+ cpu->flags.aes = cpu_has(c, X86_FEATURE_AES);
+ cpu->flags.xsave = cpu_has(c, X86_FEATURE_XSAVE);
+ cpu->flags.osxsave = cpu_has(c, X86_FEATURE_OSXSAVE);
+ cpu->flags.avx = cpu_has(c, X86_FEATURE_AVX);
+ cpu->flags.hypervisor = cpu_has(c, X86_FEATURE_HYPERVISOR);
+ cpu->flags.ace2 = cpu_has(c, X86_FEATURE_ACE2);
+ cpu->flags.ace2_en = cpu_has(c, X86_FEATURE_ACE2_EN);
+ cpu->flags.phe = cpu_has(c, X86_FEATURE_PHE);
+ cpu->flags.phe_en = cpu_has(c, X86_FEATURE_PHE_EN);
+ cpu->flags.pmm = cpu_has(c, X86_FEATURE_PMM);
+ cpu->flags.pmm_en = cpu_has(c, X86_FEATURE_PMM_EN);
+ cpu->flags.extapic = cpu_has(c, X86_FEATURE_EXTAPIC);
+ cpu->flags.cr8_legacy = cpu_has(c, X86_FEATURE_CR8_LEGACY);
+ cpu->flags.abm = cpu_has(c, X86_FEATURE_ABM);
+ cpu->flags.sse4a = cpu_has(c, X86_FEATURE_SSE4A);
+ cpu->flags.misalignsse = cpu_has(c, X86_FEATURE_MISALIGNSSE);
+ cpu->flags.nowprefetch = cpu_has(c, X86_FEATURE_3DNOWPREFETCH);
+ cpu->flags.osvw = cpu_has(c, X86_FEATURE_OSVW);
+ cpu->flags.ibs = cpu_has(c, X86_FEATURE_IBS);
+ cpu->flags.sse5 = cpu_has(c, X86_FEATURE_SSE5);
+ cpu->flags.skinit = cpu_has(c, X86_FEATURE_SKINIT);
+ cpu->flags.wdt = cpu_has(c, X86_FEATURE_WDT);
+ cpu->flags.ida = cpu_has(c, X86_FEATURE_IDA);
+ cpu->flags.arat = cpu_has(c, X86_FEATURE_ARAT);
+ cpu->flags.tpr_shadow = cpu_has(c, X86_FEATURE_TPR_SHADOW);
+ cpu->flags.vnmi = cpu_has(c, X86_FEATURE_VNMI);
+ cpu->flags.flexpriority = cpu_has(c, X86_FEATURE_FLEXPRIORITY);
+ cpu->flags.ept = cpu_has(c, X86_FEATURE_EPT);
+ cpu->flags.vpid = cpu_has(c, X86_FEATURE_VPID);
cpu->flags.svm = cpu_has(c, X86_FEATURE_SVM);
}
@@ -308,17 +424,23 @@ void set_generic_info(struct cpuinfo_x86 *c, s_cpu * cpu)
strncpy(cpu->vendor, cpu_devs[c->x86_vendor]->c_vendor,
sizeof(cpu->vendor));
strncpy(cpu->model, c->x86_model_id, sizeof(cpu->model));
+ cpu->num_cores = c->x86_num_cores;
+ cpu->l1_data_cache_size = c->x86_l1_data_cache_size;
+ cpu->l1_instruction_cache_size = c->x86_l1_instruction_cache_size;
+ cpu->l2_cache_size = c->x86_l2_cache_size;
}
void detect_cpu(s_cpu * cpu)
{
struct cpuinfo_x86 c;
c.x86_clflush_size = 32;
- c.x86_cache_size = -1;
+ c.x86_l1_data_cache_size = 0;
+ c.x86_l1_instruction_cache_size = 0;
+ c.x86_l2_cache_size = 0;
c.x86_vendor = X86_VENDOR_UNKNOWN;
c.cpuid_level = -1; /* CPUID not detected */
c.x86_model = c.x86_mask = 0; /* So far unknown... */
- c.x86_max_cores = 1;
+ c.x86_num_cores = 1;
memset(&c.x86_capability, 0, sizeof(c.x86_capability));
memset(&c.x86_vendor_id, 0, sizeof(c.x86_vendor_id));
memset(&c.x86_model_id, 0, sizeof(c.x86_model_id));
diff --git a/com32/gpllib/disk/ata.c b/com32/gpllib/disk/ata.c
index 8694470d..b0c2b63c 100644
--- a/com32/gpllib/disk/ata.c
+++ b/com32/gpllib/disk/ata.c
@@ -16,22 +16,22 @@
* caller.
*/
void ata_id_string(const uint16_t * id, unsigned char *s,
- unsigned int ofs, unsigned int len)
+ unsigned int ofs, unsigned int len)
{
- unsigned int c;
+ unsigned int c;
- while (len > 0) {
- c = id[ofs] >> 8;
- *s = c;
- s++;
+ while (len > 0) {
+ c = id[ofs] >> 8;
+ *s = c;
+ s++;
- c = id[ofs] & 0xff;
- *s = c;
- s++;
+ c = id[ofs] & 0xff;
+ *s = c;
+ s++;
- ofs++;
- len -= 2;
- }
+ ofs++;
+ len -= 2;
+ }
}
/**
@@ -49,14 +49,14 @@ void ata_id_string(const uint16_t * id, unsigned char *s,
* caller.
*/
void ata_id_c_string(const uint16_t * id, unsigned char *s,
- unsigned int ofs, unsigned int len)
+ unsigned int ofs, unsigned int len)
{
- unsigned char *p;
+ unsigned char *p;
- ata_id_string(id, s, ofs, len - 1);
+ ata_id_string(id, s, ofs, len - 1);
- p = s + strnlen(s, len - 1);
- while (p > s && p[-1] == ' ')
- p--;
- *p = '\0';
+ p = s + strnlen(s, len - 1);
+ while (p > s && p[-1] == ' ')
+ p--;
+ *p = '\0';
}
diff --git a/com32/gpllib/disk/bootloaders.c b/com32/gpllib/disk/bootloaders.c
index 4b3962ae..29aecbd4 100644
--- a/com32/gpllib/disk/bootloaders.c
+++ b/com32/gpllib/disk/bootloaders.c
@@ -23,24 +23,24 @@
* @buffer_size: @buffer size
**/
int get_bootloader_string(const struct driveinfo *d, const struct part_entry *p,
- char* buffer, const int buffer_size)
+ char *buffer, const int buffer_size)
{
- char boot_sector[SECTOR * sizeof(char)];
+ char boot_sector[SECTOR * sizeof(char)];
- if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1)
- return -1;
- else {
- if (!strncmp(boot_sector + 3, "SYSLINUX", 8))
- strncpy(buffer, "SYSLINUX", buffer_size - 1);
- else if (!strncmp(boot_sector + 3, "EXTLINUX", 8))
- strncpy(buffer, "EXTLINUX", buffer_size - 1);
- else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8))
- strncpy(buffer, "MSWIN4.1", buffer_size - 1);
- else
- return -1;
- /* Add more... */
+ if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1)
+ return -1;
+ else {
+ if (!strncmp(boot_sector + 3, "SYSLINUX", 8))
+ strncpy(buffer, "SYSLINUX", buffer_size - 1);
+ else if (!strncmp(boot_sector + 3, "EXTLINUX", 8))
+ strncpy(buffer, "EXTLINUX", buffer_size - 1);
+ else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8))
+ strncpy(buffer, "MSWIN4.1", buffer_size - 1);
+ else
+ return -1;
+ /* Add more... */
- buffer[buffer_size - 1] = '\0';
- return 0;
- }
+ buffer[buffer_size - 1] = '\0';
+ return 0;
+ }
}
diff --git a/com32/gpllib/disk/error.c b/com32/gpllib/disk/error.c
index b3fb6ce1..fe4722e1 100644
--- a/com32/gpllib/disk/error.c
+++ b/com32/gpllib/disk/error.c
@@ -17,7 +17,7 @@
*
* Fill @buffer_ptr with the last errno_disk
**/
-void get_error(const char* s)
+void get_error(const char *s)
{
- fprintf(stderr, "%s: error %d\n", s, errno_disk);
+ fprintf(stderr, "%s: error %d\n", s, errno_disk);
}
diff --git a/com32/gpllib/disk/geom.c b/com32/gpllib/disk/geom.c
index 2305ed16..9e673ed4 100644
--- a/com32/gpllib/disk/geom.c
+++ b/com32/gpllib/disk/geom.c
@@ -22,25 +22,25 @@
/**
* lba_to_chs - split given lba into cylinders/heads/sectors
**/
-void lba_to_chs(const struct driveinfo* drive_info, const int lba,
- unsigned int* cylinder, unsigned int* head,
- unsigned int* sector)
+void lba_to_chs(const struct driveinfo *drive_info, const int lba,
+ unsigned int *cylinder, unsigned int *head,
+ unsigned int *sector)
{
- unsigned int track;
-
- /* Use EDD, if valid */
- if (drive_info->edd_params.sectors_per_track > 0 &&
- drive_info->edd_params.heads > 0) {
- *cylinder = (lba % drive_info->edd_params.sectors_per_track) + 1;
- track = lba / drive_info->edd_params.sectors_per_track;
- *head = track % drive_info->edd_params.heads;
- *sector = track / drive_info->edd_params.heads;
- } else if (drive_info->cbios) {
- *cylinder = (lba % drive_info->legacy_sectors_per_track) + 1;
- track = lba / drive_info->legacy_sectors_per_track;
- *head = track % (drive_info->legacy_max_head + 1);
- *sector = track / (drive_info->legacy_max_head + 1);
- }
+ unsigned int track;
+
+ /* Use EDD, if valid */
+ if (drive_info->edd_params.sectors_per_track > 0 &&
+ drive_info->edd_params.heads > 0) {
+ *cylinder = (lba % drive_info->edd_params.sectors_per_track) + 1;
+ track = lba / drive_info->edd_params.sectors_per_track;
+ *head = track % drive_info->edd_params.heads;
+ *sector = track / drive_info->edd_params.heads;
+ } else if (drive_info->cbios) {
+ *cylinder = (lba % drive_info->legacy_sectors_per_track) + 1;
+ track = lba / drive_info->legacy_sectors_per_track;
+ *head = track % (drive_info->legacy_max_head + 1);
+ *sector = track / (drive_info->legacy_max_head + 1);
+ }
}
/**
@@ -76,28 +76,27 @@ void lba_to_chs(const struct driveinfo* drive_info, const int lba,
* extended drive parameter table is valid (see #00273,#00278)
* 3-15 reserved (0)
**/
-static int detect_extensions(struct driveinfo* drive_info)
+static int detect_extensions(struct driveinfo *drive_info)
{
- com32sys_t getebios, ebios;
-
- memset(&getebios, 0, sizeof getebios);
- memset(&ebios, 0, sizeof ebios);
-
- getebios.eflags.b[0] = 0x3; /* CF set */
- getebios.ebx.w[0] = 0x55aa;
- getebios.edx.b[0] = drive_info->disk;
- getebios.eax.b[1] = 0x41;
-
- __intcall(0x13, &getebios, &ebios);
-
- if ( !(ebios.eflags.l & EFLAGS_CF) &&
- ebios.ebx.w[0] == 0xaa55 ) {
- drive_info->ebios = 1;
- drive_info->edd_version = ebios.eax.b[1];
- drive_info->edd_functionality_subset = ebios.ecx.w[0];
- return 0;
- } else
- return -1; /* Drive does not exist? */
+ com32sys_t getebios, ebios;
+
+ memset(&getebios, 0, sizeof getebios);
+ memset(&ebios, 0, sizeof ebios);
+
+ getebios.eflags.b[0] = 0x3; /* CF set */
+ getebios.ebx.w[0] = 0x55aa;
+ getebios.edx.b[0] = drive_info->disk;
+ getebios.eax.b[1] = 0x41;
+
+ __intcall(0x13, &getebios, &ebios);
+
+ if (!(ebios.eflags.l & EFLAGS_CF) && ebios.ebx.w[0] == 0xaa55) {
+ drive_info->ebios = 1;
+ drive_info->edd_version = ebios.eax.b[1];
+ drive_info->edd_functionality_subset = ebios.ecx.w[0];
+ return 0;
+ } else
+ return -1; /* Drive does not exist? */
}
/**
@@ -118,39 +117,39 @@ static int detect_extensions(struct driveinfo* drive_info)
* numbers, stopping as soon as the number of valid drives encountered
* equals the value in 0040h:0075h
**/
-static int get_drive_parameters_with_extensions(struct driveinfo* drive_info)
+static int get_drive_parameters_with_extensions(struct driveinfo *drive_info)
{
- com32sys_t inreg, outreg;
- struct edd_device_parameters *dp = __com32.cs_bounce;
+ com32sys_t inreg, outreg;
+ struct edd_device_parameters *dp = __com32.cs_bounce;
- memset(&inreg, 0, sizeof inreg);
+ memset(&inreg, 0, sizeof inreg);
- /*
- * The caller shall set this value to the maximum Result Buffer
- * length, in bytes. If the length of this buffer is less than 30
- * bytes, this function shall not return the pointer to Drive Parameter
- * Table (DPT) extension. If the buffer length is 30 or greater on
- * entry, it shall be set to 30 on exit. If the buffer length is
- * between 26 and 29, it shall be set to 26 on exit.
- * If the buffer length is less than 26 on entry an error shall be
- * returned.
- */
- dp->len = sizeof(struct edd_device_parameters);
+ /*
+ * The caller shall set this value to the maximum Result Buffer
+ * length, in bytes. If the length of this buffer is less than 30
+ * bytes, this function shall not return the pointer to Drive Parameter
+ * Table (DPT) extension. If the buffer length is 30 or greater on
+ * entry, it shall be set to 30 on exit. If the buffer length is
+ * between 26 and 29, it shall be set to 26 on exit.
+ * If the buffer length is less than 26 on entry an error shall be
+ * returned.
+ */
+ dp->len = sizeof(struct edd_device_parameters);
- inreg.esi.w[0] = OFFS(dp);
- inreg.ds = SEG(dp);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.b[1] = 0x48;
+ inreg.esi.w[0] = OFFS(dp);
+ inreg.ds = SEG(dp);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.b[1] = 0x48;
- __intcall(0x13, &inreg, &outreg);
+ __intcall(0x13, &inreg, &outreg);
- /* CF set on error */
- if ( outreg.eflags.l & EFLAGS_CF )
- return outreg.eax.b[1];
+ /* CF set on error */
+ if (outreg.eflags.l & EFLAGS_CF)
+ return outreg.eax.b[1];
- memcpy(&drive_info->edd_params, dp, sizeof drive_info->edd_params);
+ memcpy(&drive_info->edd_params, dp, sizeof drive_info->edd_params);
- return 0;
+ return 0;
}
/**
@@ -201,53 +200,53 @@ static int get_drive_parameters_with_extensions(struct driveinfo* drive_info)
* SeeAlso: AH=06h"Adaptec",AH=13h"SyQuest",AH=48h,AH=15h,INT 1E
* SeeAlso: INT 41"HARD DISK 0"
**/
-static int get_drive_parameters_without_extensions(struct driveinfo* drive_info)
+static int get_drive_parameters_without_extensions(struct driveinfo *drive_info)
{
- com32sys_t getparm, parm;
+ com32sys_t getparm, parm;
- memset(&getparm, 0, sizeof getparm);
- memset(&parm, 0, sizeof parm);
+ memset(&getparm, 0, sizeof getparm);
+ memset(&parm, 0, sizeof parm);
- /* Ralf Brown recommends setting ES:DI to 0:0 */
- getparm.esi.w[0] = 0;
- getparm.ds = 0;
- getparm.edx.b[0] = drive_info->disk;
- getparm.eax.b[1] = 0x08;
+ /* Ralf Brown recommends setting ES:DI to 0:0 */
+ getparm.esi.w[0] = 0;
+ getparm.ds = 0;
+ getparm.edx.b[0] = drive_info->disk;
+ getparm.eax.b[1] = 0x08;
- __intcall(0x13, &getparm, &parm);
+ __intcall(0x13, &getparm, &parm);
- /* CF set on error */
- if ( parm.eflags.l & EFLAGS_CF )
- return parm.eax.b[1];
+ /* CF set on error */
+ if (parm.eflags.l & EFLAGS_CF)
+ return parm.eax.b[1];
- /* DL contains the maximum drive number (it starts at 0) */
- drive_info->legacy_max_drive = parm.edx.b[0];
+ /* DL contains the maximum drive number (it starts at 0) */
+ drive_info->legacy_max_drive = parm.edx.b[0];
- // XXX broken
- /* Drive specified greater than the bumber of attached drives */
- //if (drive_info->disk > drive_info->drives)
- // return -1;
+ // XXX broken
+ /* Drive specified greater than the bumber of attached drives */
+ //if (drive_info->disk > drive_info->drives)
+ // return -1;
- drive_info->legacy_type = parm.ebx.b[0];
+ drive_info->legacy_type = parm.ebx.b[0];
- /* DH contains the maximum head number (it starts at 0) */
- drive_info->legacy_max_head = parm.edx.b[1];
+ /* DH contains the maximum head number (it starts at 0) */
+ drive_info->legacy_max_head = parm.edx.b[1];
- /* Maximum sector number (bits 5-0) per track */
- drive_info->legacy_sectors_per_track = parm.ecx.b[0] & 0x3f;
+ /* Maximum sector number (bits 5-0) per track */
+ drive_info->legacy_sectors_per_track = parm.ecx.b[0] & 0x3f;
- /*
- * Maximum cylinder number:
- * CH = low eight bits of maximum cylinder number
- * CL = high two bits of maximum cylinder number (bits 7-6)
- */
- drive_info->legacy_max_cylinder = parm.ecx.b[1] +
- ((parm.ecx.b[0] & 0xc0) << 2);
+ /*
+ * Maximum cylinder number:
+ * CH = low eight bits of maximum cylinder number
+ * CL = high two bits of maximum cylinder number (bits 7-6)
+ */
+ drive_info->legacy_max_cylinder = parm.ecx.b[1] +
+ ((parm.ecx.b[0] & 0xc0) << 2);
- if ( drive_info->legacy_sectors_per_track > 0 )
- drive_info->cbios = 1; /* Valid geometry */
+ if (drive_info->legacy_sectors_per_track > 0)
+ drive_info->cbios = 1; /* Valid geometry */
- return 0;
+ return 0;
}
/**
@@ -256,17 +255,17 @@ static int get_drive_parameters_without_extensions(struct driveinfo* drive_info)
**/
int get_drive_parameters(struct driveinfo *drive_info)
{
- int return_code;
+ int return_code;
- if (detect_extensions(drive_info))
- return -1;
+ if (detect_extensions(drive_info))
+ return -1;
- return_code = get_drive_parameters_without_extensions(drive_info);
+ return_code = get_drive_parameters_without_extensions(drive_info);
- /* If geometry isn't valid, no need to try to get more info about the drive*/
- /* Looks like in can confuse some optical drives */
- if (drive_info->ebios && drive_info->cbios)
- get_drive_parameters_with_extensions(drive_info);
+ /* If geometry isn't valid, no need to try to get more info about the drive */
+ /* Looks like in can confuse some optical drives */
+ if (drive_info->ebios && drive_info->cbios)
+ get_drive_parameters_with_extensions(drive_info);
- return return_code;
+ return return_code;
}
diff --git a/com32/gpllib/disk/labels.c b/com32/gpllib/disk/labels.c
index 7efe1ad1..8017d48a 100644
--- a/com32/gpllib/disk/labels.c
+++ b/com32/gpllib/disk/labels.c
@@ -10,245 +10,645 @@
#include <stdlib.h>
#include <string.h>
-void get_label(int label, char** buffer_label)
+void get_label(int label, char **buffer_label)
{
- int buffer_size = (80 * sizeof(char));
- char* buffer = malloc(buffer_size);
- *buffer_label = buffer;
+ int buffer_size = (80 * sizeof(char));
+ char *buffer = malloc(buffer_size);
+ *buffer_label = buffer;
- switch (label) {
- case 0x01: strncpy(buffer, "DOS 12-bit fat", buffer_size); break;
- case 0x02: strncpy(buffer, "XENIX root", buffer_size); break;
- case 0x03: strncpy(buffer, "XENIX /usr", buffer_size); break;
- case 0x04: strncpy(buffer, "DOS 3.0+ 16-bit FAT (up to 32M)", buffer_size); break;
- case 0x05: strncpy(buffer, "DOS 3.3+ Extended Partition", buffer_size); break;
- case 0x06: strncpy(buffer, "DOS 3.31+ 16-bit FAT (over 32M)", buffer_size); break;
- case 0x07: strncpy(buffer, "OS/2 IFS (e.g., HPFS)", buffer_size); break;
+ switch (label) {
+ case 0x01:
+ strncpy(buffer, "DOS 12-bit fat", buffer_size);
+ break;
+ case 0x02:
+ strncpy(buffer, "XENIX root", buffer_size);
+ break;
+ case 0x03:
+ strncpy(buffer, "XENIX /usr", buffer_size);
+ break;
+ case 0x04:
+ strncpy(buffer, "DOS 3.0+ 16-bit FAT (up to 32M)", buffer_size);
+ break;
+ case 0x05:
+ strncpy(buffer, "DOS 3.3+ Extended Partition", buffer_size);
+ break;
+ case 0x06:
+ strncpy(buffer, "DOS 3.31+ 16-bit FAT (over 32M)", buffer_size);
+ break;
+ case 0x07:
+ strncpy(buffer, "OS/2 IFS (e.g., HPFS)", buffer_size);
+ break;
//case 0x07: strncpy(buffer, "Advanced Unix", buffer_size); break;
//case 0x07: strncpy(buffer, "Windows NT NTFS", buffer_size); break;
//case 0x07: strncpy(buffer, "QNX2.x (pre-1988)", buffer_size); break;
- case 0x08: strncpy(buffer, "OS/2 (v1.0-1.3 only)", buffer_size); break;
+ case 0x08:
+ strncpy(buffer, "OS/2 (v1.0-1.3 only)", buffer_size);
+ break;
//case 0x08: strncpy(buffer, "AIX boot partition", buffer_size); break;
//case 0x08: strncpy(buffer, "SplitDrive", buffer_size); break;
//case 0x08: strncpy(buffer, "DELL partition spanning multiple drives", buffer_size); break;
//case 0x08: strncpy(buffer, "Commodore DOS", buffer_size); break;
//case 0x08: strncpy(buffer, "QNX 1.x and 2.x ("qny")", buffer_size); break;
- case 0x09: strncpy(buffer, "AIX data partition", buffer_size); break;
+ case 0x09:
+ strncpy(buffer, "AIX data partition", buffer_size);
+ break;
//case 0x09: strncpy(buffer, "Coherent filesystem", buffer_size); break;
//case 0x09: strncpy(buffer, "QNX 1.x and 2.x ("qnz")", buffer_size); break;
- case 0x0a: strncpy(buffer, "OS/2 Boot Manager", buffer_size); break;
+ case 0x0a:
+ strncpy(buffer, "OS/2 Boot Manager", buffer_size);
+ break;
//case 0x0a: strncpy(buffer, "Coherent swap partition", buffer_size); break;
//case 0x0a: strncpy(buffer, "OPUS", buffer_size); break;
- case 0x0b: strncpy(buffer, "WIN95 OSR2 32-bit FAT", buffer_size); break;
- case 0x0c: strncpy(buffer, "WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size); break;
- case 0x0e: strncpy(buffer, "WIN95: DOS 16-bit FAT, LBA-mapped", buffer_size); break;
- case 0x0f: strncpy(buffer, "WIN95: Extended partition, LBA-mapped", buffer_size); break;
- case 0x10: strncpy(buffer, "OPUS (?)", buffer_size); break;
- case 0x11: strncpy(buffer, "Hidden DOS 12-bit FAT", buffer_size); break;
- case 0x12: strncpy(buffer, "Compaq config partition", buffer_size); break;
- case 0x14: strncpy(buffer, "Hidden DOS 16-bit FAT <32M", buffer_size); break;
- case 0x16: strncpy(buffer, "Hidden DOS 16-bit FAT >=32M", buffer_size); break;
- case 0x17: strncpy(buffer, "Hidden IFS (e.g., HPFS)", buffer_size); break;
- case 0x18: strncpy(buffer, "AST SmartSleep Partition", buffer_size); break;
- case 0x19: strncpy(buffer, "Unused (Claimed for Willowtech Photon COS)", buffer_size); break;
- case 0x1b: strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT", buffer_size); break;
- case 0x1c: strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size); break;
- case 0x1e: strncpy(buffer, "Hidden WIN95 16-bit FAT, LBA-mapped", buffer_size); break;
- case 0x20: strncpy(buffer, "Unused", buffer_size); break;
- case 0x21: strncpy(buffer, "Reserved", buffer_size); break;
+ case 0x0b:
+ strncpy(buffer, "WIN95 OSR2 32-bit FAT", buffer_size);
+ break;
+ case 0x0c:
+ strncpy(buffer, "WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x0e:
+ strncpy(buffer, "WIN95: DOS 16-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x0f:
+ strncpy(buffer, "WIN95: Extended partition, LBA-mapped", buffer_size);
+ break;
+ case 0x10:
+ strncpy(buffer, "OPUS (?)", buffer_size);
+ break;
+ case 0x11:
+ strncpy(buffer, "Hidden DOS 12-bit FAT", buffer_size);
+ break;
+ case 0x12:
+ strncpy(buffer, "Compaq config partition", buffer_size);
+ break;
+ case 0x14:
+ strncpy(buffer, "Hidden DOS 16-bit FAT <32M", buffer_size);
+ break;
+ case 0x16:
+ strncpy(buffer, "Hidden DOS 16-bit FAT >=32M", buffer_size);
+ break;
+ case 0x17:
+ strncpy(buffer, "Hidden IFS (e.g., HPFS)", buffer_size);
+ break;
+ case 0x18:
+ strncpy(buffer, "AST SmartSleep Partition", buffer_size);
+ break;
+ case 0x19:
+ strncpy(buffer, "Unused (Claimed for Willowtech Photon COS)",
+ buffer_size);
+ break;
+ case 0x1b:
+ strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT", buffer_size);
+ break;
+ case 0x1c:
+ strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT, LBA-mapped",
+ buffer_size);
+ break;
+ case 0x1e:
+ strncpy(buffer, "Hidden WIN95 16-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x20:
+ strncpy(buffer, "Unused", buffer_size);
+ break;
+ case 0x21:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
//case 0x21: strncpy(buffer, "Unused", buffer_size); break;
- case 0x22: strncpy(buffer, "Unused", buffer_size); break;
- case 0x23: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x24: strncpy(buffer, "NEC DOS 3.x", buffer_size); break;
- case 0x26: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x31: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x32: strncpy(buffer, "NOS", buffer_size); break;
- case 0x33: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x34: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x35: strncpy(buffer, "JFS on OS/2 or eCS", buffer_size); break;
- case 0x36: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x38: strncpy(buffer, "THEOS ver 3.2 2gb partition", buffer_size); break;
- case 0x39: strncpy(buffer, "Plan 9 partition", buffer_size); break;
+ case 0x22:
+ strncpy(buffer, "Unused", buffer_size);
+ break;
+ case 0x23:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x24:
+ strncpy(buffer, "NEC DOS 3.x", buffer_size);
+ break;
+ case 0x26:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x31:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x32:
+ strncpy(buffer, "NOS", buffer_size);
+ break;
+ case 0x33:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x34:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x35:
+ strncpy(buffer, "JFS on OS/2 or eCS", buffer_size);
+ break;
+ case 0x36:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x38:
+ strncpy(buffer, "THEOS ver 3.2 2gb partition", buffer_size);
+ break;
+ case 0x39:
+ strncpy(buffer, "Plan 9 partition", buffer_size);
+ break;
//case 0x39: strncpy(buffer, "THEOS ver 4 spanned partition", buffer_size); break;
- case 0x3a: strncpy(buffer, "THEOS ver 4 4gb partition", buffer_size); break;
- case 0x3b: strncpy(buffer, "THEOS ver 4 extended partition", buffer_size); break;
- case 0x3c: strncpy(buffer, "PartitionMagic recovery partition", buffer_size); break;
- case 0x3d: strncpy(buffer, "Hidden NetWare", buffer_size); break;
- case 0x40: strncpy(buffer, "Venix 80286", buffer_size); break;
- case 0x41: strncpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size); break;
+ case 0x3a:
+ strncpy(buffer, "THEOS ver 4 4gb partition", buffer_size);
+ break;
+ case 0x3b:
+ strncpy(buffer, "THEOS ver 4 extended partition", buffer_size);
+ break;
+ case 0x3c:
+ strncpy(buffer, "PartitionMagic recovery partition", buffer_size);
+ break;
+ case 0x3d:
+ strncpy(buffer, "Hidden NetWare", buffer_size);
+ break;
+ case 0x40:
+ strncpy(buffer, "Venix 80286", buffer_size);
+ break;
+ case 0x41:
+ strncpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size);
+ break;
//case 0x41: strncpy(buffer, "Personal RISC Boot", buffer_size); break;
//case 0x41: strncpy(buffer, "PPC PReP (Power PC Reference Platform) Boot", buffer_size); break;
- case 0x42: strncpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size); break;
+ case 0x42:
+ strncpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size);
+ break;
//case 0x42: strncpy(buffer, "SFS (Secure Filesystem)", buffer_size); break;
//case 0x42: strncpy(buffer, "Windows 2000 marker", buffer_size); break;
- case 0x43: strncpy(buffer, "Linux native (sharing disk with DRDOS)", buffer_size); break;
- case 0x44: strncpy(buffer, "GoBack partition", buffer_size); break;
- case 0x45: strncpy(buffer, "Boot-US boot manager", buffer_size); break;
+ case 0x43:
+ strncpy(buffer, "Linux native (sharing disk with DRDOS)", buffer_size);
+ break;
+ case 0x44:
+ strncpy(buffer, "GoBack partition", buffer_size);
+ break;
+ case 0x45:
+ strncpy(buffer, "Boot-US boot manager", buffer_size);
+ break;
//case 0x45: strncpy(buffer, "Priam", buffer_size); break;
//case 0x45: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x46: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x47: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x48: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x4a: strncpy(buffer, "AdaOS Aquila (Default)", buffer_size); break;
+ case 0x46:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x47:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x48:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x4a:
+ strncpy(buffer, "AdaOS Aquila (Default)", buffer_size);
+ break;
//case 0x4a: strncpy(buffer, "ALFS/THIN lightweight filesystem for DOS", buffer_size); break;
- case 0x4c: strncpy(buffer, "Oberon partition", buffer_size); break;
- case 0x4d: strncpy(buffer, "QNX4.x", buffer_size); break;
- case 0x4e: strncpy(buffer, "QNX4.x 2nd part", buffer_size); break;
- case 0x4f: strncpy(buffer, "QNX4.x 3rd part", buffer_size); break;
+ case 0x4c:
+ strncpy(buffer, "Oberon partition", buffer_size);
+ break;
+ case 0x4d:
+ strncpy(buffer, "QNX4.x", buffer_size);
+ break;
+ case 0x4e:
+ strncpy(buffer, "QNX4.x 2nd part", buffer_size);
+ break;
+ case 0x4f:
+ strncpy(buffer, "QNX4.x 3rd part", buffer_size);
+ break;
//case 0x4f: strncpy(buffer, "Oberon partition", buffer_size); break;
- case 0x50: strncpy(buffer, "OnTrack Disk Manager (older versions) RO", buffer_size); break;
+ case 0x50:
+ strncpy(buffer, "OnTrack Disk Manager (older versions) RO",
+ buffer_size);
+ break;
//case 0x50: strncpy(buffer, "Lynx RTOS", buffer_size); break;
//case 0x50: strncpy(buffer, "Native Oberon (alt)", buffer_size); break;
- case 0x51: strncpy(buffer, "OnTrack Disk Manager RW (DM6 Aux1)", buffer_size); break;
+ case 0x51:
+ strncpy(buffer, "OnTrack Disk Manager RW (DM6 Aux1)", buffer_size);
+ break;
//case 0x51: strncpy(buffer, "Novell", buffer_size); break;
- case 0x52: strncpy(buffer, "CP/M", buffer_size); break;
+ case 0x52:
+ strncpy(buffer, "CP/M", buffer_size);
+ break;
//case 0x52: strncpy(buffer, "Microport SysV/AT", buffer_size); break;
- case 0x53: strncpy(buffer, "Disk Manager 6.0 Aux3", buffer_size); break;
- case 0x54: strncpy(buffer, "Disk Manager 6.0 Dynamic Drive Overlay", buffer_size); break;
- case 0x55: strncpy(buffer, "EZ-Drive", buffer_size); break;
- case 0x56: strncpy(buffer, "Golden Bow VFeature Partitioned Volume.", buffer_size); break;
+ case 0x53:
+ strncpy(buffer, "Disk Manager 6.0 Aux3", buffer_size);
+ break;
+ case 0x54:
+ strncpy(buffer, "Disk Manager 6.0 Dynamic Drive Overlay", buffer_size);
+ break;
+ case 0x55:
+ strncpy(buffer, "EZ-Drive", buffer_size);
+ break;
+ case 0x56:
+ strncpy(buffer, "Golden Bow VFeature Partitioned Volume.", buffer_size);
+ break;
//case 0x56: strncpy(buffer, "DM converted to EZ-BIOS", buffer_size); break;
- case 0x57: strncpy(buffer, "DrivePro", buffer_size); break;
+ case 0x57:
+ strncpy(buffer, "DrivePro", buffer_size);
+ break;
//case 0x57: strncpy(buffer, "VNDI Partition", buffer_size); break;
- case 0x5c: strncpy(buffer, "Priam EDisk", buffer_size); break;
- case 0x61: strncpy(buffer, "SpeedStor", buffer_size); break;
- case 0x63: strncpy(buffer, "Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU Hurd", buffer_size); break;
- case 0x64: strncpy(buffer, "PC-ARMOUR protected partition", buffer_size); break;
+ case 0x5c:
+ strncpy(buffer, "Priam EDisk", buffer_size);
+ break;
+ case 0x61:
+ strncpy(buffer, "SpeedStor", buffer_size);
+ break;
+ case 0x63:
+ strncpy(buffer,
+ "Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU Hurd",
+ buffer_size);
+ break;
+ case 0x64:
+ strncpy(buffer, "PC-ARMOUR protected partition", buffer_size);
+ break;
//case 0x64: strncpy(buffer, "Novell Netware 286, 2.xx", buffer_size); break;
- case 0x65: strncpy(buffer, "Novell Netware 386, 3.xx or 4.xx", buffer_size); break;
- case 0x66: strncpy(buffer, "Novell Netware SMS Partition", buffer_size); break;
- case 0x67: strncpy(buffer, "Novell", buffer_size); break;
- case 0x68: strncpy(buffer, "Novell", buffer_size); break;
- case 0x69: strncpy(buffer, "Novell Netware 5+, Novell Netware NSS Partition", buffer_size); break;
- case 0x70: strncpy(buffer, "DiskSecure Multi-Boot", buffer_size); break;
- case 0x71: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x73: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x74: strncpy(buffer, "Reserved", buffer_size); break;
+ case 0x65:
+ strncpy(buffer, "Novell Netware 386, 3.xx or 4.xx", buffer_size);
+ break;
+ case 0x66:
+ strncpy(buffer, "Novell Netware SMS Partition", buffer_size);
+ break;
+ case 0x67:
+ strncpy(buffer, "Novell", buffer_size);
+ break;
+ case 0x68:
+ strncpy(buffer, "Novell", buffer_size);
+ break;
+ case 0x69:
+ strncpy(buffer, "Novell Netware 5+, Novell Netware NSS Partition",
+ buffer_size);
+ break;
+ case 0x70:
+ strncpy(buffer, "DiskSecure Multi-Boot", buffer_size);
+ break;
+ case 0x71:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x73:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x74:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
//case 0x74: strncpy(buffer, "Scramdisk partition", buffer_size); break;
- case 0x75: strncpy(buffer, "IBM PC/IX", buffer_size); break;
- case 0x76: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x77: strncpy(buffer, "M2FS/M2CS partition", buffer_size); break;
+ case 0x75:
+ strncpy(buffer, "IBM PC/IX", buffer_size);
+ break;
+ case 0x76:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x77:
+ strncpy(buffer, "M2FS/M2CS partition", buffer_size);
+ break;
//case 0x77: strncpy(buffer, "VNDI Partition", buffer_size); break;
- case 0x78: strncpy(buffer, "XOSL FS", buffer_size); break;
- case 0x7E: strncpy(buffer, " ", buffer_size); break;
- case 0x80: strncpy(buffer, "MINIX until 1.4a", buffer_size); break;
- case 0x81: strncpy(buffer, "MINIX since 1.4b, early Linux", buffer_size); break;
+ case 0x78:
+ strncpy(buffer, "XOSL FS", buffer_size);
+ break;
+ case 0x7E:
+ strncpy(buffer, " ", buffer_size);
+ break;
+ case 0x80:
+ strncpy(buffer, "MINIX until 1.4a", buffer_size);
+ break;
+ case 0x81:
+ strncpy(buffer, "MINIX since 1.4b, early Linux", buffer_size);
+ break;
//case 0x81: strncpy(buffer, "Mitac disk manager", buffer_size); break;
//case 0x82: strncpy(buffer, "Prime", buffer_size); break;
//case 0x82: strncpy(buffer, "Solaris x86", buffer_size); break;
- case 0x82: strncpy(buffer, "Linux swap", buffer_size); break;
- case 0x83: strncpy(buffer, "Linux native (usually ext2fs)", buffer_size); break;
- case 0x84: strncpy(buffer, "OS/2 hidden C: drive", buffer_size); break;
+ case 0x82:
+ strncpy(buffer, "Linux swap", buffer_size);
+ break;
+ case 0x83:
+ strncpy(buffer, "Linux native (usually ext2fs)", buffer_size);
+ break;
+ case 0x84:
+ strncpy(buffer, "OS/2 hidden C: drive", buffer_size);
+ break;
//case 0x84: strncpy(buffer, "Hibernation partition", buffer_size); break;
- case 0x85: strncpy(buffer, "Linux extended partition", buffer_size); break;
+ case 0x85:
+ strncpy(buffer, "Linux extended partition", buffer_size);
+ break;
//case 0x86: strncpy(buffer, "Old Linux RAID partition superblock", buffer_size); break;
- case 0x86: strncpy(buffer, "NTFS volume set", buffer_size); break;
- case 0x87: strncpy(buffer, "NTFS volume set", buffer_size); break;
- case 0x8a: strncpy(buffer, "Linux Kernel Partition (used by AiR-BOOT)", buffer_size); break;
- case 0x8b: strncpy(buffer, "Legacy Fault Tolerant FAT32 volume", buffer_size); break;
- case 0x8c: strncpy(buffer, "Legacy Fault Tolerant FAT32 volume using BIOS extd INT 13h", buffer_size); break;
- case 0x8d: strncpy(buffer, "Free FDISK hidden Primary DOS FAT12 partitition", buffer_size); break;
- case 0x8e: strncpy(buffer, "Linux Logical Volume Manager partition", buffer_size); break;
- case 0x90: strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition", buffer_size); break;
- case 0x91: strncpy(buffer, "Free FDISK hidden DOS extended partitition", buffer_size); break;
- case 0x92: strncpy(buffer, "Free FDISK hidden Primary DOS large FAT16 partitition", buffer_size); break;
- case 0x93: strncpy(buffer, "Hidden Linux native partition", buffer_size); break;
+ case 0x86:
+ strncpy(buffer, "NTFS volume set", buffer_size);
+ break;
+ case 0x87:
+ strncpy(buffer, "NTFS volume set", buffer_size);
+ break;
+ case 0x8a:
+ strncpy(buffer, "Linux Kernel Partition (used by AiR-BOOT)",
+ buffer_size);
+ break;
+ case 0x8b:
+ strncpy(buffer, "Legacy Fault Tolerant FAT32 volume", buffer_size);
+ break;
+ case 0x8c:
+ strncpy(buffer,
+ "Legacy Fault Tolerant FAT32 volume using BIOS extd INT 13h",
+ buffer_size);
+ break;
+ case 0x8d:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT12 partitition",
+ buffer_size);
+ break;
+ case 0x8e:
+ strncpy(buffer, "Linux Logical Volume Manager partition", buffer_size);
+ break;
+ case 0x90:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition",
+ buffer_size);
+ break;
+ case 0x91:
+ strncpy(buffer, "Free FDISK hidden DOS extended partitition",
+ buffer_size);
+ break;
+ case 0x92:
+ strncpy(buffer, "Free FDISK hidden Primary DOS large FAT16 partitition",
+ buffer_size);
+ break;
+ case 0x93:
+ strncpy(buffer, "Hidden Linux native partition", buffer_size);
+ break;
//case 0x93: strncpy(buffer, "Amoeba", buffer_size); break;
- case 0x94: strncpy(buffer, "Amoeba bad block table", buffer_size); break;
- case 0x95: strncpy(buffer, "MIT EXOPC native partitions", buffer_size); break;
- case 0x97: strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition", buffer_size); break;
- case 0x98: strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition (LBA)", buffer_size); break;
- case 0x99: strncpy(buffer, "DCE376 logical drive", buffer_size); break;
- case 0x9a: strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition (LBA)", buffer_size); break;
- case 0x9b: strncpy(buffer, "Free FDISK hidden DOS extended partitition (LBA)", buffer_size); break;
- case 0x9f: strncpy(buffer, "BSD/OS", buffer_size); break;
- case 0xa0: strncpy(buffer, "Laptop hibernation partition", buffer_size); break;
- case 0xa1: strncpy(buffer, "Laptop hibernation partition", buffer_size); break;
+ case 0x94:
+ strncpy(buffer, "Amoeba bad block table", buffer_size);
+ break;
+ case 0x95:
+ strncpy(buffer, "MIT EXOPC native partitions", buffer_size);
+ break;
+ case 0x97:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition",
+ buffer_size);
+ break;
+ case 0x98:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x99:
+ strncpy(buffer, "DCE376 logical drive", buffer_size);
+ break;
+ case 0x9a:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x9b:
+ strncpy(buffer, "Free FDISK hidden DOS extended partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x9f:
+ strncpy(buffer, "BSD/OS", buffer_size);
+ break;
+ case 0xa0:
+ strncpy(buffer, "Laptop hibernation partition", buffer_size);
+ break;
+ case 0xa1:
+ strncpy(buffer, "Laptop hibernation partition", buffer_size);
+ break;
//case 0xa1: strncpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break;
- case 0xa3: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xa4: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xa5: strncpy(buffer, "BSD/386, 386BSD, NetBSD, FreeBSD", buffer_size); break;
- case 0xa6: strncpy(buffer, "OpenBSD", buffer_size); break;
- case 0xa7: strncpy(buffer, "NEXTSTEP", buffer_size); break;
- case 0xa8: strncpy(buffer, "Mac OS-X", buffer_size); break;
- case 0xa9: strncpy(buffer, "NetBSD", buffer_size); break;
- case 0xaa: strncpy(buffer, "Olivetti Fat 12 1.44Mb Service Partition", buffer_size); break;
- case 0xab: strncpy(buffer, "Mac OS-X Boot partition", buffer_size); break;
+ case 0xa3:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xa4:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xa5:
+ strncpy(buffer, "BSD/386, 386BSD, NetBSD, FreeBSD", buffer_size);
+ break;
+ case 0xa6:
+ strncpy(buffer, "OpenBSD", buffer_size);
+ break;
+ case 0xa7:
+ strncpy(buffer, "NEXTSTEP", buffer_size);
+ break;
+ case 0xa8:
+ strncpy(buffer, "Mac OS-X", buffer_size);
+ break;
+ case 0xa9:
+ strncpy(buffer, "NetBSD", buffer_size);
+ break;
+ case 0xaa:
+ strncpy(buffer, "Olivetti Fat 12 1.44Mb Service Partition",
+ buffer_size);
+ break;
+ case 0xab:
+ strncpy(buffer, "Mac OS-X Boot partition", buffer_size);
+ break;
//case 0xab: strncpy(buffer, "GO! partition", buffer_size); break;
- case 0xae: strncpy(buffer, "ShagOS filesystem", buffer_size); break;
- case 0xaf: strncpy(buffer, "ShagOS swap partition", buffer_size); break;
- case 0xb0: strncpy(buffer, "BootStar Dummy", buffer_size); break;
- case 0xb1: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb3: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb4: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb6: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb7: strncpy(buffer, "BSDI BSD/386 filesystem", buffer_size); break;
- case 0xb8: strncpy(buffer, "BSDI BSD/386 swap partition", buffer_size); break;
- case 0xbb: strncpy(buffer, "Boot Wizard hidden", buffer_size); break;
- case 0xbe: strncpy(buffer, "Solaris 8 boot partition", buffer_size); break;
- case 0xc0: strncpy(buffer, "CTOS", buffer_size); break;
+ case 0xae:
+ strncpy(buffer, "ShagOS filesystem", buffer_size);
+ break;
+ case 0xaf:
+ strncpy(buffer, "ShagOS swap partition", buffer_size);
+ break;
+ case 0xb0:
+ strncpy(buffer, "BootStar Dummy", buffer_size);
+ break;
+ case 0xb1:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb3:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb4:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb6:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb7:
+ strncpy(buffer, "BSDI BSD/386 filesystem", buffer_size);
+ break;
+ case 0xb8:
+ strncpy(buffer, "BSDI BSD/386 swap partition", buffer_size);
+ break;
+ case 0xbb:
+ strncpy(buffer, "Boot Wizard hidden", buffer_size);
+ break;
+ case 0xbe:
+ strncpy(buffer, "Solaris 8 boot partition", buffer_size);
+ break;
+ case 0xc0:
+ strncpy(buffer, "CTOS", buffer_size);
+ break;
//case 0xc0: strncpy(buffer, "REAL/32 secure small partition", buffer_size); break;
//case 0xc0: strncpy(buffer, "NTFT Partition", buffer_size); break;
- case 0xc1: strncpy(buffer, "DRDOS/secured (FAT-12)", buffer_size); break;
- case 0xc2: strncpy(buffer, "Reserved for DR-DOS 7+", buffer_size); break;
+ case 0xc1:
+ strncpy(buffer, "DRDOS/secured (FAT-12)", buffer_size);
+ break;
+ case 0xc2:
+ strncpy(buffer, "Reserved for DR-DOS 7+", buffer_size);
+ break;
//case 0xc2: strncpy(buffer, "Hidden Linux", buffer_size); break;
- case 0xc3: strncpy(buffer, "Hidden Linux swap", buffer_size); break;
- case 0xc4: strncpy(buffer, "DRDOS/secured (FAT-16, < 32M)", buffer_size); break;
- case 0xc5: strncpy(buffer, "DRDOS/secured (extended)", buffer_size); break;
- case 0xc6: strncpy(buffer, "DRDOS/secured (FAT-16, >= 32M)", buffer_size); break;
+ case 0xc3:
+ strncpy(buffer, "Hidden Linux swap", buffer_size);
+ break;
+ case 0xc4:
+ strncpy(buffer, "DRDOS/secured (FAT-16, < 32M)", buffer_size);
+ break;
+ case 0xc5:
+ strncpy(buffer, "DRDOS/secured (extended)", buffer_size);
+ break;
+ case 0xc6:
+ strncpy(buffer, "DRDOS/secured (FAT-16, >= 32M)", buffer_size);
+ break;
//case 0xc6: strncpy(buffer, "Windows NT corrupted FAT16 volume/stripe set", buffer_size); break;
- case 0xc7: strncpy(buffer, "Windows NT corrupted NTFS volume/stripe set", buffer_size); break;
+ case 0xc7:
+ strncpy(buffer, "Windows NT corrupted NTFS volume/stripe set",
+ buffer_size);
+ break;
//case 0xc7: strncpy(buffer, "Syrinx boot", buffer_size); break;
- case 0xc8: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xc9: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xca: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xcb: strncpy(buffer, "reserved for DRDOS/secured (FAT32)", buffer_size); break;
- case 0xcc: strncpy(buffer, "reserved for DRDOS/secured (FAT32, LBA)", buffer_size); break;
- case 0xcd: strncpy(buffer, "CTOS Memdump?", buffer_size); break;
- case 0xce: strncpy(buffer, "reserved for DRDOS/secured (FAT16, LBA)", buffer_size); break;
- case 0xd0: strncpy(buffer, "REAL/32 secure big partition", buffer_size); break;
- case 0xd1: strncpy(buffer, "Old Multiuser DOS secured FAT12", buffer_size); break;
- case 0xd4: strncpy(buffer, "Old Multiuser DOS secured FAT16 <32M", buffer_size); break;
- case 0xd5: strncpy(buffer, "Old Multiuser DOS secured extended partition", buffer_size); break;
- case 0xd6: strncpy(buffer, "Old Multiuser DOS secured FAT16 >=32M", buffer_size); break;
- case 0xd8: strncpy(buffer, "CP/M-86", buffer_size); break;
- case 0xda: strncpy(buffer, "Non-FS Data", buffer_size); break;
- case 0xdb: strncpy(buffer, "Digital Research CP/M, Concurrent CP/M, Concurrent DOS", buffer_size); break;
+ case 0xc8:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xc9:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xca:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xcb:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT32)", buffer_size);
+ break;
+ case 0xcc:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT32, LBA)", buffer_size);
+ break;
+ case 0xcd:
+ strncpy(buffer, "CTOS Memdump?", buffer_size);
+ break;
+ case 0xce:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT16, LBA)", buffer_size);
+ break;
+ case 0xd0:
+ strncpy(buffer, "REAL/32 secure big partition", buffer_size);
+ break;
+ case 0xd1:
+ strncpy(buffer, "Old Multiuser DOS secured FAT12", buffer_size);
+ break;
+ case 0xd4:
+ strncpy(buffer, "Old Multiuser DOS secured FAT16 <32M", buffer_size);
+ break;
+ case 0xd5:
+ strncpy(buffer, "Old Multiuser DOS secured extended partition",
+ buffer_size);
+ break;
+ case 0xd6:
+ strncpy(buffer, "Old Multiuser DOS secured FAT16 >=32M", buffer_size);
+ break;
+ case 0xd8:
+ strncpy(buffer, "CP/M-86", buffer_size);
+ break;
+ case 0xda:
+ strncpy(buffer, "Non-FS Data", buffer_size);
+ break;
+ case 0xdb:
+ strncpy(buffer,
+ "Digital Research CP/M, Concurrent CP/M, Concurrent DOS",
+ buffer_size);
+ break;
//case 0xdb: strncpy(buffer, "CTOS (Convergent Technologies OS -Unisys)", buffer_size); break;
//case 0xdb: strncpy(buffer, "KDG Telemetry SCPU boot", buffer_size); break;
- case 0xdd: strncpy(buffer, "Hidden CTOS Memdump?", buffer_size); break;
- case 0xde: strncpy(buffer, "Dell PowerEdge Server utilities (FAT fs)", buffer_size); break;
- case 0xdf: strncpy(buffer, "DG/UX virtual disk manager partition", buffer_size); break;
+ case 0xdd:
+ strncpy(buffer, "Hidden CTOS Memdump?", buffer_size);
+ break;
+ case 0xde:
+ strncpy(buffer, "Dell PowerEdge Server utilities (FAT fs)",
+ buffer_size);
+ break;
+ case 0xdf:
+ strncpy(buffer, "DG/UX virtual disk manager partition", buffer_size);
+ break;
//case 0xdf: strncpy(buffer, "BootIt EMBRM", buffer_size); break;
- case 0xe0: strncpy(buffer, "Reserved by STMicroelectronics for a filesystem called ST AVFS.", buffer_size); break;
- case 0xe1: strncpy(buffer, "DOS access or SpeedStor 12-bit FAT extended partition", buffer_size); break;
- case 0xe3: strncpy(buffer, "DOS R/O or SpeedStor", buffer_size); break;
- case 0xe4: strncpy(buffer, "SpeedStor 16-bit FAT extended partition < 1024 cyl.", buffer_size); break;
- case 0xe5: strncpy(buffer, "Tandy DOS with logical sectored FAT (According to Powerquest.)", buffer_size); break;
+ case 0xe0:
+ strncpy(buffer,
+ "Reserved by STMicroelectronics for a filesystem called ST AVFS.",
+ buffer_size);
+ break;
+ case 0xe1:
+ strncpy(buffer, "DOS access or SpeedStor 12-bit FAT extended partition",
+ buffer_size);
+ break;
+ case 0xe3:
+ strncpy(buffer, "DOS R/O or SpeedStor", buffer_size);
+ break;
+ case 0xe4:
+ strncpy(buffer, "SpeedStor 16-bit FAT extended partition < 1024 cyl.",
+ buffer_size);
+ break;
+ case 0xe5:
+ strncpy(buffer,
+ "Tandy DOS with logical sectored FAT (According to Powerquest.)",
+ buffer_size);
+ break;
//case 0xe5: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xe6: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xeb: strncpy(buffer, "BFS (aka BeFS)", buffer_size); break;
- case 0xed: strncpy(buffer, "Reserved for Matthias Paul's Sprytix", buffer_size); break;
- case 0xee: strncpy(buffer, "Indication that this legacy MBR is followed by an EFI header", buffer_size); break;
- case 0xef: strncpy(buffer, "Partition that contains an EFI file system", buffer_size); break;
- case 0xf0: strncpy(buffer, "Linux/PA-RISC boot loader", buffer_size); break;
- case 0xf1: strncpy(buffer, "SpeedStor", buffer_size); break;
- case 0xf2: strncpy(buffer, "DOS 3.3+ secondary partition (Powerquest writes: Unisys DOS with logical sectored FAT.)", buffer_size); break;
- case 0xf3: strncpy(buffer, "Reserved (Powerquest writes: Storage Dimensions SpeedStor.)", buffer_size); break;
- case 0xf4: strncpy(buffer, "SpeedStor large partition", buffer_size); break;
+ case 0xe6:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xeb:
+ strncpy(buffer, "BFS (aka BeFS)", buffer_size);
+ break;
+ case 0xed:
+ strncpy(buffer, "Reserved for Matthias Paul's Sprytix", buffer_size);
+ break;
+ case 0xee:
+ strncpy(buffer,
+ "Indication that this legacy MBR is followed by an EFI header",
+ buffer_size);
+ break;
+ case 0xef:
+ strncpy(buffer, "Partition that contains an EFI file system",
+ buffer_size);
+ break;
+ case 0xf0:
+ strncpy(buffer, "Linux/PA-RISC boot loader", buffer_size);
+ break;
+ case 0xf1:
+ strncpy(buffer, "SpeedStor", buffer_size);
+ break;
+ case 0xf2:
+ strncpy(buffer,
+ "DOS 3.3+ secondary partition (Powerquest writes: Unisys DOS with logical sectored FAT.)",
+ buffer_size);
+ break;
+ case 0xf3:
+ strncpy(buffer,
+ "Reserved (Powerquest writes: Storage Dimensions SpeedStor.)",
+ buffer_size);
+ break;
+ case 0xf4:
+ strncpy(buffer, "SpeedStor large partition", buffer_size);
+ break;
//case 0xf4: strncpy(buffer, "Prologue single-volume partition", buffer_size); break;
- case 0xf5: strncpy(buffer, "Prologue multi-volume partition", buffer_size); break;
- case 0xf6: strncpy(buffer, "Reserved (Powerquest writes: Storage Dimensions SpeedStor. )", buffer_size); break;
- case 0xfa: strncpy(buffer, "Bochs", buffer_size); break;
- case 0xfb: strncpy(buffer, "VMware File System partition", buffer_size); break;
- case 0xfc: strncpy(buffer, "VMware Swap partition", buffer_size); break;
- case 0xfd: strncpy(buffer, "Linux raid partition with autodetect using persistent superblock (Powerquest writes: Reserved for FreeDOS. )", buffer_size); break;
- case 0xfe: strncpy(buffer, "SpeedStor > 1024 cyl.", buffer_size); break;
+ case 0xf5:
+ strncpy(buffer, "Prologue multi-volume partition", buffer_size);
+ break;
+ case 0xf6:
+ strncpy(buffer,
+ "Reserved (Powerquest writes: Storage Dimensions SpeedStor. )",
+ buffer_size);
+ break;
+ case 0xfa:
+ strncpy(buffer, "Bochs", buffer_size);
+ break;
+ case 0xfb:
+ strncpy(buffer, "VMware File System partition", buffer_size);
+ break;
+ case 0xfc:
+ strncpy(buffer, "VMware Swap partition", buffer_size);
+ break;
+ case 0xfd:
+ strncpy(buffer,
+ "Linux raid partition with autodetect using persistent superblock (Powerquest writes: Reserved for FreeDOS. )",
+ buffer_size);
+ break;
+ case 0xfe:
+ strncpy(buffer, "SpeedStor > 1024 cyl.", buffer_size);
+ break;
//case 0xfe: strncpy(buffer, "LANstep", buffer_size); break;
//case 0xfe: strncpy(buffer, "IBM PS/2 IML (Initial Microcode Load) partition, located at the end of the disk.", buffer_size); break;
//case 0xfe: strncpy(buffer, "Windows NT Disk Administrator hidden partition", buffer_size); break;
//case 0xfe: strncpy(buffer, "Linux Logical Volume Manager partition (old)", buffer_size); break;
- case 0xff: strncpy(buffer, "Xenix Bad Block Table ", buffer_size); break;
- default: strncpy(buffer, "Unknown", buffer_size); break;
- }
+ case 0xff:
+ strncpy(buffer, "Xenix Bad Block Table ", buffer_size);
+ break;
+ default:
+ strncpy(buffer, "Unknown", buffer_size);
+ break;
+ }
}
diff --git a/com32/gpllib/disk/mbrs.c b/com32/gpllib/disk/mbrs.c
index 0abf087a..b468f791 100644
--- a/com32/gpllib/disk/mbrs.c
+++ b/com32/gpllib/disk/mbrs.c
@@ -20,53 +20,87 @@
* @buffer: pre-allocated buffer
* @buffer_size: @buffer size
**/
-void get_mbr_string(const uint32_t label, char* buffer, const int buffer_size)
+void get_mbr_string(const uint32_t label, char *buffer, const int buffer_size)
{
- /* 2 bytes are usually enough to identify the MBR */
- uint16_t s_label = label >> 16;
+ /* 2 bytes are usually enough to identify the MBR */
+ uint16_t s_label = label >> 16;
- switch (s_label) {
- case 0x0000:
- case 0xfa33:
- case 0xfab8:
- case 0xfabe:
- strncpy(buffer, "No bootloader", buffer_size - 1); break;
- case 0x0ebe: strncpy(buffer, "ThinkPad", buffer_size - 1); break;
- case 0x31c0: strncpy(buffer, "Acer 3", buffer_size - 1); break;
- case 0x33c0: strncpy(buffer, "Windows", buffer_size - 1); break;
- case 0x33ff: strncpy(buffer, "HP/Gateway", buffer_size - 1); break;
- case 0xb800: strncpy(buffer, "Plop", buffer_size - 1); break;
- case 0xea1e: strncpy(buffer, "Truecrypt Boot Loader", buffer_size - 1); break;
- case 0xeb04: strncpy(buffer, "Solaris", buffer_size - 1); break;
- case 0xeb48: strncpy(buffer, "Grub", buffer_size - 1); break;
- case 0xeb63:
- case 0xeb4c: strncpy(buffer, "Grub2", buffer_size - 1); break;
- case 0xeb5e:
- /* We need more than 2 bytes */
- if (((label >> 8) & 0xff) == 0x00)
- strncpy(buffer, "fbinst", buffer_size - 1);
- else if (((label >> 8) & 0xff) == 0x80)
- strncpy(buffer, "Grub4Dos", buffer_size - 1);
- else
- strncpy(buffer, "Unknown mbr", buffer_size - 1); break;
- break;
- case 0xfa31:
- /* We need more than 2 bytes */
- if (((label >> 8) & 0xff) == 0xc9)
- strncpy(buffer, "Master Boot LoaDeR", buffer_size - 1);
- else if (((label >> 8) & 0xff) == 0xc0)
- strncpy(buffer, "Syslinux", buffer_size - 1);
- else
- strncpy(buffer, "Unknown mbr", buffer_size - 1); break;
- break;
- case 0xfaeb: strncpy(buffer, "Lilo", buffer_size - 1); break;
- case 0xfc31: strncpy(buffer, "Testdisk", buffer_size - 1); break;
- case 0xfc33: strncpy(buffer, "Gag", buffer_size - 1); break;
- case 0xfceb: strncpy(buffer, "BootIT NG", buffer_size - 1); break;
- default: strncpy(buffer, "Unknown mbr", buffer_size - 1); break;
- }
+ switch (s_label) {
+ case 0x0000:
+ case 0xfa33:
+ case 0xfab8:
+ case 0xfabe:
+ strncpy(buffer, "No bootloader", buffer_size - 1);
+ break;
+ case 0x0ebe:
+ strncpy(buffer, "ThinkPad", buffer_size - 1);
+ break;
+ case 0x31c0:
+ strncpy(buffer, "Acer 3", buffer_size - 1);
+ break;
+ case 0x33c0:
+ strncpy(buffer, "Windows", buffer_size - 1);
+ break;
+ case 0x33ff:
+ strncpy(buffer, "HP/Gateway", buffer_size - 1);
+ break;
+ case 0xb800:
+ strncpy(buffer, "PloP", buffer_size - 1);
+ break;
+ case 0xea05:
+ strncpy(buffer, "XOSL", buffer_size - 1);
+ break;
+ case 0xea1e:
+ strncpy(buffer, "Truecrypt Boot Loader", buffer_size - 1);
+ break;
+ case 0xeb04:
+ strncpy(buffer, "Solaris", buffer_size - 1);
+ break;
+ case 0xeb48:
+ strncpy(buffer, "Grub", buffer_size - 1);
+ break;
+ case 0xeb4c:
+ strncpy(buffer, "Grub2 (v1.96)", buffer_size - 1);
+ break;
+ case 0xeb63:
+ strncpy(buffer, "Grub2 (v1.97)", buffer_size - 1);
+ break;
+ case 0xeb5e:
+ /* We need more than 2 bytes */
+ if (((label >> 8) & 0xff) == 0x00)
+ strncpy(buffer, "fbinst", buffer_size - 1);
+ else if (((label >> 8) & 0xff) == 0x80)
+ strncpy(buffer, "Grub4Dos", buffer_size - 1);
+ else
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ case 0xfa31:
+ /* We need more than 2 bytes */
+ if (((label >> 8) & 0xff) == 0xc9)
+ strncpy(buffer, "Master Boot LoaDeR", buffer_size - 1);
+ else if (((label >> 8) & 0xff) == 0xc0)
+ strncpy(buffer, "Syslinux", buffer_size - 1);
+ else
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ case 0xfaeb:
+ strncpy(buffer, "Lilo", buffer_size - 1);
+ break;
+ case 0xfc31:
+ strncpy(buffer, "Testdisk", buffer_size - 1);
+ break;
+ case 0xfc33:
+ strncpy(buffer, "GAG", buffer_size - 1);
+ break;
+ case 0xfceb:
+ strncpy(buffer, "BootIT NG", buffer_size - 1);
+ break;
+ default:
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ }
- buffer[buffer_size - 1] = '\0';
+ buffer[buffer_size - 1] = '\0';
}
/**
@@ -75,17 +109,17 @@ void get_mbr_string(const uint32_t label, char* buffer, const int buffer_size)
**/
uint32_t get_mbr_id(const struct driveinfo *d)
{
- char mbr[SECTOR * sizeof(char)];
+ char mbr[SECTOR * sizeof(char)];
- if (read_mbr(d->disk, &mbr) == -1)
- return -1;
- else {
- uint32_t mbr_id;
- /* Reverse the opcodes */
- mbr_id = (*(uint8_t *) (mbr + 3));
- mbr_id += (*(uint8_t *) (mbr + 2) << 8);
- mbr_id += (*(uint8_t *) (mbr + 1) << 16);
- mbr_id += (*(uint8_t *) mbr) << 24;
- return mbr_id;
- }
+ if (read_mbr(d->disk, &mbr) == -1)
+ return -1;
+ else {
+ uint32_t mbr_id;
+ /* Reverse the opcodes */
+ mbr_id = (*(uint8_t *) (mbr + 3));
+ mbr_id += (*(uint8_t *) (mbr + 2) << 8);
+ mbr_id += (*(uint8_t *) (mbr + 1) << 16);
+ mbr_id += (*(uint8_t *) mbr) << 24;
+ return mbr_id;
+ }
}
diff --git a/com32/gpllib/disk/msdos.c b/com32/gpllib/disk/msdos.c
index 1d1ef4df..affec43b 100644
--- a/com32/gpllib/disk/msdos.c
+++ b/com32/gpllib/disk/msdos.c
@@ -22,13 +22,13 @@
static inline int is_extended_partition(struct part_entry *ptab)
{
- return (ptab->ostype == 0x05 ||
- ptab->ostype == 0x0f ||
- ptab->ostype == 0x85);
+ return (ptab->ostype == 0x05 ||
+ ptab->ostype == 0x0f || ptab->ostype == 0x85);
}
+
static inline int msdos_magic_present(const char *ptab)
{
- return ( *(uint16_t *)(ptab + 0x1fe) == 0xaa55 );
+ return (*(uint16_t *) (ptab + 0x1fe) == 0xaa55);
}
/**
@@ -44,65 +44,63 @@ static inline int msdos_magic_present(const char *ptab)
static int process_extended_partition(struct driveinfo *drive_info,
const int partition_offset,
const int ebr_offset,
- p_callback callback,
- int nb_part_seen)
+ p_callback callback, int nb_part_seen)
{
- int status = 0;
- /* The ebr is located at the first sector of the extended partition */
- char* ebr = malloc(SECTOR * sizeof(char));
-
- if (read_sectors(drive_info, ebr, partition_offset + ebr_offset, 1) == -1)
- goto abort;
-
- /* Check msdos magic signature */
- if (!msdos_magic_present(ebr))
- goto abort;
-
- struct part_entry *ptab = (struct part_entry *)(ebr + PARTITION_TABLES_OFFSET);
-
- for (int i = 0; i < 4; i++) {
- if (status == -1)
- goto abort;
-
- if (!is_extended_partition(&ptab[i])) {
- /*
- * This EBR partition table entry points to the
- * logical partition associated to that EBR
- */
- int logical_partition_start = ebr_offset + ptab[i].start_lba;
-
- /* Last EBR in the extended partition? */
- if (!logical_partition_start)
- continue;
-
- /*
- * Check for garbage:
- * 3rd and 4th entries in an EBR should be zero
- * Some (malformed) partitioning software still add some
- * data partitions there.
- */
- if (ptab[i].start_lba <= 0 || ptab[i].length <= 0)
- continue;
-
- nb_part_seen++;
- callback(drive_info,
- &ptab[i],
- partition_offset + logical_partition_start,
- nb_part_seen);
- } else
- status = process_extended_partition(drive_info,
- partition_offset,
- ptab[i].start_lba,
- callback,
- nb_part_seen);
- }
-
- free(ebr);
- return 0;
+ int status = 0;
+ /* The ebr is located at the first sector of the extended partition */
+ char *ebr = malloc(SECTOR * sizeof(char));
+
+ if (read_sectors(drive_info, ebr, partition_offset + ebr_offset, 1) == -1)
+ goto abort;
+
+ /* Check msdos magic signature */
+ if (!msdos_magic_present(ebr))
+ goto abort;
+
+ struct part_entry *ptab =
+ (struct part_entry *)(ebr + PARTITION_TABLES_OFFSET);
+
+ for (int i = 0; i < 4; i++) {
+ if (status == -1)
+ goto abort;
+
+ if (!is_extended_partition(&ptab[i])) {
+ /*
+ * This EBR partition table entry points to the
+ * logical partition associated to that EBR
+ */
+ int logical_partition_start = ebr_offset + ptab[i].start_lba;
+
+ /* Last EBR in the extended partition? */
+ if (!logical_partition_start)
+ continue;
+
+ /*
+ * Check for garbage:
+ * 3rd and 4th entries in an EBR should be zero
+ * Some (malformed) partitioning software still add some
+ * data partitions there.
+ */
+ if (ptab[i].start_lba <= 0 || ptab[i].length <= 0)
+ continue;
+
+ nb_part_seen++;
+ callback(drive_info,
+ &ptab[i],
+ partition_offset + logical_partition_start, nb_part_seen);
+ } else
+ status = process_extended_partition(drive_info,
+ partition_offset,
+ ptab[i].start_lba,
+ callback, nb_part_seen);
+ }
+
+ free(ebr);
+ return 0;
abort:
- free(ebr);
- return -1;
+ free(ebr);
+ return -1;
}
/**
@@ -114,28 +112,24 @@ abort:
static int process_mbr(struct driveinfo *drive_info, struct part_entry *ptab,
p_callback callback)
{
- int status = 0;
-
- for (int i = 0; i < 4; i++) {
- if (status == -1)
- return -1;
-
- if (ptab[i].start_sect > 0) {
- if (is_extended_partition(&ptab[i])) {
- callback(drive_info,
- &ptab[i],
- ptab[i].start_lba,
- i+1);
- status = process_extended_partition(drive_info, ptab[i].start_lba, 0, callback, 4);
- } else
- callback(drive_info,
- &ptab[i],
- ptab[i].start_lba,
- i+1);
- }
+ int status = 0;
+
+ for (int i = 0; i < 4; i++) {
+ if (status == -1)
+ return -1;
+
+ if (ptab[i].start_sect > 0) {
+ if (is_extended_partition(&ptab[i])) {
+ callback(drive_info, &ptab[i], ptab[i].start_lba, i + 1);
+ status =
+ process_extended_partition(drive_info, ptab[i].start_lba, 0,
+ callback, 4);
+ } else
+ callback(drive_info, &ptab[i], ptab[i].start_lba, i + 1);
}
+ }
- return 0;
+ return 0;
}
/**
@@ -152,16 +146,17 @@ static int process_mbr(struct driveinfo *drive_info, struct part_entry *ptab,
**/
int parse_partition_table(struct driveinfo *d, p_callback callback)
{
- char *mbr = malloc(SECTOR * sizeof(char));
+ char *mbr = malloc(SECTOR * sizeof(char));
- if (read_mbr(d->disk, mbr) == -1)
- return -1;
- else {
- /* Check msdos magic signature */
- if (!msdos_magic_present(mbr))
- return -1;
+ if (read_mbr(d->disk, mbr) == -1)
+ return -1;
+ else {
+ /* Check msdos magic signature */
+ if (!msdos_magic_present(mbr))
+ return -1;
- struct part_entry *ptab = (struct part_entry *)(mbr + PARTITION_TABLES_OFFSET);
- return process_mbr(d, ptab, callback);
- }
+ struct part_entry *ptab =
+ (struct part_entry *)(mbr + PARTITION_TABLES_OFFSET);
+ return process_mbr(d, ptab, callback);
+ }
}
diff --git a/com32/gpllib/disk/read.c b/com32/gpllib/disk/read.c
index 74840829..7a6cc430 100644
--- a/com32/gpllib/disk/read.c
+++ b/com32/gpllib/disk/read.c
@@ -36,11 +36,11 @@
**/
int read_mbr(int drive, void *buf)
{
- struct driveinfo drive_info;
- drive_info.disk = drive;
+ struct driveinfo drive_info;
+ drive_info.disk = drive;
- /* MBR: lba = 0, 1 sector */
- return read_sectors(&drive_info, buf, 0, 1);
+ /* MBR: lba = 0, 1 sector */
+ return read_sectors(&drive_info, buf, 0, 1);
}
/**
@@ -54,12 +54,12 @@ int read_mbr(int drive, void *buf)
* Return the number of sectors read on success or -1 on failure.
* errno_disk contains the error number.
**/
-int dev_read(int drive, void * buf, unsigned int lba, int sectors)
+int dev_read(int drive, void *buf, unsigned int lba, int sectors)
{
- struct driveinfo drive_info;
- drive_info.disk = drive;
+ struct driveinfo drive_info;
+ drive_info.disk = drive;
- return read_sectors(&drive_info, buf, lba, sectors);
+ return read_sectors(&drive_info, buf, lba, sectors);
}
/**
@@ -72,62 +72,64 @@ int dev_read(int drive, void * buf, unsigned int lba, int sectors)
* Return the number of sectors read on success or -1 on failure.
* errno_disk contains the error number.
**/
-int read_sectors(struct driveinfo* drive_info, void *data,
+int read_sectors(struct driveinfo *drive_info, void *data,
const unsigned int lba, const int sectors)
{
- com32sys_t inreg, outreg;
- struct ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + sectors * SECTOR;
- char *bufp = data;
-
- if (get_drive_parameters(drive_info) == -1)
- return -1;
-
- memset(&inreg, 0, sizeof inreg);
-
- if (drive_info->ebios) {
- dapa->len = sizeof(*dapa);
- dapa->count = sectors;
- dapa->off = OFFS(buf);
- dapa->seg = SEG(buf);
- dapa->lba = lba;
-
- inreg.esi.w[0] = OFFS(dapa);
- inreg.ds = SEG(dapa);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.b[1] = 0x42; /* Extended read */
- } else {
- unsigned int c, h, s;
-
- if (!drive_info->cbios) { // XXX errno
- /* We failed to get the geometry */
- if (lba)
- return -1; /* Can only read MBR */
-
- s = 1; h = 0; c = 0;
- } else
- lba_to_chs(drive_info, lba, &s, &h, &c);
-
- // XXX errno
- if ( s > 63 || h > 256 || c > 1023 )
- return -1;
-
- inreg.eax.w[0] = 0x0201; /* Read one sector */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = s + (c >> 6);
- inreg.edx.b[1] = h;
- inreg.edx.b[0] = drive_info->disk;
- inreg.ebx.w[0] = OFFS(buf);
- inreg.es = SEG(buf);
- }
-
- /* Perform the read */
- if (int13_retry(&inreg, &outreg)) {
- errno_disk = outreg.eax.b[1];
- return -1; /* Give up */
- }
-
- memcpy(bufp, buf, sectors * SECTOR);
-
- return sectors;
+ com32sys_t inreg, outreg;
+ struct ebios_dapa *dapa = __com32.cs_bounce;
+ void *buf = (char *)__com32.cs_bounce + sectors * SECTOR;
+ char *bufp = data;
+
+ if (get_drive_parameters(drive_info) == -1)
+ return -1;
+
+ memset(&inreg, 0, sizeof inreg);
+
+ if (drive_info->ebios) {
+ dapa->len = sizeof(*dapa);
+ dapa->count = sectors;
+ dapa->off = OFFS(buf);
+ dapa->seg = SEG(buf);
+ dapa->lba = lba;
+
+ inreg.esi.w[0] = OFFS(dapa);
+ inreg.ds = SEG(dapa);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.b[1] = 0x42; /* Extended read */
+ } else {
+ unsigned int c, h, s;
+
+ if (!drive_info->cbios) { // XXX errno
+ /* We failed to get the geometry */
+ if (lba)
+ return -1; /* Can only read MBR */
+
+ s = 1;
+ h = 0;
+ c = 0;
+ } else
+ lba_to_chs(drive_info, lba, &s, &h, &c);
+
+ // XXX errno
+ if (s > 63 || h > 256 || c > 1023)
+ return -1;
+
+ inreg.eax.w[0] = 0x0201; /* Read one sector */
+ inreg.ecx.b[1] = c & 0xff;
+ inreg.ecx.b[0] = s + (c >> 6);
+ inreg.edx.b[1] = h;
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.ebx.w[0] = OFFS(buf);
+ inreg.es = SEG(buf);
+ }
+
+ /* Perform the read */
+ if (int13_retry(&inreg, &outreg)) {
+ errno_disk = outreg.eax.b[1];
+ return -1; /* Give up */
+ }
+
+ memcpy(bufp, buf, sectors * SECTOR);
+
+ return sectors;
}
diff --git a/com32/gpllib/disk/swsusp.c b/com32/gpllib/disk/swsusp.c
index ac9724aa..ef782fd5 100644
--- a/com32/gpllib/disk/swsusp.c
+++ b/com32/gpllib/disk/swsusp.c
@@ -12,16 +12,16 @@
**/
int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab)
{
- struct swsusp_header header_p;
- int offset;
- int found;
+ struct swsusp_header header_p;
+ int offset;
+ int found;
- /* Read first page of the swap device */
- offset = ptab->start_lba;
- if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE/SECTOR) == -1) {
- return -1;
- } else {
- found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
- return found;
- }
+ /* Read first page of the swap device */
+ offset = ptab->start_lba;
+ if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE / SECTOR) == -1) {
+ return -1;
+ } else {
+ found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
+ return found;
+ }
}
diff --git a/com32/gpllib/disk/util.c b/com32/gpllib/disk/util.c
index 6faac399..59c0328f 100644
--- a/com32/gpllib/disk/util.c
+++ b/com32/gpllib/disk/util.c
@@ -26,19 +26,20 @@
*
* Call int 13h, but with retry on failure. Especially floppies need this.
**/
-int int13_retry(const com32sys_t *inreg, com32sys_t *outreg)
+int int13_retry(const com32sys_t * inreg, com32sys_t * outreg)
{
- int retry = MAX_NB_RETRIES; /* Number of retries */
- com32sys_t tmpregs;
+ int retry = MAX_NB_RETRIES; /* Number of retries */
+ com32sys_t tmpregs;
- if ( !outreg ) outreg = &tmpregs;
+ if (!outreg)
+ outreg = &tmpregs;
- while ( retry-- ) {
- __intcall(0x13, inreg, outreg);
- if ( !(outreg->eflags.l & EFLAGS_CF) )
- return 0; /* CF=0 => OK */
- }
+ while (retry--) {
+ __intcall(0x13, inreg, outreg);
+ if (!(outreg->eflags.l & EFLAGS_CF))
+ return 0; /* CF=0 => OK */
+ }
- /* If we get here: error */
- return -1;
+ /* If we get here: error */
+ return -1;
}
diff --git a/com32/gpllib/disk/write.c b/com32/gpllib/disk/write.c
index a236f37d..89e530d9 100644
--- a/com32/gpllib/disk/write.c
+++ b/com32/gpllib/disk/write.c
@@ -32,58 +32,60 @@
* Return the number of sectors write on success or -1 on failure.
* errno_disk contains the error number.
**/
-int write_sectors(const struct driveinfo* drive_info, const unsigned int lba,
+int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
const void *data, const int size)
{
- com32sys_t inreg, outreg;
- struct ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + size;
-
- memcpy(buf, data, size);
- memset(&inreg, 0, sizeof inreg);
-
- if (drive_info->ebios) {
- dapa->len = sizeof(*dapa);
- dapa->count = size;
- dapa->off = OFFS(buf);
- dapa->seg = SEG(buf);
- dapa->lba = lba;
-
- inreg.esi.w[0] = OFFS(dapa);
- inreg.ds = SEG(dapa);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.w[0] = 0x4300; /* Extended write */
- } else {
- unsigned int c, h, s;
-
- if (!drive_info->cbios) { // XXX errno
- /* We failed to get the geometry */
- if (lba)
- return -1; /* Can only write MBR */
-
- s = 1; h = 0; c = 0;
- } else
- lba_to_chs(drive_info, lba, &s, &h, &c);
-
- // XXX errno
- if ( s > 63 || h > 256 || c > 1023 )
- return -1;
-
- inreg.eax.w[0] = 0x0301; /* Write one sector */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = s + (c >> 6);
- inreg.edx.b[1] = h;
- inreg.edx.b[0] = drive_info->disk;
- inreg.ebx.w[0] = OFFS(buf);
- inreg.es = SEG(buf);
- }
-
- /* Perform the write */
- if (int13_retry(&inreg, &outreg)) {
- errno_disk = outreg.eax.b[1];
- return -1; /* Give up */
+ com32sys_t inreg, outreg;
+ struct ebios_dapa *dapa = __com32.cs_bounce;
+ void *buf = (char *)__com32.cs_bounce + size;
+
+ memcpy(buf, data, size);
+ memset(&inreg, 0, sizeof inreg);
+
+ if (drive_info->ebios) {
+ dapa->len = sizeof(*dapa);
+ dapa->count = size;
+ dapa->off = OFFS(buf);
+ dapa->seg = SEG(buf);
+ dapa->lba = lba;
+
+ inreg.esi.w[0] = OFFS(dapa);
+ inreg.ds = SEG(dapa);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.w[0] = 0x4300; /* Extended write */
+ } else {
+ unsigned int c, h, s;
+
+ if (!drive_info->cbios) { // XXX errno
+ /* We failed to get the geometry */
+ if (lba)
+ return -1; /* Can only write MBR */
+
+ s = 1;
+ h = 0;
+ c = 0;
} else
- return size;
+ lba_to_chs(drive_info, lba, &s, &h, &c);
+
+ // XXX errno
+ if (s > 63 || h > 256 || c > 1023)
+ return -1;
+
+ inreg.eax.w[0] = 0x0301; /* Write one sector */
+ inreg.ecx.b[1] = c & 0xff;
+ inreg.ecx.b[0] = s + (c >> 6);
+ inreg.edx.b[1] = h;
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.ebx.w[0] = OFFS(buf);
+ inreg.es = SEG(buf);
+ }
+
+ /* Perform the write */
+ if (int13_retry(&inreg, &outreg)) {
+ errno_disk = outreg.eax.b[1];
+ return -1; /* Give up */
+ } else
+ return size;
}
/**
@@ -92,11 +94,10 @@ int write_sectors(const struct driveinfo* drive_info, const unsigned int lba,
* @lba: Position to write
* @data: Buffer to write
**/
-int write_verify_sector(struct driveinfo* drive_info,
- const unsigned int lba,
- const void *data)
+int write_verify_sector(struct driveinfo *drive_info,
+ const unsigned int lba, const void *data)
{
- return write_verify_sectors(drive_info, lba, data, SECTOR);
+ return write_verify_sectors(drive_info, lba, data, SECTOR);
}
/**
@@ -106,20 +107,20 @@ int write_verify_sector(struct driveinfo* drive_info,
* @data: Buffer to write
* @size: Size of the buffer (number of sectors)
**/
-int write_verify_sectors(struct driveinfo* drive_info,
+int write_verify_sectors(struct driveinfo *drive_info,
const unsigned int lba,
const void *data, const int size)
{
- char *rb = malloc(SECTOR * size * sizeof(char));
- int status;
+ char *rb = malloc(SECTOR * size * sizeof(char));
+ int status;
- if (write_sectors(drive_info, lba, data, size) == -1)
- return -1; /* Write failure */
+ if (write_sectors(drive_info, lba, data, size) == -1)
+ return -1; /* Write failure */
- if (read_sectors(drive_info, rb, lba, size) == -1)
- return -1; /* Readback failure */
+ if (read_sectors(drive_info, rb, lba, size) == -1)
+ return -1; /* Readback failure */
- status = memcmp(data, rb, SECTOR * size);
- free(rb);
- return status ? -1 : 0;
+ status = memcmp(data, rb, SECTOR * size);
+ free(rb);
+ return status ? -1 : 0;
}
diff --git a/com32/gpllib/dmi/dmi.c b/com32/gpllib/dmi/dmi.c
index 9f770376..d3a43a8d 100644
--- a/com32/gpllib/dmi/dmi.c
+++ b/com32/gpllib/dmi/dmi.c
@@ -43,40 +43,44 @@ const char *bad_index = "<BAD INDEX>";
static const char *dmi_on_board_devices_type(uint8_t code)
{
- /* 3.3.11.1 */
- static const char *type[]={
- "Other", /* 0x01 */
- "Unknown",
- "Video",
- "SCSI Controller",
- "Ethernet",
- "Token Ring",
- "Sound",
- "PATA Controller",
- "SATA Controller",
- "SAS Controller" /* 0x0A */
- };
-
- if (code>=0x01 && code<=0x0A)
- return type[code-0x01];
- return out_of_spec;
+ /* 3.3.11.1 */
+ static const char *type[] = {
+ "Other", /* 0x01 */
+ "Unknown",
+ "Video",
+ "SCSI Controller",
+ "Ethernet",
+ "Token Ring",
+ "Sound",
+ "PATA Controller",
+ "SATA Controller",
+ "SAS Controller" /* 0x0A */
+ };
+
+ if (code >= 0x01 && code <= 0x0A)
+ return type[code - 0x01];
+ return out_of_spec;
}
-static void dmi_on_board_devices(struct dmi_header *h, s_dmi* dmi)
+static void dmi_on_board_devices(struct dmi_header *h, s_dmi * dmi)
{
- uint8_t *p = h->data+4;
- uint8_t count = (h->length-0x04)/2;
- unsigned int i;
-
- for (i=0; i<count && i<sizeof dmi->base_board.devices_information/sizeof *dmi->base_board.devices_information; i++) {
- strncpy(dmi->base_board.devices_information[i].type,
- dmi_on_board_devices_type(p[2*i]&0x7F),
- sizeof dmi->base_board.devices_information[i].type);
- dmi->base_board.devices_information[i].status = p[2*i]&0x80;
- strncpy(dmi->base_board.devices_information[i].description,
- dmi_string(h, p[2*i+1]),
- sizeof dmi->base_board.devices_information[i].description);
- }
+ uint8_t *p = h->data + 4;
+ uint8_t count = (h->length - 0x04) / 2;
+ unsigned int i;
+
+ for (i = 0;
+ i < count
+ && i <
+ sizeof dmi->base_board.devices_information /
+ sizeof *dmi->base_board.devices_information; i++) {
+ strncpy(dmi->base_board.devices_information[i].type,
+ dmi_on_board_devices_type(p[2 * i] & 0x7F),
+ sizeof dmi->base_board.devices_information[i].type);
+ dmi->base_board.devices_information[i].status = p[2 * i] & 0x80;
+ strncpy(dmi->base_board.devices_information[i].description,
+ dmi_string(h, p[2 * i + 1]),
+ sizeof dmi->base_board.devices_information[i].description);
+ }
}
/*
@@ -85,31 +89,31 @@ static void dmi_on_board_devices(struct dmi_header *h, s_dmi* dmi)
static const char *dmi_system_reset_boot_option(uint8_t code)
{
- static const char *option[]={
- "Operating System", /* 0x1 */
- "System Utilities",
- "Do Not Reboot" /* 0x3 */
- };
-
- if (code >= 0x1)
- return option[code-0x1];
- return out_of_spec;
+ static const char *option[] = {
+ "Operating System", /* 0x1 */
+ "System Utilities",
+ "Do Not Reboot" /* 0x3 */
+ };
+
+ if (code >= 0x1)
+ return option[code - 0x1];
+ return out_of_spec;
}
-static void dmi_system_reset_count(uint16_t code, char* array)
+static void dmi_system_reset_count(uint16_t code, char *array)
{
- if (code == 0xFFFF)
- strncpy(array, "Unknown", sizeof array);
- else
- snprintf(array, sizeof array, "%u", code);
+ if (code == 0xFFFF)
+ strncpy(array, "Unknown", sizeof array);
+ else
+ snprintf(array, sizeof array, "%u", code);
}
-static void dmi_system_reset_timer(uint16_t code, char* array)
+static void dmi_system_reset_timer(uint16_t code, char *array)
{
- if (code == 0xFFFF)
- strncpy(array, "Unknown", sizeof array);
- else
- snprintf(array, sizeof array, "%u min", code);
+ if (code == 0xFFFF)
+ strncpy(array, "Unknown", sizeof array);
+ else
+ snprintf(array, sizeof array, "%u min", code);
}
/*
@@ -118,68 +122,71 @@ static void dmi_system_reset_timer(uint16_t code, char* array)
static const char *dmi_hardware_security_status(uint8_t code)
{
- static const char *status[]={
- "Disabled", /* 0x00 */
- "Enabled",
- "Not Implemented",
- "Unknown" /* 0x03 */
- };
-
- return status[code];
+ static const char *status[] = {
+ "Disabled", /* 0x00 */
+ "Enabled",
+ "Not Implemented",
+ "Unknown" /* 0x03 */
+ };
+
+ return status[code];
}
/*
* 3.3.12 OEM Strings (Type 11)
*/
-static void dmi_oem_strings(struct dmi_header *h, const char *prefix, s_dmi *dmi)
+static void dmi_oem_strings(struct dmi_header *h, const char *prefix,
+ s_dmi * dmi)
{
- uint8_t *p=h->data+4;
- uint8_t count=p[0x00];
- int i;
+ uint8_t *p = h->data + 4;
+ uint8_t count = p[0x00];
+ int i;
- for(i=1; i<=count; i++)
- snprintf(dmi->oem_strings, OEM_STRINGS_SIZE, "%s %s %s\n",
- dmi->oem_strings, prefix, dmi_string(h, i));
+ for (i = 1; i <= count; i++)
+ snprintf(dmi->oem_strings, OEM_STRINGS_SIZE, "%s %s %s\n",
+ dmi->oem_strings, prefix, dmi_string(h, i));
}
/*
* 3.3.13 System Configuration Options (Type 12)
*/
-static void dmi_system_configuration_options(struct dmi_header *h, const char *prefix, s_dmi *dmi)
+static void dmi_system_configuration_options(struct dmi_header *h,
+ const char *prefix, s_dmi * dmi)
{
- uint8_t *p = h->data+4;
- uint8_t count = p[0x00];
- int i;
+ uint8_t *p = h->data + 4;
+ uint8_t count = p[0x00];
+ int i;
- for (i=1; i<=count; i++)
- snprintf(dmi->system.configuration_options, SYSTEM_CONFIGURATION_OPTIONS_SIZE, "%s %s %s\n",
- dmi->system.configuration_options, prefix, dmi_string(h, i));
+ for (i = 1; i <= count; i++)
+ snprintf(dmi->system.configuration_options,
+ SYSTEM_CONFIGURATION_OPTIONS_SIZE, "%s %s %s\n",
+ dmi->system.configuration_options, prefix, dmi_string(h, i));
}
-static void dmi_system_boot_status(uint8_t code, char* array)
+static void dmi_system_boot_status(uint8_t code, char *array)
{
- static const char *status[]={
- "No errors detected", /* 0 */
- "No bootable media",
- "Operating system failed to load",
- "Firmware-detected hardware failure",
- "Operating system-detected hardware failure",
- "User-requested boot",
- "System security violation",
- "Previously-requested image",
- "System watchdog timer expired" /* 8 */
- };
-
- if (code<=8)
- strncpy(array, status[code], SYSTEM_BOOT_STATUS_SIZE);
- if (code>=128 && code<=191)
- strncpy(array, "OEM-specific", SYSTEM_BOOT_STATUS_SIZE);
- if (code>=192)
- strncpy(array, "Product-specific", SYSTEM_BOOT_STATUS_SIZE);
+ static const char *status[] = {
+ "No errors detected", /* 0 */
+ "No bootable media",
+ "Operating system failed to load",
+ "Firmware-detected hardware failure",
+ "Operating system-detected hardware failure",
+ "User-requested boot",
+ "System security violation",
+ "Previously-requested image",
+ "System watchdog timer expired" /* 8 */
+ };
+
+ if (code <= 8)
+ strncpy(array, status[code], SYSTEM_BOOT_STATUS_SIZE);
+ if (code >= 128 && code <= 191)
+ strncpy(array, "OEM-specific", SYSTEM_BOOT_STATUS_SIZE);
+ if (code >= 192)
+ strncpy(array, "Product-specific", SYSTEM_BOOT_STATUS_SIZE);
}
-void dmi_bios_runtime_size(uint32_t code, s_dmi *dmi)
+void dmi_bios_runtime_size(uint32_t code, s_dmi * dmi)
{
if (code & 0x000003FF) {
dmi->bios.runtime_size = code;
@@ -291,19 +298,19 @@ static void dmi_base_board_features(uint8_t code, s_dmi * dmi)
static void dmi_processor_voltage(uint8_t code, s_dmi * dmi)
{
/* 3.3.5.4 */
- static const float voltage[] = {
- 5.0,
- 3.3,
- 2.9
+ static const uint16_t voltage[] = {
+ 5000,
+ 3300,
+ 2900
};
int i;
if (code & 0x80)
- dmi->processor.voltage = ((float)(code & 0x7f) / 10);
+ dmi->processor.voltage_mv = (code & 0x7f) * 100;
else {
for (i = 0; i <= 2; i++)
if (code & (1 << i))
- dmi->processor.voltage = voltage[i];
+ dmi->processor.voltage_mv = voltage[i];
}
}
@@ -454,35 +461,34 @@ int checksum(uint8_t * buf, int len)
return (sum == 0);
}
-static int smbios_decode(s_dmi *dmi, uint8_t *buf)
+static int smbios_decode(s_dmi * dmi, uint8_t * buf)
{
- dmi->dmitable.ver = (buf[0x06] << 8) + buf[0x07];
- /* Some BIOS report weird SMBIOS version, fix that up */
- switch (dmi->dmitable.ver) {
- case 0x021F:
- dmi->dmitable.ver = 0x0203;
- break;
- case 0x0233:
- dmi->dmitable.ver = 0x0206;
- break;
- }
- dmi->dmitable.major_version=dmi->dmitable.ver >> 8;
- dmi->dmitable.minor_version=dmi->dmitable.ver & 0xFF;
-
- return DMI_TABLE_PRESENT;
-}
+ dmi->dmitable.ver = (buf[0x06] << 8) + buf[0x07];
+ /* Some BIOS report weird SMBIOS version, fix that up */
+ switch (dmi->dmitable.ver) {
+ case 0x021F:
+ dmi->dmitable.ver = 0x0203;
+ break;
+ case 0x0233:
+ dmi->dmitable.ver = 0x0206;
+ break;
+ }
+ dmi->dmitable.major_version = dmi->dmitable.ver >> 8;
+ dmi->dmitable.minor_version = dmi->dmitable.ver & 0xFF;
+ return DMI_TABLE_PRESENT;
+}
-static int legacy_decode(s_dmi *dmi, uint8_t *buf)
+static int legacy_decode(s_dmi * dmi, uint8_t * buf)
{
dmi->dmitable.num = buf[13] << 8 | buf[12];
dmi->dmitable.len = buf[7] << 8 | buf[6];
- dmi->dmitable.base =
- buf[11] << 24 | buf[10] << 16 | buf[9] << 8 | buf[8];
+ dmi->dmitable.base = buf[11] << 24 | buf[10] << 16 | buf[9] << 8 | buf[8];
/* Version already found? */
- if (dmi->dmitable.ver>0) return DMI_TABLE_PRESENT;
+ if (dmi->dmitable.ver > 0)
+ return DMI_TABLE_PRESENT;
dmi->dmitable.ver = (buf[0x06] << 8) + buf[0x07];
@@ -491,16 +497,15 @@ static int legacy_decode(s_dmi *dmi, uint8_t *buf)
* the SMBIOS version, which we don't know at this point.
*/
if (buf[14] != 0) {
- dmi->dmitable.major_version = buf[14] >> 4;
- dmi->dmitable.minor_version = buf[14] & 0x0F;
+ dmi->dmitable.major_version = buf[14] >> 4;
+ dmi->dmitable.minor_version = buf[14] & 0x0F;
} else {
- dmi->dmitable.major_version = 0;
- dmi->dmitable.minor_version = 0;
+ dmi->dmitable.major_version = 0;
+ dmi->dmitable.minor_version = 0;
}
return DMI_TABLE_PRESENT;
}
-
int dmi_iterate(s_dmi * dmi)
{
uint8_t *p, *q;
@@ -526,31 +531,30 @@ int dmi_iterate(s_dmi * dmi)
dmi->processor.filled = false;
dmi->system.filled = false;
- p = (uint8_t *)0xF0000; /* The start address to look at the dmi table */
+ p = (uint8_t *) 0xF0000; /* The start address to look at the dmi table */
/* The anchor-string is 16-bytes aligned */
for (q = p; q < p + 0x10000; q += 16) {
- /* To validate the presence of SMBIOS:
- * + the overall checksum must be correct
- * + the intermediate anchor-string must be _DMI_
- * + the intermediate checksum must be correct
- */
- if (memcmp(q, "_SM_", 4) == 0 &&
- checksum(q, q[0x05]) &&
- memcmp(q + 0x10, "_DMI_", 5)==0 &&
- checksum(q + 0x10, 0x0F)) {
- /* Do not return, legacy_decode will need to be called
- * on the intermediate structure to get the table length
- * and address
- */
- smbios_decode(dmi, q);
- } else if (memcmp(q, "_DMI_", 5) == 0 && checksum(q, 0x0F)) {
- found = 1;
- legacy_decode(dmi, q);
- }
+ /* To validate the presence of SMBIOS:
+ * + the overall checksum must be correct
+ * + the intermediate anchor-string must be _DMI_
+ * + the intermediate checksum must be correct
+ */
+ if (memcmp(q, "_SM_", 4) == 0 &&
+ checksum(q, q[0x05]) &&
+ memcmp(q + 0x10, "_DMI_", 5) == 0 && checksum(q + 0x10, 0x0F)) {
+ /* Do not return, legacy_decode will need to be called
+ * on the intermediate structure to get the table length
+ * and address
+ */
+ smbios_decode(dmi, q);
+ } else if (memcmp(q, "_DMI_", 5) == 0 && checksum(q, 0x0F)) {
+ found = 1;
+ legacy_decode(dmi, q);
+ }
}
if (found)
- return DMI_TABLE_PRESENT;
+ return DMI_TABLE_PRESENT;
dmi->dmitable.base = 0;
dmi->dmitable.num = 0;
@@ -630,231 +634,264 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi)
break;
break;
case 3: /* 3.3.4 Chassis Information */
- if(h->length<0x09) break;
- dmi->chassis.filled=true;
- strcpy(dmi->chassis.manufacturer,dmi_string(h,data[0x04]));
- strcpy(dmi->chassis.type,dmi_chassis_type(data[0x05]&0x7F));
- strcpy(dmi->chassis.lock,dmi_chassis_lock(data[0x05]>>7));
- strcpy(dmi->chassis.version,dmi_string(h,data[0x06]));
- strcpy(dmi->chassis.serial,dmi_string(h,data[0x07]));
- strcpy(dmi->chassis.asset_tag,dmi_string(h,data[0x08]));
- if(h->length<0x0D) break;
- strcpy(dmi->chassis.boot_up_state,dmi_chassis_state(data[0x09]));
- strcpy(dmi->chassis.power_supply_state,dmi_chassis_state(data[0x0A]));
- strcpy(dmi->chassis.thermal_state,dmi_chassis_state(data[0x0B]));
- strcpy(dmi->chassis.security_status,dmi_chassis_security_status(data[0x0C]));
- if(h->length<0x11) break;
- sprintf(dmi->chassis.oem_information,"0x%08X",DWORD(data+0x0D));
- if(h->length<0x15) break;
- dmi->chassis.height=data[0x11];
- dmi->chassis.nb_power_cords=data[0x12];
- break;
-
- case 4: /* 3.3.5 Processor Information */
- if(h->length<0x1A) break;
- dmi->processor.filled=true;
- strcpy(dmi->processor.socket_designation,dmi_string(h, data[0x04]));
- strcpy(dmi->processor.type,dmi_processor_type(data[0x05]));
- strcpy(dmi->processor.manufacturer,dmi_string(h, data[0x07]));
- strcpy(dmi->processor.family,dmi_processor_family(data[0x06],dmi->processor.manufacturer));
- dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), dmi);
- strcpy(dmi->processor.version,dmi_string(h, data[0x10]));
- dmi_processor_voltage(data[0x11],dmi);
- dmi->processor.external_clock=WORD(data+0x12);
- dmi->processor.max_speed=WORD(data+0x14);
- dmi->processor.current_speed=WORD(data+0x16);
- if(data[0x18]&(1<<6))
- strcpy(dmi->processor.status,dmi_processor_status(data[0x18]&0x07));
- else
- sprintf(dmi->processor.status,"Unpopulated");
- strcpy(dmi->processor.upgrade,dmi_processor_upgrade(data[0x19]));
- if(h->length<0x20) break;
- dmi_processor_cache(WORD(data+0x1A), "L1", ver,dmi->processor.cache1);
- dmi_processor_cache(WORD(data+0x1C), "L2", ver,dmi->processor.cache2);
- dmi_processor_cache(WORD(data+0x1E), "L3", ver,dmi->processor.cache3);
- if(h->length<0x23) break;
- strcpy(dmi->processor.serial,dmi_string(h, data[0x20]));
- strcpy(dmi->processor.asset_tag,dmi_string(h, data[0x21]));
- strcpy(dmi->processor.part_number,dmi_string(h, data[0x22]));
- break;
- case 6: /* 3.3.7 Memory Module Information */
- if(h->length<0x0C) break;
- dmi->memory_module_count++;
- s_memory_module *module = &dmi->memory_module[dmi->memory_module_count-1];
- dmi->memory_module[dmi->memory_module_count-1].filled=true;
- strncpy(module->socket_designation, dmi_string(h, data[0x04]),
- sizeof(module->socket_designation));
- dmi_memory_module_connections(data[0x05], module->bank_connections);
- dmi_memory_module_speed(data[0x06], module->speed);
- dmi_memory_module_types(WORD(data+0x07), " ", module->type);
- dmi_memory_module_size(data[0x09], module->installed_size);
- dmi_memory_module_size(data[0x0A], module->enabled_size);
- dmi_memory_module_error(data[0x0B], "\t\t", module->error_status);
- break;
- case 7: /* 3.3.8 Cache Information */
- if(h->length<0x0F) break;
- dmi->cache_count++;
- if (dmi->cache_count > MAX_DMI_CACHE_ITEMS) break;
- strcpy(dmi->cache[dmi->cache_count-1].socket_designation,
- dmi_string(h, data[0x04]));
- sprintf(dmi->cache[dmi->cache_count-1].configuration,
- "%s, %s, %u",
- WORD(data+0x05)&0x0080?"Enabled":"Disabled",
- WORD(data+0x05)&0x0008?"Socketed":"Not Socketed",
- (WORD(data+0x05)&0x0007)+1);
- strcpy(dmi->cache[dmi->cache_count-1].mode,
- dmi_cache_mode((WORD(data+0x05)>>8)&0x0003));
- strcpy(dmi->cache[dmi->cache_count-1].location,
- dmi_cache_location((WORD(data+0x05)>>5)&0x0003));
- dmi->cache[dmi->cache_count-1].installed_size =
- dmi_cache_size(WORD(data+0x09));
- dmi->cache[dmi->cache_count-1].max_size =
- dmi_cache_size(WORD(data+0x07));
- dmi_cache_types(WORD(data+0x0B), " ",
- dmi->cache[dmi->cache_count-1].supported_sram_types);
- dmi_cache_types(WORD(data+0x0D), " ",
- dmi->cache[dmi->cache_count-1].installed_sram_types);
- if(h->length<0x13) break;
- dmi->cache[dmi->cache_count-1].speed = data[0x0F]; /* ns */
- strcpy(dmi->cache[dmi->cache_count-1].error_correction_type,
- dmi_cache_ec_type(data[0x10]));
- strcpy(dmi->cache[dmi->cache_count-1].system_type,
- dmi_cache_type(data[0x11]));
- strcpy(dmi->cache[dmi->cache_count-1].associativity,
- dmi_cache_associativity(data[0x12]));
- break;
- case 10: /* 3.3.11 On Board Devices Information */
- dmi_on_board_devices(h, dmi);
- break;
- case 11: /* 3.3.12 OEM Strings */
- if (h->length<0x05) break;
- dmi_oem_strings(h, "\t", dmi);
- break;
- case 12: /* 3.3.13 System Configuration Options */
- if (h->length < 0x05) break;
- dmi_system_configuration_options(h, "\t", dmi);
- break;
- case 17: /* 3.3.18 Memory Device */
- if (h->length < 0x15) break;
- dmi->memory_count++;
- if (dmi->memory_count > MAX_DMI_MEMORY_ITEMS) break;
- s_memory *mem = &dmi->memory[dmi->memory_count-1];
- dmi->memory[dmi->memory_count-1].filled=true;
- dmi_memory_array_error_handle(WORD(data + 0x06),mem->error);
- dmi_memory_device_width(WORD(data + 0x08),mem->total_width);
- dmi_memory_device_width(WORD(data + 0x0A),mem->data_width);
- dmi_memory_device_size(WORD(data + 0x0C),mem->size);
- strcpy(mem->form_factor,dmi_memory_device_form_factor(data[0x0E]));
- dmi_memory_device_set(data[0x0F],mem->device_set);
- strcpy(mem->device_locator,dmi_string(h, data[0x10]));
- strcpy(mem->bank_locator,dmi_string(h, data[0x11]));
- strcpy(mem->type,dmi_memory_device_type(data[0x12]));
- dmi_memory_device_type_detail(WORD(data + 0x13),mem->type_detail);
- if (h->length < 0x17) break;
- dmi_memory_device_speed(WORD(data + 0x15),mem->speed);
- if (h->length < 0x1B) break;
- strcpy(mem->manufacturer, dmi_string(h, data[0x17]));
- strcpy(mem->serial,dmi_string(h, data[0x18]));
- strcpy(mem->asset_tag,dmi_string(h, data[0x19]));
- strcpy(mem->part_number,dmi_string(h, data[0x1A]));
- break;
- case 22: /* 3.3.23 Portable Battery */
- if (h->length < 0x10) break;
- dmi->battery.filled=true;
- strcpy(dmi->battery.location,dmi_string(h, data[0x04]));
- strcpy(dmi->battery.manufacturer,dmi_string(h, data[0x05]));
-
- if (data[0x06] || h->length < 0x1A)
- strcpy(dmi->battery.manufacture_date, dmi_string(h, data[0x06]));
-
- if (data[0x07] || h->length < 0x1A)
- strcpy(dmi->battery.serial, dmi_string(h, data[0x07]));
-
- strcpy(dmi->battery.name,dmi_string(h, data[0x08]));
-
- if (data[0x09] != 0x02 || h->length < 0x1A)
- strcpy(dmi->battery.chemistry,dmi_battery_chemistry(data[0x09]));
-
- if (h->length < 0x1A)
- dmi_battery_capacity(WORD(data + 0x0A), 1,dmi->battery.design_capacity);
- else
- dmi_battery_capacity(WORD(data + 0x0A), data[0x15],dmi->battery.design_capacity);
- dmi_battery_voltage(WORD(data + 0x0C),dmi->battery.design_voltage);
- strcpy(dmi->battery.sbds,dmi_string(h, data[0x0E]));
- dmi_battery_maximum_error(data[0x0F],dmi->battery.maximum_error);
- if (h->length < 0x1A) break;
- if (data[0x07] == 0)
- sprintf(dmi->battery.sbds_serial,"%04X", WORD(data + 0x10));
-
- if (data[0x06] == 0)
- sprintf(dmi->battery.sbds_manufacture_date,"%u-%02u-%02u",
- 1980 + (WORD(data + 0x12) >> 9),
- (WORD(data + 0x12) >> 5) & 0x0F,
- WORD(data + 0x12) & 0x1F);
- if (data[0x09] == 0x02)
- strcpy(dmi->battery.sbds_chemistry, dmi_string(h, data[0x14]));
-
- // sprintf(dmi->battery.oem_info,"0x%08X",DWORD(h, data+0x16));
- break;
- case 23: /* 3.3.24 System Reset */
- if(h->length<0x0D) break;
- dmi->system.system_reset.filled = true;
- dmi->system.system_reset.status = data[0x04]&(1<<0);
- dmi->system.system_reset.watchdog = data[0x04]&(1<<5);
- if (!(data[0x04]&(1<<5)))
- break;
- strncpy(dmi->system.system_reset.boot_option,
- dmi_system_reset_boot_option((data[0x04]>>1)&0x3),
- sizeof dmi->system.system_reset.boot_option);
- strncpy(dmi->system.system_reset.boot_option_on_limit,
- dmi_system_reset_boot_option((data[0x04]>>3)&0x3),
- sizeof dmi->system.system_reset.boot_option_on_limit);
- dmi_system_reset_count(WORD(data+0x05), dmi->system.system_reset.reset_count);
- dmi_system_reset_count(WORD(data+0x07), dmi->system.system_reset.reset_limit);
- dmi_system_reset_timer(WORD(data+0x09), dmi->system.system_reset.timer_interval);
- dmi_system_reset_timer(WORD(data+0x0B), dmi->system.system_reset.timeout);
- break;
- case 24: /* 3.3.25 Hardware Security */
- if (h->length<0x05) break;
- dmi->hardware_security.filled = true;
- strncpy(dmi->hardware_security.power_on_passwd_status,
- dmi_hardware_security_status(data[0x04]>>6),
- sizeof dmi->hardware_security.power_on_passwd_status);
- strncpy(dmi->hardware_security.keyboard_passwd_status,
- dmi_hardware_security_status((data[0x04]>>4)&0x3),
- sizeof dmi->hardware_security.keyboard_passwd_status);
- strncpy(dmi->hardware_security.administrator_passwd_status,
- dmi_hardware_security_status((data[0x04]>>2)&0x3),
- sizeof dmi->hardware_security.administrator_passwd_status);
- strncpy(dmi->hardware_security.front_panel_reset_status,
- dmi_hardware_security_status(data[0x04]&0x3),
- sizeof dmi->hardware_security.front_panel_reset_status);
- break;
- case 32: /* 3.3.33 System Boot Information */
- if (h->length < 0x0B) break;
- dmi_system_boot_status(data[0x0A],
- dmi->system.system_boot_status);
- case 38: /* 3.3.39 IPMI Device Information */
- if (h->length < 0x10) break;
- dmi->ipmi.filled=true;
- snprintf(dmi->ipmi.interface_type,sizeof(dmi->ipmi.interface_type),
- "%s", dmi_ipmi_interface_type(data[0x04]));
- dmi->ipmi.major_specification_version=data[0x05] >> 4;
- dmi->ipmi.minor_specification_version=data[0x05] & 0x0F;
- dmi->ipmi.I2C_slave_address=data[0x06] >> 1;
- if (data[0x07] != 0xFF)
- dmi->ipmi.nv_address=data[0x07];
- else
- dmi->ipmi.nv_address=0; /* Not Present */
- dmi_ipmi_base_address(data[0x04], data + 0x08,
- &dmi->ipmi);
- if (h->length < 0x12) break;
- if (data[0x11] != 0x00)
- {
- dmi->ipmi.irq=data[0x11];
- }
- break;
- }
+ if (h->length < 0x09)
+ break;
+ dmi->chassis.filled = true;
+ strcpy(dmi->chassis.manufacturer, dmi_string(h, data[0x04]));
+ strcpy(dmi->chassis.type, dmi_chassis_type(data[0x05] & 0x7F));
+ strcpy(dmi->chassis.lock, dmi_chassis_lock(data[0x05] >> 7));
+ strcpy(dmi->chassis.version, dmi_string(h, data[0x06]));
+ strcpy(dmi->chassis.serial, dmi_string(h, data[0x07]));
+ strcpy(dmi->chassis.asset_tag, dmi_string(h, data[0x08]));
+ if (h->length < 0x0D)
+ break;
+ strcpy(dmi->chassis.boot_up_state, dmi_chassis_state(data[0x09]));
+ strcpy(dmi->chassis.power_supply_state, dmi_chassis_state(data[0x0A]));
+ strcpy(dmi->chassis.thermal_state, dmi_chassis_state(data[0x0B]));
+ strcpy(dmi->chassis.security_status,
+ dmi_chassis_security_status(data[0x0C]));
+ if (h->length < 0x11)
+ break;
+ sprintf(dmi->chassis.oem_information, "0x%08X", DWORD(data + 0x0D));
+ if (h->length < 0x15)
+ break;
+ dmi->chassis.height = data[0x11];
+ dmi->chassis.nb_power_cords = data[0x12];
+ break;
+
+ case 4: /* 3.3.5 Processor Information */
+ if (h->length < 0x1A)
+ break;
+ dmi->processor.filled = true;
+ strcpy(dmi->processor.socket_designation, dmi_string(h, data[0x04]));
+ strcpy(dmi->processor.type, dmi_processor_type(data[0x05]));
+ strcpy(dmi->processor.manufacturer, dmi_string(h, data[0x07]));
+ strcpy(dmi->processor.family,
+ dmi_processor_family(data[0x06], dmi->processor.manufacturer));
+ dmi_processor_id(data[0x06], data + 8, dmi_string(h, data[0x10]), dmi);
+ strcpy(dmi->processor.version, dmi_string(h, data[0x10]));
+ dmi_processor_voltage(data[0x11], dmi);
+ dmi->processor.external_clock = WORD(data + 0x12);
+ dmi->processor.max_speed = WORD(data + 0x14);
+ dmi->processor.current_speed = WORD(data + 0x16);
+ if (data[0x18] & (1 << 6))
+ strcpy(dmi->processor.status,
+ dmi_processor_status(data[0x18] & 0x07));
+ else
+ sprintf(dmi->processor.status, "Unpopulated");
+ strcpy(dmi->processor.upgrade, dmi_processor_upgrade(data[0x19]));
+ if (h->length < 0x20)
+ break;
+ dmi_processor_cache(WORD(data + 0x1A), "L1", ver,
+ dmi->processor.cache1);
+ dmi_processor_cache(WORD(data + 0x1C), "L2", ver,
+ dmi->processor.cache2);
+ dmi_processor_cache(WORD(data + 0x1E), "L3", ver,
+ dmi->processor.cache3);
+ if (h->length < 0x23)
+ break;
+ strcpy(dmi->processor.serial, dmi_string(h, data[0x20]));
+ strcpy(dmi->processor.asset_tag, dmi_string(h, data[0x21]));
+ strcpy(dmi->processor.part_number, dmi_string(h, data[0x22]));
+ break;
+ case 6: /* 3.3.7 Memory Module Information */
+ if (h->length < 0x0C)
+ break;
+ dmi->memory_module_count++;
+ s_memory_module *module =
+ &dmi->memory_module[dmi->memory_module_count - 1];
+ dmi->memory_module[dmi->memory_module_count - 1].filled = true;
+ strncpy(module->socket_designation, dmi_string(h, data[0x04]),
+ sizeof(module->socket_designation));
+ dmi_memory_module_connections(data[0x05], module->bank_connections);
+ dmi_memory_module_speed(data[0x06], module->speed);
+ dmi_memory_module_types(WORD(data + 0x07), " ", module->type);
+ dmi_memory_module_size(data[0x09], module->installed_size);
+ dmi_memory_module_size(data[0x0A], module->enabled_size);
+ dmi_memory_module_error(data[0x0B], "\t\t", module->error_status);
+ break;
+ case 7: /* 3.3.8 Cache Information */
+ if (h->length < 0x0F)
+ break;
+ dmi->cache_count++;
+ if (dmi->cache_count > MAX_DMI_CACHE_ITEMS)
+ break;
+ strcpy(dmi->cache[dmi->cache_count - 1].socket_designation,
+ dmi_string(h, data[0x04]));
+ sprintf(dmi->cache[dmi->cache_count - 1].configuration,
+ "%s, %s, %u",
+ WORD(data + 0x05) & 0x0080 ? "Enabled" : "Disabled",
+ WORD(data + 0x05) & 0x0008 ? "Socketed" : "Not Socketed",
+ (WORD(data + 0x05) & 0x0007) + 1);
+ strcpy(dmi->cache[dmi->cache_count - 1].mode,
+ dmi_cache_mode((WORD(data + 0x05) >> 8) & 0x0003));
+ strcpy(dmi->cache[dmi->cache_count - 1].location,
+ dmi_cache_location((WORD(data + 0x05) >> 5) & 0x0003));
+ dmi->cache[dmi->cache_count - 1].installed_size =
+ dmi_cache_size(WORD(data + 0x09));
+ dmi->cache[dmi->cache_count - 1].max_size =
+ dmi_cache_size(WORD(data + 0x07));
+ dmi_cache_types(WORD(data + 0x0B), " ",
+ dmi->cache[dmi->cache_count - 1].supported_sram_types);
+ dmi_cache_types(WORD(data + 0x0D), " ",
+ dmi->cache[dmi->cache_count - 1].installed_sram_types);
+ if (h->length < 0x13)
+ break;
+ dmi->cache[dmi->cache_count - 1].speed = data[0x0F]; /* ns */
+ strcpy(dmi->cache[dmi->cache_count - 1].error_correction_type,
+ dmi_cache_ec_type(data[0x10]));
+ strcpy(dmi->cache[dmi->cache_count - 1].system_type,
+ dmi_cache_type(data[0x11]));
+ strcpy(dmi->cache[dmi->cache_count - 1].associativity,
+ dmi_cache_associativity(data[0x12]));
+ break;
+ case 10: /* 3.3.11 On Board Devices Information */
+ dmi_on_board_devices(h, dmi);
+ break;
+ case 11: /* 3.3.12 OEM Strings */
+ if (h->length < 0x05)
+ break;
+ dmi_oem_strings(h, "\t", dmi);
+ break;
+ case 12: /* 3.3.13 System Configuration Options */
+ if (h->length < 0x05)
+ break;
+ dmi_system_configuration_options(h, "\t", dmi);
+ break;
+ case 17: /* 3.3.18 Memory Device */
+ if (h->length < 0x15)
+ break;
+ dmi->memory_count++;
+ if (dmi->memory_count > MAX_DMI_MEMORY_ITEMS)
+ break;
+ s_memory *mem = &dmi->memory[dmi->memory_count - 1];
+ dmi->memory[dmi->memory_count - 1].filled = true;
+ dmi_memory_array_error_handle(WORD(data + 0x06), mem->error);
+ dmi_memory_device_width(WORD(data + 0x08), mem->total_width);
+ dmi_memory_device_width(WORD(data + 0x0A), mem->data_width);
+ dmi_memory_device_size(WORD(data + 0x0C), mem->size);
+ strcpy(mem->form_factor, dmi_memory_device_form_factor(data[0x0E]));
+ dmi_memory_device_set(data[0x0F], mem->device_set);
+ strcpy(mem->device_locator, dmi_string(h, data[0x10]));
+ strcpy(mem->bank_locator, dmi_string(h, data[0x11]));
+ strcpy(mem->type, dmi_memory_device_type(data[0x12]));
+ dmi_memory_device_type_detail(WORD(data + 0x13), mem->type_detail);
+ if (h->length < 0x17)
+ break;
+ dmi_memory_device_speed(WORD(data + 0x15), mem->speed);
+ if (h->length < 0x1B)
+ break;
+ strcpy(mem->manufacturer, dmi_string(h, data[0x17]));
+ strcpy(mem->serial, dmi_string(h, data[0x18]));
+ strcpy(mem->asset_tag, dmi_string(h, data[0x19]));
+ strcpy(mem->part_number, dmi_string(h, data[0x1A]));
+ break;
+ case 22: /* 3.3.23 Portable Battery */
+ if (h->length < 0x10)
+ break;
+ dmi->battery.filled = true;
+ strcpy(dmi->battery.location, dmi_string(h, data[0x04]));
+ strcpy(dmi->battery.manufacturer, dmi_string(h, data[0x05]));
+
+ if (data[0x06] || h->length < 0x1A)
+ strcpy(dmi->battery.manufacture_date, dmi_string(h, data[0x06]));
+
+ if (data[0x07] || h->length < 0x1A)
+ strcpy(dmi->battery.serial, dmi_string(h, data[0x07]));
+
+ strcpy(dmi->battery.name, dmi_string(h, data[0x08]));
+
+ if (data[0x09] != 0x02 || h->length < 0x1A)
+ strcpy(dmi->battery.chemistry, dmi_battery_chemistry(data[0x09]));
+
+ if (h->length < 0x1A)
+ dmi_battery_capacity(WORD(data + 0x0A), 1,
+ dmi->battery.design_capacity);
+ else
+ dmi_battery_capacity(WORD(data + 0x0A), data[0x15],
+ dmi->battery.design_capacity);
+ dmi_battery_voltage(WORD(data + 0x0C), dmi->battery.design_voltage);
+ strcpy(dmi->battery.sbds, dmi_string(h, data[0x0E]));
+ dmi_battery_maximum_error(data[0x0F], dmi->battery.maximum_error);
+ if (h->length < 0x1A)
+ break;
+ if (data[0x07] == 0)
+ sprintf(dmi->battery.sbds_serial, "%04X", WORD(data + 0x10));
+
+ if (data[0x06] == 0)
+ sprintf(dmi->battery.sbds_manufacture_date, "%u-%02u-%02u",
+ 1980 + (WORD(data + 0x12) >> 9),
+ (WORD(data + 0x12) >> 5) & 0x0F, WORD(data + 0x12) & 0x1F);
+ if (data[0x09] == 0x02)
+ strcpy(dmi->battery.sbds_chemistry, dmi_string(h, data[0x14]));
+
+ // sprintf(dmi->battery.oem_info,"0x%08X",DWORD(h, data+0x16));
+ break;
+ case 23: /* 3.3.24 System Reset */
+ if (h->length < 0x0D)
+ break;
+ dmi->system.system_reset.filled = true;
+ dmi->system.system_reset.status = data[0x04] & (1 << 0);
+ dmi->system.system_reset.watchdog = data[0x04] & (1 << 5);
+ if (!(data[0x04] & (1 << 5)))
+ break;
+ strncpy(dmi->system.system_reset.boot_option,
+ dmi_system_reset_boot_option((data[0x04] >> 1) & 0x3),
+ sizeof dmi->system.system_reset.boot_option);
+ strncpy(dmi->system.system_reset.boot_option_on_limit,
+ dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3),
+ sizeof dmi->system.system_reset.boot_option_on_limit);
+ dmi_system_reset_count(WORD(data + 0x05),
+ dmi->system.system_reset.reset_count);
+ dmi_system_reset_count(WORD(data + 0x07),
+ dmi->system.system_reset.reset_limit);
+ dmi_system_reset_timer(WORD(data + 0x09),
+ dmi->system.system_reset.timer_interval);
+ dmi_system_reset_timer(WORD(data + 0x0B),
+ dmi->system.system_reset.timeout);
+ break;
+ case 24: /* 3.3.25 Hardware Security */
+ if (h->length < 0x05)
+ break;
+ dmi->hardware_security.filled = true;
+ strncpy(dmi->hardware_security.power_on_passwd_status,
+ dmi_hardware_security_status(data[0x04] >> 6),
+ sizeof dmi->hardware_security.power_on_passwd_status);
+ strncpy(dmi->hardware_security.keyboard_passwd_status,
+ dmi_hardware_security_status((data[0x04] >> 4) & 0x3),
+ sizeof dmi->hardware_security.keyboard_passwd_status);
+ strncpy(dmi->hardware_security.administrator_passwd_status,
+ dmi_hardware_security_status((data[0x04] >> 2) & 0x3),
+ sizeof dmi->hardware_security.administrator_passwd_status);
+ strncpy(dmi->hardware_security.front_panel_reset_status,
+ dmi_hardware_security_status(data[0x04] & 0x3),
+ sizeof dmi->hardware_security.front_panel_reset_status);
+ break;
+ case 32: /* 3.3.33 System Boot Information */
+ if (h->length < 0x0B)
+ break;
+ dmi_system_boot_status(data[0x0A], dmi->system.system_boot_status);
+ case 38: /* 3.3.39 IPMI Device Information */
+ if (h->length < 0x10)
+ break;
+ dmi->ipmi.filled = true;
+ snprintf(dmi->ipmi.interface_type, sizeof(dmi->ipmi.interface_type),
+ "%s", dmi_ipmi_interface_type(data[0x04]));
+ dmi->ipmi.major_specification_version = data[0x05] >> 4;
+ dmi->ipmi.minor_specification_version = data[0x05] & 0x0F;
+ dmi->ipmi.I2C_slave_address = data[0x06] >> 1;
+ if (data[0x07] != 0xFF)
+ dmi->ipmi.nv_address = data[0x07];
+ else
+ dmi->ipmi.nv_address = 0; /* Not Present */
+ dmi_ipmi_base_address(data[0x04], data + 0x08, &dmi->ipmi);
+ if (h->length < 0x12)
+ break;
+ if (data[0x11] != 0x00) {
+ dmi->ipmi.irq = data[0x11];
+ }
+ break;
+ }
}
void parse_dmitable(s_dmi * dmi)
diff --git a/com32/gpllib/dmi/dmi_cache.c b/com32/gpllib/dmi/dmi_cache.c
index bc1fc45f..4c3f83ce 100644
--- a/com32/gpllib/dmi/dmi_cache.c
+++ b/com32/gpllib/dmi/dmi_cache.c
@@ -25,111 +25,110 @@
const char *dmi_cache_mode(uint8_t code)
{
- static const char *mode[]={
- "Write Through", /* 0x00 */
- "Write Back",
- "Varies With Memory Address",
- "Unknown" /* 0x03 */
- };
-
- return mode[code];
+ static const char *mode[] = {
+ "Write Through", /* 0x00 */
+ "Write Back",
+ "Varies With Memory Address",
+ "Unknown" /* 0x03 */
+ };
+
+ return mode[code];
}
const char *dmi_cache_location(uint8_t code)
{
- static const char *location[4]={
- "Internal", /* 0x00 */
- "External",
- NULL, /* 0x02 */
- "Unknown" /* 0x03 */
- };
-
- if(location[code]!=NULL)
- return location[code];
- return out_of_spec;
+ static const char *location[4] = {
+ "Internal", /* 0x00 */
+ "External",
+ "<OUT OF SPEC", /* 0x02 */
+ "Unknown" /* 0x03 */
+ };
+
+ if (location[code] != NULL)
+ return location[code];
+ return out_of_spec;
}
uint16_t dmi_cache_size(uint16_t code)
{
- if(code&0x8000)
- return (code&0x7FFF)<<6; /* KB */
- else
- return code; /* KB */
+ if (code & 0x8000)
+ return (code & 0x7FFF) << 6; /* KB */
+ else
+ return code; /* KB */
}
-void dmi_cache_types(uint16_t code, const char *sep, char* array)
+void dmi_cache_types(uint16_t code, const char *sep, char *array)
{
- /* 3.3.8.2 */
- static const char *types[]={
- "Other", /* 0 */
- "Unknown",
- "Non-burst",
- "Burst",
- "Pipeline Burst",
- "Synchronous",
- "Asynchronous" /* 6 */
- };
-
- if((code&0x007F)==0)
- strcpy(array, "None");
- else
- {
- int i;
-
- for(i=0; i<=6; i++)
- if(code&(1<<i))
- sprintf(array, "%s%s", sep, types[i]);
- }
+ /* 3.3.8.2 */
+ static const char *types[] = {
+ "Other", /* 0 */
+ "Unknown",
+ "Non-burst",
+ "Burst",
+ "Pipeline Burst",
+ "Synchronous",
+ "Asynchronous" /* 6 */
+ };
+
+ if ((code & 0x007F) == 0)
+ strcpy(array, "None");
+ else {
+ int i;
+
+ for (i = 0; i <= 6; i++)
+ if (code & (1 << i))
+ sprintf(array, "%s%s", sep, types[i]);
+ }
}
const char *dmi_cache_ec_type(uint8_t code)
{
- /* 3.3.8.3 */
- static const char *type[]={
- "Other", /* 0x01 */
- "Unknown",
- "None",
- "Parity",
- "Single-bit ECC",
- "Multi-bit ECC" /* 0x06 */
- };
-
- if(code>=0x01 && code<=0x06)
- return type[code-0x01];
- return out_of_spec;
+ /* 3.3.8.3 */
+ static const char *type[] = {
+ "Other", /* 0x01 */
+ "Unknown",
+ "None",
+ "Parity",
+ "Single-bit ECC",
+ "Multi-bit ECC" /* 0x06 */
+ };
+
+ if (code >= 0x01 && code <= 0x06)
+ return type[code - 0x01];
+ return out_of_spec;
}
const char *dmi_cache_type(uint8_t code)
{
- /* 3.3.8.4 */
- static const char *type[]={
- "Other", /* 0x01 */
- "Unknown",
- "Instruction",
- "Data",
- "Unified" /* 0x05 */
- };
-
- if(code>=0x01 && code<=0x05)
- return type[code-0x01];
- return out_of_spec;
+ /* 3.3.8.4 */
+ static const char *type[] = {
+ "Other", /* 0x01 */
+ "Unknown",
+ "Instruction",
+ "Data",
+ "Unified" /* 0x05 */
+ };
+
+ if (code >= 0x01 && code <= 0x05)
+ return type[code - 0x01];
+ return out_of_spec;
}
const char *dmi_cache_associativity(uint8_t code)
{
- /* 3.3.8.5 */
- static const char *type[]={
- "Other", /* 0x01 */
- "Unknown",
- "Direct Mapped",
- "2-way Set-associative",
- "4-way Set-associative",
- "Fully Associative",
- "8-way Set-associative",
- "16-way Set-associative" /* 0x08 */
- };
-
- if(code>=0x01 && code<=0x08)
- return type[code-0x01];
- return out_of_spec;
+ /* 3.3.8.5 */
+ static const char *type[] = {
+ "Other", /* 0x01 */
+ "Unknown",
+ "Direct Mapped",
+ "2-way Set-associative",
+ "4-way Set-associative",
+ "Fully Associative",
+ "8-way Set-associative",
+ "16-way Set-associative" /* 0x08 */
+ };
+
+ if (code >= 0x01 && code <= 0x08)
+ return type[code - 0x01];
+ return out_of_spec;
}
diff --git a/com32/gpllib/dmi/dmi_chassis.c b/com32/gpllib/dmi/dmi_chassis.c
index 84dbe909..afca5c26 100644
--- a/com32/gpllib/dmi/dmi_chassis.c
+++ b/com32/gpllib/dmi/dmi_chassis.c
@@ -57,10 +57,14 @@ const char *dmi_chassis_type(uint8_t code)
"RAID Chassis",
"Rack Mount Chassis",
"Sealed-case PC",
- "Multi-system" /* 0x19 */
+ "Multi-system", /* 0x19 */
+ "CompactPCI",
+ "AdvancedTCA",
+ "Blade",
+ "Blade Enclosing" /* 0x1D */
};
- if (code >= 0x01 && code <= 0x19)
+ if (code >= 0x01 && code <= 0x1D)
return type[code - 0x01];
return out_of_spec;
}
diff --git a/com32/gpllib/dmi/dmi_memory.c b/com32/gpllib/dmi/dmi_memory.c
index 5c747d69..58f43a00 100644
--- a/com32/gpllib/dmi/dmi_memory.c
+++ b/com32/gpllib/dmi/dmi_memory.c
@@ -175,88 +175,85 @@ void dmi_memory_device_speed(uint16_t code, char *speed)
void dmi_memory_module_types(uint16_t code, const char *sep, char *type)
{
- /* 3.3.7.1 */
- static const char *types[]={
- "Other", /* 0 */
- "Unknown",
- "Standard",
- "FPM",
- "EDO",
- "Parity",
- "ECC",
- "SIMM",
- "DIMM",
- "Burst EDO",
- "SDRAM" /* 10 */
- };
+ /* 3.3.7.1 */
+ static const char *types[] = {
+ "Other", /* 0 */
+ "Unknown",
+ "Standard",
+ "FPM",
+ "EDO",
+ "Parity",
+ "ECC",
+ "SIMM",
+ "DIMM",
+ "Burst EDO",
+ "SDRAM" /* 10 */
+ };
- if((code&0x07FF)==0)
- sprintf(type, "%s", "None");
- else
- {
- int i;
+ if ((code & 0x07FF) == 0)
+ sprintf(type, "%s", "None");
+ else {
+ int i;
- for(i=0; i<=10; i++)
- if(code&(1<<i))
- sprintf(type, "%s%s", sep, types[i]);
- }
+ for (i = 0; i <= 10; i++)
+ if (code & (1 << i))
+ sprintf(type, "%s%s%s", type, sep, types[i]);
+ }
}
-void dmi_memory_module_connections(uint8_t code, char* connection)
+void dmi_memory_module_connections(uint8_t code, char *connection)
{
- if(code==0xFF)
- sprintf(connection, "%s", "None");
- else
- {
- if((code&0xF0)!=0xF0)
- sprintf(connection, "%u", code>>4);
- if((code&0x0F)!=0x0F)
- sprintf(connection, "%u", code&0x0F);
- }
+ if (code == 0xFF)
+ sprintf(connection, "%s", "None");
+ else {
+ if ((code & 0xF0) != 0xF0)
+ sprintf(connection, "%u ", code >> 4);
+ if ((code & 0x0F) != 0x0F)
+ sprintf(connection, "%s%u", connection, code & 0x0F);
+ }
}
-void dmi_memory_module_speed(uint8_t code, char* speed)
+void dmi_memory_module_speed(uint8_t code, char *speed)
{
- if(code==0)
- sprintf(speed, "%s", "Unknown");
- else
- sprintf(speed, "%u ns", code);
+ if (code == 0)
+ sprintf(speed, "%s", "Unknown");
+ else
+ sprintf(speed, "%u ns", code);
}
-void dmi_memory_module_size(uint8_t code, char* size)
+void dmi_memory_module_size(uint8_t code, char *size)
{
- /* 3.3.7.2 */
- switch(code&0x7F)
- {
- case 0x7D:
- sprintf(size, "%s", "Not Determinable");
- break;
- case 0x7E:
- sprintf(size, "%s", "Disabled");
- break;
- case 0x7F:
- sprintf(size, "%s", "Not Installed");
- return;
- default:
- sprintf(size, "%u MB", 1<<(code&0x7F));
- }
+ /* 3.3.7.2 */
+ switch (code & 0x7F) {
+ case 0x7D:
+ sprintf(size, "%s", "Not Determinable");
+ break;
+ case 0x7E:
+ sprintf(size, "%s", "Disabled");
+ break;
+ case 0x7F:
+ sprintf(size, "%s", "Not Installed");
+ return;
+ default:
+ sprintf(size, "%u MB", 1 << (code & 0x7F));
+ }
- if(code&0x80)
- sprintf(size, "%s", "(Double-bank Connection)");
- else
- sprintf(size, "%s", "(Single-bank Connection)");
+ if (code & 0x80)
+ sprintf(size, "%s %s", size, "(Double-bank Connection)");
+ else
+ sprintf(size, "%s %s", size, "(Single-bank Connection)");
}
void dmi_memory_module_error(uint8_t code, const char *prefix, char *error)
{
- if(code&(1<<2))
- sprintf(error, "%s", "See Event Log\n");
- else
- { if((code&0x03)==0)
- sprintf(error, "%s", "OK\n");
- if(code&(1<<0))
- sprintf(error, "%sUncorrectable Errors\n", prefix);
- if(code&(1<<1))
- sprintf(error, "%sCorrectable Errors\n", prefix);
- }
+ if (code & (1 << 2))
+ sprintf(error, "%s", "See Event Log\n");
+ else {
+ if ((code & 0x03) == 0)
+ sprintf(error, "%s", "OK\n");
+ if (code & (1 << 0))
+ sprintf(error, "%sUncorrectable Errors\n", prefix);
+ if (code & (1 << 1))
+ sprintf(error, "%sCorrectable Errors\n", prefix);
+ }
}
diff --git a/com32/gpllib/dmi/dmi_processor.c b/com32/gpllib/dmi/dmi_processor.c
index 8f3dda63..fd007da3 100644
--- a/com32/gpllib/dmi/dmi_processor.c
+++ b/com32/gpllib/dmi/dmi_processor.c
@@ -305,7 +305,54 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
NULL, /* 0xFC */
NULL,
NULL,
- NULL /* 0xFF */
+ NULL, /* 0xFF */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "SH-3",
+ "SH-4",
+ NULL, /*0x106*/
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /*0x110*/
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "ARM",
+ "StrongARM",
+ NULL, /*0x19A*/
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /*0x120*/
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /*0x12A*/
+ NULL,
+ "6x86",
+ "MediaGX",
+ "MII" /*0x12E*/
/* master.mif has values beyond that, but they can't be used for DMI */
};
/* Special case for ambiguous value 0xBE */
@@ -320,7 +367,7 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
return "Core 2 or K7";
}
- if (family[code] != NULL) {
+ if ((code<=0x12E) && (family[code] != NULL)) {
return family[code];
}
return out_of_spec;
@@ -368,7 +415,7 @@ const char *dmi_processor_upgrade(uint8_t code)
"Socket 754",
"Socket 940",
"Socket 939" /* 0x12 */
- "Socket mPGA604",
+ "Socket mPGA604",
"Socket LGA771",
"Socket LGA775",
"Socket S1",
@@ -376,7 +423,7 @@ const char *dmi_processor_upgrade(uint8_t code)
"Socket F (1207)"
};
- if (code >= 0x01 && code <= 0x11)
+ if (code >= 0x01 && code <= 0x18)
return upgrade[code - 0x01];
return out_of_spec;
}
diff --git a/com32/gpllib/memory.c b/com32/gpllib/memory.c
index 6c6e351c..d98de030 100644
--- a/com32/gpllib/memory.c
+++ b/com32/gpllib/memory.c
@@ -25,26 +25,26 @@
#include <string.h>
#include <memory.h>
-const char * const e820_types[] = {
- "usable",
- "reserved",
- "ACPI reclaim",
- "ACPI NVS",
- "unusable",
+const char *const e820_types[] = {
+ "usable",
+ "reserved",
+ "ACPI reclaim",
+ "ACPI NVS",
+ "unusable",
};
struct e820_ext_entry {
- struct e820entry std;
- uint32_t ext_flags;
-} __attribute__((packed));
+ struct e820entry std;
+ uint32_t ext_flags;
+} __attribute__ ((packed));
#define SMAP 0x534d4150 /* ASCII "SMAP" */
void get_type(int type, char *type_ptr, int type_ptr_sz)
{
- unsigned int real_type = type - 1;
- if (real_type < sizeof(e820_types)/sizeof(e820_types[0]))
- strncpy(type_ptr, e820_types[real_type], type_ptr_sz);
+ unsigned int real_type = type - 1;
+ if (real_type < sizeof(e820_types) / sizeof(e820_types[0]))
+ strncpy(type_ptr, e820_types[real_type], type_ptr_sz);
}
/**
@@ -85,66 +85,65 @@ void get_type(int type, char *type_ptr, int type_ptr_sz)
**/
void detect_memory_e820(struct e820entry *desc, int size_map, int *size_found)
{
- int count = 0;
- static struct e820_ext_entry buf; /* static so it is zeroed */
+ int count = 0;
+ static struct e820_ext_entry buf; /* static so it is zeroed */
- com32sys_t ireg, oreg;
- memset(&ireg, 0, sizeof ireg);
+ com32sys_t ireg, oreg;
+ memset(&ireg, 0, sizeof ireg);
- ireg.eax.w[0] = 0xe820;
- ireg.edx.l = SMAP;
- ireg.ecx.l = sizeof(struct e820_ext_entry);
- ireg.edi.w[0] = OFFS(__com32.cs_bounce);
- ireg.es = SEG(__com32.cs_bounce);
+ ireg.eax.w[0] = 0xe820;
+ ireg.edx.l = SMAP;
+ ireg.ecx.l = sizeof(struct e820_ext_entry);
+ ireg.edi.w[0] = OFFS(__com32.cs_bounce);
+ ireg.es = SEG(__com32.cs_bounce);
- /*
- * Set this here so that if the BIOS doesn't change this field
- * but still doesn't change %ecx, we're still okay...
- */
- memset(&buf, 0, sizeof buf);
- buf.ext_flags = 1;
-
- do {
- memcpy(__com32.cs_bounce, &buf, sizeof buf);
-
- /* Important: %edx and %esi are clobbered by some BIOSes,
- so they must be either used for the error output
- or explicitly marked clobbered. Given that, assume there
- is something out there clobbering %ebp and %edi, too. */
- __intcall(0x15, &ireg, &oreg);
-
- /* Some BIOSes stop returning SMAP in the middle of
- the search loop. We don't know exactly how the BIOS
- screwed up the map at that point, we might have a
- partial map, the full map, or complete garbage, so
- just return failure. */
- if (oreg.eax.l != SMAP) {
- count = 0;
- break;
- }
+ /*
+ * Set this here so that if the BIOS doesn't change this field
+ * but still doesn't change %ecx, we're still okay...
+ */
+ memset(&buf, 0, sizeof buf);
+ buf.ext_flags = 1;
- if (oreg.eflags.l & EFLAGS_CF ||
- oreg.ecx.l < 20)
- break;
+ do {
+ memcpy(__com32.cs_bounce, &buf, sizeof buf);
- memcpy(&buf, __com32.cs_bounce, sizeof buf);
+ /* Important: %edx and %esi are clobbered by some BIOSes,
+ so they must be either used for the error output
+ or explicitly marked clobbered. Given that, assume there
+ is something out there clobbering %ebp and %edi, too. */
+ __intcall(0x15, &ireg, &oreg);
- /*
- * ACPI 3.0 added the extended flags support. If bit 0
- * in the extended flags is zero, we're supposed to simply
- * ignore the entry -- a backwards incompatible change!
- */
- if (oreg.ecx.l > 20 && !(buf.ext_flags & 1))
- continue;
+ /* Some BIOSes stop returning SMAP in the middle of
+ the search loop. We don't know exactly how the BIOS
+ screwed up the map at that point, we might have a
+ partial map, the full map, or complete garbage, so
+ just return failure. */
+ if (oreg.eax.l != SMAP) {
+ count = 0;
+ break;
+ }
- memcpy(&desc[count], &buf, sizeof buf);
- count++;
+ if (oreg.eflags.l & EFLAGS_CF || oreg.ecx.l < 20)
+ break;
- /* Set continuation value */
- ireg.ebx.l = oreg.ebx.l;
- } while (ireg.ebx.l && count < size_map);
+ memcpy(&buf, __com32.cs_bounce, sizeof buf);
- *size_found = count;
+ /*
+ * ACPI 3.0 added the extended flags support. If bit 0
+ * in the extended flags is zero, we're supposed to simply
+ * ignore the entry -- a backwards incompatible change!
+ */
+ if (oreg.ecx.l > 20 && !(buf.ext_flags & 1))
+ continue;
+
+ memcpy(&desc[count], &buf, sizeof buf);
+ count++;
+
+ /* Set continuation value */
+ ireg.ebx.l = oreg.ebx.l;
+ } while (ireg.ebx.l && count < size_map);
+
+ *size_found = count;
}
/**
@@ -172,45 +171,275 @@ void detect_memory_e820(struct e820entry *desc, int size_map, int *size_found)
* (for example with parameter /EISA) (see also MEM F000h:FFD9h), or no
* Compaq machine was detected, or parameter /NOABOVE16 was given.
**/
-int detect_memory_e801(int* mem_size_below_16, int* mem_size_above_16)
+int detect_memory_e801(int *mem_size_below_16, int *mem_size_above_16)
{
- com32sys_t ireg, oreg;
- memset(&ireg, 0, sizeof ireg);
+ com32sys_t ireg, oreg;
+ memset(&ireg, 0, sizeof ireg);
- ireg.eax.w[0] = 0xe801;
+ ireg.eax.w[0] = 0xe801;
- __intcall(0x15, &ireg, &oreg);
+ __intcall(0x15, &ireg, &oreg);
- if (oreg.eflags.l & EFLAGS_CF)
- return -1;
+ if (oreg.eflags.l & EFLAGS_CF)
+ return -1;
- if (oreg.eax.w[0] > 0x3c00)
- return -1; /* Bogus! */
+ if (oreg.eax.w[0] > 0x3c00)
+ return -1; /* Bogus! */
- /* Linux seems to use ecx and edx by default if they are defined */
- if (oreg.eax.w[0] || oreg.eax.w[0]) {
- oreg.eax.w[0] = oreg.ecx.w[0];
- oreg.ebx.w[0] = oreg.edx.w[0];
- }
+ /* Linux seems to use ecx and edx by default if they are defined */
+ if (oreg.eax.w[0] || oreg.eax.w[0]) {
+ oreg.eax.w[0] = oreg.ecx.w[0];
+ oreg.ebx.w[0] = oreg.edx.w[0];
+ }
- *mem_size_below_16 = oreg.eax.w[0]; /* 1K blocks */
- *mem_size_above_16 = oreg.ebx.w[0]; /* 64K blocks */
+ *mem_size_below_16 = oreg.eax.w[0]; /* 1K blocks */
+ *mem_size_above_16 = oreg.ebx.w[0]; /* 64K blocks */
- return 0;
+ return 0;
}
-int detect_memory_88(int* mem_size)
+int detect_memory_88(int *mem_size)
{
- com32sys_t ireg, oreg;
- memset(&ireg, 0, sizeof ireg);
+ com32sys_t ireg, oreg;
+ memset(&ireg, 0, sizeof ireg);
- ireg.eax.w[0] = 0x8800;
+ ireg.eax.w[0] = 0x8800;
- __intcall(0x15, &ireg, &oreg);
+ __intcall(0x15, &ireg, &oreg);
+
+ if (oreg.eflags.l & EFLAGS_CF)
+ return -1;
+
+ *mem_size = oreg.eax.w[0];
+ return 0;
+}
+
+/*
+ * Sanitize the BIOS e820 map.
+ *
+ * This code come from the memtest86 project. It have been adjusted to match
+ * the syslinux environement.
+ * Some e820 responses include overlapping entries. The following
+ * replaces the original e820 map with a new one, removing overlaps.
+ *
+ * The following stuff could be merge once the addr_t will be set to 64bits.
+ * syslinux_scan_memory can be used for that purpose
+ */
+int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios,
+ short old_nr)
+{
+ struct change_member {
+ struct e820entry *pbios; /* pointer to original bios entry */
+ unsigned long long addr; /* address for this change point */
+ };
+ struct change_member change_point_list[2 * E820MAX];
+ struct change_member *change_point[2 * E820MAX];
+ struct e820entry *overlap_list[E820MAX];
+ struct e820entry biosmap[E820MAX];
+ struct change_member *change_tmp;
+ unsigned long current_type, last_type;
+ unsigned long long last_addr;
+ int chgidx, still_changing;
+ int overlap_entries;
+ int new_bios_entry;
+ int i;
+
+ /*
+ Visually we're performing the following (1,2,3,4 = memory types)...
+ Sample memory map (w/overlaps):
+ ____22__________________
+ ______________________4_
+ ____1111________________
+ _44_____________________
+ 11111111________________
+ ____________________33__
+ ___________44___________
+ __________33333_________
+ ______________22________
+ ___________________2222_
+ _________111111111______
+ _____________________11_
+ _________________4______
+
+ Sanitized equivalent (no overlap):
+ 1_______________________
+ _44_____________________
+ ___1____________________
+ ____22__________________
+ ______11________________
+ _________1______________
+ __________3_____________
+ ___________44___________
+ _____________33_________
+ _______________2________
+ ________________1_______
+ _________________4______
+ ___________________2____
+ ____________________33__
+ ______________________4_
+ */
+ /* First make a copy of the map */
+ for (i = 0; i < old_nr; i++) {
+ biosmap[i].addr = orig_map[i].addr;
+ biosmap[i].size = orig_map[i].size;
+ biosmap[i].type = orig_map[i].type;
+ }
- if (oreg.eflags.l & EFLAGS_CF)
- return -1;
+ /* bail out if we find any unreasonable addresses in bios map */
+ for (i = 0; i < old_nr; i++) {
+ if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
+ return 0;
+ }
- *mem_size = oreg.eax.w[0];
+ /* create pointers for initial change-point information (for sorting) */
+ for (i = 0; i < 2 * old_nr; i++)
+ change_point[i] = &change_point_list[i];
+
+ /* record all known change-points (starting and ending addresses) */
+ chgidx = 0;
+ for (i = 0; i < old_nr; i++) {
+ change_point[chgidx]->addr = biosmap[i].addr;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ }
+
+ /* sort change-point list by memory addresses (low -> high) */
+ still_changing = 1;
+ while (still_changing) {
+ still_changing = 0;
+ for (i = 1; i < 2 * old_nr; i++) {
+ /* if <current_addr> > <last_addr>, swap */
+ /* or, if current=<start_addr> & last=<end_addr>, swap */
+ if ((change_point[i]->addr < change_point[i - 1]->addr) ||
+ ((change_point[i]->addr == change_point[i - 1]->addr) &&
+ (change_point[i]->addr == change_point[i]->pbios->addr) &&
+ (change_point[i - 1]->addr !=
+ change_point[i - 1]->pbios->addr))
+ ) {
+ change_tmp = change_point[i];
+ change_point[i] = change_point[i - 1];
+ change_point[i - 1] = change_tmp;
+ still_changing = 1;
+ }
+ }
+ }
+
+ /* create a new bios memory map, removing overlaps */
+ overlap_entries = 0; /* number of entries in the overlap table */
+ new_bios_entry = 0; /* index for creating new bios map entries */
+ last_type = 0; /* start with undefined memory type */
+ last_addr = 0; /* start with 0 as last starting address */
+ /* loop through change-points, determining affect on the new bios map */
+ for (chgidx = 0; chgidx < 2 * old_nr; chgidx++) {
+ /* keep track of all overlapping bios entries */
+ if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr) {
+ /* add map entry to overlap list (> 1 entry implies an overlap) */
+ overlap_list[overlap_entries++] = change_point[chgidx]->pbios;
+ } else {
+ /* remove entry from list (order independent, so swap with last) */
+ for (i = 0; i < overlap_entries; i++) {
+ if (overlap_list[i] == change_point[chgidx]->pbios)
+ overlap_list[i] = overlap_list[overlap_entries - 1];
+ }
+ overlap_entries--;
+ }
+ /* if there are overlapping entries, decide which "type" to use */
+ /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
+ current_type = 0;
+ for (i = 0; i < overlap_entries; i++)
+ if (overlap_list[i]->type > current_type)
+ current_type = overlap_list[i]->type;
+ /* continue building up new bios map based on this information */
+ if (current_type != last_type) {
+ if (last_type != 0) {
+ new_bios[new_bios_entry].size =
+ change_point[chgidx]->addr - last_addr;
+ /* move forward only if the new size was non-zero */
+ if (new_bios[new_bios_entry].size != 0)
+ if (++new_bios_entry >= E820MAX)
+ break; /* no more space left for new bios entries */
+ }
+ if (current_type != 0) {
+ new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
+ new_bios[new_bios_entry].type = current_type;
+ last_addr = change_point[chgidx]->addr;
+ }
+ last_type = current_type;
+ }
+ }
+ return (new_bios_entry);
+}
+
+/* The following stuff could be merge once the addr_t will be set to 64bits.
+ * syslinux_scan_memory can be used for that purpose */
+unsigned long detect_memsize(void)
+{
+ unsigned long memory_size = 0;
+
+ /* Try to detect memory via e820 */
+ struct e820entry map[E820MAX];
+ int count = 0;
+ detect_memory_e820(map, E820MAX, &count);
+ memory_size = memsize_e820(map, count);
+ if (memory_size > 0)
+ return memory_size;
+
+ /*e820 failed, let's try e801 */
+ int mem_low, mem_high = 0;
+ if (!detect_memory_e801(&mem_low, &mem_high))
+ return mem_low + (mem_high << 6);
+
+ /*e801 failed, let's try e88 */
+ int mem_size = 0;
+ if (!detect_memory_88(&mem_size))
+ return mem_size;
+
+ /* We were enable to detect any kind of memory */
+ return 0;
+}
+
+/* The following stuff could be merge once the addr_t will be set to 64bits.
+ * syslinux_scan_memory can be used for that purpose */
+unsigned long memsize_e820(struct e820entry *e820, int e820_nr)
+{
+ int i, n, nr;
+ unsigned long memory_size = 0;
+ struct e820entry nm[E820MAX];
+
+ /* Clean up, adjust and copy the BIOS-supplied E820-map. */
+ nr = sanitize_e820_map(e820, nm, e820_nr);
+
+ /* If there is not a good 820 map returning 0 to indicate
+ that we don't have any idea of the amount of ram we have */
+ if (nr < 1 || nr > E820MAX) {
return 0;
+ }
+
+ /* Build the memory map for testing */
+ n = 0;
+ for (i = 0; i < nr; i++) {
+ if (nm[i].type == E820_RAM || nm[i].type == E820_ACPI) {
+ unsigned long long start;
+ unsigned long long end;
+ start = nm[i].addr;
+ end = start + nm[i].size;
+
+ /* Don't ever use memory between 640 and 1024k */
+ if (start > RES_START && start < RES_END) {
+ if (end < RES_END) {
+ continue;
+ }
+ start = RES_END;
+ }
+ if (end > RES_START && end < RES_END) {
+ end = RES_START;
+ }
+ memory_size += (end >> 12) - ((start + 4095) >> 12);
+ n++;
+ } else if (nm[i].type == E820_NVS) {
+ memory_size += nm[i].size >> 12;
+ }
+ }
+ return memory_size * 4;
}
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index b3eb88dc..5c02c43f 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -26,55 +26,90 @@ 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.00/memtest86+-4.00.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
-REBOOT_COM32 ?= $(com32)/modules/reboot.c32
+GZ_PCI_IDS_FILE ?= $(PCI_IDS_FILE).gz
+REBOOT_COM32 ?= $(com32)/modules/reboot.c32
+MENU_COM32 ?= $(com32)/menu/menu.c32
+ART_DIR ?= art/
all: $(MODULES) $(TESTFILES)
hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
-hdt.img: hdt.c32 $(FLOPPY_DIR)/hdt.cfg $(FLOPPY_DIR)/mtools.conf $(topdir)/mtools/syslinux $(REBOOT_COM32)
- rm -f hdt.img
- MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MFORMAT) -v HDT -f 2880 -C a:
+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 $(REBOOT_COM32) $(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 $(PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE)
- -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE)
- -[ -f $(MODULES_ALIAS_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MODULES_ALIAS_FILE) a:
- -[ -f $(MODULES_PCIMAP_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MODULES_PCIMAP_FILE) a:
+ -[ ! -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:
MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(REBOOT_COM32) a:
- @ [ -f $(PCI_IDS_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(PCI_IDS_FILE) a: || 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"
- MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/hdt.cfg a:syslinux.cfg
+ @ [ -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.img >hdt.img.gz
+ 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
+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)
- cp $(FLOPPY_DIR)/hdt.cfg $(ISO_DIR)/$(ISOLINUX_DIR)/isolinux.cfg
+ $(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 $(REBOOT_COM32) $(ISO_DIR)/$(ISOLINUX_DIR)
- -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE)
- -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE)
- -[ -f $(MODULES_ALIAS_FILE) ] && cp $(MODULES_ALIAS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)
- -[ -f $(MODULES_PCIMAP_FILE) ] && cp $(MODULES_PCIMAP_FILE) $(ISO_DIR)/$(ISOLINUX_DIR)
- -[ ! -f $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids ] && cp $(PCI_IDS_FILE) $(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
@@ -83,8 +118,10 @@ clean: tidy
rm -f *.lnx
spotless: clean
- rm -f *.lss *.c32 *.com hdt.img hdt.iso
+ 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:
diff --git a/com32/hdt/art/backgnd.png b/com32/hdt/art/backgnd.png
new file mode 100644
index 00000000..a51efeb0
--- /dev/null
+++ b/com32/hdt/art/backgnd.png
Binary files differ
diff --git a/com32/hdt/art/hdt-black.png b/com32/hdt/art/hdt-black.png
new file mode 100644
index 00000000..9bfdd943
--- /dev/null
+++ b/com32/hdt/art/hdt-black.png
Binary files differ
diff --git a/com32/hdt/art/hdt.png b/com32/hdt/art/hdt.png
new file mode 100644
index 00000000..3dad8e75
--- /dev/null
+++ b/com32/hdt/art/hdt.png
Binary files differ
diff --git a/com32/hdt/floppy/hdt.cfg b/com32/hdt/floppy/hdt.cfg
index 8f707d0f..27d11bac 100644
--- a/com32/hdt/floppy/hdt.cfg
+++ b/com32/hdt/floppy/hdt.cfg
@@ -1,7 +1,78 @@
+UI menu.c32
DEFAULT hdt
PROMPT 0
-SERIAL 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
+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.00
+TEXT HELP
+ Starts Memtest86+ 4.00
+ENDTEXT
+LINUX memtest.bin
diff --git a/com32/hdt/hdt-ata.h b/com32/hdt/hdt-ata.h
index a9550837..ff35a59d 100644
--- a/com32/hdt/hdt-ata.h
+++ b/com32/hdt/hdt-ata.h
@@ -34,42 +34,42 @@
#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];
+ 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;
+ 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,
+ 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);
+ unsigned int len);
void ata_id_string(const uint16_t * id, unsigned char *s, unsigned int ofs,
- unsigned int len);
+ unsigned int len);
void printregs(const com32sys_t * r);
#endif
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index d2b5979f..aa7ec8f7 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -37,162 +37,191 @@
void main_show_cpu(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- cpu_detect(hardware);
- detect_dmi(hardware);
- more_printf("CPU\n");
- more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
- more_printf(" Product : %s \n", del_multi_spaces(hardware->cpu.model));
- if ((hardware->cpu.flags.lm == false)
- && (hardware->cpu.flags.smp == false)) {
- more_printf(" Features : %d MhZ : x86 32bits\n",
- hardware->dmi.processor.current_speed);
- } else if ((hardware->cpu.flags.lm == false)
- && (hardware->cpu.flags.smp == true)) {
- more_printf(" Features : %d MhZ : x86 32bits SMP\n",
- hardware->dmi.processor.current_speed);
- } else if ((hardware->cpu.flags.lm == true)
- && (hardware->cpu.flags.smp == false)) {
- more_printf(" Features : %d MhZ : x86_64 64bits\n",
- hardware->dmi.processor.current_speed);
- } else {
- more_printf(" Features : %d MhZ : x86_64 64bits SMP\n",
- hardware->dmi.processor.current_speed);
- }
+ 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(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];
- char buffer1[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("Vendor ID : %d\n", hardware->cpu.vendor_id);
- 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);
+ 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);
- 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");
- }
+ 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");
+ }
- memset(buffer, 0, sizeof(buffer));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.fpu)
- strcat(buffer1, "fpu ");
- if (hardware->cpu.flags.vme)
- strcat(buffer1, "vme ");
- if (hardware->cpu.flags.de)
- strcat(buffer1, "de ");
- if (hardware->cpu.flags.pse)
- strcat(buffer1, "pse ");
- if (hardware->cpu.flags.tsc)
- strcat(buffer1, "tsc ");
- if (hardware->cpu.flags.msr)
- strcat(buffer1, "msr ");
- if (hardware->cpu.flags.pae)
- strcat(buffer1, "pae ");
- if (hardware->cpu.flags.mce)
- strcat(buffer1, "mce ");
- if (hardware->cpu.flags.cx8)
- strcat(buffer1, "cx8 ");
- if (hardware->cpu.flags.apic)
- strcat(buffer1, "apic ");
- if (hardware->cpu.flags.sep)
- strcat(buffer1, "sep ");
- if (hardware->cpu.flags.mtrr)
- strcat(buffer1, "mtrr ");
- if (hardware->cpu.flags.pge)
- strcat(buffer1, "pge ");
- if (hardware->cpu.flags.mca)
- strcat(buffer1, "mca ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ 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));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.cmov)
- strcat(buffer1, "cmov ");
- if (hardware->cpu.flags.pat)
- strcat(buffer1, "pat ");
- if (hardware->cpu.flags.pse_36)
- strcat(buffer1, "pse_36 ");
- if (hardware->cpu.flags.psn)
- strcat(buffer1, "psn ");
- if (hardware->cpu.flags.clflsh)
- strcat(buffer1, "clflsh ");
- if (hardware->cpu.flags.dts)
- strcat(buffer1, "dts ");
- if (hardware->cpu.flags.acpi)
- strcat(buffer1, "acpi ");
- if (hardware->cpu.flags.mmx)
- strcat(buffer1, "mmx ");
- if (hardware->cpu.flags.sse)
- strcat(buffer1, "sse ");
- if (hardware->cpu.flags.sse2)
- strcat(buffer1, "sse2 ");
- if (hardware->cpu.flags.ss)
- strcat(buffer1, "ss ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ 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);
- memset(buffer, 0, sizeof(buffer));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.htt)
- strcat(buffer1, "ht ");
- if (hardware->cpu.flags.acc)
- strcat(buffer1, "acc ");
- if (hardware->cpu.flags.syscall)
- strcat(buffer1, "syscall ");
- if (hardware->cpu.flags.mp)
- strcat(buffer1, "mp ");
- if (hardware->cpu.flags.nx)
- strcat(buffer1, "nx ");
- if (hardware->cpu.flags.mmxext)
- strcat(buffer1, "mmxext ");
- if (hardware->cpu.flags.lm)
- strcat(buffer1, "lm ");
- if (hardware->cpu.flags.nowext)
- strcat(buffer1, "3dnowext ");
- if (hardware->cpu.flags.now)
- strcat(buffer1, "3dnow! ");
- if (hardware->cpu.flags.svm)
- strcat(buffer1, "svm ");
- if (hardware->cpu.flags.vmx)
- strcat(buffer1, "vmx ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ /* Let's flush the remaining flags */
+ show_flag(buffer, false, "", true);
}
struct cli_module_descr cpu_show_modules = {
- .modules = NULL,
- .default_callback = show_cpu,
+ .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,
+ .mode = CPU_MODE,
+ .name = CLI_CPU,
+ .default_modules = NULL,
+ .show_modules = &cpu_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index 7f6b00db..c43b7ca7 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -55,185 +55,199 @@ static void show_partition_information(struct driveinfo *drive_info,
int partition_offset,
int nb_partitions_seen)
{
- char size[9];
- char bootloader_name[9];
- char *parttype;
- unsigned int start, end;
+ char size[11];
+ char bootloader_name[9];
+ char *parttype;
+ unsigned int start, end;
- int i = nb_partitions_seen;
+ int i = nb_partitions_seen;
reset_more_printf();
- start = partition_offset;
- end = start + ptab->length - 1;
+ 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 (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");
+ 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);
+ 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)");
+ /* 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);
+ if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0)
+ more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name);
- more_printf("\n");
+ more_printf("\n");
- free(parttype);
+ free(parttype);
}
-void main_show_disk(int argc, char **argv,
- struct s_hardware *hardware)
+void main_show_disk(int argc, char **argv, struct s_hardware *hardware)
{
- if (!argc) {
- more_printf("Which disk?\n");
- return;
- }
+ if (!argc) {
+ more_printf("Which disk?\n");
+ return;
+ }
- int drive = strtol(argv[0], (char**) NULL, 16);
+ int drive = strtol(argv[0], (char **)NULL, 16);
- if (drive < 0x80 || drive >= 0xff) {
- more_printf("Invalid disk: %d.\n", drive);
- return;
- }
+ 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[9];
- char mbr_name[50];
+ int i = drive - 0x80;
+ struct driveinfo *d = &hardware->disk_info[i];
+ char disk_size[11];
+ char mbr_name[50];
- detect_disks(hardware);
+ detect_disks(hardware);
reset_more_printf();
- if (!hardware->disk_info[i].cbios)
- return; /* Invalid geometry */
+ 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);
+ 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",
+ 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");
+ 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");
+ more_printf("\n");
}
void main_show_disks(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- reset_more_printf();
- detect_disks(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) {
- 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);
- }
+ 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,
+void disks_summary(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- int i = -1;
-
- detect_disks(hardware);
- reset_more_printf();
-
- for (int drive = 0x80; drive < 0xff; drive++) {
- i++;
- if (!hardware->disk_info[i].cbios)
- continue; /* Invalid geometry */
- struct driveinfo *d = &hardware->disk_info[i];
- char disk_size[9];
-
- 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);
- 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));
- }
+ 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,
- },
+ {
+ .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,
+ .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,
+ .mode = DISK_MODE,
+ .name = CLI_DISK,
+ .default_modules = NULL,
+ .show_modules = &disk_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 194cded3..968308b1 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -34,471 +34,458 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-static void show_dmi_modules(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+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;
- }
+ 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;
- }
+ }
+ 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);
+ }
+ 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)
+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]);
+ 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);
+
+ 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)
+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);
+ 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)
+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]);
+ 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_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]);
+ 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)
+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);
+ 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)
+ 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);
+ 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)
+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);
+ 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)
+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);
+ 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]);
+ 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)
+void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware)
{
- int bank = -1;
+ int bank = -1;
- /* Sanitize arguments */
- if (argc > 0)
- bank = strtol(argv[0], (char **)NULL, 10);
+ /* 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 (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);
+ 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)
+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;
- }
+ 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);
+ 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;
- }
+ 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);
+ 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)
+void show_dmi_memory_module(int argc, char **argv, struct s_hardware *hardware)
{
- int module = -1;
+ int module = -1;
- /* Sanitize arguments */
- if (argc > 0)
- module = strtol(argv[0], (char **)NULL, 10);
+ /* 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 (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 ((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;
- }
+ 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",
+ 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",
+ more_printf(" Bank Connections : %s\n",
hardware->dmi.memory_module[module].bank_connections);
- more_printf(" Current Speed : %s\n",
+ more_printf(" Current Speed : %s\n",
hardware->dmi.memory_module[module].speed);
- more_printf(" Type : %s\n",
+ more_printf(" Type : %s\n",
hardware->dmi.memory_module[module].type);
- more_printf(" Installed Size : %s\n",
+ more_printf(" Installed Size : %s\n",
hardware->dmi.memory_module[module].installed_size);
- more_printf(" Enabled Size : %s\n",
+ more_printf(" Enabled Size : %s\n",
hardware->dmi.memory_module[module].enabled_size);
- more_printf(" Error Status : %s\n",
+ more_printf(" Error Status : %s\n",
hardware->dmi.memory_module[module].error_status);
}
@@ -506,179 +493,196 @@ void main_show_dmi(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_dmi(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);
+ 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);
+ show_dmi_modules(0, NULL, hardware);
}
-void show_dmi_memory_modules(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+void show_dmi_memory_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- int show_free_banks = 1;
+ /* Do we have so display unpopulated banks ? */
+ int show_free_banks = 1;
- /* Needed, if called by the memory mode */
- detect_dmi(hardware);
+ /* Needed, if called by the memory mode */
+ detect_dmi(hardware);
- /* Sanitize arguments */
- if (argc > 0) {
- show_free_banks = strtol(argv[0], NULL, 10);
- if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1)
- goto usage;
- }
+ /* Detecting installed memory */
+ detect_memory(hardware);
- char bank_number[10];
- char available_dmi_commands[1024];
- memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
+ 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) {
- more_printf("No memory module found\n");
- return;
- }
-
- reset_more_printf();
- more_printf("Memory Banks\n");
- for (int i = 0; i < hardware->dmi.memory_count; i++) {
- if (hardware->dmi.memory[i].filled == true) {
- /* When discovering the first item, let's clear the screen */
- strncat(available_dmi_commands, CLI_DMI_MEMORY_BANK,
- sizeof(CLI_DMI_MEMORY_BANK) - 1);
- memset(bank_number, 0, sizeof(bank_number));
- snprintf(bank_number, sizeof(bank_number), "%d ", i);
- strncat(available_dmi_commands, bank_number,
- sizeof(bank_number));
- 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);
- }
+ 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");
+ return;
+ //printf("Type 'show bank<bank_number>' for more details.\n");
usage:
- more_printf("show memory <clear screen? <show free banks?>>\n");
- return;
+ 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)
+void show_dmi_oem_strings(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- reset_more_printf();
+ reset_more_printf();
- if (strlen(hardware->dmi.oem_strings))
- more_printf("OEM Strings\n%s", hardware->dmi.oem_strings);
+ 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)
+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);
+ 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,
- },
+ {
+ .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,
+ .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,
+ .mode = DMI_MODE,
+ .name = CLI_DMI,
+ .default_modules = NULL,
+ .show_modules = &dmi_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index f11cbec4..65bb4444 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -38,27 +38,27 @@
/**
* cli_clear_screen - clear (erase) the entire screen
**/
-static void cli_clear_screen(int argc __unused, char** argv __unused,
+static void cli_clear_screen(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- clear_screen();
+ clear_screen();
}
/**
* main_show_modes - show availables modes
**/
-static void main_show_modes(int argc __unused, char** argv __unused,
+static void main_show_modes(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- int i = 0;
+ int i = 0;
reset_more_printf();
- printf("Available modes:\n");
- while (list_modes[i]) {
- printf("%s ", list_modes[i]->name);
- i++;
- }
- printf("\n");
+ printf("Available modes:\n");
+ while (list_modes[i]) {
+ printf("%s ", list_modes[i]->name);
+ i++;
+ }
+ printf("\n");
}
/**
@@ -66,137 +66,128 @@ static void main_show_modes(int argc __unused, char** argv __unused,
*
* The mode number must be supplied in argv, position 0.
**/
-static void cli_set_mode(int argc, char **argv,
- struct s_hardware *hardware)
+static void cli_set_mode(int argc, char **argv, struct s_hardware *hardware)
{
- cli_mode_t new_mode;
+ 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);
+ 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,
+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);
+ 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,
+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");
- }
+ int j = 0;
+ struct cli_mode_descr *current_mode;
+ struct cli_callback_descr *associated_module = NULL;
- /* 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");
- }
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
- /* 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");
- }
+ printf("Available commands are:\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");
+ /* 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");
- main_show_modes(argc, argv, hardware);
+ }
+
+ /* 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,
+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;
+ char version_string[256];
+ snprintf(version_string, sizeof version_string, "%s %s (%s)",
+ PRODUCT_NAME, VERSION, CODENAME);
+ start_menu_mode(hardware, version_string);
+ return;
}
/**
@@ -205,181 +196,181 @@ static void goto_menu(int argc __unused, char** argv __unused,
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_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);
-
- int argc = 1;
- char *argv[1] = { "0" };
- show_dmi_memory_modules(argc, argv, hardware);
- }
- main_show_pci(argc, argv, hardware);
-
- if (hardware->is_pxe_valid)
- main_show_pxe(argc, argv, hardware);
-
- main_show_kernel(argc, argv, hardware);
+ 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(" Project Leader : %s\n", AUTHOR);
- more_printf(" Contact : %s\n", CONTACT);
- 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]);
- }
+ 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)
+static void do_reboot(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
/* Use specific syslinux call if needed */
if (issyslinux())
- return runsyslinuxcmd(hardware->reboot_label);
+ return runsyslinuxcmd(hardware->reboot_label);
else
- return csprint(hardware->reboot_label, 0x07);
+ return csprint(hardware->reboot_label, 0x07);
}
/* 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 = NULL,
- .exec = NULL
- },
+ {
+ .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,
- },
+ {
+ .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,
- },
+ {
+ .name = CLI_MODE,
+ .exec = cli_set_mode,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr hdt_default_modules = {
- .modules = list_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,
+ .modules = list_hdt_show_modules,
+ .default_callback = main_show_summary,
};
struct cli_module_descr hdt_set_modules = {
- .modules = list_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,
+ .mode = HDT_MODE,
+ .name = CLI_HDT,
+ .default_modules = &hdt_default_modules,
+ .show_modules = &hdt_show_modules,
+ .set_modules = &hdt_set_modules,
};
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index d33cdd80..d4946f30 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -37,125 +37,119 @@
void main_show_kernel(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char buffer[1024];
- struct pci_device *pci_device;
- bool found = false;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ 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];
- memset(buffer, 0, sizeof(buffer));
-
- detect_pci(hardware);
+ detect_pci(hardware);
reset_more_printf();
- more_printf("Kernel modules\n");
+ 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;
+ 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);
}
- /* 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(buffer);
+ 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(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];
- char category_name[MAX_PCI_CLASSES][256];
-
- detect_pci(hardware);
- memset(&modules, 0, sizeof(modules));
-
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- nopciids = true;
- more_printf(" Missing pci.ids, we can't compute the list\n");
- return;
- }
+ 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;
+ }
- 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);
}
- 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);
- }
+ 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]);
- }
+ }
+ /* 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,
+ .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,
+ .mode = KERNEL_MODE,
+ .name = CLI_KERNEL,
+ .default_modules = NULL,
+ .show_modules = &kernel_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index 3f8ed75a..51d087e8 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -31,86 +31,104 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-#define E820MAX 128
-
static void show_memory_e820(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- struct e820entry map[E820MAX];
- int count = 0;
- char type[14];
+ 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);
- detect_memory_e820(map, E820MAX, &count);
- reset_more_printf();
- 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));
- }
+ 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;
+ 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("e801: %d Kb (%d MiB) - %d Kb (%d MiB)\n",
- mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
- }
+ 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;
+ 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);
- }
+ 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,
- },
+ {
+ .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,
+ .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,
+ .mode = MEMORY_MODE,
+ .name = CLI_MEMORY,
+ .default_modules = NULL,
+ .show_modules = &memory_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 75e28968..c86a7928 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -36,292 +36,283 @@
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);
+ 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)
+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;
+ 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);
+ /* 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 (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;
- }
+ 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);
+ 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);
}
- if (pci_device->dev_info->linux_kernel_module_count == 0)
- strlcpy(kernel_modules, "unknown", 7);
+ 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);
+ 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 (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);
- }
+ 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);
+ 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");
- }
+ 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];
+ 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);
+ 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;
- }
+ 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;
+ 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);
+ /* 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);
+ 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(first_line);
- more_printf(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++;
+ more_printf(first_line);
+ more_printf(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;
+ 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");
+ 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;
- }
+ 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);
- }
- }
+ /* 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,
- },
+ {
+ .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,
+ .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,
+ .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);
- }
+ 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/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index a281d158..3a61bc02 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -32,6 +32,7 @@
#include <errno.h>
#include <syslinux/pxe.h>
#include <syslinux/config.h>
+#include <sys/gpxe.h>
#include "hdt-cli.h"
#include "hdt-common.h"
@@ -39,55 +40,59 @@
void main_show_pxe(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char buffer[81];
- memset(buffer, 0, sizeof(81));
+ 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;
- }
+ 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;
- }
+ 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);
+ 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(buffer);
- } else {
- snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
- p->pci_device->dev_info->vendor_name);
- more_printf(buffer);
- snprintf(buffer, sizeof(buffer), " Product : %s \n",
- p->pci_device->dev_info->product_name);
- more_printf(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 (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(buffer);
+ } else {
+ snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
+ p->pci_device->dev_info->vendor_name);
+ more_printf(buffer);
+ snprintf(buffer, sizeof(buffer), " Product : %s \n",
+ p->pci_device->dev_info->product_name);
+ more_printf(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,
+ .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,
+ .mode = PXE_MODE,
+ .name = CLI_PXE,
+ .default_modules = NULL,
+ .show_modules = &pxe_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c
index 160e33c4..6c231ed5 100644
--- a/com32/hdt/hdt-cli-syslinux.c
+++ b/com32/hdt/hdt-cli-syslinux.c
@@ -37,26 +37,26 @@
#include "hdt-common.h"
void main_show_syslinux(int argc __unused, char **argv __unused,
- struct s_hardware *hardware)
+ 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 + 2);
- 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 + 1);
+ reset_more_printf();
+ more_printf("SYSLINUX\n");
+ more_printf(" Bootloader : %s\n", hardware->syslinux_fs);
+ more_printf(" Version : %s\n", hardware->sv->version_string + 2);
+ 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 + 1);
}
struct cli_module_descr syslinux_show_modules = {
- .modules = NULL,
- .default_callback = main_show_syslinux,
+ .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,
+ .mode = SYSLINUX_MODE,
+ .name = CLI_SYSLINUX,
+ .default_modules = NULL,
+ .show_modules = &syslinux_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index c6eea072..a4a80fae 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -37,68 +37,106 @@ 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);
+ 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");
+ 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);
+}
- 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 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,
- },
+ {
+ .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,
+ .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 = NULL,
- .show_modules = &vesa_show_modules,
- .set_modules = NULL,
+ .mode = VESA_MODE,
+ .name = CLI_VESA,
+ .default_modules = &vesa_commands,
+ .show_modules = &vesa_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-vpd.c b/com32/hdt/hdt-cli-vpd.c
index a445d833..4974720b 100644
--- a/com32/hdt/hdt-cli-vpd.c
+++ b/com32/hdt/hdt-cli-vpd.c
@@ -35,40 +35,47 @@
void main_show_vpd(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- reset_more_printf();
- detect_vpd(hardware);
+ reset_more_printf();
+ detect_vpd(hardware);
- if (!hardware->is_vpd_valid) {
- more_printf("No VPD structure detected.\n");
- return;
- }
+ if (!hardware->is_vpd_valid) {
+ more_printf("No VPD structure detected.\n");
+ return;
+ }
- more_printf("VPD present at address : 0x%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);
+ more_printf("VPD present at address : 0x%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,
+ .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,
+ .mode = VPD_MODE,
+ .name = CLI_VPD,
+ .default_modules = NULL,
+ .show_modules = &vpd_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 060f953b..69a2b61f 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -34,18 +34,18 @@
#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,
+ &hdt_mode,
+ &dmi_mode,
+ &syslinux_mode,
+ &pxe_mode,
+ &kernel_mode,
+ &cpu_mode,
+ &pci_mode,
+ &vesa_mode,
+ &disk_mode,
+ &vpd_mode,
+ &memory_mode,
+ NULL,
};
/*
@@ -53,61 +53,61 @@ struct cli_mode_descr *list_modes[] = {
* 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", "?"};
+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,
- },
+ {
+ .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;
+ 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;
+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));
+ struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list));
- strncpy(new->autocomplete_token, token, sizeof(new->autocomplete_token));
- new->next = NULL;
- autocomplete_backlog++;
+ strncpy(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;
+ if (autocomplete_tail != NULL)
+ autocomplete_tail->next = new;
+ if (autocomplete_head == NULL)
+ autocomplete_head = new;
+ autocomplete_tail = new;
}
static void autocomplete_destroy_list()
{
- 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;
+ 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;
}
/**
@@ -116,106 +116,95 @@ static void autocomplete_destroy_list()
*
* Unlike cli_set_mode, this function is not used by the cli directly.
**/
-void set_mode(cli_mode_t mode, struct s_hardware* hardware)
+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++;
- }
+ 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;
}
-
- 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);
+ 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);
+ }
}
/**
@@ -223,19 +212,18 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware)
**/
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;
+ 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;
}
/**
@@ -249,17 +237,16 @@ cli_mode_t mode_s_to_mode_t(char *name)
**/
void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
{
- int i = 0;
+ int i = 0;
- while (list_modes[i] &&
- list_modes[i]->mode != mode)
- i++;
+ 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];
+ /* Shouldn't get here... */
+ if (!list_modes[i])
+ *mode_found = NULL;
+ else
+ *mode_found = list_modes[i];
}
/**
@@ -276,55 +263,55 @@ void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
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));
- strncpy(argv[0], *command, sizeof(*command) + 1);
- dprintf("CLI DEBUG: ALIAS %s ", *command);
+ 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));
+ strncpy(argv[0], *command, sizeof(*command) + 1);
+ dprintf("CLI DEBUG: ALIAS %s ", *command);
- strncpy(*command, CLI_SET, sizeof(CLI_SET)); /* set */
+ strncpy(*command, CLI_SET, sizeof(CLI_SET)); /* set */
- *module = malloc(sizeof(CLI_MODE) * sizeof(char));
- strncpy(*module, CLI_MODE, sizeof(CLI_MODE)); /* mode */
+ *module = malloc(sizeof(CLI_MODE) * sizeof(char));
+ strncpy(*module, CLI_MODE, sizeof(CLI_MODE)); /* mode */
- dprintf("--> %s %s %s\n", *command, *module, argv[0]);
- goto out;
- }
+ 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);
- strncpy(*command, hdt_aliases[i].command,
- sizeof(hdt_aliases[i].command) + 1);
- dprintf("--> %s\n", *command);
- goto out; /* Don't allow chaining aliases */
- }
- }
+ /* 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);
+ strncpy(*command, hdt_aliases[i].command,
+ sizeof(hdt_aliases[i].command) + 1);
+ dprintf("--> %s\n", *command);
+ goto out; /* Don't allow chaining aliases */
+ }
}
- return;
+ }
+ 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;
+ 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;
}
/**
@@ -337,88 +324,88 @@ out:
*
* 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));
- strncpy(*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));
- strncpy(*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);
+ 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;
- /* Skip arguments handling if none is supplied */
- if (!*argc)
- return;
+ *command = NULL;
+ *module = NULL;
+ *argc = 0;
- /* 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));
- strncpy(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);
+ 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));
+ strncpy(*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));
+ strncpy(*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));
+ strncpy(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);
+ }
}
/**
@@ -430,30 +417,29 @@ static void parse_command_line(char *line, char **command, char **module,
* 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)
+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;
+ int modules_iter = 0;
- if (modules_list == NULL)
- goto not_found;
+ 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++;
+ /* 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;
- }
+ 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;
+ *module_found = NULL;
+ return;
}
/**
@@ -466,76 +452,81 @@ not_found:
**/
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);
+ 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);
}
- if (strncmp(CLI_SET, command, strlen(command)) == 0) {
- printf("%s\n", CLI_SET);
- autocomplete_add_token_to_list(CLI_SET);
+ 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++;
}
+ }
- /*
- * 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++;
- }
+ /*
+ * 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;
- /*
- * Let's go now through the list of default_modules for the current mode
- * (single token commands for the current_mode)
- */
- j = 0;
- 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++;
- }
+ 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) {
/*
- * Finally, if the current_mode is not hdt, list the available
- * default_modules of hdt (these are always available from any mode).
+ * 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.
*/
- if (current_mode->mode == HDT_MODE)
- return;
-
- 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 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++;
+ 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++;
+ }
}
/**
@@ -548,39 +539,41 @@ static void autocomplete_command(char *command)
* 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)
+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) {
- 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;
- 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++;
- }
+ 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++;
}
+ }
}
/**
@@ -589,97 +582,88 @@ static void autocomplete_module(char *command, char* module)
**/
static void autocomplete(char *line)
{
- int i;
- int argc = 0;
- char *command = NULL, *module = NULL;
- char **argv = NULL;
+ int i;
+ int argc = 0;
+ char *command = NULL, *module = NULL;
+ char **argv = NULL;
- parse_command_line(line, &command, &module, &argc, argv);
+ parse_command_line(line, &command, &module, &argc, argv);
- /* If the user specified arguments, there is nothing we can complete */
- if (argc != 0)
- goto out;
+ /* 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);
- goto out;
- }
-
- /* No argument, no module, (the start of) a command has been specified */
- if (command != NULL) {
- autocomplete_command(command);
- goto out;
- }
+ /* No argument, (the start of) a module has been specified */
+ if (module != NULL) {
+ autocomplete_module(command, module);
+ free(module);
+ goto out;
+ }
- /* Nothing specified, list available commands */
- //autocomplete_commands();
+ /* 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 */
- free(command);
- free(module);
- for (i = 0; i < argc; i++)
- free(argv[i]);
+ /* Let's not forget to clean ourselves */
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ if (argc > 0)
free(argv);
- return;
+ return;
}
-
/**
* exec_command - main logic to map the command line to callbacks
**/
-static void exec_command(char *line,
- struct s_hardware *hardware)
+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 that will need to be freed */
- parse_command_line(line, &command, &module, &argc, argv);
-
- /* Expand shortcuts, if needed */
- expand_aliases(line, &command, &module, &argc, argv);
-
- if (module == NULL) {
- dprintf("CLI DEBUG: single command detected\n", CLI_SHOW);
- /*
- * 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)
- return 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)
- return 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)
- return 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)
- return current_module->exec(argc, argv, 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);
- return;
}
-
+ } else {
/*
* A module has been specified! We now need to find the type of command.
*
@@ -693,392 +677,442 @@ static void exec_command(char *line,
* hdt> set mode dmi
*/
if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
- dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW);
- find_cli_callback_descr(module, current_mode->show_modules,
+ 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 */
+ /* Execute the callback, if found */
if (current_module != NULL)
- return current_module->exec(argc, argv, hardware);
- else {
- find_cli_callback_descr(module, hdt_mode.show_modules,
- &current_module);
- if (current_module != NULL)
- return current_module->exec(argc, argv, hardware);
- }
-
- printf("unknown module: '%s'\n", module);
- return;
-
+ 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);
- find_cli_callback_descr(module, current_mode->set_modules,
+ 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 */
+ /* Execute the callback, if found */
if (current_module != NULL)
- return current_module->exec(argc, argv, hardware);
- else {
- find_cli_callback_descr(module, hdt_mode.set_modules,
- &current_module);
- if (current_module != NULL)
- return current_module->exec(argc, argv, hardware);
- }
-
- printf("unknown module: '%s'\n", module);
- return;
-
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown module: '%s'\n", module);
+ }
}
+ }
- printf("I don't understand: '%s'. Try 'help'.\n", line);
-
- /* Let's not forget to clean ourselves */
+out:
+ /* 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]);
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ if (argc > 0)
free(argv);
}
static void reset_prompt()
{
- /* No need to display the prompt if we exit */
- if (hdt_cli.mode != EXIT_MODE) {
- printf("%s", hdt_cli.prompt);
- /* Reset the line */
- memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
- hdt_cli.cursor_pos = 0;
- }
+ /* 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)) {
- 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]);
- }
+ 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("\nExiting Auto mode\n");
more_printf("\n");
}
+void print_history()
+{
+ 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; /* Temp variable*/
- bool display_history=true; /* Temp Variable*/
- char temp_command[MAX_LINE_SIZE];
-
- hdt_cli.cursor_pos=0;
- memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
- 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;
- }
+ 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;
- /* Start the auto mode if the command line is set*/
- if (strlen(hardware->auto_label) > 0) {
- start_auto_mode(hardware);
- }
+ case KEY_UP:
+
+ /* Saving future position */
+ current_future_history_pos = future_history_pos;
- 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(&hdt_cli.input[hdt_cli.cursor_pos], 0,
- strlen(hdt_cli.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(hdt_cli.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(hdt_cli.input) - hdt_cli.cursor_pos) > 0) {
- /* Return to the begining of line */
- move_cursor_right(strlen(hdt_cli.input) - hdt_cli.cursor_pos);
- hdt_cli.cursor_pos = strlen(hdt_cli.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:
- /* We have to compute the next position*/
- future_history_pos=hdt_cli.history_pos;
- if (future_history_pos==1) {
- future_history_pos=MAX_HISTORY_SIZE-1;
- } else {
- future_history_pos--;
- }
- /* Does the next position is valid */
- if (strlen(hdt_cli.history[future_history_pos])==0) break;
-
- /* Let's make that future position the one we use*/
- hdt_cli.history_pos=future_history_pos;
-
- /* Clear the line */
- clear_line();
-
- /* Move to the begining of line*/
- move_cursor_to_column(0);
-
- reset_prompt();
- printf("%s",hdt_cli.history[hdt_cli.history_pos]);
- strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.input);
- break;
-
- case KEY_DOWN:
- display_history=true;
-
- /* We have to compute the next position*/
- future_history_pos=hdt_cli.history_pos;
- if (future_history_pos==MAX_HISTORY_SIZE-1) {
- 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) break;
-
- /* Let's make that future position the one we use*/
- hdt_cli.history_pos=future_history_pos;
-
- /* Clear the line */
- clear_line();
-
- /* Move to the begining of line*/
- move_cursor_to_column(0);
-
- reset_prompt();
- printf("%s",hdt_cli.history[hdt_cli.history_pos]);
- strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.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);
- strncpy(hdt_cli.input,autocomplete_last_seen->autocomplete_token,sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.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(hdt_cli.input));
- autocomplete_last_seen = autocomplete_head;
-
- printf("%s%s", hdt_cli.prompt, hdt_cli.input);
- }
- break;
-
- case KEY_ENTER:
- printf("\n");
- if (strlen(remove_spaces(hdt_cli.input)) < 1) {
- reset_prompt();
- break;
- }
- if (hdt_cli.history_pos == MAX_HISTORY_SIZE-1) hdt_cli.history_pos=1;
- strncpy(hdt_cli.history[hdt_cli.history_pos],remove_spaces(hdt_cli.input),sizeof(hdt_cli.history[hdt_cli.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;
- exec_command(remove_spaces(hdt_cli.input), hardware);
- reset_prompt();
- break;
-
- case KEY_CTRL('d'):
- case KEY_DELETE:
- /* No need to delete when input is empty */
- if (strlen(hdt_cli.input)==0) break;
- /* Don't delete when cursor is at the end of the line */
- if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break;
-
- for (int c = hdt_cli.cursor_pos;
- c < (int)strlen(hdt_cli.input) - 1; c++)
- hdt_cli.input[c] = hdt_cli.input[c + 1];
- hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
-
- /* Clear the end of the line */
- clear_end_of_line();
-
- /* Print the resulting buffer */
- printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
-
- /* Replace the cursor at the proper place */
- if (strlen(hdt_cli.input + hdt_cli.cursor_pos)>0)
- move_cursor_left(strlen(hdt_cli.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(hdt_cli.input) - 1; c++)
- hdt_cli.input[c] = hdt_cli.input[c + 1];
- hdt_cli.input[strlen(hdt_cli.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", hdt_cli.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(hdt_cli.input)) {
- char key[2];
- int trailing_chars =
- strlen(hdt_cli.input) - hdt_cli.cursor_pos;
- memset(temp_command, 0, sizeof(temp_command));
- strncpy(temp_command, hdt_cli.input,
- hdt_cli.cursor_pos);
- sprintf(key, "%c", current_key);
- strncat(temp_command, key, 1);
- strncat(temp_command,
- hdt_cli.input + hdt_cli.cursor_pos,
- trailing_chars);
- memset(hdt_cli.input, 0, sizeof(hdt_cli.input));
- snprintf(hdt_cli.input, sizeof(hdt_cli.input), "%s",
- temp_command);
-
- /* Clear the end of the line */
- clear_end_of_line();
-
- /* Print the resulting buffer */
- printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
-
- /* Return where we must put the new char */
- move_cursor_left(trailing_chars);
-
- } else {
- putchar(current_key);
- hdt_cli.input[hdt_cli.cursor_pos] = current_key;
- }
- hdt_cli.cursor_pos++;
- break;
- }
+ /* 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));
+ strncpy(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));
+ strncpy(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);
+ strncpy(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));
+ strncpy(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/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 3684fa40..898b53f8 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -68,66 +68,69 @@
#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,
+ 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];
- char input[MAX_LINE_SIZE];
- uint8_t cursor_pos;
- char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE];
- int history_pos;
- int max_history_pos;
+ 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;
+ 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 );
+ 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 );
+ 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 */
+ const char *command; /* Original command */
+ const int nb_aliases; /* Size of aliases array */
+ const char **aliases; /* List of aliases */
};
/* List of implemented modes */
@@ -156,6 +159,9 @@ 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();
+
// DMI STUFF
#define CLI_DMI_BASE_BOARD "base_board"
#define CLI_DMI_BATTERY "battery"
@@ -171,8 +177,9 @@ void main_show(char *item, struct s_hardware *hardware);
#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);
+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"
@@ -198,5 +205,6 @@ void main_show_syslinux(int argc, char **argv, struct s_hardware *hardware);
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);
+void main_show_vpd(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 5cfa9e87..59175cec 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -35,146 +35,172 @@
#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 not 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 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)
+ struct s_hardware *hardware)
{
- /* Quiet mode - make the output more quiet */
- quiet = false;
-
- for (int i = 1; i < argc; i++) {
- if (!strncmp(argv[i], "quiet", 5)) {
- quiet = true;
- } else if (!strncmp(argv[i], "modules_pcimap=", 15)) {
- strncpy(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)) {
- strncpy(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)) {
- strncpy(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)) {
- strncpy(hardware->memtest_label, argv[i] + 8,
- sizeof(hardware->memtest_label));
- convert_isolinux_filename(hardware->memtest_label,hardware);
- } else if (!strncmp(argv[i], "reboot=", 7)) {
- strncpy(hardware->reboot_label, argv[i] + 7,
- sizeof(hardware->reboot_label));
- convert_isolinux_filename(hardware->reboot_label,hardware);
- } 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;
+ /* 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)) {
+ strncpy(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)) {
+ strncpy(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)) {
+ strncpy(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)) {
+ strncpy(hardware->memtest_label, argv[i] + 8,
+ sizeof(hardware->memtest_label));
+ convert_isolinux_filename(hardware->memtest_label, hardware);
+ } else if (!strncmp(argv[i], "reboot=", 7)) {
+ strncpy(hardware->reboot_label, argv[i] + 7,
+ sizeof(hardware->reboot_label));
+ convert_isolinux_filename(hardware->reboot_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)) {
+ strncpy(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++;
+ }
- /* 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;
- }
+ /* 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;
- }
+ 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->nb_pci_devices = 0;
- hardware->is_dmi_valid = false;
- hardware->is_pxe_valid = false;
- hardware->is_vpd_valid = false;
- hardware->pci_domain = NULL;
-
- /* Cleaning structures */
- memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
- 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->reboot_label, 0, sizeof hardware->reboot_label);
- memset(hardware->auto_label, 0, sizeof hardware->auto_label);
- 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");
- strcat(hardware->reboot_label, "reboot.c32");
+ 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->reboot_label, 0, sizeof hardware->reboot_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");
+ strcat(hardware->reboot_label, "reboot.c32");
+ strncpy(hardware->vesa_background, CLI_DEFAULT_BACKGROUND,
+ sizeof(hardware->vesa_background));
}
/*
@@ -183,17 +209,17 @@ void init_hardware(struct s_hardware *hardware)
*/
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;
- }
+ 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;
+ parse_dmitable(&hardware->dmi);
+ hardware->is_dmi_valid = true;
+ return 0;
}
/**
@@ -206,321 +232,315 @@ int detect_dmi(struct s_hardware *hardware)
**/
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;
- }
+ 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);
- strncpy(hardware->vesa.vendor,oem_ptr,sizeof(hardware->vesa.vendor));
- oem_ptr = GET_PTR(gi->oem_product_name_ptr);
- strncpy(hardware->vesa.product,oem_ptr,sizeof(hardware->vesa.product));
- oem_ptr = GET_PTR(gi->oem_product_rev_ptr);
- strncpy(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);
+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);
- /* Must be a supported mode */
- if ( rm.eax.w[0] != 0x004f )
- continue;
+ 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);
+ strncpy(hardware->vesa.vendor, oem_ptr, sizeof(hardware->vesa.vendor));
+ oem_ptr = GET_PTR(gi->oem_product_name_ptr);
+ strncpy(hardware->vesa.product, oem_ptr, sizeof(hardware->vesa.product));
+ oem_ptr = GET_PTR(gi->oem_product_rev_ptr);
+ strncpy(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;
- /* 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;
+ while ((mode = *mode_ptr++) != 0xFFFF) {
- hardware->vesa.vmi_count++;
- }
- hardware->is_vesa_valid = true;
- return 0;
+ 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;
+ int i = -1;
+ int err;
- if (hardware->disk_detection)
- return;
+ 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]);
+ 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;
+ /*
+ * 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]);
+ /* Detect MBR */
+ hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]);
- hardware->disks_count++;
- }
+ 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;
- }
+ 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;
- }
- }
+ 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;
+ 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);
+ 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);
- hardware->cpu_detection = true;
+ 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)
+ strncpy(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 */
+ strncpy(hardware->cpu.model,del_multi_spaces(hardware->cpu.model),sizeof(hardware->cpu.model));
+ hardware->cpu_detection = true;
}
/*
@@ -529,104 +549,124 @@ void cpu_detect(struct s_hardware *hardware)
*/
const char *find_argument(const char **argv, const char *argument)
{
- int la = strlen(argument);
- const char **arg;
- const char *ptr = NULL;
+ int la = strlen(argument);
+ const char **arg;
+ const char *ptr = NULL;
- for (arg = argv; *arg; arg++) {
- if (!memcmp(*arg, argument, la))
- ptr = *arg + la;
- }
+ for (arg = argv; *arg; arg++) {
+ if (!memcmp(*arg, argument, la))
+ ptr = *arg + la;
+ }
- return ptr;
+ 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();
- reset_more_printf();
+ 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++;
- }
+ while (*p && *p <= ' ') {
+ p++;
+ }
- return 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;
+ 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;
+ 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*/
- strncpy(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;
+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*/
+ strncpy(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() {
- display_line_nb=0;
+void reset_more_printf()
+{
+ 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/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index f178b223..d7a58e2f 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -30,6 +30,9 @@
#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>
@@ -66,9 +69,23 @@
/* 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;
@@ -84,7 +101,7 @@ extern bool disable_more_printf;
*/
#define more_printf(...) do {\
if (__likely(!disable_more_printf)) {\
- if (display_line_nb == 20) {\
+ if (display_line_nb == max_console_lines) {\
display_line_nb=0;\
printf("\n--More--");\
get_key(stdin, 0);\
@@ -98,87 +115,90 @@ extern bool disable_more_printf;
/* 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);
+ 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 */
+ 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 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;
+ 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;
-
- 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? */
-
- 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 reboot_label[255];
- char auto_label[AUTO_COMMAND_SIZE];
+ 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 reboot_label[255];
+ char auto_label[AUTO_COMMAND_SIZE];
+ char vesa_background[255];
};
void reset_more_printf();
@@ -197,6 +217,8 @@ 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);
+ 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/com32/hdt/hdt-menu-about.c b/com32/hdt/hdt-menu-about.c
index 53b58f21..1e8a6ff1 100644
--- a/com32/hdt/hdt-menu-about.c
+++ b/com32/hdt/hdt-menu-about.c
@@ -31,46 +31,57 @@
/* Computing About menu*/
void compute_aboutmenu(struct s_my_menu *menu)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" About ", -1);
- menu->items_count = 0;
+ menu->menu = add_menu(" About ", -1);
+ menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ 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, "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, "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, "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, "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, "Contact : %s", CONTACT);
- snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT);
- 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++;
- 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++;
+ add_item("", "", OPT_SEP, "", 0);
- 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++;
- }
+ 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++;
- printf("MENU: About menu done (%d items)\n", 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/com32/hdt/hdt-menu-disk.c b/com32/hdt/hdt-menu-disk.c
index 2f3571b9..b0b4a5ac 100644
--- a/com32/hdt/hdt-menu-disk.c
+++ b/com32/hdt/hdt-menu-disk.c
@@ -34,25 +34,27 @@
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)
+ struct part_entry *ptab __unused,
+ int partition_offset __unused,
+ int nb_partitions_seen)
{
- char menu_title[MENULEN + 1];
- char menu_title_ref[MENULEN + 1];
+ char menu_title[MENULEN + 1];
+ char menu_title_ref[MENULEN + 1];
- if (nb_partitions_seen == 1)
- add_sep();
+ 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);
+ 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);
+ 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
@@ -69,197 +71,194 @@ static void show_partition_information(struct driveinfo *drive_info,
* 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)
+ struct part_entry *ptab,
+ int partition_offset,
+ int nb_partitions_seen)
{
- char size[9];
- 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));
+ 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, "Type : %s",
- parttype);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s",
- parttype);
- 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);
- 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, "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, "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);
- 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);
-
- 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);
- }
+ /* 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)
+ 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[9]; // GiB
- 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);
-
- snprintf(buffer, sizeof buffer, "Size : %s/%d %s (%d %s)", remove_spaces(size_iec),
- size, unit, previous_size, previous_unit);
- snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)", remove_spaces(size_iec), size,
- unit, previous_size, previous_unit);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- 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]);
+ 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++;
-
- dn=disk_number;
-
- parse_partition_table(&d[disk_number], &show_partition_information);
- if (!parse_partition_table(&d[disk_number], &compute_partition_information)) {
+ }
+
+ 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;
+ 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);
+ 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/com32/hdt/hdt-menu-dmi.c b/com32/hdt/hdt-menu-dmi.c
index 77ee90e5..7a413a15 100644
--- a/com32/hdt/hdt-menu-dmi.c
+++ b/com32/hdt/hdt-menu-dmi.c
@@ -31,369 +31,351 @@
/* 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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/com32/hdt/hdt-menu-kernel.c b/com32/hdt/hdt-menu-kernel.c
index 81b44dbf..98e52091 100644
--- a/com32/hdt/hdt-menu-kernel.c
+++ b/com32/hdt/hdt-menu-kernel.c
@@ -31,62 +31,57 @@
/* 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;
+ 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);
+ 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);
+ 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++;
- }
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+ }
}
- }
- printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
+ printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-memory.c b/com32/hdt/hdt-menu-memory.c
index ddc26fef..6c82b11c 100644
--- a/com32/hdt/hdt-menu-memory.c
+++ b/com32/hdt/hdt-menu-memory.c
@@ -33,245 +33,350 @@
/* 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);
- for (int j = 0; j < count; j++) {
+ 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(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++;
- }
+ "%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, "%d Kb (%d MiB) - %d Kb (%d MiB)",
- mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
- snprintf(statbuffer, sizeof statbuffer, "%d Kb (%d MiB) - %d Kb (%d MiB)",
- mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
- menu->items_count++;
+ 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 e88 submenu */
-static void compute_e88(struct s_my_menu *menu)
+/* Compute the 88 submenu */
+static void compute_88(struct s_my_menu *menu)
{
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " e88 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", "e88 output is bogus");
- snprintf(statbuffer, sizeof statbuffer, "%s", "e88 output is bogus");
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- } else {
- snprintf(buffer, sizeof buffer, "%d Kb (%d MiB)",
- mem_size, mem_size >> 10);
- snprintf(statbuffer, sizeof statbuffer, "%d Kb (%d MiB)",
- mem_size, mem_size >> 10);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
- menu->items_count++;
+ 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 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, "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(buffer, sizeof statbuffer, "Part Number: %s",
- dmi->memory[i].part_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ 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)
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi,
+ struct s_hardware *hardware)
{
- char buffer[MENULEN + 1];
- int i=0;
- for (i = 0; i < dmi->memory_count; i++) {
- compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
- }
-
- compute_e820(&(menu->memory_sub_menu[++i]));
- compute_e801(&(menu->memory_sub_menu[++i]));
- compute_e88(&(menu->memory_sub_menu[++i]));
-
- menu->memory_menu.menu = add_menu(" Memory Banks ", -1);
- menu->memory_menu.items_count = 0;
-
- for (i = 0; i < dmi->memory_count; i++) {
- snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
- add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[i].menu);
+ 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);
- snprintf(buffer, sizeof buffer, " e820 ");
- add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[++i].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, " e801 ");
+ add_item(buffer, "e801 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
- snprintf(buffer, sizeof buffer, " e88 ");
- add_item(buffer, "e88 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);
+ 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/com32/hdt/hdt-menu-pci.c b/com32/hdt/hdt-menu-pci.c
index d4a6b7e7..734b7444 100644
--- a/com32/hdt/hdt-menu-pci.c
+++ b/com32/hdt/hdt-menu-pci.c
@@ -30,168 +30,174 @@
/* 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 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);
+ 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, "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, "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++;
+ }
}
- 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);
+ 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++;
}
- 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;
+ printf("MENU: PCI menu done (%d items)\n", hdt_menu->pci_menu.items_count);
+ return 0;
}
diff --git a/com32/hdt/hdt-menu-processor.c b/com32/hdt/hdt-menu-processor.c
index 4e102cb5..f303eb6a 100644
--- a/com32/hdt/hdt-menu-processor.c
+++ b/com32/hdt/hdt-menu-processor.c
@@ -28,217 +28,260 @@
#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", del_multi_spaces(hardware->cpu.model));
- snprintf(statbuffer, sizeof statbuffer, "Model: %s",
- del_multi_spaces(hardware->cpu.model));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Vendor ID : %d",
- hardware->cpu.vendor_id);
- snprintf(statbuffer, sizeof statbuffer, "Vendor ID: %d",
- hardware->cpu.vendor_id);
- 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);
+ 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, "Cur. Speed: %d",
- hardware->dmi.processor.current_speed);
+ 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,
- "Current Speed (MHz): %d",
- hardware->dmi.processor.current_speed);
+ "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, "Max Speed : %d",
- hardware->dmi.processor.max_speed);
- snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d",
- hardware->dmi.processor.max_speed);
+ 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, "Upgrade : %s",
- hardware->dmi.processor.upgrade);
- snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s",
- hardware->dmi.processor.upgrade);
+ 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++;
- }
-
- 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++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.fpu)
- strcat(buffer1, "fpu ");
- if (hardware->cpu.flags.vme)
- strcat(buffer1, "vme ");
- if (hardware->cpu.flags.de)
- strcat(buffer1, "de ");
- if (hardware->cpu.flags.pse)
- strcat(buffer1, "pse ");
- if (hardware->cpu.flags.tsc)
- strcat(buffer1, "tsc ");
- if (hardware->cpu.flags.msr)
- strcat(buffer1, "msr ");
- if (hardware->cpu.flags.pae)
- strcat(buffer1, "pae ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.mce)
- strcat(buffer1, "mce ");
- if (hardware->cpu.flags.cx8)
- strcat(buffer1, "cx8 ");
- if (hardware->cpu.flags.apic)
- strcat(buffer1, "apic ");
- if (hardware->cpu.flags.sep)
- strcat(buffer1, "sep ");
- if (hardware->cpu.flags.mtrr)
- strcat(buffer1, "mtrr ");
- if (hardware->cpu.flags.pge)
- strcat(buffer1, "pge ");
- if (hardware->cpu.flags.mca)
- strcat(buffer1, "mca ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.cmov)
- strcat(buffer1, "cmov ");
- if (hardware->cpu.flags.pat)
- strcat(buffer1, "pat ");
- if (hardware->cpu.flags.pse_36)
- strcat(buffer1, "pse_36 ");
- if (hardware->cpu.flags.psn)
- strcat(buffer1, "psn ");
- if (hardware->cpu.flags.clflsh)
- strcat(buffer1, "clflsh ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.dts)
- strcat(buffer1, "dts ");
- if (hardware->cpu.flags.acpi)
- strcat(buffer1, "acpi ");
- if (hardware->cpu.flags.mmx)
- strcat(buffer1, "mmx ");
- if (hardware->cpu.flags.sse)
- strcat(buffer1, "sse ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.sse2)
- strcat(buffer1, "sse2 ");
- if (hardware->cpu.flags.ss)
- strcat(buffer1, "ss ");
- if (hardware->cpu.flags.htt)
- strcat(buffer1, "ht ");
- if (hardware->cpu.flags.acc)
- strcat(buffer1, "acc ");
- if (hardware->cpu.flags.syscall)
- strcat(buffer1, "syscall ");
- if (hardware->cpu.flags.mp)
- strcat(buffer1, "mp ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.nx)
- strcat(buffer1, "nx ");
- if (hardware->cpu.flags.mmxext)
- strcat(buffer1, "mmxext ");
- if (hardware->cpu.flags.lm)
- strcat(buffer1, "lm ");
- if (hardware->cpu.flags.nowext)
- strcat(buffer1, "3dnowext ");
- if (hardware->cpu.flags.now)
- strcat(buffer1, "3dnow! ");
- if (hardware->cpu.flags.vmx)
- strcat(buffer1, "vmx ");
- if (hardware->cpu.flags.svm)
- strcat(buffer1, "svm ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: Processor menu done (%d items)\n", 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/com32/hdt/hdt-menu-pxe.c b/com32/hdt/hdt-menu-pxe.c
index 497fa776..426bfe07 100644
--- a/com32/hdt/hdt-menu-pxe.c
+++ b/com32/hdt/hdt-menu-pxe.c
@@ -27,94 +27,99 @@
*/
#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];
-
- 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);
+ 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, "PCI Product : %d",
- p->vendor_id);
- snprintf(infobar, sizeof infobar, "PCI Product : %d",
- p->vendor_id);
+ 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++;
- 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++;
+ if (is_gpxe()) strcat(gpxe,"Yes");
+ else strcat (gpxe,"No");
- snprintf(buffer, sizeof buffer, "PCI SubProduct : %d",
- p->subproduct_id);
- snprintf(infobar, sizeof infobar, "PCI SubProduct : %d",
- p->subproduct_id);
+ 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++;
- 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++;
-
- printf("MENU: PXE menu done (%d items)\n", menu->items_count);
+ printf("MENU: PXE menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-summary.c b/com32/hdt/hdt-menu-summary.c
index e8e2fc65..e9d56caf 100644
--- a/com32/hdt/hdt-menu-summary.c
+++ b/com32/hdt/hdt-menu-summary.c
@@ -31,179 +31,165 @@
/* Computing Summary menu */
void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
- char bank_number[10];
-
- 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++;
-
- 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++;
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- 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++;
+ menu->menu = add_menu(" Summary ", -1);
+ menu->items_count = 0;
- snprintf(buffer, sizeof buffer, "System Serial : %s",
- hardware->dmi.system.serial);
- snprintf(statbuffer, sizeof statbuffer,
- "System Serial Number: %s",
- hardware->dmi.system.serial);
+ 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++;
- 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);
+ 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++;
- 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);
+ 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);
-
- for (int i = 0; i < hardware->dmi.memory_count; i++) {
- if (hardware->dmi.memory[i].filled == true) {
- /* When discovering the first item, let's clear the screen */
- memset(bank_number, 0, sizeof(bank_number));
- snprintf(bank_number, sizeof(bank_number),
- "%d ", i);
- if (strncmp
- (hardware->dmi.memory[i].size, "Free", 4)) {
- snprintf(buffer, sizeof buffer,
- "Mem bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- snprintf(statbuffer, sizeof statbuffer,
- "Memory bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- add_item(buffer, statbuffer,
- OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
- }
+ 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, "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++;
-
- add_item("", "", OPT_SEP, "", 0);
- if (hardware->is_pxe_valid == true) {
- 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);
+ 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++;
- 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("", "", 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++;
- add_item("", "", OPT_SEP, "", 0);
- }
-
- if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
- 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;
- }
+ 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;
+ }
+ }
}
- if (kmod == true)
- add_item("", "", OPT_SEP, "", 0);
- }
- printf("MENU: Summary menu done (%d items)\n", menu->items_count);
+ printf("MENU: Summary menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-syslinux.c b/com32/hdt/hdt-menu-syslinux.c
index 758274fe..c85bfbf4 100644
--- a/com32/hdt/hdt-menu-syslinux.c
+++ b/com32/hdt/hdt-menu-syslinux.c
@@ -32,55 +32,51 @@
/* 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];
+ char syslinux_fs_menu[24];
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu);
+ 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(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, "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 + 2);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- hardware->sv->version_string + 2);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Version : %s",
+ hardware->sv->version_string + 2);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ hardware->sv->version_string + 2);
+ 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, "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++;
+ snprintf(buffer, sizeof buffer, "Max API : %u", hardware->sv->max_api);
+ snprintf(statbuffer, sizeof statbuffer, "Max API: %u",
+ hardwa