[syslinux:pathbased] memdisk: Change patch area to include the entire MDI
syslinux-bot for Shao Miller
shao.miller at yrdsb.edu.on.ca
Thu Jun 17 11:45:24 PDT 2010
Commit-ID: 3397b50cfc534f7ee0b65b7501b1081df03a106b
Gitweb: http://syslinux.zytor.com/commit/3397b50cfc534f7ee0b65b7501b1081df03a106b
Author: Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Tue, 9 Mar 2010 16:54:17 -0500
Committer: Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Fri, 11 Jun 2010 01:49:10 +0000
memdisk: Change patch area to include the entire MDI
Previously, the patch area began after the beginning of
the MDI, but continued past its end. This is difficult
to express with C structures, so we've simply changed
the patch area to include the entire MDI. So it now
includes the MDI size and MEMDISK version info, which
we simply make constant to avoid modifying.
Signed-off-by: Shao Miller <shao.miller at yrdsb.edu.on.ca>
---
memdisk/memdisk.inc | 8 ++++----
memdisk/mstructs.h | 14 ++++++++++++--
memdisk/setup.c | 32 +++++++++++++++++---------------
3 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/memdisk/memdisk.inc b/memdisk/memdisk.inc
index e1a0901..90e6ef9 100644
--- a/memdisk/memdisk.inc
+++ b/memdisk/memdisk.inc
@@ -119,7 +119,7 @@
; must be first in the binary
Pointers: dw Int13Start
dw Int15Start
- dw PatchArea
+ dw MemDisk_Info ; Portions are patched by installer
dw TotalSize
dw IretPtr
@@ -1076,12 +1076,11 @@ mBFT:
; Note that the above ends on a DWORD boundary.
; The MDI has always started at such a boundary.
+; Portions of the MDI are patched by the installer
MemDisk_Info equ $ ; Pointed to by installation check
MDI_Bytes dw MDI_Len ; Total bytes in MDI structure
MDI_Version db VERSION_MINOR, VERSION_MAJOR ; MEMDISK version
-PatchArea equ $ ; This gets filled in by the installer
-
DiskBuf dd 0 ; Linear address of high memory disk
DiskSize dd 0 ; Size of disk in blocks
CommandLine dw 0, 0 ; Far pointer to saved command line
@@ -1171,7 +1170,8 @@ CD_PKT:
%endif ; EDD
- ; End patch area
+; End patch area
+
alignb 4, db 0
Stack dd 0 ; Saved SS:ESP on invocation
dw 0
diff --git a/memdisk/mstructs.h b/memdisk/mstructs.h
index ee9568f..9e82818 100644
--- a/memdisk/mstructs.h
+++ b/memdisk/mstructs.h
@@ -88,8 +88,13 @@ struct edd_dpt {
/* Requirement for struct edd4_cd_pkt */
#include "../memdisk/eltorito.h"
+/* Official MEMDISK Info structure ("MDI") */
MEMDISK_PACKED_PREFIX
-struct patch_area {
+struct mdi {
+ const uint16_t bytes;
+ const uint8_t version_minor;
+ const uint8_t version_major;
+
uint32_t diskbuf;
uint32_t disksize;
real_addr_t cmdline;
@@ -102,7 +107,12 @@ struct patch_area {
uint8_t _pad1;
uint16_t dpt_ptr;
- /* End of the official MemDisk_Info */
+} MEMDISK_PACKED_POSTFIX;
+
+MEMDISK_PACKED_PREFIX
+struct patch_area {
+ struct mdi mdi;
+
uint8_t driveshiftlimit; /* Do not shift drives above this region */
uint8_t _pad2; /* Pad to DWORD */
uint16_t _pad3; /* Pad to QWORD */
diff --git a/memdisk/setup.c b/memdisk/setup.c
index 9f9eb7d..ee4540e 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -836,7 +836,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
pptr = (struct patch_area *)(memdisk_hook + hptr->patch_offs);
dosmem_k = rdz_16(BIOS_BASEMEM);
- pptr->olddosmem = dosmem_k;
+ pptr->mdi.olddosmem = dosmem_k;
stddosmem = dosmem_k << 10;
/* If INT 15 E820 and INT 12 disagree, go with the most conservative */
if (stddosmem > dos_mem)
@@ -847,11 +847,11 @@ void setup(const struct real_mode_args *rm_args_ptr)
pptr->cylinders = geometry->c; /* Possible precision loss */
pptr->heads = geometry->h;
pptr->sectors = geometry->s;
- pptr->disksize = geometry->sectors;
- pptr->diskbuf = ramdisk_image + geometry->offset;
+ pptr->mdi.disksize = geometry->sectors;
+ pptr->mdi.diskbuf = ramdisk_image + geometry->offset;
pptr->statusptr = (geometry->driveno & 0x80) ? 0x474 : 0x441;
- pptr->bootloaderid = shdr->type_of_loader;
+ pptr->mdi.bootloaderid = shdr->type_of_loader;
pptr->configflags = CONFIG_SAFEINT; /* Default */
/* Set config flags */
@@ -953,7 +953,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
pptr->edd_dpt.flags |= 0x0014;
}
- pptr->edd_dpt.devpath[0] = pptr->diskbuf;
+ pptr->edd_dpt.devpath[0] = pptr->mdi.diskbuf;
pptr->edd_dpt.chksum = -checksum_buf(&pptr->edd_dpt.dpikey, 73 - 30);
}
@@ -1022,8 +1022,8 @@ void setup(const struct real_mode_args *rm_args_ptr)
/* Anything beyond the end is for the stack */
pptr->mystack = (uint16_t) (stddosmem - driveraddr);
- pptr->oldint13.uint32 = rdz_32(BIOS_INT13);
- pptr->oldint15.uint32 = rdz_32(BIOS_INT15);
+ pptr->mdi.oldint13.uint32 = rdz_32(BIOS_INT13);
+ pptr->mdi.oldint15.uint32 = rdz_32(BIOS_INT15);
/* Adjust the E820 table: if there are null ranges (type 0)
at the end, change them to type end of list (-1).
@@ -1038,7 +1038,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
bios_drives = 0;
pptr->drivecnt = 0;
no_bpt = 1;
- pptr->oldint13.uint32 = driverptr + hptr->iret_offs;
+ pptr->mdi.oldint13.uint32 = driverptr + hptr->iret_offs;
wrz_8(BIOS_EQUIP, rdz_8(BIOS_EQUIP) & ~0xc1);
wrz_8(BIOS_HD_COUNT, 0);
} else if (getcmditem("nopass") != CMD_NOTFOUND) {
@@ -1101,8 +1101,8 @@ void setup(const struct real_mode_args *rm_args_ptr)
pptr->driveshiftlimit);
/* Pointer to the command line */
- pptr->cmdline.seg_off.offset = bin_size + (nranges + 1) * sizeof(ranges[0]);
- pptr->cmdline.seg_off.segment = driverseg;
+ pptr->mdi.cmdline.seg_off.offset = bin_size + (nranges + 1) * sizeof(ranges[0]);
+ pptr->mdi.cmdline.seg_off.segment = driverseg;
/* Copy driver followed by E820 table followed by command line */
{
@@ -1120,7 +1120,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
}
/* Note the previous INT 13h hook in the "safe hook" structure */
- hptr->safe_hook.old_hook.uint32 = pptr->oldint13.uint32;
+ 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 =
@@ -1155,7 +1155,8 @@ void setup(const struct real_mode_args *rm_args_ptr)
if (getcmditem("dpt") != CMD_NOTFOUND ||
((nflop == 1 || no_bpt) && getcmditem("nodpt") == CMD_NOTFOUND)) {
/* Do install a replacement DPT into INT 1Eh */
- pptr->dpt_ptr = hptr->patch_offs + offsetof(struct patch_area, dpt);
+ pptr->mdi.dpt_ptr =
+ hptr->patch_offs + offsetof(struct patch_area, dpt);
}
}
@@ -1175,8 +1176,8 @@ void setup(const struct real_mode_args *rm_args_ptr)
wrz_32(BIOS_INT13, driverptr + hptr->int13_offs);
wrz_32(BIOS_INT15, driverptr + hptr->int15_offs);
- if (pptr->dpt_ptr)
- wrz_32(BIOS_INT1E, driverptr + pptr->dpt_ptr);
+ if (pptr->mdi.dpt_ptr)
+ wrz_32(BIOS_INT1E, driverptr + pptr->mdi.dpt_ptr);
printf("new: int13 = %08x int15 = %08x int1e = %08x\n",
rdz_32(BIOS_INT13), rdz_32(BIOS_INT15), rdz_32(BIOS_INT1E));
@@ -1202,7 +1203,8 @@ void setup(const struct real_mode_args *rm_args_ptr)
/* Reboot into the new "disk" */
puts("Loading boot sector... ");
- memcpy((void *)boot_base, (char *)pptr->diskbuf + geometry->boot_lba * 512,
+ memcpy((void *)boot_base,
+ (char *)pptr->mdi.diskbuf + geometry->boot_lba * 512,
boot_len);
if (getcmditem("pause") != CMD_NOTFOUND) {
More information about the Syslinux-commits
mailing list