Annotation of /tags/mkinitrd-6_1_8/isolinux/bootsect.inc
Parent Directory | Revision Log
Revision 916 -
(hide annotations)
(download)
Wed Oct 28 00:17:50 2009 UTC (14 years, 11 months ago) by niro
File size: 3666 byte(s)
Wed Oct 28 00:17:50 2009 UTC (14 years, 11 months ago) by niro
File size: 3666 byte(s)
tagged 'mkinitrd-6_1_8'
1 | niro | 532 | ;; $Id: bootsect.inc,v 1.1 2007-09-01 22:44:04 niro Exp $ |
2 | ;; ----------------------------------------------------------------------- | ||
3 | ;; | ||
4 | ;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved | ||
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 || IS_MDSLINUX | ||
29 | ; Transfer zero bytes | ||
30 | mov byte [CopySuper],0 | ||
31 | jmp short load_bootsec | ||
32 | |||
33 | is_bss_sector: | ||
34 | ; Transfer the superblock | ||
35 | mov byte [CopySuper],superblock_len | ||
36 | %endif | ||
37 | load_bootsec: | ||
38 | xchg dx,ax | ||
39 | shl eax,16 | ||
40 | xchg dx,ax ; Now EAX = file length | ||
41 | mov edi, 100000h | ||
42 | mov [trackbuf+4],edi ; Copy from this address | ||
43 | push edi ; Save load address | ||
44 | xor dx,dx ; No padding | ||
45 | call load_high | ||
46 | call crlf | ||
47 | |||
48 | sub edi,100000h | ||
49 | mov [trackbuf+8],edi ; Save length | ||
50 | |||
51 | mov eax,7C00h ; Entry point | ||
52 | mov [trackbuf],eax ; Copy to this address | ||
53 | mov [EntryPoint],eax ; Jump to this address when done | ||
54 | |||
55 | %if IS_SYSLINUX || IS_MDSLINUX | ||
56 | movzx ecx,byte [CopySuper] | ||
57 | jcxz .not_bss | ||
58 | |||
59 | ; For a BSS boot sector we have to patch. | ||
60 | mov esi,superblock | ||
61 | mov edi,100000h+(superblock-bootsec) | ||
62 | call bcopy | ||
63 | |||
64 | .not_bss: | ||
65 | %endif | ||
66 | |||
67 | xor edx,edx | ||
68 | xor esi,esi | ||
69 | %if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX | ||
70 | ; Restore original FDC table | ||
71 | mov eax,[OrigFDCTabPtr] | ||
72 | mov [fdctab],eax | ||
73 | |||
74 | mov dl,[DriveNumber] | ||
75 | mov si,PartInfo ; Partition info buffer | ||
76 | mov di,800h-18 ; Put partition info here | ||
77 | push di | ||
78 | mov cx,8 ; 16 bytes | ||
79 | xor ax,ax | ||
80 | rep movsw | ||
81 | pop si ; DS:SI points to partition info | ||
82 | %elif IS_ISOLINUX | ||
83 | mov dl,[DriveNo] | ||
84 | %elif IS_PXELINUX | ||
85 | mov byte [KeepPXE],1 ; Chainloading another NBP | ||
86 | call reset_pxe | ||
87 | %endif | ||
88 | xor bx,bx | ||
89 | |||
90 | ; | ||
91 | ; replace_bootstrap for the special case where we have exactly one | ||
92 | ; descriptor, and it's the first entry in the trackbuf | ||
93 | ; | ||
94 | |||
95 | replace_bootstrap_one: | ||
96 | push word trackbuf ; Address of descriptor list | ||
97 | push word 1 ; Length of descriptor list | ||
98 | ; Fall through | ||
99 | |||
100 | ; | ||
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. | ||
106 | ; | ||
107 | replace_bootstrap: | ||
108 | ; | ||
109 | ; Prepare for shutting down | ||
110 | ; | ||
111 | call vgaclearmode | ||
112 | |||
113 | ; | ||
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 | ||
117 | ; | ||
118 | xor ax,ax | ||
119 | mov ds,ax | ||
120 | mov es,ax | ||
121 | |||
122 | %if IS_PXELINUX | ||
123 | test byte [KeepPXE],01h | ||
124 | jz .stdstack | ||
125 | les di,[InitStack] ; Reset stack to PXE original | ||
126 | jmp .stackok | ||
127 | %endif | ||
128 | .stdstack: | ||
129 | mov di,7C00h-44 | ||
130 | push di | ||
131 | mov cx,22 ; 44 bytes | ||
132 | rep stosw | ||
133 | pop di | ||
134 | .stackok: | ||
135 | |||
136 | mov [es:di+28],edx | ||
137 | mov [es:di+12],esi | ||
138 | mov [es:di+6],bx | ||
139 | |||
140 | pop ax ; Copy list count | ||
141 | pop bx ; Copy from... | ||
142 | |||
143 | cli | ||
144 | mov cx,es | ||
145 | mov ss,cx | ||
146 | movzx esp,di | ||
147 | |||
148 | jmp shuffle_and_boot | ||
149 | |||
150 | %if IS_SYSLINUX || IS_MDSLINUX | ||
151 | ; Nothing | ||
152 | %else | ||
153 | is_bss_sector: | ||
154 | mov si,err_bssimage | ||
155 | call cwritestr | ||
156 | jmp enter_command | ||
157 | %endif |