Magellan Linux

Contents of /trunk/mkinitrd-magellan/isolinux/bootsect.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations) (download)
Thu Aug 19 09:50:43 2010 UTC (13 years, 8 months ago) by niro
File size: 5195 byte(s)
-updated to isolinux-3.86
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
5 ;;
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.
11 ;;
12 ;; -----------------------------------------------------------------------
13
14 ;;
15 ;; bootsect.inc
16 ;;
17 ;; Load a boot sector (or other bootstrap program.)
18 ;;
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.
22 ;;
23
24 ;
25 ; Load a boot sector
26 ;
27 is_bootsector:
28 %if IS_SYSLINUX
29 ; Transfer zero bytes
30 push word 0
31 jmp short load_bootsec
32
33 is_bss_sector:
34 ; Transfer the superblock
35 SuperSize equ $+1
36 push word superblock_len_fat16
37 %endif
38 load_bootsec:
39 mov edi,100000h
40 mov [trackbuf+4],edi ; Copy from this address
41 xor dx,dx ; No padding
42 mov bx,abort_check ; Don't print dots, but allow abort
43 call load_high
44
45 sub edi,100000h
46 mov [trackbuf+8],edi ; Save length
47
48 mov eax,7C00h ; Entry point
49 mov [trackbuf],eax ; Copy to this address
50
51 %if IS_SYSLINUX
52 xor ecx,ecx
53 pop cx
54
55 ; For a BSS boot sector we have to patch.
56 mov esi,superblock
57 mov edi,100000h+(superblock-bootsec)
58 call bcopy
59 %endif
60 push eax ; Save entry point
61
62 xor edx,edx
63 xor esi,esi
64 %if IS_SYSLINUX || IS_EXTLINUX
65 ; Restore original FDC table
66 mov eax,[OrigFDCTabPtr]
67 mov [fdctab],eax
68
69 mov dl,[DriveNumber]
70 mov si,PartInfo ; Partition info buffer
71 mov di,800h-18 ; Put partition info here
72 push di
73 mov cx,8 ; 16 bytes
74 xor ax,ax
75 rep movsw
76 pop si ; DS:SI points to partition info
77 xor bx,bx
78 %elif IS_ISOLINUX
79 mov dl,[DriveNumber]
80 xor bx,bx
81 %elif IS_PXELINUX
82 mov byte [KeepPXE],03h ; Chainloading + keep PXE
83 call reset_pxe
84 lfs si,[InitStack]
85 ; Put restore DS, EDX and ESI to the true initial values
86 mov bx,[fs:si+6]
87 mov edx,[fs:si+28]
88 mov esi,[fs:si+12]
89 %endif
90
91 ;
92 ; replace_bootstrap for the special case where we have exactly one
93 ; descriptor, based in low memory. We will generate a second descriptor
94 ; to clear remaining FBM.
95 ;
96
97 replace_bootstrap_one:
98 mov eax,[trackbuf] ; Base address
99 add eax,[trackbuf+8] ; Length
100 movzx ecx,word [BIOS_fbm]
101 shl ecx,10 ; Free Base Memory
102 sub ecx,eax
103 mov [trackbuf+12],eax
104 or dword [trackbuf+16],-1 ; Zero memory
105 mov [trackbuf+20],ecx
106 push word 2 ; Length of descriptor list
107 ; Fall through
108
109 ;
110 ; Entrypoint for "shut down and replace bootstrap" -- also invoked by
111 ; the COMBOOT API. This routine expects the entry point (CS, IP) and the
112 ; count of the descriptor sequence on the stack; the shuffle
113 ; descriptors start at the first byte of the trackbuf.
114 ;
115 ; The registers EDX and ESI are passed on to the called program,
116 ; and BX is passed on as DS.
117 ;
118 replace_bootstrap:
119 ;
120 ; Prepare for shutting down
121 ;
122 call vgaclearmode
123
124 ;
125 ; We jump here when loading a kernel image, so that we don't reset
126 ; the screen mode in "quiet" mode
127 ;
128 replace_bootstrap_noclearmode:
129 call cleanup_hardware
130
131 ;
132 ; Set up initial stack frame (not used by PXE if keeppxe is
133 ; set - we use the PXE stack then.)
134 ;
135 xor ax,ax
136 mov ds,ax
137 mov es,ax
138
139 %if IS_PXELINUX
140 cmp byte [KeepPXE],0
141 je .stdstack
142 les di,[InitStack] ; Reset stack to PXE original
143 jmp .stackok
144 %endif
145 .stdstack:
146 mov di,7C00h-44
147 push di
148 mov cx,22 ; 44 bytes
149 rep stosw
150 pop di
151 .stackok:
152
153 mov [es:di+28],edx ; New EDX
154 mov [es:di+12],esi ; New ESI
155 mov [es:di+6],bx ; New DS
156
157 %if IS_PXELINUX == 0
158 ; DON'T DO THIS FOR PXELINUX...
159 ; For PXE, ES:BX -> PXENV+, and this would corrupt
160 ; that use.
161
162 ; Restore ES:DI -> $PnP (if we were ourselves called
163 ; that way...)
164 mov ax,[OrigESDI]
165 mov bx,[OrigESDI+2]
166
167 mov [es:di+8],ax ; New DI
168 mov [es:di+4],bx ; New ES
169 %endif
170 pop ax ; List length
171
172 push di
173 push es
174
175 push ds
176 pop es
177
178 mov ebx,trackbuf
179 imul di,ax,12
180 add di,bx ; DI <- end of list
181 push di
182
183 ; Terminating entry...
184 lea eax,[replace_stub] ; Entrypoint
185 push ax
186 stosd
187 xor ax,ax ; EAX[31:16] == 0 already
188 stosd ; 16-bit mode
189 stosd ; End of list
190
191 ; Copy the stub
192 pop di
193 mov si,__replacestub_lma
194 mov cx,__replacestub_dwords
195 rep movsd
196
197 xor ecx,ecx
198 pop cx ; ECX <- length of list
199
200 pop word [replace_stub.ss]
201 pop word [replace_stub.esp]
202 pop dword [replace_stub.csip]
203
204 cli
205 mov ss,[replace_stub.ss]
206 mov esp,[replace_stub.esp]
207
208 mov edi,trackbuf
209 mov esi,edi
210
211 jmp shuffle_and_boot_raw
212
213 ; This stub gets run after the shuffle. It is copied
214 ; below 0x7c00 in order to properly handle the case
215 ; of bootstrap replacement.
216 section .replacestub
217 replace_stub:
218 mov cr0,eax
219 jmp 0:.next
220 .next:
221 mov ax,strict word 0
222 .ss equ $-2
223 mov ss,ax
224 mov esp,strict dword 0
225 .esp equ $-4
226 pop gs
227 pop fs
228 pop es
229 pop ds
230 popad
231 popfd
232 jmp 0:0
233 .csip equ $-4
234
235 section .text