1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;; (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
16 ;; Load a boot sector (or other bootstrap program.)
18 ;; Unlike previous versions of this software, this doesn't require that
19 ;; the length is 512 bytes. This allows PXE bootstraps and WinNT
20 ;; "CD boot sectors" to be invoked.
27 %if IS_SYSLINUX || IS_MDSLINUX
29 mov byte [CopySuper],0
30 jmp short load_bootsec
33 ; Transfer the superblock
34 mov byte [CopySuper],superblock_len
39 xchg dx,ax ; Now EAX = file length
41 mov [trackbuf+4],edi ; Copy from this address
42 push edi ; Save load address
43 xor dx,dx ; No padding
48 mov [trackbuf+8],edi ; Save length
50 mov eax,7C00h ; Entry point
51 mov [trackbuf],eax ; Copy to this address
52 mov [EntryPoint],eax ; Jump to this address when done
54 %if IS_SYSLINUX || IS_MDSLINUX
55 movzx ecx,byte [CopySuper]
58 ; For a BSS boot sector we have to patch.
60 mov edi,100000h+(superblock-bootsec)
68 %if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX
69 ; Restore original FDC table
70 mov eax,[OrigFDCTabPtr]
74 mov si,PartInfo ; Partition info buffer
75 mov di,800h-18 ; Put partition info here
80 pop si ; DS:SI points to partition info
84 mov byte [KeepPXE],1 ; Chainloading another NBP
90 ; replace_bootstrap for the special case where we have exactly one
91 ; descriptor, and it's the first entry in the trackbuf
94 replace_bootstrap_one:
95 push word trackbuf ; Address of descriptor list
96 push word 1 ; Length of descriptor list
100 ; Entrypoint for "shut down and replace bootstrap" -- also invoked by
101 ; the COMBOOT API. This routine expects two words on the stack:
102 ; address of the copy list (versus DS) and count. Additionally,
103 ; the values of ESI and EDX are passed on to the new bootstrap;
104 ; the value of BX becomes the new DS.
108 ; Prepare for shutting down
113 ; Set up initial stack frame (not used by PXE if keeppxe is
114 ; set - we use the PXE stack then.)
115 ; AFTER THIS POINT ONLY .earlybss IS AVAILABLE, NOT .bss
122 test byte [KeepPXE],01h
124 les di,[InitStack] ; Reset stack to PXE original
139 pop ax ; Copy list count
140 pop bx ; Copy from...
149 %if IS_SYSLINUX || IS_MDSLINUX