Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
424 giacomo 1
/*
2
 *  include/asm-i386/mach-pc9800/apm.h
3
 *
4
 *  Machine specific APM BIOS functions for NEC PC9800.
5
 *  Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
6
 */
7
 
8
#ifndef _ASM_APM_H
9
#define _ASM_APM_H
10
 
11
#include <linux/apm_bios.h>
12
 
13
#ifdef APM_ZERO_SEGS
14
#       define APM_DO_ZERO_SEGS \
15
                "pushl %%ds\n\t" \
16
                "pushl %%es\n\t" \
17
                "xorl %%edx, %%edx\n\t" \
18
                "mov %%dx, %%ds\n\t" \
19
                "mov %%dx, %%es\n\t" \
20
                "mov %%dx, %%fs\n\t" \
21
                "mov %%dx, %%gs\n\t"
22
#       define APM_DO_POP_SEGS \
23
                "popl %%es\n\t" \
24
                "popl %%ds\n\t"
25
#else
26
#       define APM_DO_ZERO_SEGS
27
#       define APM_DO_POP_SEGS
28
#endif
29
 
30
static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
31
                                        u32 *eax, u32 *ebx, u32 *ecx,
32
                                        u32 *edx, u32 *esi)
33
{
34
        /*
35
         * N.B. We do NOT need a cld after the BIOS call
36
         * because we always save and restore the flags.
37
         */
38
        __asm__ __volatile__(APM_DO_ZERO_SEGS
39
                "pushl %%edi\n\t"
40
                "pushl %%ebp\n\t"
41
                "pushfl\n\t"
42
                "lcall *%%cs:apm_bios_entry\n\t"
43
                "setc %%al\n\t"
44
                "popl %%ebp\n\t"
45
                "popl %%edi\n\t"
46
                APM_DO_POP_SEGS
47
                : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
48
                  "=S" (*esi)
49
                : "a" (func), "b" (ebx_in), "c" (ecx_in)
50
                : "memory", "cc");
51
}
52
 
53
static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
54
                                                u32 ecx_in, u32 *eax)
55
{
56
        int     cx, dx, si;
57
        u8      error;
58
 
59
        /*
60
         * N.B. We do NOT need a cld after the BIOS call
61
         * because we always save and restore the flags.
62
         */
63
        __asm__ __volatile__(APM_DO_ZERO_SEGS
64
                "pushl %%edi\n\t"
65
                "pushl %%ebp\n\t"
66
                "pushfl\n\t"
67
                "lcall *%%cs:apm_bios_entry\n\t"
68
                "setc %%bl\n\t"
69
                "popl %%ebp\n\t"
70
                "popl %%edi\n\t"
71
                APM_DO_POP_SEGS
72
                : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
73
                  "=S" (si)
74
                : "a" (func), "b" (ebx_in), "c" (ecx_in)
75
                : "memory", "cc");
76
        if (func == APM_FUNC_VERSION)
77
                *eax = (*eax & 0xff00) | ((*eax & 0x00f0) >> 4);
78
 
79
        return error;
80
}
81
 
82
#endif /* _ASM_APM_H */