/* -----------------------------------------------------------------------1*2* Copyright 2009 Intel Corporation; author H. Peter Anvin3*4* This file is part of the Linux kernel, and is made available under5* the terms of the GNU General Public License version 2 or (at your6* option) any later version; incorporated herein by reference.7*8* ----------------------------------------------------------------------- */910/*11* "Glove box" for BIOS calls. Avoids the constant problems with BIOSes12* touching registers they shouldn't be.13*/1415.code16gcc16.text17.globl intcall18.type intcall, @function19intcall:20/* Self-modify the INT instruction. Ugly, but works. */21cmpb %al, 3f22je 1f23movb %al, 3f24jmp 1f /* Synchronize pipeline */251:26/* Save state */27pushfl28pushw %fs29pushw %gs30pushal3132/* Copy input state to stack frame */33subw $44, %sp34movw %dx, %si35movw %sp, %di36movw $11, %cx37rep; movsd3839/* Pop full state from the stack */40popal41popw %gs42popw %fs43popw %es44popw %ds45popfl4647/* Actual INT */48.byte 0xcd /* INT opcode */493: .byte 05051/* Push full state to the stack */52pushfl53pushw %ds54pushw %es55pushw %fs56pushw %gs57pushal5859/* Re-establish C environment invariants */60cld61movzwl %sp, %esp62movw %cs, %ax63movw %ax, %ds64movw %ax, %es6566/* Copy output state from stack frame */67movw 68(%esp), %di /* Original %cx == 3rd argument */68andw %di, %di69jz 4f70movw %sp, %si71movw $11, %cx72rep; movsd734: addw $44, %sp7475/* Restore state and return */76popal77popw %gs78popw %fs79popfl80retl81.size intcall, .-intcall828384