Преглед изворни кода

[romprefix] On a PCI3.0, non-BBS system, use the correct %cs for INT19

On a system that doesn't support BBS, we end up hooking INT19 to gain
control of the boot process.  If the system is PCI3.0, we must take
care to use the runtime value for %cs, rather than the POST-time
value, otherwise we end up pointing INT19 to the temporary option ROM
POST scratch area.
tags/v0.9.4
Michael Brown пре 15 година
родитељ
комит
82baea0a4b
1 измењених фајлова са 45 додато и 26 уклоњено
  1. 45
    26
      src/arch/i386/prefix/romprefix.S

+ 45
- 26
src/arch/i386/prefix/romprefix.S Прегледај датотеку

@@ -144,6 +144,7 @@ init:
144 144
 	popw	%ds
145 145
 	pushw	$0x40
146 146
 	popw	%fs
147
+
147 148
 	/* Shuffle some registers around.  We need %di available for
148 149
 	 * the print_xxx functions, and in a register that's
149 150
 	 * addressable from %es, so shuffle as follows:
@@ -153,21 +154,53 @@ init:
153 154
 	 */
154 155
 	movw	%bx, %gs
155 156
 	movw	%di, %bx
157
+
156 158
 	/* Print message as early as possible */
157 159
 	movw	$init_message, %si
158 160
 	xorw	%di, %di
159 161
 	call	print_message
160 162
 	call	print_pci_busdevfn
163
+
161 164
 	/* Fill in product name string, if possible */
162 165
 	movw	$prodstr_pci_id, %di
163 166
 	call	print_pci_busdevfn
164 167
 	movb	$' ', prodstr_separator
168
+
165 169
 	/* Print segment address */
166 170
 	movb	$' ', %al
167 171
 	xorw	%di, %di
168 172
 	call	print_character
169 173
 	movw	%cs, %ax
170 174
 	call	print_hex_word
175
+
176
+	/* Check for PCI BIOS version */
177
+	pushl	%ebx
178
+	pushl	%edx
179
+	stc
180
+	movw	$0xb101, %ax
181
+	int	$0x1a
182
+	jc	1f
183
+	cmpl	$PCI_SIGNATURE, %edx
184
+	jne	1f
185
+	testb	%ah, %ah
186
+	jnz	1f
187
+	movw	$init_message_pci, %si
188
+	xorw	%di, %di
189
+	call	print_message
190
+	movb	%bh, %al
191
+	call	print_hex_nibble
192
+	movb	$'.', %al
193
+	call	print_character
194
+	movb	%bl, %al
195
+	call	print_hex_byte
196
+	cmpb	$3, %bh
197
+	jae	2f
198
+1:	/* PCI <3.0: set %gs (runtime segment) = %cs (init-time segment) */
199
+	pushw	%cs
200
+	popw	%gs
201
+2:	popl	%edx
202
+	popl	%ebx
203
+
171 204
 	/* Check for PnP BIOS */
172 205
 	testw	$0x0f, %bx	/* PnP signature must be aligned - bochs    */
173 206
 	jnz	hook_int19	/* uses unalignment to indicate 'fake' PnP. */
@@ -177,6 +210,7 @@ init:
177 210
 	movw	$init_message_pnp, %si
178 211
 	xorw	%di, %di
179 212
 	call	print_message
213
+
180 214
 	/* Check for BBS */
181 215
 	pushw	%es:0x1b(%bx)	/* Real-mode data segment */
182 216
 	pushw	%ds		/* &(bbs_version) */
@@ -199,10 +233,11 @@ hook_int19:
199 233
 	movw	%ax, %es
200 234
 	pushl	%es:( 0x19 * 4 )
201 235
 	popl	orig_int19
202
-	pushw	%cs
236
+	pushw	%gs /* %gs contains runtime %cs */
203 237
 	pushw	$int19_entry
204 238
 	popl	%es:( 0x19 * 4 )
205 239
 hook_bbs:
240
+
206 241
 	/* Check for PMM */
207 242
 	movw	$( 0xe000 - 1 ), %bx
208 243
 pmm_scan:
@@ -259,29 +294,11 @@ gotpmm:	/* PMM allocation succeeded: copy ROM to PMM block */
259 294
 	subb	%bl, checksum
260 295
 	popal
261 296
 no_pmm:
262
-	/* Check for PCI BIOS */
263
-	pushl	%edx
264
-	stc
265
-	movw	$0xb101, %ax
266
-	int	$0x1a
267
-	jc	no_pci
268
-	cmpl	$PCI_SIGNATURE, %edx
269
-	popl	%edx
270
-	jne	no_pci
271
-	testb	%ah, %ah
272
-	jnz	no_pci
273
-	movw	$init_message_pci, %si
274
-	xorw	%di, %di
275
-	call	print_message
276
-	movb	%bh, %al
277
-	call	print_hex_nibble
278
-	movb	$'.', %al
279
-	call	print_character
280
-	movb	%bl, %al
281
-	call	print_hex_byte
282
-	cmpb	$3, %bh
283
-	jb	no_pci3
284
-	/* Copy self to option ROM space (required for PCI3.0) */
297
+
298
+	/* Copy self to option ROM space.  Required for PCI3.0, which
299
+	 * loads us to a temporary location in low memory.  Will be a
300
+	 * no-op for lower PCI versions.
301
+	 */
285 302
 	movb	$' ', %al
286 303
 	xorw	%di, %di
287 304
 	call	print_character
@@ -293,8 +310,7 @@ no_pmm:
293 310
 	xorw	%si, %si
294 311
 	xorw	%di, %di
295 312
 	cs rep	movsb
296
-no_pci3:
297
-no_pci:
313
+
298 314
 	/* Prompt for POST-time shell */
299 315
 	movw	$init_message_prompt, %si
300 316
 	xorw	%di, %di
@@ -338,16 +354,19 @@ wait_for_key:
338 354
 	pushw	%cs
339 355
 	call	exec
340 356
 no_key_pressed:
357
+
341 358
 	/* Print blank lines to terminate messages */
342 359
 	movw	$init_message_end, %si
343 360
 	xorw	%di, %di
344 361
 	call	print_message
362
+
345 363
 	/* Restore registers */
346 364
 	popw	%gs
347 365
 	popw	%fs
348 366
 	popw	%es
349 367
 	popw	%ds
350 368
 	popaw
369
+
351 370
 	/* Indicate boot capability to PnP BIOS, if present */
352 371
 	movw	$0x20, %ax
353 372
 	lret

Loading…
Откажи
Сачувај