aboutsummaryrefslogtreecommitdiffstats
path: root/memdisk
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-06-22 10:55:03 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-22 10:55:03 -0700
commitd966918e7304ff405fae20916cf137d737c92dea (patch)
tree67dfe5d27d7abbcc7fae039787e87f8dc7406295 /memdisk
parente2a24eacc5d5ab9f994bcee17bf7d65e2178b6d1 (diff)
downloadsyslinux-d966918e7304ff405fae20916cf137d737c92dea.tar.gz
syslinux-d966918e7304ff405fae20916cf137d737c92dea.tar.xz
syslinux-d966918e7304ff405fae20916cf137d737c92dea.zip
memdisk: add a sector_shift field to the MDI; fix memdiskfind
Add a sector_shift field to the MDI rather than assuming 512-byte sectors. Fix memdiskfind to report size in bytes, not in sectors. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'memdisk')
-rw-r--r--memdisk/mstructs.h2
-rw-r--r--memdisk/setup.c21
2 files changed, 12 insertions, 11 deletions
diff --git a/memdisk/mstructs.h b/memdisk/mstructs.h
index c2e6352b..fecbff40 100644
--- a/memdisk/mstructs.h
+++ b/memdisk/mstructs.h
@@ -93,7 +93,7 @@ struct mdi {
uint16_t olddosmem;
uint8_t bootloaderid;
- uint8_t _pad1;
+ uint8_t sector_shift;
uint16_t dpt_ptr;
} MEMDISK_PACKED_POSTFIX;
diff --git a/memdisk/setup.c b/memdisk/setup.c
index 20b48c47..3f69cd35 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -242,7 +242,7 @@ struct geometry {
uint32_t boot_lba; /* LBA of bootstrap code */
uint8_t type; /* Type byte for INT 13h AH=08h */
uint8_t driveno; /* Drive no */
- uint16_t sector_size; /* Sector size in bytes (512 vs. 2048) */
+ uint8_t sector_shift; /* Sector size as a power of 2 */
const char *hsrc, *ssrc; /* Origins of H and S geometries */
};
@@ -322,13 +322,13 @@ static const struct geometry *get_disk_image_geometry(uint32_t where,
printf("command line: %s\n", shdr->cmdline);
- hd_geometry.sector_size = 512; /* Assume floppy/HDD at first */
+ hd_geometry.sector_shift = 9; /* Assume floppy/HDD at first */
offset = 0;
if (CMD_HASDATA(p = getcmditem("offset")) && (v = atou(p)))
offset = v;
- sectors = xsectors = (size - offset) >> 9;
+ sectors = xsectors = (size - offset) >> hd_geometry.sector_shift;
hd_geometry.hsrc = "guess";
hd_geometry.ssrc = "guess";
@@ -372,8 +372,7 @@ static const struct geometry *get_disk_image_geometry(uint32_t where,
hd_geometry.h = 255;
hd_geometry.s = 15;
/* 2048-byte sectors, so adjust the size and count */
- hd_geometry.sector_size = 2048;
- sectors = (size - hd_geometry.offset) >> 11;
+ hd_geometry.sector_shift = 11;
break;
case 1: /* 1.2 MB floppy */
hd_geometry.s = 15;
@@ -393,9 +392,10 @@ static const struct geometry *get_disk_image_geometry(uint32_t where,
case 4:
hd_geometry.driveno = 0x80;
hd_geometry.type = 0;
- sectors = (size - hd_geometry.offset) >> 9;
break;
}
+ sectors = (size - hd_geometry.offset) >> hd_geometry.sector_shift;
+
/* For HDD emulation, we figure out the geometry later. Otherwise: */
if (hd_geometry.s) {
hd_geometry.hsrc = hd_geometry.ssrc = "El Torito";
@@ -413,7 +413,7 @@ static const struct geometry *get_disk_image_geometry(uint32_t where,
hd_geometry.h = dosemu.h;
hd_geometry.s = dosemu.s;
hd_geometry.offset += dosemu.offset;
- sectors = (size - hd_geometry.offset) >> 9;
+ sectors = (size - hd_geometry.offset) >> hd_geometry.sector_shift;
hd_geometry.hsrc = hd_geometry.ssrc = "DOSEMU";
}
@@ -466,7 +466,7 @@ static const struct geometry *get_disk_image_geometry(uint32_t where,
if (!(max_h | max_s)) {
/* No FAT filesystem found to steal geometry from... */
- if ((sectors < 4096 * 2) && (hd_geometry.sector_size == 512)) {
+ if ((sectors < 4096 * 2) && (hd_geometry.sector_shift == 9)) {
int ok = 0;
unsigned int xsectors = sectors;
@@ -778,7 +778,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
/* Choose the appropriate installable memdisk hook */
if (do_eltorito) {
- if (geometry->sector_size == 2048) {
+ if (geometry->sector_shift == 11) {
bin_size = (int)&_binary_memdisk_iso_2048_bin_size;
memdisk_hook = (char *)&_binary_memdisk_iso_2048_bin_start;
} else {
@@ -817,6 +817,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
pptr->sectors = geometry->s;
pptr->mdi.disksize = geometry->sectors;
pptr->mdi.diskbuf = ramdisk_image + geometry->offset;
+ pptr->mdi.sector_shift = geometry->sector_shift;
pptr->statusptr = (geometry->driveno & 0x80) ? 0x474 : 0x441;
pptr->mdi.bootloaderid = shdr->type_of_loader;
@@ -912,7 +913,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
* for INT 0x13, AH=0x48 "EDD Get Disk Parameters" call on an
* El Torito ODD. Check for 2048-byte sector size
*/
- if (geometry->sector_size != 2048)
+ if (geometry->sector_shift != 11)
pptr->edd_dpt.flags |= 0x0002; /* Geometry valid */
}
if (!(geometry->driveno & 0x80)) {