]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/pc/apmjump.s
kernel: cleanup the software mouse cursor mess
[plan9front.git] / sys / src / 9 / pc / apmjump.s
1 /*
2  * Far call, absolute indirect.
3  * The argument is the offset.
4  * We use a global structure for the jump params,
5  * so this is *not* reentrant or thread safe.
6  */
7
8 #include "mem.h"
9
10 #define SSOVERRIDE      BYTE $0x36
11 #define CSOVERRIDE      BYTE $0x2E
12
13 GLOBL   apmjumpstruct+0(SB), $8
14
15 TEXT apmfarcall(SB), $0
16         /*
17          * We call push and pop ourselves.
18          * As soon as we do the first push or pop,
19          * we can't use FP anymore.
20          */
21         MOVL    off+4(FP), BX
22         MOVL    seg+0(FP), CX
23         MOVL    BX, apmjumpstruct+0(SB)
24         MOVL    CX, apmjumpstruct+4(SB)
25
26         /* load necessary registers from Ureg */
27         MOVL    ureg+8(FP), DI
28         MOVL    28(DI), AX
29         MOVL    16(DI), BX
30         MOVL    24(DI), CX
31         MOVL    20(DI), DX
32
33         /* save registers, segments */
34         PUSHL   DS
35         PUSHL   ES
36         PUSHL   FS
37         PUSHL   GS
38         PUSHL   BP
39         PUSHL   DI
40
41         /*
42          * paranoia: zero the segments, since it's the
43          * BIOS's responsibility to initialize them.
44          * (trick picked up from Linux driver).
45          */
46         PUSHL   DX
47         XORL    DX, DX
48         PUSHL   DX
49         POPL    DS
50         PUSHL   DX
51         POPL    ES
52         PUSHL   DX
53         POPL    FS
54         PUSHL   DX
55         POPL    GS
56         POPL    DX
57
58         /*
59          * The actual call.
60          */
61         CSOVERRIDE; BYTE $0xFF; BYTE $0x1D
62         LONG $apmjumpstruct+0(SB)
63
64         /* restore segments, registers */
65         POPL    DI
66         POPL    BP
67         POPL    GS
68         POPL    FS
69         POPL    ES
70         POPL    DS
71
72         PUSHFL
73         POPL    64(DI)
74
75         /* store interesting registers back in Ureg */
76         MOVL    AX, 28(DI)
77         MOVL    BX, 16(DI)
78         MOVL    CX, 24(DI)
79         MOVL    DX, 20(DI)
80         MOVL    SI, 4(DI)
81
82         PUSHFL
83         POPL    AX
84         ANDL    $1, AX  /* carry flag */
85         RET