aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-11-24 13:42:41 +0100
committerErwan Velu <erwan.velu@free.fr>2009-11-24 13:42:41 +0100
commit2672e142b4b69ab5161d24261812d3509cb8915b (patch)
treee3b1b60b265044c2148c0c53682619343ff4f74a /com32
parenta06075995c5ea9c4c473820cba03033e9c945a41 (diff)
downloadsyslinux-2672e142b4b69ab5161d24261812d3509cb8915b.tar.gz
syslinux-2672e142b4b69ab5161d24261812d3509cb8915b.tar.xz
syslinux-2672e142b4b69ab5161d24261812d3509cb8915b.zip
gpllibs: Running Nindent
Impact: visual Running Nindent on gpllib / gplinclude
Diffstat (limited to 'com32')
-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_system.h10
-rw-r--r--com32/gplinclude/memory.h21
-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.c145
-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.c761
-rw-r--r--com32/gpllib/dmi/dmi_cache.c167
-rw-r--r--com32/gpllib/dmi/dmi_memory.c133
-rw-r--r--com32/gpllib/memory.c583
32 files changed, 2192 insertions, 1730 deletions
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 e97c5eb7..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[48];
-char installed_size[48];
-char enabled_size[48];
-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_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 1fee1782..fe33c18d 100644
--- a/com32/gplinclude/memory.h
+++ b/com32/gplinclude/memory.h
@@ -25,28 +25,29 @@
#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_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);
+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/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 5bf96050..b468f791 100644
--- a/com32/gpllib/disk/mbrs.c
+++ b/com32/gpllib/disk/mbrs.c
@@ -20,54 +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 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;
+ 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;
- }
+ /* 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';
}
/**
@@ -76,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..55b625ae 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;
@@ -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..24e564b6 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",
+ NULL, /* 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_memory.c b/com32/gpllib/dmi/dmi_memory.c
index c49cf550..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%s", type, 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, "%s%u", connection, 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 %s", size, "(Double-bank Connection)");
- else
- sprintf(size, "%s %s", size, "(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/memory.c b/com32/gpllib/memory.c
index 52ca3523..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);
+
+ 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;
+ }
- com32sys_t ireg, oreg;
- memset(&ireg, 0, sizeof ireg);
+ if (oreg.eflags.l & EFLAGS_CF || oreg.ecx.l < 20)
+ break;
- 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);
+ memcpy(&buf, __com32.cs_bounce, sizeof buf);
/*
- * Set this here so that if the BIOS doesn't change this field
- * but still doesn't change %ecx, we're still okay...
+ * 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!
*/
- 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;
- }
+ if (oreg.ecx.l > 20 && !(buf.ext_flags & 1))
+ continue;
- if (oreg.eflags.l & EFLAGS_CF ||
- oreg.ecx.l < 20)
- break;
+ memcpy(&desc[count], &buf, sizeof buf);
+ count++;
- memcpy(&buf, __com32.cs_bounce, sizeof buf);
+ /* Set continuation value */
+ ireg.ebx.l = oreg.ebx.l;
+ } while (ireg.ebx.l && count < size_map);
- /*
- * 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;
+ *size_found = count;
}
/**
@@ -172,47 +171,47 @@ 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;
+ if (oreg.eflags.l & EFLAGS_CF)
+ return -1;
- *mem_size = oreg.eax.w[0];
- return 0;
+ *mem_size = oreg.eax.w[0];
+ return 0;
}
/*
@@ -227,222 +226,220 @@ int detect_memory_88(int* mem_size)
* syslinux_scan_memory can be used for that purpose
*/
int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios,
- short old_nr)
+ 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;
- }
-
- /* 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;
+ 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;
+ }
+
+ /* 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;
+ }
+
+ /* 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 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];
+ }
+
+ /* 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--;
}
-
- /* 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;
- }
- }
+ /* 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;
}
-
- /* 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);
+ }
+ 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;
+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;
- }
+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);
- /* 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;
+ /* 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;
+ }
+ return memory_size * 4;
}