2009-04-02 05:08:28 +04:00
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
2014-01-05 02:29:08 +04:00
* Copyright 2 0 0 9 - 2 0 1 4 I n t e l C o r p o r a t i o n ; author H. Peter Anvin
2009-04-02 05:08:28 +04:00
*
* This f i l e i s p a r t o f t h e L i n u x k e r n e l , a n d i s m a d e a v a i l a b l e u n d e r
* the t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 o r ( a t y o u r
* option) a n y l a t e r v e r s i o n ; incorporated herein by reference.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /
/ *
* " Glove b o x " f o r B I O S c a l l s . A v o i d s t h e c o n s t a n t p r o b l e m s w i t h B I O S e s
2009-04-12 09:24:05 +04:00
* touching r e g i s t e r s t h e y s h o u l d n ' t b e .
2009-04-02 05:08:28 +04:00
* /
2014-01-04 02:30:42 +04:00
.code16
2014-01-05 02:29:08 +04:00
.section " .inittext " , " ax"
2009-04-02 05:08:28 +04:00
.globl intcall
.type intcall, @function
intcall :
/* Self-modify the INT instruction. Ugly, but works. */
cmpb % a l , 3 f
je 1 f
movb % a l , 3 f
jmp 1 f / * S y n c h r o n i z e p i p e l i n e * /
1 :
/* Save state */
pushfl
pushw % f s
pushw % g s
pushal
/* Copy input state to stack frame */
subw $ 4 4 , % s p
movw % d x , % s i
movw % s p , % d i
movw $ 1 1 , % c x
rep; movsd
/* Pop full state from the stack */
popal
popw % g s
popw % f s
popw % e s
popw % d s
popfl
/* Actual INT */
.byte 0xcd /* INT opcode */
3 : .byte 0
/* Push full state to the stack */
pushfl
pushw % d s
pushw % e s
pushw % f s
pushw % g s
pushal
/* Re-establish C environment invariants */
cld
movzwl % s p , % e s p
movw % c s , % a x
movw % a x , % d s
movw % a x , % e s
/* Copy output state from stack frame */
movw 6 8 ( % e s p ) , % d i / * O r i g i n a l % c x = = 3 r d a r g u m e n t * /
andw % d i , % d i
jz 4 f
movw % s p , % s i
movw $ 1 1 , % c x
rep; movsd
4 : addw $ 4 4 , % s p
/* Restore state and return */
popal
popw % g s
popw % f s
popfl
retl
.size intcall, . - i n t c a l l