diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2010-06-21 17:29:11 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-06-21 17:29:11 -0700 |
commit | 7556a891b2f28617f6c95aa271aeaf29883d0981 (patch) | |
tree | 703e50c4970c9e64f2e11f76e81001af8fb7d33e /memdisk | |
parent | 3df42588472b07c54b9de11a7e118d6f3f4f6c41 (diff) | |
download | syslinux-7556a891b2f28617f6c95aa271aeaf29883d0981.tar.gz syslinux-7556a891b2f28617f6c95aa271aeaf29883d0981.tar.xz syslinux-7556a891b2f28617f6c95aa271aeaf29883d0981.zip |
memdisk: make mstructs.h includable from Linux
Make mstructs.h includable from a Linux utility.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'memdisk')
-rw-r--r-- | memdisk/Makefile | 2 | ||||
-rw-r--r-- | memdisk/compiler.h | 9 | ||||
-rw-r--r-- | memdisk/eltorito.h | 1 | ||||
-rw-r--r-- | memdisk/memdisk.h | 4 | ||||
-rw-r--r-- | memdisk/mstructs.h | 11 | ||||
-rw-r--r-- | memdisk/setup.c | 19 |
6 files changed, 23 insertions, 23 deletions
diff --git a/memdisk/Makefile b/memdisk/Makefile index 2e6330f9..d2f20c51 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -16,7 +16,7 @@ include $(topdir)/MCONFIG.embedded -include $(topdir)/version.mk INCLUDES = -I$(topdir)/com32/include -CFLAGS += -DDATE='"$(DATE)"' +CFLAGS += -D__MEMDISK__ -DDATE='"$(DATE)"' LDFLAGS = $(GCCOPT) -g NASM = nasm NASMOPT = -O9999 diff --git a/memdisk/compiler.h b/memdisk/compiler.h new file mode 100644 index 00000000..d1b03e06 --- /dev/null +++ b/memdisk/compiler.h @@ -0,0 +1,9 @@ + +#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 diff --git a/memdisk/eltorito.h b/memdisk/eltorito.h index 27b570da..494c4a12 100644 --- a/memdisk/eltorito.h +++ b/memdisk/eltorito.h @@ -17,6 +17,7 @@ */ #include <stdint.h> +#include "compiler.h" /* EDD-4 Bootable Optical Disc Drive Boot Volume Descriptor */ MEMDISK_PACKED_PREFIX diff --git a/memdisk/memdisk.h b/memdisk/memdisk.h index af40823a..b6b277a8 100644 --- a/memdisk/memdisk.h +++ b/memdisk/memdisk.h @@ -134,8 +134,4 @@ extern int check_zip(void *indata, uint32_t size, uint32_t * zbytes_p, 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 diff --git a/memdisk/mstructs.h b/memdisk/mstructs.h index e060aceb..c2e6352b 100644 --- a/memdisk/mstructs.h +++ b/memdisk/mstructs.h @@ -16,6 +16,7 @@ /* These structures are common to MEMDISK and MDISKCHK.COM */ #include <stdint.h> +#include "compiler.h" struct seg_off { uint16_t offset; @@ -38,10 +39,7 @@ struct safe_hook { 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 { @@ -106,10 +104,7 @@ struct mdi { 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; diff --git a/memdisk/setup.c b/memdisk/setup.c index ffaa2c66..20b48c47 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -718,6 +718,7 @@ void setup(const struct real_mode_args *rm_args_ptr) 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; @@ -1090,8 +1091,8 @@ void setup(const struct real_mode_args *rm_args_ptr) 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) */ @@ -1128,14 +1129,12 @@ void setup(const struct real_mode_args *rm_args_ptr) } /* 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", |