summaryrefslogtreecommitdiff
path: root/bootsect.inc
diff options
context:
space:
mode:
authorhpa <hpa>2002-04-28 00:32:34 +0000
committerhpa <hpa>2002-04-28 00:32:34 +0000
commit3e012b34a2eac374cd3db4c74657fb059d357536 (patch)
tree963bed3846a7978c37460df9f04ac89438c87663 /bootsect.inc
parent7fb748081728cf625444cd7f37c96ae4435e06a6 (diff)
downloadsyslinux-3e012b34a2eac374cd3db4c74657fb059d357536.tar.gz
Generalize and factor out bootsector-generation code.syslinux-1.73-pre5
Diffstat (limited to 'bootsect.inc')
-rw-r--r--bootsect.inc102
1 files changed, 102 insertions, 0 deletions
diff --git a/bootsect.inc b/bootsect.inc
new file mode 100644
index 00000000..4546eda2
--- /dev/null
+++ b/bootsect.inc
@@ -0,0 +1,102 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;
+;; Copyright 1994-2002 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., 53 Temple Place Ste 330,
+;; Bostom MA 02111-1307, USA; either version 2 of the License, or
+;; (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; bootsect.inc
+;;
+;; Load a boot sector (or other bootstrap program.)
+;;
+;; Unlike previous versions of this software, this doesn't require that
+;; the length is 512 bytes. This allows PXE bootstraps and WinNT
+;; "CD boot sectors" to be invoked.
+;;
+
+;
+; Load a boot sector
+;
+is_bootsector:
+%if IS_SYSLINUX
+ ; Transfer zero bytes
+ xor cx,cx
+ jmp short load_bootsec
+is_bss_sector:
+ ; Transfer the superblock
+ mov cx,superblock_len
+load_bootsec:
+ push cx
+%endif
+ xchg dx,ax
+ shr eax,16
+ xchg dx,ax ; Now EAX = file length
+ mov edi, 100000h
+ call load_high
+
+%if IS_SYSLINUX
+ pop cx
+%endif
+
+ sub edi,100000h
+ push edi ; Save length
+
+%if IS_SYSLINUX
+ jcxz .not_bss
+
+ ; For a BSS boot sector we have to patch.
+ mov esi,superblock
+ mov edi,100000h+(superblock-bootsec)
+ movzx ecx,cx
+ call bcopy
+
+.not_bss:
+%endif
+;
+; Prepare for shutting down
+;
+ call vgaclearmode
+ xor edx,edx
+ xor eax,eax
+%if IS_SYSLINUX
+ mov dl,[bsDriveNumber]
+
+ mov si,PartInfo
+ mov di,800h-18 ; Put partition info here
+ push di
+ mov cx,8 ; 16 bytes
+ rep movsw
+ pop ax ; DS:SI points to partition info
+%elif IS_ISOLINUX
+ mov dl,[DriveNo]
+%endif
+
+ mov esi,7C00h
+ mov edi,100000h
+ pop ecx ; Byte count
+
+ cli
+ xor ebx,ebx
+ mov ds,bx
+%if IS_PXELINUX
+ lss sp,[Stack] ; Reset stack to PXE original
+ les bx,[InitESBX] ; ES:BX -> PXENV+
+%else
+ mov es,bx
+ mov esp,esi
+%endif
+ jmp bcopy_over_self
+
+%if IS_SYSLINUX = 0
+is_bss_image:
+ mov si,err_bssimage
+ call cwritestr
+ jmp enter_command
+%endif