1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2008 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
38 mov [trackbuf+4],edi ; Copy from this address
39 push edi ; Save load address
40 xor dx,dx ; No padding
41 mov bx,abort_check ; Don't print dots, but allow abort
45 mov [trackbuf+8],edi ; Save length
47 mov eax,7C00h ; Entry point
48 mov [trackbuf],eax ; Copy to this address
49 mov [EntryPoint],eax ; Jump to this address when done
51 %if IS_SYSLINUX || IS_MDSLINUX
52 movzx ecx,byte [CopySuper]
55 ; For a BSS boot sector we have to patch.
57 mov edi,100000h+(superblock-bootsec)
65 %if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX
66 ; Restore original FDC table
67 mov eax,[OrigFDCTabPtr]
71 mov si,PartInfo ; Partition info buffer
72 mov di,800h-18 ; Put partition info here
77 pop si ; DS:SI points to partition info
81 mov byte [KeepPXE],1 ; Chainloading another NBP
87 ; replace_bootstrap for the special case where we have exactly one
88 ; descriptor, and it's the first entry in the trackbuf
91 replace_bootstrap_one:
92 push word 1 ; Length of descriptor list
93 push word trackbuf ; Address of descriptor list
97 ; Entrypoint for "shut down and replace bootstrap" -- also invoked by
98 ; the COMBOOT API. This routine expects two words on the stack:
99 ; address of the copy list (versus DS) and count. Additionally,
100 ; the values of ESI and EDX are passed on to the new bootstrap;
101 ; the value of BX becomes the new DS.
105 ; Prepare for shutting down
108 call cleanup_hardware
111 ; Set up initial stack frame (not used by PXE if keeppxe is
112 ; set - we use the PXE stack then.)
113 ; AFTER THIS POINT ONLY .earlybss IS AVAILABLE, NOT .bss
120 test byte [KeepPXE],01h
122 les di,[InitStack] ; Reset stack to PXE original
133 mov [es:di+28],edx ; New EDX
134 mov [es:di+12],esi ; New ESI
135 mov [es:di+6],bx ; New DS
138 ; DON'T DO THIS FOR PXELINUX...
139 ; For PXE, ES:BX -> PXENV+, and this would corrupt
142 ; Restore ES:DI -> $PnP (if we were ourselves called
147 mov [es:di+8],ax ; New DI
148 mov [es:di+4],bx ; New ES
150 pop bx ; Copy from...
151 pop ax ; Copy list count