aboutsummaryrefslogtreecommitdiffstats
path: root/mbr
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-04-04 15:32:24 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-04-04 15:32:24 -0700
commitf7b5a2254ab7c8aa87679c1b731d2ea285c22e80 (patch)
tree08e1e00576717e1ca557101164b7e6639e0172a1 /mbr
parentdd51053bbd4a1613d1e3384928a7da7bb164562f (diff)
downloadsyslinux.git-f7b5a2254ab7c8aa87679c1b731d2ea285c22e80.tar.gz
syslinux.git-f7b5a2254ab7c8aa87679c1b731d2ea285c22e80.tar.xz
syslinux.git-f7b5a2254ab7c8aa87679c1b731d2ea285c22e80.zip
mbr: generate normal versions, force-80 versions, and ctrl-80 versions
Produce MBR variants with normal (DL) behavior, force to drive 80 behavior, and force to 80 on Ctrl pressed behavior. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'mbr')
-rw-r--r--mbr/Makefile32
-rw-r--r--mbr/adjust.h53
-rw-r--r--mbr/altmbr.S10
-rwxr-xr-xmbr/checksize.pl16
-rw-r--r--mbr/gptmbr.S13
-rw-r--r--mbr/isohdpfx.S17
-rw-r--r--mbr/mbr.S12
7 files changed, 107 insertions, 46 deletions
diff --git a/mbr/Makefile b/mbr/Makefile
index e9fc3875..6cd677c0 100644
--- a/mbr/Makefile
+++ b/mbr/Makefile
@@ -1,6 +1,7 @@
## -----------------------------------------------------------------------
##
-## Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## 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
@@ -17,34 +18,31 @@
topdir = ..
include $(topdir)/MCONFIG.embedded
-all: mbr.bin altmbr.bin gptmbr.bin isohdpfx.bin
+all: mbr.bin altmbr.bin gptmbr.bin isohdpfx.bin \
+ mbr_c.bin altmbr_c.bin gptmbr_c.bin isohdpfx_c.bin \
+ mbr_f.bin altmbr_f.bin gptmbr_f.bin isohdpfx_f.bin
.PRECIOUS: %.o
-%.o: %.S
+%.o: %.S adjust.h
$(CC) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
+%_c.o: %.S adjust.h
+ $(CC) $(SFLAGS) -Wa,-a=$*_c.lst -DCTRL_80 -c -o $@ $<
+
+%_f.o: %.S adjust.h
+ $(CC) $(SFLAGS) -Wa,-a=$*_f.lst -DFORCE_80 -c -o $@ $<
+
.PRECIOUS: %.elf
%.elf: %.o mbr.ld
$(LD) $(LDFLAGS) -T mbr.ld -e _start -o $@ $<
-mbr.bin: mbr.elf checksize.pl
- $(OBJCOPY) -O binary $< $@
- $(PERL) checksize.pl $@ 440
-
-altmbr.bin: altmbr.elf checksize.pl
+%.bin: %.elf checksize.pl
$(OBJCOPY) -O binary $< $@
- $(PERL) checksize.pl $@ 439 440
-
-isohdpfx.bin: isohdpfx.elf checksize.pl
- $(OBJCOPY) -O binary $< $@
- $(PERL) checksize.pl $@ 432
+ $(PERL) checksize.pl $@
+ $(CHMOD) -x $@
mbr_bin.c: mbr.bin
-gptmbr.bin: gptmbr.elf checksize.pl
- $(OBJCOPY) -O binary $< $@
- $(PERL) checksize.pl $@ 424
-
tidy dist:
rm -f *.o *.elf *.lst
diff --git a/mbr/adjust.h b/mbr/adjust.h
new file mode 100644
index 00000000..42c12a35
--- /dev/null
+++ b/mbr/adjust.h
@@ -0,0 +1,53 @@
+/* -*- asm -*- -----------------------------------------------------------
+ *
+ * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * adjust.h
+ *
+ * Macros to adjust the drive number
+ */
+
+#ifndef ADJUST_H
+#define ADJUST_H
+
+#ifdef CTRL_80
+ .macro ADJUST_DRIVE
+ testb $0x04, BIOS_kbdflags
+ jz 1f
+ movb $0x80, %dl
+1:
+ .endm
+#elif defined(FORCE_80)
+ .macro ADJUST_DRIVE
+ movb $0x80, %dl
+ .endm
+#else
+ .macro ADJUST_DRIVE
+ .endm
+#endif
+
+#endif /* ADJUST_H */
diff --git a/mbr/altmbr.S b/mbr/altmbr.S
index b85bf8be..4a502ed0 100644
--- a/mbr/altmbr.S
+++ b/mbr/altmbr.S
@@ -26,6 +26,8 @@
*
* ----------------------------------------------------------------------- */
+#include "adjust.h"
+
.code16
.text
@@ -66,12 +68,8 @@ _start:
ljmpw $0, $next
next:
-
- /* Escape for the user: if Ctrl is pressed, assume drive hd0 */
- testb $0x04, BIOS_kbdflags /* Ctrl pressed */
- jz 1f
- movb $0x80, %dl
-1:
+
+ ADJUST_DRIVE
pushw %dx /* dl -> drive number */
/* Check to see if we have EBIOS */
diff --git a/mbr/checksize.pl b/mbr/checksize.pl
index a3643101..4648c95c 100755
--- a/mbr/checksize.pl
+++ b/mbr/checksize.pl
@@ -1,6 +1,7 @@
## -----------------------------------------------------------------------
##
## Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## 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
@@ -20,6 +21,21 @@ use bytes;
($file, $maxsize, $padsize) = @ARGV;
+if (!defined($maxsize)) {
+ # Defaults based on the filename
+ if ($file =~ /^mbr[^0-9a-z]/) {
+ $maxsize = $padsize = 440;
+ } elsif ($file =~ /^gptmbr[^0-9a-z]/) {
+ $maxsize = $padsize = 424;
+ } elsif ($file =~ /^isohdpfx[^0-9a-z]/) {
+ $maxsize = $padsize = 432;
+ } elsif ($file =~ /^altmbr[^0-9a-z]/) {
+ $maxsize = 439; $padsize = 440;
+ } else {
+ die "$0: no default size for filename: $file\n";
+ }
+}
+
$padsize = $maxsize unless(defined($padsize));
open(FILE, '+<', $file) or die;
diff --git a/mbr/gptmbr.S b/mbr/gptmbr.S
index 6df67f42..8d42e8b8 100644
--- a/mbr/gptmbr.S
+++ b/mbr/gptmbr.S
@@ -26,6 +26,8 @@
*
* ----------------------------------------------------------------------- */
+#include "adjust.h"
+
.code16
.text
@@ -74,11 +76,8 @@ _start:
ljmpw $0, $next
next:
- /* Escape for the user: if Ctrl is pressed, assume drive hd0 */
- testb $0x04, BIOS_kbdflags /* Ctrl pressed */
- jz 1f
- movb $0x80, %dl
-1:
+
+ ADJUST_DRIVE
pushw %dx /* 0(%bp) = %dl -> drive number */
/* Check to see if we have EBIOS */
@@ -170,10 +169,10 @@ find_part:
found_part:
xchgw %ax,%cx /* Set up %cx for rep movsb further down */
-
+
movw $dssi_out,%di
pushw %di
-
+
/* 80 00 00 00 ee 00 00 00
- bootable partition, type EFI (EE), no CHS information */
xorl %eax,%eax
diff --git a/mbr/isohdpfx.S b/mbr/isohdpfx.S
index 0c5b95e6..f42b4b5b 100644
--- a/mbr/isohdpfx.S
+++ b/mbr/isohdpfx.S
@@ -1,6 +1,7 @@
/* -----------------------------------------------------------------------
*
* Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
+ * Copyright 2009 Intel Corporation; author: H. Peter Anvin
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -32,12 +33,14 @@
* loader of a hard-coded offset, but that's good enough to load
* ISOLINUX.
*/
-
+
+#include "adjust.h"
+
.code16
.text
HYBRID_MAGIC = 0x7078c0fb
-isolinux_hybrid_signature = 0x7c00+64
+isolinux_hybrid_signature = 0x7c00+64
isolinux_start_hybrid = 0x7c00+64+4
.globl bootsec
@@ -81,12 +84,8 @@ _start:
ljmpw $0, $next
next:
-
- /* Escape for the user: if Ctrl is pressed, assume drive hd0 */
- testb $0x04, BIOS_kbdflags /* Ctrl pressed */
- jz 1f
- movb $0x80, %dl
-1:
+
+ ADJUST_DRIVE
pushw %dx /* dl -> drive number */
/* Check to see if we have EBIOS */
@@ -147,7 +146,7 @@ next:
*/
cmpl $HYBRID_MAGIC,(isolinux_hybrid_signature)
jne bad_signature
-
+
cli
movw $heads, %sp
diff --git a/mbr/mbr.S b/mbr/mbr.S
index 2407663e..7caf4fc4 100644
--- a/mbr/mbr.S
+++ b/mbr/mbr.S
@@ -26,6 +26,8 @@
*
* ----------------------------------------------------------------------- */
+#include "adjust.h"
+
.code16
.text
@@ -37,7 +39,7 @@ secpercyl = (stack-12)
BIOS_kbdflags = 0x417
BIOS_page = 0x462
-
+
/* gas/ld has issues with doing this as absolute addresses... */
.section ".bootsec", "a", @nobits
.globl bootsec
@@ -66,12 +68,8 @@ _start:
ljmpw $0, $next
next:
-
- /* Escape for the user: if Ctrl is pressed, assume drive hd0 */
- testb $0x04, BIOS_kbdflags /* Ctrl pressed */
- jz 1f
- movb $0x80, %dl
-1:
+
+ ADJUST_DRIVE
pushw %dx /* dl -> drive number */
/* Check to see if we have EBIOS */