2 ** Copyright 2004, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
6 #define FUNCTION(x) .global x; .type x,@function; x
8 /* everything between int86_code_start and int86_code_stop gets
9 * copied to 0x7c00 before being called
11 .globl int86_code_start
24 * void int86(int interrupt, struct regs *r);
32 /* copy ourselves to 0x7c00 */
33 movl $0x7c00,%edi /* destination */
34 movl $int86_code_start,%esi /* source */
35 movl $int86_code_stop-int86_code_start,%ecx /* count */
39 /* set the idt back to zero */
42 /* get the interrupt vector and patch the instruction at the target address */
44 mov %al,(intinstruction+1-int86_code_start+0x7c00)
46 /* load the regs from the passed-in structure */
47 movl 44(%esp),%ebp /* ebp will hold the structure */
48 /* dont get eax yet */
55 movl (%ebp),%ebp /* this value will go to %eax before the int call */
63 /* switch down to the low-memory version of this code */
64 jmp .foo-int86_code_start+0x7c00
67 /* unset the protected mode and paging bits */
72 /* switch into 16-bit code */
73 ljmp $0x7c0,$real-int86_code_start
90 /* save the flags (we care about the carry bit) */
93 /* save %eax from the call */
96 /* set the protected mode and paging bit */
112 /* restore the stack */
115 /* save the registers from the call */
138 .globl int86_code_stop