Loading...
1/* -----------------------------------------------------------------------
2 *
3 * Copyright 2009-2014 Intel Corporation; author H. Peter Anvin
4 *
5 * This file is part of the Linux kernel, and is made available under
6 * the terms of the GNU General Public License version 2 or (at your
7 * option) any later version; incorporated herein by reference.
8 *
9 * ----------------------------------------------------------------------- */
10
11/*
12 * "Glove box" for BIOS calls. Avoids the constant problems with BIOSes
13 * touching registers they shouldn't be.
14 */
15
16 .code16
17 .section ".inittext","ax"
18 .globl intcall
19 .type intcall, @function
20intcall:
21 /* Self-modify the INT instruction. Ugly, but works. */
22 cmpb %al, 3f
23 je 1f
24 movb %al, 3f
25 jmp 1f /* Synchronize pipeline */
261:
27 /* Save state */
28 pushfl
29 pushw %fs
30 pushw %gs
31 pushal
32
33 /* Copy input state to stack frame */
34 subw $44, %sp
35 movw %dx, %si
36 movw %sp, %di
37 movw $11, %cx
38 rep; movsd
39
40 /* Pop full state from the stack */
41 popal
42 popw %gs
43 popw %fs
44 popw %es
45 popw %ds
46 popfl
47
48 /* Actual INT */
49 .byte 0xcd /* INT opcode */
503: .byte 0
51
52 /* Push full state to the stack */
53 pushfl
54 pushw %ds
55 pushw %es
56 pushw %fs
57 pushw %gs
58 pushal
59
60 /* Re-establish C environment invariants */
61 cld
62 movzwl %sp, %esp
63 movw %cs, %ax
64 movw %ax, %ds
65 movw %ax, %es
66
67 /* Copy output state from stack frame */
68 movw 68(%esp), %di /* Original %cx == 3rd argument */
69 andw %di, %di
70 jz 4f
71 movw %sp, %si
72 movw $11, %cx
73 rep; movsd
744: addw $44, %sp
75
76 /* Restore state and return */
77 popal
78 popw %gs
79 popw %fs
80 popfl
81 retl
82 .size intcall, .-intcall
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* -----------------------------------------------------------------------
3 *
4 * Copyright 2009-2014 Intel Corporation; author H. Peter Anvin
5 *
6 * ----------------------------------------------------------------------- */
7
8/*
9 * "Glove box" for BIOS calls. Avoids the constant problems with BIOSes
10 * touching registers they shouldn't be.
11 */
12
13 .code16
14 .section ".inittext","ax"
15 .globl intcall
16 .type intcall, @function
17intcall:
18 /* Self-modify the INT instruction. Ugly, but works. */
19 cmpb %al, 3f
20 je 1f
21 movb %al, 3f
22 jmp 1f /* Synchronize pipeline */
231:
24 /* Save state */
25 pushfl
26 pushw %fs
27 pushw %gs
28 pushal
29
30 /* Copy input state to stack frame */
31 subw $44, %sp
32 movw %dx, %si
33 movw %sp, %di
34 movw $11, %cx
35 rep; movsl
36
37 /* Pop full state from the stack */
38 popal
39 popw %gs
40 popw %fs
41 popw %es
42 popw %ds
43 popfl
44
45 /* Actual INT */
46 .byte 0xcd /* INT opcode */
473: .byte 0
48
49 /* Push full state to the stack */
50 pushfl
51 pushw %ds
52 pushw %es
53 pushw %fs
54 pushw %gs
55 pushal
56
57 /* Re-establish C environment invariants */
58 cld
59 movzwl %sp, %esp
60 movw %cs, %ax
61 movw %ax, %ds
62 movw %ax, %es
63
64 /* Copy output state from stack frame */
65 movw 68(%esp), %di /* Original %cx == 3rd argument */
66 andw %di, %di
67 jz 4f
68 movw %sp, %si
69 movw $11, %cx
70 rep; movsl
714: addw $44, %sp
72
73 /* Restore state and return */
74 popal
75 popw %gs
76 popw %fs
77 popfl
78 retl
79 .size intcall, .-intcall