TJ
2009-Mar-30 19:08 UTC
[syslinux] [PATCH] gptmbr: Ctrl-key press forces load from first hard disk
--- mbr/gptmbr.S | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mbr/gptmbr.S b/mbr/gptmbr.S index 385afe7..c161b44 100644 --- a/mbr/gptmbr.S +++ b/mbr/gptmbr.S @@ -59,6 +59,7 @@ _start: movw %ax, %ss movw $stack, %sp movw %sp, %si + movw %sp, %bp /* needed later if drive number is to be forced due to Ctrl key being pressed */ pushw %es /* 4(%bp) es:di -> $PnP header */ pushw %di /* 2(%bp) */ pushw %dx /* 0(%bp) = %dl -> drive number */ @@ -74,7 +75,18 @@ _start: ljmpw $0, $next next: + /* Provide a way for the user to force boot from first hard-disk by pressing a Ctrl key */ +get_shift_keys: + movb $0x02, %ah /* function: get keyboard shift flags */ + int $0x16 /* read keys; shift flags returned in AL */ + testb $0x04, %al /* control key pressed? */ + jz detect_bios_type +force_first_hard_disk: + movb $0x80, -6(%bp) /* offset from top-of-stack to drive number; force it to be first hard disk */ + +detect_bios_type: /* Check to see if we have EBIOS */ + movw -6(%bp), %dx pushw %dx /* drive number */ movb $0x41, %ah /* %al == 0 already */ movw $0x55aa, %bx @@ -210,7 +222,7 @@ boot: missing_os: call error - .ascii "Operating system not bootable\r\n" + .ascii "OS unbootable\r\n" saturate_stosl: pushl %eax @@ -265,7 +277,7 @@ read_common: disk_error: call error - .ascii "Disk error on boot\r\n" + .ascii "Disk boot error\r\n" /* * Print error messages. This is invoked with "call", with the -- 1.6.0.4