aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-04-20 00:55:29 -0400
committerH. Peter Anvin <hpa@zytor.com>2008-04-20 00:55:29 -0400
commitb1d380a638c5087bcf1e096ae8a250d835b62025 (patch)
tree9dc86ea2b886cd8786fe4b7f67bb7f66412c5bb9
parent75f156f68da694eae5f12cfe995903f91ad23e8b (diff)
downloadsyslinux-elf-b1d380a638c5087bcf1e096ae8a250d835b62025.tar.gz
syslinux-elf-b1d380a638c5087bcf1e096ae8a250d835b62025.tar.xz
syslinux-elf-b1d380a638c5087bcf1e096ae8a250d835b62025.zip
localboot.inc: file missing from previous checkin
-rw-r--r--localboot.inc78
1 files changed, 78 insertions, 0 deletions
diff --git a/localboot.inc b/localboot.inc
new file mode 100644
index 00000000..288d390a
--- /dev/null
+++ b/localboot.inc
@@ -0,0 +1,78 @@
+; -----------------------------------------------------------------------
+;
+; Copyright 1999-2008 H. Peter Anvin - All Rights Reserved
+;
+; 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
+; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+; Boston MA 02110-1301, USA; either version 2 of the License, or
+; (at your option) any later version; incorporated herein by reference.
+;
+; -----------------------------------------------------------------------
+
+;
+; localboot.inc
+;
+; Boot from a local disk, or invoke INT 18h.
+;
+
+%if HAS_LOCALBOOT
+
+;
+; Boot a specified local disk. AX specifies the BIOS disk number; or
+; -1 in case we should execute INT 18h ("next device.")
+;
+ section .text
+
+local_boot:
+ call vgaclearmode
+ lss sp,[cs:Stack] ; Restore stack pointer
+ xor dx,dx
+ mov ds,dx
+ mov es,dx
+ mov fs,dx
+ mov gs,dx
+ mov si,localboot_msg
+ call writestr
+ cmp ax,-1
+ je .int18
+
+ ; Load boot sector from the specified BIOS device and jump to it.
+ mov dl,al
+ xor dh,dh
+ push dx
+ xor ax,ax ; Reset drive
+ int 13h
+ mov ax,0201h ; Read one sector
+ mov cx,0001h ; C/H/S = 0/0/1 (first sector)
+ mov bx,trackbuf
+ mov bp,retry_count
+.again:
+ pusha
+ int 13h
+ popa
+ jnc .ok
+ dec bp
+ jnz .again
+ jmp kaboom ; Failure...
+.ok:
+ pop dx
+ cli ; Abandon hope, ye who enter here
+ mov si,trackbuf
+ mov di,07C00h
+ mov cx,512 ; Probably overkill, but should be safe
+ rep movsd
+ mov ss,cx ; SS <- 0
+ mov sp,7C00h
+ jmp 0:07C00h ; Jump to new boot sector
+
+.int18:
+ int 18h ; Hope this does the right thing...
+ jmp kaboom ; If we returned, oh boy...
+
+ section .data
+localboot_msg db 'Booting from local disk...', CR, LF, 0
+
+ section .text
+
+%endif ; HAS_LOCALBOOT