stage1: add bios call hook
parent
ce19f70440
commit
2ec426677f
@ -0,0 +1,61 @@
|
||||
.text
|
||||
.code32
|
||||
|
||||
/*
|
||||
* This has got to be one of the most cursed routines within stage1.
|
||||
* Temporarily returns to Real Mode, does a BIOS interrupt, and then
|
||||
* goes back to Protected Mode again. Furthermore, the interrupt
|
||||
* number is written ahead of time by the callee.
|
||||
*/
|
||||
GLOBL __do_bios_int
|
||||
push %ebp /* '1 v */
|
||||
mov %esp, %ebp
|
||||
pushal /* '2 v */
|
||||
|
||||
mov 8(%ebp), %ebp
|
||||
mov (%ebp), %ax
|
||||
mov 2(%ebp), %cx
|
||||
mov 4(%ebp), %dx
|
||||
mov 6(%ebp), %bx
|
||||
mov 8(%ebp), %si
|
||||
mov 10(%ebp), %di
|
||||
|
||||
push %ebp /* '3 v */
|
||||
|
||||
push %eax /* '4 v */
|
||||
push %edx /* '5 v */
|
||||
call prot_to_real
|
||||
.code16
|
||||
pop %edx /* '5 ^ */
|
||||
pop %eax /* '4 ^ */
|
||||
|
||||
/* call that polymorphism! */
|
||||
.byte 0xcd /* opcode for `int imm8` */
|
||||
GLOBL __bios_int_number, object
|
||||
.byte 0x18 /* this is the imm8 */
|
||||
|
||||
push %eax /* '4 v */
|
||||
push %edx /* '5 v */
|
||||
pushfl /* '6 v */
|
||||
call real_to_prot
|
||||
.code32
|
||||
popfl /* '6 ^ */
|
||||
pop %edx /* '5 ^ */
|
||||
pop %eax /* '4 ^ */
|
||||
|
||||
pop %ebp /* '3 ^ */
|
||||
|
||||
mov %ax, (%ebp)
|
||||
mov %cx, 2(%ebp)
|
||||
mov %dx, 4(%ebp)
|
||||
mov %bx, 6(%ebp)
|
||||
mov %si, 8(%ebp)
|
||||
mov %di, 10(%ebp)
|
||||
mov %al, 12(%ebp)
|
||||
|
||||
popal /* '2 ^ */
|
||||
setc %al
|
||||
movzbl %al, %eax
|
||||
pop %ebx /* '1 ^ */
|
||||
ret
|
||||
END __do_bios_int
|
Loading…
Reference in New Issue