1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2006 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
44 mov bx,abort_check ; Don't print dots, but allow abort
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 1 ; Length of descriptor list
96 push word trackbuf ; Address 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
111 call cleanup_hardware
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
136 mov [es:di+28],edx ; New EDX
137 mov [es:di+12],esi ; New ESI
138 mov [es:di+6],bx ; New DS
141 ; DON'T DO THIS FOR PXELINUX...
142 ; For PXE, ES:BX -> PXENV+, and this would corrupt
145 ; Hunt for $PnP header if one exists
150 cmp dword [fs:bx], "$PnP"
153 cmp bx,-3 ; Don't get a segment overflow error!
155 jmp .donepnp ; No $PnP header found
157 movzx cx,byte [fs:bx+5] ; Size of $PnP header
159 jb .findpnp ; Invalid $PnP header (too short)
170 ; Found a valid $PnP header, point ES:DI to it
171 mov [es:di+8], bx ; New DI
172 mov [es:di+4], fs ; New ES
176 pop bx ; Copy from...
177 pop ax ; Copy list count