Make mstructs.h includable from a Linux utility.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
-/* OpenWatcom uses a packed structure prefix */
-#define MEMDISK_PACKED_PREFIX _Packed
-#define MEMDISK_PACKED_POSTFIX
-
/* Pull in MEMDISK common structures */
#include "../memdisk/mstructs.h"
struct patch_area far *patch_area;
/* Copy the MDI from the mBFT. Offset is a misnomer here */
- mbft = MK_FP(hook->mBFT.offset >> 4, 0); /* Always aligned */
+ mbft = MK_FP(hook->mbft >> 4, 0); /* Always aligned */
_fmemcpy((void far *)&m, &mbft->mdi, sizeof(struct mdi));
/* Adjust C/H/S since we actually know
* it directly for any MEMDISK with an mBFT
-include $(topdir)/version.mk
INCLUDES = -I$(topdir)/com32/include
-CFLAGS += -DDATE='"$(DATE)"'
+CFLAGS += -D__MEMDISK__ -DDATE='"$(DATE)"'
LDFLAGS = $(GCCOPT) -g
NASM = nasm
NASMOPT = -O9999
--- /dev/null
+
+#ifdef __WATCOMC__
+# define MEMDISK_PACKED_PREFIX _Packed
+# define MEMDISK_PACKED_POSTFIX
+#else
+/* Assume GNU C for now */
+# define MEMDISK_PACKED_PREFIX
+# define MEMDISK_PACKED_POSTFIX __attribute__((packed))
+#endif
*/
#include <stdint.h>
+#include "compiler.h"
/* EDD-4 Bootable Optical Disc Drive Boot Volume Descriptor */
MEMDISK_PACKED_PREFIX
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
/* These structures are common to MEMDISK and MDISKCHK.COM */
#include <stdint.h>
+#include "compiler.h"
struct seg_off {
uint16_t offset;
real_addr_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 */
- union {
- uint32_t offset; /* Offset from hook to the mBFT; refilled */
- struct mBFT *ptr; /* by setup() with the physical address */
- } mBFT;
+ uint32_t mbft;
} MEMDISK_PACKED_POSTFIX;
struct memdisk_header {
MEMDISK_PACKED_PREFIX
struct mBFT {
struct acpi_description_header acpi;
- union {
- struct safe_hook *ptr;
- uint32_t phys_addr;
- } safe_hook; /* "Safe hook" physical address */
+ uint32_t safe_hook; /* "Safe hook" physical address */
struct mdi mdi;
} MEMDISK_PACKED_POSTFIX;
char *memdisk_hook;
struct memdisk_header *hptr;
struct patch_area *pptr;
+ struct mBFT *mbft;
uint16_t driverseg;
uint32_t driverptr, driveraddr;
uint16_t dosmem_k;
hptr->safe_hook.old_hook.uint32 = pptr->mdi.oldint13.uint32;
/* Re-fill the "safe hook" mBFT field with the physical address */
- hptr->safe_hook.mBFT.ptr =
- (struct mBFT *)(((const char *)hptr) + hptr->safe_hook.mBFT.offset);
+ mbft = (struct mBFT *)(((const char *)hptr) + hptr->safe_hook.mbft);
+ hptr->safe_hook.mbft = (size_t)mbft;
/* Update various BIOS magic data areas (gotta love this shit) */
}
/* Complete the mBFT */
- hptr->safe_hook.mBFT.ptr->acpi.signature[0] = 'm'; /* "mBFT" */
- hptr->safe_hook.mBFT.ptr->acpi.signature[1] = 'B';
- hptr->safe_hook.mBFT.ptr->acpi.signature[2] = 'F';
- hptr->safe_hook.mBFT.ptr->acpi.signature[3] = 'T';
- hptr->safe_hook.mBFT.ptr->safe_hook.ptr = &hptr->safe_hook;
- hptr->safe_hook.mBFT.ptr->acpi.checksum =
- -checksum_buf(hptr->safe_hook.mBFT.ptr,
- hptr->safe_hook.mBFT.ptr->acpi.length);
+ mbft->acpi.signature[0] = 'm'; /* "mBFT" */
+ mbft->acpi.signature[1] = 'B';
+ mbft->acpi.signature[2] = 'F';
+ mbft->acpi.signature[3] = 'T';
+ mbft->safe_hook = (size_t)&hptr->safe_hook;
+ mbft->acpi.checksum = -checksum_buf(mbft, mbft->acpi.length);
/* Install the interrupt handlers */
printf("old: int13 = %08x int15 = %08x int1e = %08x\n",