* This is the structure common to the start of all ACPI system
* description tables.
*/
+MEMDISK_PACKED_PREFIX
struct acpi_description_header {
/** ACPI signature (4 ASCII characters) */
char signature[4];
char asl_compiler_id[4];
/** ASL compiler revision number */
uint32_t asl_compiler_revision;
-} __attribute__ (( packed ));
+} MEMDISK_PACKED_POSTFIX;
/* ----------------------------------------------------------------------- *
*
- * Copyright 2009 Shao Miller - All Rights Reserved
+ * Copyright 2009-2010 Shao Miller - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <stdint.h>
-/*
- * Uncomment for El Torito debugging
- *
- * #define DBG_ELTORITO 1
- */
-
-#ifdef DBG_ELTORITO
-extern void eltorito_dump(uint32_t);
-#endif
-
/* EDD-4 Bootable Optical Disc Drive Boot Volume Descriptor */
+MEMDISK_PACKED_PREFIX
struct edd4_bvd {
uint8_t boot_rec_ind; /* Boot Record Indicator */
uint8_t iso9660_id[5]; /* ISO9660 ID */
uint8_t res1[32]; /* Reserved */
uint32_t boot_cat; /* Boot catalog sector */
uint8_t res2[1973]; /* Reserved */
-} __attribute__ ((packed));
+} MEMDISK_PACKED_POSTFIX;
+MEMDISK_PACKED_PREFIX
struct validation_entry {
uint8_t header_id; /* Header ID */
uint8_t platform_id; /* Platform ID */
uint16_t checksum; /* Sums with whole record to zero */
uint8_t key55; /* Key byte 0x55 */
uint8_t keyAA; /* Key byte 0xAA */
-} __attribute__ ((packed));
+} MEMDISK_PACKED_POSTFIX;
+MEMDISK_PACKED_PREFIX
struct initial_entry {
uint8_t header_id; /* Header ID */
uint8_t media_type; /* Media type */
uint16_t sect_count; /* Emulated sectors to load */
uint32_t load_block; /* Starting sector of image */
uint8_t res2[4]; /* Reserved */
-} __attribute__ ((packed));
+} MEMDISK_PACKED_POSTFIX;
/* EDD-4 Bootable Optical Disc Drive Boot Catalog (fixed-size portions) */
+MEMDISK_PACKED_PREFIX
struct edd4_bootcat {
struct validation_entry validation_entry;
struct initial_entry initial_entry;
-} __attribute__ ((packed));
+} MEMDISK_PACKED_POSTFIX;
/* EDD-4 CD Specification Packet */
+MEMDISK_PACKED_PREFIX
struct edd4_cd_pkt {
uint8_t size; /* Packet size */
uint8_t type; /* Boot media type (flags) */
uint8_t geom1; /* Cylinders bits 0 thru 7 */
uint8_t geom2; /* Sects/track 0 thru 5, cyls 8, 9 */
uint8_t geom3; /* Heads */
-} __attribute__ ((packed));
+} MEMDISK_PACKED_POSTFIX;
+
extern void *unzip(void *indata, uint32_t zbytes, uint32_t dbytes,
uint32_t orig_crc, void *target);
+/* Structure packing can be different for different compilers */
+#define MEMDISK_PACKED_PREFIX
+#define MEMDISK_PACKED_POSTFIX __attribute__ (( packed ))
+
#endif
--- /dev/null
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2001-2009 H. Peter Anvin - All Rights Reserved
+ * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
+ * Portions copyright 2009-2010 Shao Miller
+ * [El Torito code, mBFT, "safe hook"]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/* These structures are common to MEMDISK and MDISKCHK.COM */
+
+MEMDISK_PACKED_PREFIX
+struct safe_hook {
+ uint8_t jump[3]; /* Max. three bytes for jump */
+ uint8_t signature[8]; /* "$INT13SF" */
+ uint8_t vendor[8]; /* "MEMDISK " */
+ uint32_t old_hook; /* SEG:OFF for previous INT 13h hook */
+ uint32_t flags; /* "Safe hook" flags */
+ /* The next field is a MEMDISK extension to the "safe hook" structure */
+ uint32_t mBFT; /* Offset from hook to the mBFT; refilled
+ * by setup() with the physical address
+ */
+} MEMDISK_PACKED_POSTFIX;
+
+/* Requirement for struct acpi_description_header */
+#include "../memdisk/acpi.h"
+
+MEMDISK_PACKED_PREFIX
+struct mBFT {
+ struct acpi_description_header acpi;
+ uint32_t safe_hook; /* "Safe hook" physical address */
+} MEMDISK_PACKED_POSTFIX;
+
+MEMDISK_PACKED_PREFIX
+/* EDD disk parameter table */
+struct edd_dpt {
+ uint16_t len; /* Length of table */
+ uint16_t flags; /* Information flags */
+ uint32_t c; /* Physical cylinders (count!) */
+ uint32_t h; /* Physical heads (count!) */
+ uint32_t s; /* Physical sectors/track (count!) */
+ uint64_t sectors; /* Total sectors */
+ uint16_t bytespersec; /* Bytes/sector */
+ uint16_t dpte_off, dpte_seg; /* DPTE pointer */
+ uint16_t dpikey; /* Device Path Info magic */
+ uint8_t dpilen; /* Device Path Info length */
+ uint8_t res1; /* Reserved */
+ uint16_t res2; /* Reserved */
+ uint8_t bustype[4]; /* Host bus type */
+ uint8_t inttype[8]; /* Interface type */
+ uint64_t intpath; /* Interface path */
+ uint64_t devpath[2]; /* Device path (double QuadWord!) */
+ uint8_t res3; /* Reserved */
+ uint8_t chksum; /* DPI checksum */
+} MEMDISK_PACKED_POSTFIX;
+
+/* Requirement for struct edd4_cd_pkt */
+#include "../memdisk/eltorito.h"
+
+MEMDISK_PACKED_PREFIX
+struct patch_area {
+ uint32_t diskbuf;
+ uint32_t disksize;
+ uint16_t cmdline_off, cmdline_seg;
+
+ uint32_t oldint13;
+ uint32_t oldint15;
+
+ uint16_t olddosmem;
+ uint8_t bootloaderid;
+ uint8_t _pad1;
+
+ uint16_t dpt_ptr;
+ /* End of the official MemDisk_Info */
+ uint8_t driveshiftlimit; /* Do not shift drives above this region */
+ uint8_t _pad2; /* Pad to DWORD */
+ uint16_t _pad3; /* Pad to QWORD */
+
+ uint16_t memint1588;
+
+ uint16_t cylinders;
+ uint16_t heads;
+ uint32_t sectors;
+
+ uint32_t mem1mb;
+ uint32_t mem16mb;
+
+ uint8_t driveno;
+ uint8_t drivetype;
+ uint8_t drivecnt;
+ uint8_t configflags;
+
+#define CONFIG_READONLY 0x01
+#define CONFIG_RAW 0x02
+#define CONFIG_SAFEINT 0x04
+#define CONFIG_BIGRAW 0x08 /* MUST be 8! */
+#define CONFIG_MODEMASK 0x0e
+
+ uint16_t mystack;
+ uint16_t statusptr;
+
+ dpt_t dpt;
+ struct edd_dpt edd_dpt;
+ struct edd4_cd_pkt cd_pkt; /* Only really in a memdisk_iso_* hook */
+} MEMDISK_PACKED_POSTFIX;
+
* ----------------------------------------------------------------------- */
#include <stdint.h>
-#include "acpi.h"
#include "bda.h"
#include "dskprobe.h"
#include "e820.h"
-#include "eltorito.h"
#include "conio.h"
#include "version.h"
#include "memdisk.h"
uint16_t iret_offs;
};
-struct safe_hook {
- uint8_t jump[3]; /* Max. three bytes for jump */
- uint8_t signature[8]; /* "$INT13SF" */
- uint8_t vendor[8]; /* "MEMDISK " */
- uint32_t old_hook; /* SEG:OFF for previous INT 13h hook */
- uint32_t flags; /* "Safe hook" flags */
- /* The next field is a MEMDISK extension to the "safe hook" structure */
- uint32_t mBFT; /* Offset from hook to the mBFT; refilled
- * by setup() with the physical address
- */
-} __attribute__((packed));
-
/* The Disk Parameter Table may be required */
typedef union {
struct hd_dpt {
} fd;
} dpt_t;
-/* EDD disk parameter table */
-struct edd_dpt {
- uint16_t len; /* Length of table */
- uint16_t flags; /* Information flags */
- uint32_t c; /* Physical cylinders (count!) */
- uint32_t h; /* Physical heads (count!) */
- uint32_t s; /* Physical sectors/track (count!) */
- uint64_t sectors; /* Total sectors */
- uint16_t bytespersec; /* Bytes/sector */
- uint16_t dpte_off, dpte_seg; /* DPTE pointer */
- uint16_t dpikey; /* Device Path Info magic */
- uint8_t dpilen; /* Device Path Info length */
- uint8_t res1; /* Reserved */
- uint16_t res2; /* Reserved */
- uint8_t bustype[4]; /* Host bus type */
- uint8_t inttype[8]; /* Interface type */
- uint64_t intpath; /* Interface path */
- uint64_t devpath[2]; /* Device path (double QuadWord!) */
- uint8_t res3; /* Reserved */
- uint8_t chksum; /* DPI checksum */
-} __attribute__((packed));
-
-struct mBFT {
- struct acpi_description_header acpi;
- uint32_t safe_hook; /* "Safe hook" physical address */
-} __attribute__((packed));
-
-struct patch_area {
- uint32_t diskbuf;
- uint32_t disksize;
- uint16_t cmdline_off, cmdline_seg;
-
- uint32_t oldint13;
- uint32_t oldint15;
-
- uint16_t olddosmem;
- uint8_t bootloaderid;
- uint8_t _pad1;
-
- uint16_t dpt_ptr;
- /* End of the official MemDisk_Info */
- uint8_t driveshiftlimit; /* Do not shift drives above this region */
- uint8_t _pad2; /* Pad to DWORD */
- uint16_t _pad3; /* Pad to QWORD */
-
- uint16_t memint1588;
-
- uint16_t cylinders;
- uint16_t heads;
- uint32_t sectors;
-
- uint32_t mem1mb;
- uint32_t mem16mb;
-
- uint8_t driveno;
- uint8_t drivetype;
- uint8_t drivecnt;
- uint8_t configflags;
-
-#define CONFIG_READONLY 0x01
-#define CONFIG_RAW 0x02
-#define CONFIG_SAFEINT 0x04
-#define CONFIG_BIGRAW 0x08 /* MUST be 8! */
-#define CONFIG_MODEMASK 0x0e
-
- uint16_t mystack;
- uint16_t statusptr;
-
- dpt_t dpt;
- struct edd_dpt edd_dpt;
- struct edd4_cd_pkt cd_pkt; /* Only really in a memdisk_iso_* hook */
-} __attribute__((packed));
+/* Pull in structures common to MEMDISK and MDISKCHK.COM */
+#include "mstructs.h"
/* An EDD disk packet */
struct edd_dsk_pkt {
uint64_t buf64; /* 64-bit buf pointer */
} __attribute__ ((packed));
+/* Change to 1 for El Torito debugging */
+#define DBG_ELTORITO 0
+
+#if DBG_ELTORITO
+extern void eltorito_dump(uint32_t);
+#endif
+
/*
* Routine to seek for a command-line item and return a pointer
* to the data portion, if present
hd_geometry.offset = offset;
if ((p = getcmditem("iso")) != CMD_NOTFOUND) {
-#ifdef DBG_ELTORITO
+#if DBG_ELTORITO
eltorito_dump(where);
#endif
struct edd4_bvd *bvd = (struct edd4_bvd *)(where + 17 * 2048);
shdr->esdi = pnp_install_check();
shdr->edx = geometry->driveno;
}
+