Browse Source

[prefix] When we have to hook INT 19, chain to original handler if possible

When the BIOS doesn't support BBS, hooking INT 19 is the only way to add
ourselves as a boot device.  If we have to do this, we should at least
try to chain to the original INT 19 vector if our boot fails.

Idea suggested by Andrew Schran <aschran@google.com>
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
cd0e9bcd22
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      src/arch/i386/prefix/romprefix.S

+ 14
- 2
src/arch/i386/prefix/romprefix.S View File

@@ -173,6 +173,8 @@ hook_int19:
173 173
 	call	print_message
174 174
 	xorw	%ax, %ax
175 175
 	movw	%ax, %es
176
+	pushl	%es:( 0x19 * 4 )
177
+	popl	orig_int19
176 178
 	pushw	%cs
177 179
 	pushw	$int19_entry
178 180
 	popl	%es:( 0x19 * 4 )
@@ -345,14 +347,24 @@ bev_entry:
345 347
 
346 348
 /* INT19 entry point
347 349
  *
348
- * Called via the hooked INT 19 if we detected a non-PnP BIOS.
350
+ * Called via the hooked INT 19 if we detected a non-PnP BIOS.  We
351
+ * attempt to return via the original INT 19 vector (if we were able to
352
+ * store it).
349 353
  */
350 354
 int19_entry:
351 355
 	pushw	%cs
352 356
 	call	exec
353
-	/* No real way to return from INT19 */
357
+	movl	%cs:orig_int19, %eax
358
+	testl	%eax, %eax
359
+	je	1f
360
+	/* Chain to original INT 19 vector */
361
+	ljmp	*%cs:orig_int19
362
+1:	/* No chained vector: issue INT 18 as a last resort */
354 363
 	int	$0x18
355 364
 	.size	int19_entry, . - int19_entry
365
+orig_int19:
366
+	.long	0
367
+	.size	orig_int19, . - orig_int19
356 368
 
357 369
 /* Execute as a boot device
358 370
  *

Loading…
Cancel
Save