3 * Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /* Only these flags are propagated into Int386() */
27 #define FLAGS_PROP (I386FLAG_CF | \
67 * int Int386(int ivec, REGS* in, REGS* out);
72 /* Get the function parameters */
74 movl %eax,Int386_vector
75 movb %al,Int386_vector_opcode
77 movl %eax,Int386_regsin
79 movl %eax,Int386_regsout
81 /* Save all registers + segment registers */
88 /* Copy the input regs to our variables */
89 movl $Int386_REGS,%edi
90 movl Int386_regsin,%esi
99 /* Setup the registers */
100 movw %cs:Int386_ds,%ax
101 movw %ax,%ds /* DS register */
102 movw %cs:Int386_es,%ax
103 movw %ax,%es /* ES register */
104 movw %cs:Int386_fs,%ax
105 movw %ax,%fs /* FS register */
106 movw %cs:Int386_gs,%ax
107 movw %ax,%gs /* GS register */
109 /* Prepare EFLAGS for recover */
111 movw %cs:Int386_eflags, %ax
113 andw $FLAGS_PROP, %ax
114 andw $~FLAGS_PROP, %cx
118 /* Recover general purpose registers */
119 movl %cs:Int386_eax,%eax /* EAX register */
120 movl %cs:Int386_ebx,%ebx /* EBX register */
121 movl %cs:Int386_ecx,%ecx /* ECX register */
122 movl %cs:Int386_edx,%edx /* EDX register */
124 movl %cs:Int386_esi,%esi /* ESI register */
125 movl %cs:Int386_edi,%edi /* EDI register */
127 /* Recover previously prepared flags */
130 /* Do not set the flags register */
131 /* only return its value in regsout */
132 //pushl Int386_eflags
133 //popfl /* EFLAGS register */
135 /* Call the interrupt vector */
136 /*int Int386_vector*/
139 Int386_vector_opcode:
142 /* Save the registers */
143 movl %eax,%cs:Int386_eax /* EAX register */
144 movl %ebx,%cs:Int386_ebx /* EBX register */
145 movl %ecx,%cs:Int386_ecx /* ECX register */
146 movl %edx,%cs:Int386_edx /* EDX register */
148 movl %esi,%cs:Int386_esi /* ESI register */
149 movl %edi,%cs:Int386_edi /* EDI register */
151 movw %ds,%ax /* DS register */
152 movw %ax,%cs:Int386_ds
153 movw %es,%ax /* ES register */
154 movw %ax,%cs:Int386_es
155 movw %fs,%ax /* FS register */
156 movw %ax,%cs:Int386_fs
157 movw %gs,%ax /* GS register */
158 movw %ax,%cs:Int386_gs
161 popw %cs:Int386_eflags /* EFLAGS register */
166 /* Copy the variables to the output regs */
167 movl $Int386_REGS,%esi
168 movl Int386_regsout,%edi
174 /* Restore segment and all other registers */
183 /* Get return value */