- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / include / asm / mach_traps.h
1 /*
2  *  Machine specific NMI handling for generic.
3  *  Split out from traps.c by Osamu Tomita <tomita@cinet.co.jp>
4  */
5 #ifndef _ASM_X86_MACH_DEFAULT_MACH_TRAPS_H
6 #define _ASM_X86_MACH_DEFAULT_MACH_TRAPS_H
7
8 #include <linux/nmi.h>
9 #include <asm/delay.h>
10 #include <asm/mc146818rtc.h>
11
12 #define NMI_REASON_PORT         0x61
13
14 #define NMI_REASON_SERR         0x80
15 #define NMI_REASON_IOCHK        0x40
16 #define NMI_REASON_MASK         (NMI_REASON_SERR | NMI_REASON_IOCHK)
17
18 #define NMI_REASON_CLEAR_SERR   0x04
19 #define NMI_REASON_CLEAR_IOCHK  0x08
20 #define NMI_REASON_CLEAR_MASK   0x0f
21
22 static inline unsigned char default_get_nmi_reason(void)
23 {
24         return inb(NMI_REASON_PORT);
25 }
26
27 static inline void clear_serr_error(unsigned char reason)
28 {
29         reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_SERR;
30         outb(reason, NMI_REASON_PORT);
31 }
32
33 static inline void clear_io_check_error(unsigned char reason)
34 {
35         unsigned long i;
36
37         reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_IOCHK;
38         outb(reason, NMI_REASON_PORT);
39
40         i = 20000;
41         while (--i) {
42                 touch_nmi_watchdog();
43                 udelay(100);
44         }
45
46         reason &= ~NMI_REASON_CLEAR_IOCHK;
47         outb(reason, NMI_REASON_PORT);
48 }
49
50 static inline void reassert_nmi(void)
51 {
52         int old_reg = -1;
53
54         if (do_i_have_lock_cmos())
55                 old_reg = current_lock_cmos_reg();
56         else
57                 lock_cmos(0); /* register doesn't matter here */
58         outb(0x8f, 0x70);
59         inb(0x71);              /* dummy */
60         outb(0x0f, 0x70);
61         inb(0x71);              /* dummy */
62         if (old_reg >= 0)
63                 outb(old_reg, 0x70);
64         else
65                 unlock_cmos();
66 }
67
68 #endif /* _ASM_X86_MACH_DEFAULT_MACH_TRAPS_H */