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