diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:20:03 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:20:03 -0400 |
commit | 96a388de5dc53a8b234b3fd41f3ae2cedc9ffd42 (patch) | |
tree | d947a467aa2da3140279617bc4b9b101640d7bf4 /include/asm-x86 | |
parent | 27bd0c955648646abf2a353a8371d28c37bcd982 (diff) |
i386/x86_64: move headers to include/asm-x86
Move the headers to include/asm-x86 and fixup the
header install make rules
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86')
521 files changed, 37717 insertions, 0 deletions
diff --git a/include/asm-x86/8253pit.h b/include/asm-x86/8253pit.h new file mode 100644 index 000000000000..d3c2b38a6618 --- /dev/null +++ b/include/asm-x86/8253pit.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "8253pit_32.h" | ||
3 | #else | ||
4 | # include "8253pit_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/8253pit_32.h b/include/asm-x86/8253pit_32.h new file mode 100644 index 000000000000..96c7c3592daf --- /dev/null +++ b/include/asm-x86/8253pit_32.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* | ||
2 | * 8253/8254 Programmable Interval Timer | ||
3 | */ | ||
4 | |||
5 | #ifndef _8253PIT_H | ||
6 | #define _8253PIT_H | ||
7 | |||
8 | #include <asm/timex.h> | ||
9 | |||
10 | #define PIT_TICK_RATE CLOCK_TICK_RATE | ||
11 | |||
12 | #endif | ||
diff --git a/include/asm-x86/8253pit_64.h b/include/asm-x86/8253pit_64.h new file mode 100644 index 000000000000..285f78488ccb --- /dev/null +++ b/include/asm-x86/8253pit_64.h | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * 8253/8254 Programmable Interval Timer | ||
3 | */ | ||
4 | |||
5 | #ifndef _8253PIT_H | ||
6 | #define _8253PIT_H | ||
7 | |||
8 | #define PIT_TICK_RATE 1193182UL | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild new file mode 100644 index 000000000000..c5e43cb39874 --- /dev/null +++ b/include/asm-x86/Kbuild | |||
@@ -0,0 +1,88 @@ | |||
1 | include include/asm-generic/Kbuild.asm | ||
2 | |||
3 | header-y += boot.h | ||
4 | header-y += bootsetup.h | ||
5 | header-y += debugreg_32.h | ||
6 | header-y += debugreg_64.h | ||
7 | header-y += debugreg.h | ||
8 | header-y += ldt_32.h | ||
9 | header-y += ldt_64.h | ||
10 | header-y += ldt.h | ||
11 | header-y += msr-index.h | ||
12 | header-y += prctl.h | ||
13 | header-y += ptrace-abi_32.h | ||
14 | header-y += ptrace-abi_64.h | ||
15 | header-y += ptrace-abi.h | ||
16 | header-y += sigcontext32.h | ||
17 | header-y += ucontext_32.h | ||
18 | header-y += ucontext_64.h | ||
19 | header-y += ucontext.h | ||
20 | header-y += vsyscall32.h | ||
21 | |||
22 | unifdef-y += a.out_32.h | ||
23 | unifdef-y += a.out_64.h | ||
24 | unifdef-y += auxvec_32.h | ||
25 | unifdef-y += auxvec_64.h | ||
26 | unifdef-y += byteorder_32.h | ||
27 | unifdef-y += byteorder_64.h | ||
28 | unifdef-y += elf_32.h | ||
29 | unifdef-y += elf_64.h | ||
30 | unifdef-y += errno_32.h | ||
31 | unifdef-y += errno_64.h | ||
32 | unifdef-y += ioctls_32.h | ||
33 | unifdef-y += ioctls_64.h | ||
34 | unifdef-y += ipcbuf_32.h | ||
35 | unifdef-y += ipcbuf_64.h | ||
36 | unifdef-y += mce.h | ||
37 | unifdef-y += mman_32.h | ||
38 | unifdef-y += mman_64.h | ||
39 | unifdef-y += msgbuf_32.h | ||
40 | unifdef-y += msgbuf_64.h | ||
41 | unifdef-y += msr_32.h | ||
42 | unifdef-y += msr_64.h | ||
43 | unifdef-y += msr.h | ||
44 | unifdef-y += mtrr_32.h | ||
45 | unifdef-y += mtrr_64.h | ||
46 | unifdef-y += mtrr.h | ||
47 | unifdef-y += page_32.h | ||
48 | unifdef-y += page_64.h | ||
49 | unifdef-y += param_32.h | ||
50 | unifdef-y += param_64.h | ||
51 | unifdef-y += posix_types_32.h | ||
52 | unifdef-y += posix_types_64.h | ||
53 | unifdef-y += ptrace_32.h | ||
54 | unifdef-y += ptrace_64.h | ||
55 | unifdef-y += resource_32.h | ||
56 | unifdef-y += resource_64.h | ||
57 | unifdef-y += sembuf_32.h | ||
58 | unifdef-y += sembuf_64.h | ||
59 | unifdef-y += setup_32.h | ||
60 | unifdef-y += setup_64.h | ||
61 | unifdef-y += shmbuf_32.h | ||
62 | unifdef-y += shmbuf_64.h | ||
63 | unifdef-y += shmparam_32.h | ||
64 | unifdef-y += shmparam_64.h | ||
65 | unifdef-y += sigcontext_32.h | ||
66 | unifdef-y += sigcontext_64.h | ||
67 | unifdef-y += siginfo_32.h | ||
68 | unifdef-y += siginfo_64.h | ||
69 | unifdef-y += signal_32.h | ||
70 | unifdef-y += signal_64.h | ||
71 | unifdef-y += sockios_32.h | ||
72 | unifdef-y += sockios_64.h | ||
73 | unifdef-y += stat_32.h | ||
74 | unifdef-y += stat_64.h | ||
75 | unifdef-y += statfs_32.h | ||
76 | unifdef-y += statfs_64.h | ||
77 | unifdef-y += termbits_32.h | ||
78 | unifdef-y += termbits_64.h | ||
79 | unifdef-y += termios_32.h | ||
80 | unifdef-y += termios_64.h | ||
81 | unifdef-y += types_32.h | ||
82 | unifdef-y += types_64.h | ||
83 | unifdef-y += unistd_32.h | ||
84 | unifdef-y += unistd_64.h | ||
85 | unifdef-y += user_32.h | ||
86 | unifdef-y += user_64.h | ||
87 | unifdef-y += vm86.h | ||
88 | unifdef-y += vsyscall.h | ||
diff --git a/include/asm-x86/a.out.h b/include/asm-x86/a.out.h new file mode 100644 index 000000000000..5bc9b1d3b227 --- /dev/null +++ b/include/asm-x86/a.out.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "a.out_32.h" | ||
4 | # else | ||
5 | # include "a.out_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "a.out_32.h" | ||
10 | # else | ||
11 | # include "a.out_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/a.out_32.h b/include/asm-x86/a.out_32.h new file mode 100644 index 000000000000..851a60f8258c --- /dev/null +++ b/include/asm-x86/a.out_32.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef __I386_A_OUT_H__ | ||
2 | #define __I386_A_OUT_H__ | ||
3 | |||
4 | struct exec | ||
5 | { | ||
6 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */ | ||
7 | unsigned a_text; /* length of text, in bytes */ | ||
8 | unsigned a_data; /* length of data, in bytes */ | ||
9 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | ||
10 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | ||
11 | unsigned a_entry; /* start address */ | ||
12 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | ||
13 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | ||
14 | }; | ||
15 | |||
16 | #define N_TRSIZE(a) ((a).a_trsize) | ||
17 | #define N_DRSIZE(a) ((a).a_drsize) | ||
18 | #define N_SYMSIZE(a) ((a).a_syms) | ||
19 | |||
20 | #ifdef __KERNEL__ | ||
21 | |||
22 | #define STACK_TOP TASK_SIZE | ||
23 | #define STACK_TOP_MAX STACK_TOP | ||
24 | |||
25 | #endif | ||
26 | |||
27 | #endif /* __A_OUT_GNU_H__ */ | ||
diff --git a/include/asm-x86/a.out_64.h b/include/asm-x86/a.out_64.h new file mode 100644 index 000000000000..e789300e41a5 --- /dev/null +++ b/include/asm-x86/a.out_64.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __X8664_A_OUT_H__ | ||
2 | #define __X8664_A_OUT_H__ | ||
3 | |||
4 | /* 32bit a.out */ | ||
5 | |||
6 | struct exec | ||
7 | { | ||
8 | unsigned int a_info; /* Use macros N_MAGIC, etc for access */ | ||
9 | unsigned a_text; /* length of text, in bytes */ | ||
10 | unsigned a_data; /* length of data, in bytes */ | ||
11 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | ||
12 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | ||
13 | unsigned a_entry; /* start address */ | ||
14 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | ||
15 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | ||
16 | }; | ||
17 | |||
18 | #define N_TRSIZE(a) ((a).a_trsize) | ||
19 | #define N_DRSIZE(a) ((a).a_drsize) | ||
20 | #define N_SYMSIZE(a) ((a).a_syms) | ||
21 | |||
22 | #ifdef __KERNEL__ | ||
23 | #include <linux/thread_info.h> | ||
24 | #define STACK_TOP TASK_SIZE | ||
25 | #define STACK_TOP_MAX TASK_SIZE64 | ||
26 | #endif | ||
27 | |||
28 | #endif /* __A_OUT_GNU_H__ */ | ||
diff --git a/include/asm-x86/acpi.h b/include/asm-x86/acpi.h new file mode 100644 index 000000000000..0693689d4146 --- /dev/null +++ b/include/asm-x86/acpi.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "acpi_32.h" | ||
3 | #else | ||
4 | # include "acpi_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/acpi_32.h b/include/asm-x86/acpi_32.h new file mode 100644 index 000000000000..125179adf044 --- /dev/null +++ b/include/asm-x86/acpi_32.h | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | * asm-i386/acpi.h | ||
3 | * | ||
4 | * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
5 | * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | ||
25 | |||
26 | #ifndef _ASM_ACPI_H | ||
27 | #define _ASM_ACPI_H | ||
28 | |||
29 | #ifdef __KERNEL__ | ||
30 | |||
31 | #include <acpi/pdc_intel.h> | ||
32 | |||
33 | #include <asm/system.h> /* defines cmpxchg */ | ||
34 | |||
35 | #define COMPILER_DEPENDENT_INT64 long long | ||
36 | #define COMPILER_DEPENDENT_UINT64 unsigned long long | ||
37 | |||
38 | /* | ||
39 | * Calling conventions: | ||
40 | * | ||
41 | * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) | ||
42 | * ACPI_EXTERNAL_XFACE - External ACPI interfaces | ||
43 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces | ||
44 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces | ||
45 | */ | ||
46 | #define ACPI_SYSTEM_XFACE | ||
47 | #define ACPI_EXTERNAL_XFACE | ||
48 | #define ACPI_INTERNAL_XFACE | ||
49 | #define ACPI_INTERNAL_VAR_XFACE | ||
50 | |||
51 | /* Asm macros */ | ||
52 | |||
53 | #define ACPI_ASM_MACROS | ||
54 | #define BREAKPOINT3 | ||
55 | #define ACPI_DISABLE_IRQS() local_irq_disable() | ||
56 | #define ACPI_ENABLE_IRQS() local_irq_enable() | ||
57 | #define ACPI_FLUSH_CPU_CACHE() wbinvd() | ||
58 | |||
59 | int __acpi_acquire_global_lock(unsigned int *lock); | ||
60 | int __acpi_release_global_lock(unsigned int *lock); | ||
61 | |||
62 | #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \ | ||
63 | ((Acq) = __acpi_acquire_global_lock(&facs->global_lock)) | ||
64 | |||
65 | #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \ | ||
66 | ((Acq) = __acpi_release_global_lock(&facs->global_lock)) | ||
67 | |||
68 | /* | ||
69 | * Math helper asm macros | ||
70 | */ | ||
71 | #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ | ||
72 | asm("divl %2;" \ | ||
73 | :"=a"(q32), "=d"(r32) \ | ||
74 | :"r"(d32), \ | ||
75 | "0"(n_lo), "1"(n_hi)) | ||
76 | |||
77 | |||
78 | #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ | ||
79 | asm("shrl $1,%2;" \ | ||
80 | "rcrl $1,%3;" \ | ||
81 | :"=r"(n_hi), "=r"(n_lo) \ | ||
82 | :"0"(n_hi), "1"(n_lo)) | ||
83 | |||
84 | #ifdef CONFIG_X86_IO_APIC | ||
85 | extern void check_acpi_pci(void); | ||
86 | #else | ||
87 | static inline void check_acpi_pci(void) { } | ||
88 | #endif | ||
89 | |||
90 | #ifdef CONFIG_ACPI | ||
91 | extern int acpi_lapic; | ||
92 | extern int acpi_ioapic; | ||
93 | extern int acpi_noirq; | ||
94 | extern int acpi_strict; | ||
95 | extern int acpi_disabled; | ||
96 | extern int acpi_ht; | ||
97 | extern int acpi_pci_disabled; | ||
98 | static inline void disable_acpi(void) | ||
99 | { | ||
100 | acpi_disabled = 1; | ||
101 | acpi_ht = 0; | ||
102 | acpi_pci_disabled = 1; | ||
103 | acpi_noirq = 1; | ||
104 | } | ||
105 | |||
106 | /* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */ | ||
107 | #define FIX_ACPI_PAGES 4 | ||
108 | |||
109 | extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); | ||
110 | |||
111 | #ifdef CONFIG_X86_IO_APIC | ||
112 | extern int acpi_skip_timer_override; | ||
113 | extern int acpi_use_timer_override; | ||
114 | #endif | ||
115 | |||
116 | static inline void acpi_noirq_set(void) { acpi_noirq = 1; } | ||
117 | static inline void acpi_disable_pci(void) | ||
118 | { | ||
119 | acpi_pci_disabled = 1; | ||
120 | acpi_noirq_set(); | ||
121 | } | ||
122 | extern int acpi_irq_balance_set(char *str); | ||
123 | |||
124 | /* routines for saving/restoring kernel state */ | ||
125 | extern int acpi_save_state_mem(void); | ||
126 | extern void acpi_restore_state_mem(void); | ||
127 | |||
128 | extern unsigned long acpi_wakeup_address; | ||
129 | |||
130 | /* early initialization routine */ | ||
131 | extern void acpi_reserve_bootmem(void); | ||
132 | |||
133 | #else /* !CONFIG_ACPI */ | ||
134 | |||
135 | #define acpi_lapic 0 | ||
136 | #define acpi_ioapic 0 | ||
137 | static inline void acpi_noirq_set(void) { } | ||
138 | static inline void acpi_disable_pci(void) { } | ||
139 | static inline void disable_acpi(void) { } | ||
140 | |||
141 | #endif /* !CONFIG_ACPI */ | ||
142 | |||
143 | #define ARCH_HAS_POWER_INIT 1 | ||
144 | |||
145 | #endif /*__KERNEL__*/ | ||
146 | |||
147 | #endif /*_ASM_ACPI_H*/ | ||
diff --git a/include/asm-x86/acpi_64.h b/include/asm-x86/acpi_64.h new file mode 100644 index 000000000000..98173357dd89 --- /dev/null +++ b/include/asm-x86/acpi_64.h | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | * asm-x86_64/acpi.h | ||
3 | * | ||
4 | * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
5 | * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | ||
25 | |||
26 | #ifndef _ASM_ACPI_H | ||
27 | #define _ASM_ACPI_H | ||
28 | |||
29 | #ifdef __KERNEL__ | ||
30 | |||
31 | #include <acpi/pdc_intel.h> | ||
32 | #include <asm/numa.h> | ||
33 | |||
34 | #define COMPILER_DEPENDENT_INT64 long long | ||
35 | #define COMPILER_DEPENDENT_UINT64 unsigned long long | ||
36 | |||
37 | /* | ||
38 | * Calling conventions: | ||
39 | * | ||
40 | * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) | ||
41 | * ACPI_EXTERNAL_XFACE - External ACPI interfaces | ||
42 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces | ||
43 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces | ||
44 | */ | ||
45 | #define ACPI_SYSTEM_XFACE | ||
46 | #define ACPI_EXTERNAL_XFACE | ||
47 | #define ACPI_INTERNAL_XFACE | ||
48 | #define ACPI_INTERNAL_VAR_XFACE | ||
49 | |||
50 | /* Asm macros */ | ||
51 | |||
52 | #define ACPI_ASM_MACROS | ||
53 | #define BREAKPOINT3 | ||
54 | #define ACPI_DISABLE_IRQS() local_irq_disable() | ||
55 | #define ACPI_ENABLE_IRQS() local_irq_enable() | ||
56 | #define ACPI_FLUSH_CPU_CACHE() wbinvd() | ||
57 | |||
58 | int __acpi_acquire_global_lock(unsigned int *lock); | ||
59 | int __acpi_release_global_lock(unsigned int *lock); | ||
60 | |||
61 | #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \ | ||
62 | ((Acq) = __acpi_acquire_global_lock(&facs->global_lock)) | ||
63 | |||
64 | #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \ | ||
65 | ((Acq) = __acpi_release_global_lock(&facs->global_lock)) | ||
66 | |||
67 | /* | ||
68 | * Math helper asm macros | ||
69 | */ | ||
70 | #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ | ||
71 | asm("divl %2;" \ | ||
72 | :"=a"(q32), "=d"(r32) \ | ||
73 | :"r"(d32), \ | ||
74 | "0"(n_lo), "1"(n_hi)) | ||
75 | |||
76 | |||
77 | #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ | ||
78 | asm("shrl $1,%2;" \ | ||
79 | "rcrl $1,%3;" \ | ||
80 | :"=r"(n_hi), "=r"(n_lo) \ | ||
81 | :"0"(n_hi), "1"(n_lo)) | ||
82 | |||
83 | #ifdef CONFIG_ACPI | ||
84 | extern int acpi_lapic; | ||
85 | extern int acpi_ioapic; | ||
86 | extern int acpi_noirq; | ||
87 | extern int acpi_strict; | ||
88 | extern int acpi_disabled; | ||
89 | extern int acpi_pci_disabled; | ||
90 | extern int acpi_ht; | ||
91 | static inline void disable_acpi(void) | ||
92 | { | ||
93 | acpi_disabled = 1; | ||
94 | acpi_ht = 0; | ||
95 | acpi_pci_disabled = 1; | ||
96 | acpi_noirq = 1; | ||
97 | } | ||
98 | |||
99 | /* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */ | ||
100 | #define FIX_ACPI_PAGES 4 | ||
101 | |||
102 | extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); | ||
103 | static inline void acpi_noirq_set(void) { acpi_noirq = 1; } | ||
104 | static inline void acpi_disable_pci(void) | ||
105 | { | ||
106 | acpi_pci_disabled = 1; | ||
107 | acpi_noirq_set(); | ||
108 | } | ||
109 | extern int acpi_irq_balance_set(char *str); | ||
110 | |||
111 | /* routines for saving/restoring kernel state */ | ||
112 | extern int acpi_save_state_mem(void); | ||
113 | extern void acpi_restore_state_mem(void); | ||
114 | |||
115 | extern unsigned long acpi_wakeup_address; | ||
116 | |||
117 | /* early initialization routine */ | ||
118 | extern void acpi_reserve_bootmem(void); | ||
119 | |||
120 | #else /* !CONFIG_ACPI */ | ||
121 | |||
122 | #define acpi_lapic 0 | ||
123 | #define acpi_ioapic 0 | ||
124 | static inline void acpi_noirq_set(void) { } | ||
125 | static inline void acpi_disable_pci(void) { } | ||
126 | |||
127 | #endif /* !CONFIG_ACPI */ | ||
128 | |||
129 | extern int acpi_numa; | ||
130 | extern int acpi_scan_nodes(unsigned long start, unsigned long end); | ||
131 | #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) | ||
132 | |||
133 | extern int acpi_disabled; | ||
134 | extern int acpi_pci_disabled; | ||
135 | |||
136 | #define ARCH_HAS_POWER_INIT 1 | ||
137 | |||
138 | extern int acpi_skip_timer_override; | ||
139 | extern int acpi_use_timer_override; | ||
140 | |||
141 | #ifdef CONFIG_ACPI_NUMA | ||
142 | extern void __init acpi_fake_nodes(const struct bootnode *fake_nodes, | ||
143 | int num_nodes); | ||
144 | #else | ||
145 | static inline void acpi_fake_nodes(const struct bootnode *fake_nodes, | ||
146 | int num_nodes) | ||
147 | { | ||
148 | } | ||
149 | #endif | ||
150 | |||
151 | #endif /*__KERNEL__*/ | ||
152 | |||
153 | #endif /*_ASM_ACPI_H*/ | ||
diff --git a/include/asm-x86/agp.h b/include/asm-x86/agp.h new file mode 100644 index 000000000000..9348f1e4f6f1 --- /dev/null +++ b/include/asm-x86/agp.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "agp_32.h" | ||
3 | #else | ||
4 | # include "agp_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/agp_32.h b/include/asm-x86/agp_32.h new file mode 100644 index 000000000000..6af173dbf123 --- /dev/null +++ b/include/asm-x86/agp_32.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef AGP_H | ||
2 | #define AGP_H 1 | ||
3 | |||
4 | #include <asm/pgtable.h> | ||
5 | #include <asm/cacheflush.h> | ||
6 | |||
7 | /* | ||
8 | * Functions to keep the agpgart mappings coherent with the MMU. | ||
9 | * The GART gives the CPU a physical alias of pages in memory. The alias region is | ||
10 | * mapped uncacheable. Make sure there are no conflicting mappings | ||
11 | * with different cachability attributes for the same page. This avoids | ||
12 | * data corruption on some CPUs. | ||
13 | */ | ||
14 | |||
15 | /* Caller's responsibility to call global_flush_tlb() for | ||
16 | * performance reasons */ | ||
17 | #define map_page_into_agp(page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE) | ||
18 | #define unmap_page_from_agp(page) change_page_attr(page, 1, PAGE_KERNEL) | ||
19 | #define flush_agp_mappings() global_flush_tlb() | ||
20 | |||
21 | /* Could use CLFLUSH here if the cpu supports it. But then it would | ||
22 | need to be called for each cacheline of the whole page so it may not be | ||
23 | worth it. Would need a page for it. */ | ||
24 | #define flush_agp_cache() wbinvd() | ||
25 | |||
26 | /* Convert a physical address to an address suitable for the GART. */ | ||
27 | #define phys_to_gart(x) (x) | ||
28 | #define gart_to_phys(x) (x) | ||
29 | |||
30 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
31 | #define alloc_gatt_pages(order) \ | ||
32 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
33 | #define free_gatt_pages(table, order) \ | ||
34 | free_pages((unsigned long)(table), (order)) | ||
35 | |||
36 | #endif | ||
diff --git a/include/asm-x86/agp_64.h b/include/asm-x86/agp_64.h new file mode 100644 index 000000000000..de338666f3f9 --- /dev/null +++ b/include/asm-x86/agp_64.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef AGP_H | ||
2 | #define AGP_H 1 | ||
3 | |||
4 | #include <asm/cacheflush.h> | ||
5 | |||
6 | /* | ||
7 | * Functions to keep the agpgart mappings coherent. | ||
8 | * The GART gives the CPU a physical alias of memory. The alias is | ||
9 | * mapped uncacheable. Make sure there are no conflicting mappings | ||
10 | * with different cachability attributes for the same page. | ||
11 | */ | ||
12 | |||
13 | /* Caller's responsibility to call global_flush_tlb() for | ||
14 | * performance reasons */ | ||
15 | #define map_page_into_agp(page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE) | ||
16 | #define unmap_page_from_agp(page) change_page_attr(page, 1, PAGE_KERNEL) | ||
17 | #define flush_agp_mappings() global_flush_tlb() | ||
18 | |||
19 | /* Could use CLFLUSH here if the cpu supports it. But then it would | ||
20 | need to be called for each cacheline of the whole page so it may not be | ||
21 | worth it. Would need a page for it. */ | ||
22 | #define flush_agp_cache() asm volatile("wbinvd":::"memory") | ||
23 | |||
24 | /* Convert a physical address to an address suitable for the GART. */ | ||
25 | #define phys_to_gart(x) (x) | ||
26 | #define gart_to_phys(x) (x) | ||
27 | |||
28 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
29 | #define alloc_gatt_pages(order) \ | ||
30 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
31 | #define free_gatt_pages(table, order) \ | ||
32 | free_pages((unsigned long)(table), (order)) | ||
33 | |||
34 | #endif | ||
diff --git a/include/asm-x86/alternative-asm.i b/include/asm-x86/alternative-asm.i new file mode 100644 index 000000000000..4f360cd3c888 --- /dev/null +++ b/include/asm-x86/alternative-asm.i | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "alternative-asm_32.i" | ||
3 | #else | ||
4 | # include "alternative-asm_64.i" | ||
5 | #endif | ||
diff --git a/include/asm-x86/alternative-asm_32.i b/include/asm-x86/alternative-asm_32.i new file mode 100644 index 000000000000..f0510209ccbe --- /dev/null +++ b/include/asm-x86/alternative-asm_32.i | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifdef CONFIG_SMP | ||
2 | .macro LOCK_PREFIX | ||
3 | 1: lock | ||
4 | .section .smp_locks,"a" | ||
5 | .align 4 | ||
6 | .long 1b | ||
7 | .previous | ||
8 | .endm | ||
9 | #else | ||
10 | .macro LOCK_PREFIX | ||
11 | .endm | ||
12 | #endif | ||
diff --git a/include/asm-x86/alternative-asm_64.i b/include/asm-x86/alternative-asm_64.i new file mode 100644 index 000000000000..0b3f1a2bb2cb --- /dev/null +++ b/include/asm-x86/alternative-asm_64.i | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifdef CONFIG_SMP | ||
2 | .macro LOCK_PREFIX | ||
3 | 1: lock | ||
4 | .section .smp_locks,"a" | ||
5 | .align 8 | ||
6 | .quad 1b | ||
7 | .previous | ||
8 | .endm | ||
9 | #else | ||
10 | .macro LOCK_PREFIX | ||
11 | .endm | ||
12 | #endif | ||
diff --git a/include/asm-x86/alternative.h b/include/asm-x86/alternative.h new file mode 100644 index 000000000000..9eef6a32a130 --- /dev/null +++ b/include/asm-x86/alternative.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "alternative_32.h" | ||
3 | #else | ||
4 | # include "alternative_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/alternative_32.h b/include/asm-x86/alternative_32.h new file mode 100644 index 000000000000..bda6c810c0f4 --- /dev/null +++ b/include/asm-x86/alternative_32.h | |||
@@ -0,0 +1,154 @@ | |||
1 | #ifndef _I386_ALTERNATIVE_H | ||
2 | #define _I386_ALTERNATIVE_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/stddef.h> | ||
6 | #include <linux/types.h> | ||
7 | |||
8 | struct alt_instr { | ||
9 | u8 *instr; /* original instruction */ | ||
10 | u8 *replacement; | ||
11 | u8 cpuid; /* cpuid bit set for replacement */ | ||
12 | u8 instrlen; /* length of original instruction */ | ||
13 | u8 replacementlen; /* length of new instruction, <= instrlen */ | ||
14 | u8 pad; | ||
15 | }; | ||
16 | |||
17 | extern void alternative_instructions(void); | ||
18 | extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end); | ||
19 | |||
20 | struct module; | ||
21 | #ifdef CONFIG_SMP | ||
22 | extern void alternatives_smp_module_add(struct module *mod, char *name, | ||
23 | void *locks, void *locks_end, | ||
24 | void *text, void *text_end); | ||
25 | extern void alternatives_smp_module_del(struct module *mod); | ||
26 | extern void alternatives_smp_switch(int smp); | ||
27 | #else | ||
28 | static inline void alternatives_smp_module_add(struct module *mod, char *name, | ||
29 | void *locks, void *locks_end, | ||
30 | void *text, void *text_end) {} | ||
31 | static inline void alternatives_smp_module_del(struct module *mod) {} | ||
32 | static inline void alternatives_smp_switch(int smp) {} | ||
33 | #endif /* CONFIG_SMP */ | ||
34 | |||
35 | /* | ||
36 | * Alternative instructions for different CPU types or capabilities. | ||
37 | * | ||
38 | * This allows to use optimized instructions even on generic binary | ||
39 | * kernels. | ||
40 | * | ||
41 | * length of oldinstr must be longer or equal the length of newinstr | ||
42 | * It can be padded with nops as needed. | ||
43 | * | ||
44 | * For non barrier like inlines please define new variants | ||
45 | * without volatile and memory clobber. | ||
46 | */ | ||
47 | #define alternative(oldinstr, newinstr, feature) \ | ||
48 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
49 | ".section .altinstructions,\"a\"\n" \ | ||
50 | " .align 4\n" \ | ||
51 | " .long 661b\n" /* label */ \ | ||
52 | " .long 663f\n" /* new instruction */ \ | ||
53 | " .byte %c0\n" /* feature bit */ \ | ||
54 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
55 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
56 | ".previous\n" \ | ||
57 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
58 | "663:\n\t" newinstr "\n664:\n" /* replacement */\ | ||
59 | ".previous" :: "i" (feature) : "memory") | ||
60 | |||
61 | /* | ||
62 | * Alternative inline assembly with input. | ||
63 | * | ||
64 | * Pecularities: | ||
65 | * No memory clobber here. | ||
66 | * Argument numbers start with 1. | ||
67 | * Best is to use constraints that are fixed size (like (%1) ... "r") | ||
68 | * If you use variable sized constraints like "m" or "g" in the | ||
69 | * replacement maake sure to pad to the worst case length. | ||
70 | */ | ||
71 | #define alternative_input(oldinstr, newinstr, feature, input...) \ | ||
72 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
73 | ".section .altinstructions,\"a\"\n" \ | ||
74 | " .align 4\n" \ | ||
75 | " .long 661b\n" /* label */ \ | ||
76 | " .long 663f\n" /* new instruction */ \ | ||
77 | " .byte %c0\n" /* feature bit */ \ | ||
78 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
79 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
80 | ".previous\n" \ | ||
81 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
82 | "663:\n\t" newinstr "\n664:\n" /* replacement */\ | ||
83 | ".previous" :: "i" (feature), ##input) | ||
84 | |||
85 | /* Like alternative_input, but with a single output argument */ | ||
86 | #define alternative_io(oldinstr, newinstr, feature, output, input...) \ | ||
87 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
88 | ".section .altinstructions,\"a\"\n" \ | ||
89 | " .align 4\n" \ | ||
90 | " .long 661b\n" /* label */ \ | ||
91 | " .long 663f\n" /* new instruction */ \ | ||
92 | " .byte %c[feat]\n" /* feature bit */ \ | ||
93 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
94 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
95 | ".previous\n" \ | ||
96 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
97 | "663:\n\t" newinstr "\n664:\n" /* replacement */ \ | ||
98 | ".previous" : output : [feat] "i" (feature), ##input) | ||
99 | |||
100 | /* | ||
101 | * use this macro(s) if you need more than one output parameter | ||
102 | * in alternative_io | ||
103 | */ | ||
104 | #define ASM_OUTPUT2(a, b) a, b | ||
105 | |||
106 | /* | ||
107 | * Alternative inline assembly for SMP. | ||
108 | * | ||
109 | * The LOCK_PREFIX macro defined here replaces the LOCK and | ||
110 | * LOCK_PREFIX macros used everywhere in the source tree. | ||
111 | * | ||
112 | * SMP alternatives use the same data structures as the other | ||
113 | * alternatives and the X86_FEATURE_UP flag to indicate the case of a | ||
114 | * UP system running a SMP kernel. The existing apply_alternatives() | ||
115 | * works fine for patching a SMP kernel for UP. | ||
116 | * | ||
117 | * The SMP alternative tables can be kept after boot and contain both | ||
118 | * UP and SMP versions of the instructions to allow switching back to | ||
119 | * SMP at runtime, when hotplugging in a new CPU, which is especially | ||
120 | * useful in virtualized environments. | ||
121 | * | ||
122 | * The very common lock prefix is handled as special case in a | ||
123 | * separate table which is a pure address list without replacement ptr | ||
124 | * and size information. That keeps the table sizes small. | ||
125 | */ | ||
126 | |||
127 | #ifdef CONFIG_SMP | ||
128 | #define LOCK_PREFIX \ | ||
129 | ".section .smp_locks,\"a\"\n" \ | ||
130 | " .align 4\n" \ | ||
131 | " .long 661f\n" /* address */ \ | ||
132 | ".previous\n" \ | ||
133 | "661:\n\tlock; " | ||
134 | |||
135 | #else /* ! CONFIG_SMP */ | ||
136 | #define LOCK_PREFIX "" | ||
137 | #endif | ||
138 | |||
139 | struct paravirt_patch_site; | ||
140 | #ifdef CONFIG_PARAVIRT | ||
141 | void apply_paravirt(struct paravirt_patch_site *start, | ||
142 | struct paravirt_patch_site *end); | ||
143 | #else | ||
144 | static inline void | ||
145 | apply_paravirt(struct paravirt_patch_site *start, | ||
146 | struct paravirt_patch_site *end) | ||
147 | {} | ||
148 | #define __parainstructions NULL | ||
149 | #define __parainstructions_end NULL | ||
150 | #endif | ||
151 | |||
152 | extern void text_poke(void *addr, unsigned char *opcode, int len); | ||
153 | |||
154 | #endif /* _I386_ALTERNATIVE_H */ | ||
diff --git a/include/asm-x86/alternative_64.h b/include/asm-x86/alternative_64.h new file mode 100644 index 000000000000..ab161e810151 --- /dev/null +++ b/include/asm-x86/alternative_64.h | |||
@@ -0,0 +1,159 @@ | |||
1 | #ifndef _X86_64_ALTERNATIVE_H | ||
2 | #define _X86_64_ALTERNATIVE_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/types.h> | ||
7 | #include <linux/stddef.h> | ||
8 | |||
9 | /* | ||
10 | * Alternative inline assembly for SMP. | ||
11 | * | ||
12 | * The LOCK_PREFIX macro defined here replaces the LOCK and | ||
13 | * LOCK_PREFIX macros used everywhere in the source tree. | ||
14 | * | ||
15 | * SMP alternatives use the same data structures as the other | ||
16 | * alternatives and the X86_FEATURE_UP flag to indicate the case of a | ||
17 | * UP system running a SMP kernel. The existing apply_alternatives() | ||
18 | * works fine for patching a SMP kernel for UP. | ||
19 | * | ||
20 | * The SMP alternative tables can be kept after boot and contain both | ||
21 | * UP and SMP versions of the instructions to allow switching back to | ||
22 | * SMP at runtime, when hotplugging in a new CPU, which is especially | ||
23 | * useful in virtualized environments. | ||
24 | * | ||
25 | * The very common lock prefix is handled as special case in a | ||
26 | * separate table which is a pure address list without replacement ptr | ||
27 | * and size information. That keeps the table sizes small. | ||
28 | */ | ||
29 | |||
30 | #ifdef CONFIG_SMP | ||
31 | #define LOCK_PREFIX \ | ||
32 | ".section .smp_locks,\"a\"\n" \ | ||
33 | " .align 8\n" \ | ||
34 | " .quad 661f\n" /* address */ \ | ||
35 | ".previous\n" \ | ||
36 | "661:\n\tlock; " | ||
37 | |||
38 | #else /* ! CONFIG_SMP */ | ||
39 | #define LOCK_PREFIX "" | ||
40 | #endif | ||
41 | |||
42 | /* This must be included *after* the definition of LOCK_PREFIX */ | ||
43 | #include <asm/cpufeature.h> | ||
44 | |||
45 | struct alt_instr { | ||
46 | u8 *instr; /* original instruction */ | ||
47 | u8 *replacement; | ||
48 | u8 cpuid; /* cpuid bit set for replacement */ | ||
49 | u8 instrlen; /* length of original instruction */ | ||
50 | u8 replacementlen; /* length of new instruction, <= instrlen */ | ||
51 | u8 pad[5]; | ||
52 | }; | ||
53 | |||
54 | extern void alternative_instructions(void); | ||
55 | extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end); | ||
56 | |||
57 | struct module; | ||
58 | |||
59 | #ifdef CONFIG_SMP | ||
60 | extern void alternatives_smp_module_add(struct module *mod, char *name, | ||
61 | void *locks, void *locks_end, | ||
62 | void *text, void *text_end); | ||
63 | extern void alternatives_smp_module_del(struct module *mod); | ||
64 | extern void alternatives_smp_switch(int smp); | ||
65 | #else | ||
66 | static inline void alternatives_smp_module_add(struct module *mod, char *name, | ||
67 | void *locks, void *locks_end, | ||
68 | void *text, void *text_end) {} | ||
69 | static inline void alternatives_smp_module_del(struct module *mod) {} | ||
70 | static inline void alternatives_smp_switch(int smp) {} | ||
71 | #endif | ||
72 | |||
73 | #endif | ||
74 | |||
75 | /* | ||
76 | * Alternative instructions for different CPU types or capabilities. | ||
77 | * | ||
78 | * This allows to use optimized instructions even on generic binary | ||
79 | * kernels. | ||
80 | * | ||
81 | * length of oldinstr must be longer or equal the length of newinstr | ||
82 | * It can be padded with nops as needed. | ||
83 | * | ||
84 | * For non barrier like inlines please define new variants | ||
85 | * without volatile and memory clobber. | ||
86 | */ | ||
87 | #define alternative(oldinstr, newinstr, feature) \ | ||
88 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
89 | ".section .altinstructions,\"a\"\n" \ | ||
90 | " .align 8\n" \ | ||
91 | " .quad 661b\n" /* label */ \ | ||
92 | " .quad 663f\n" /* new instruction */ \ | ||
93 | " .byte %c0\n" /* feature bit */ \ | ||
94 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
95 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
96 | ".previous\n" \ | ||
97 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
98 | "663:\n\t" newinstr "\n664:\n" /* replacement */ \ | ||
99 | ".previous" :: "i" (feature) : "memory") | ||
100 | |||
101 | /* | ||
102 | * Alternative inline assembly with input. | ||
103 | * | ||
104 | * Pecularities: | ||
105 | * No memory clobber here. | ||
106 | * Argument numbers start with 1. | ||
107 | * Best is to use constraints that are fixed size (like (%1) ... "r") | ||
108 | * If you use variable sized constraints like "m" or "g" in the | ||
109 | * replacement make sure to pad to the worst case length. | ||
110 | */ | ||
111 | #define alternative_input(oldinstr, newinstr, feature, input...) \ | ||
112 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
113 | ".section .altinstructions,\"a\"\n" \ | ||
114 | " .align 8\n" \ | ||
115 | " .quad 661b\n" /* label */ \ | ||
116 | " .quad 663f\n" /* new instruction */ \ | ||
117 | " .byte %c0\n" /* feature bit */ \ | ||
118 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
119 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
120 | ".previous\n" \ | ||
121 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
122 | "663:\n\t" newinstr "\n664:\n" /* replacement */ \ | ||
123 | ".previous" :: "i" (feature), ##input) | ||
124 | |||
125 | /* Like alternative_input, but with a single output argument */ | ||
126 | #define alternative_io(oldinstr, newinstr, feature, output, input...) \ | ||
127 | asm volatile ("661:\n\t" oldinstr "\n662:\n" \ | ||
128 | ".section .altinstructions,\"a\"\n" \ | ||
129 | " .align 8\n" \ | ||
130 | " .quad 661b\n" /* label */ \ | ||
131 | " .quad 663f\n" /* new instruction */ \ | ||
132 | " .byte %c[feat]\n" /* feature bit */ \ | ||
133 | " .byte 662b-661b\n" /* sourcelen */ \ | ||
134 | " .byte 664f-663f\n" /* replacementlen */ \ | ||
135 | ".previous\n" \ | ||
136 | ".section .altinstr_replacement,\"ax\"\n" \ | ||
137 | "663:\n\t" newinstr "\n664:\n" /* replacement */ \ | ||
138 | ".previous" : output : [feat] "i" (feature), ##input) | ||
139 | |||
140 | /* | ||
141 | * use this macro(s) if you need more than one output parameter | ||
142 | * in alternative_io | ||
143 | */ | ||
144 | #define ASM_OUTPUT2(a, b) a, b | ||
145 | |||
146 | struct paravirt_patch; | ||
147 | #ifdef CONFIG_PARAVIRT | ||
148 | void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end); | ||
149 | #else | ||
150 | static inline void | ||
151 | apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end) | ||
152 | {} | ||
153 | #define __parainstructions NULL | ||
154 | #define __parainstructions_end NULL | ||
155 | #endif | ||
156 | |||
157 | extern void text_poke(void *addr, unsigned char *opcode, int len); | ||
158 | |||
159 | #endif /* _X86_64_ALTERNATIVE_H */ | ||
diff --git a/include/asm-x86/apic.h b/include/asm-x86/apic.h new file mode 100644 index 000000000000..9fbcc0bd2ac4 --- /dev/null +++ b/include/asm-x86/apic.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "apic_32.h" | ||
3 | #else | ||
4 | # include "apic_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/apic_32.h b/include/asm-x86/apic_32.h new file mode 100644 index 000000000000..4091b33dcb10 --- /dev/null +++ b/include/asm-x86/apic_32.h | |||
@@ -0,0 +1,126 @@ | |||
1 | #ifndef __ASM_APIC_H | ||
2 | #define __ASM_APIC_H | ||
3 | |||
4 | #include <linux/pm.h> | ||
5 | #include <linux/delay.h> | ||
6 | #include <asm/fixmap.h> | ||
7 | #include <asm/apicdef.h> | ||
8 | #include <asm/processor.h> | ||
9 | #include <asm/system.h> | ||
10 | |||
11 | #define Dprintk(x...) | ||
12 | |||
13 | /* | ||
14 | * Debugging macros | ||
15 | */ | ||
16 | #define APIC_QUIET 0 | ||
17 | #define APIC_VERBOSE 1 | ||
18 | #define APIC_DEBUG 2 | ||
19 | |||
20 | extern int apic_verbosity; | ||
21 | |||
22 | /* | ||
23 | * Define the default level of output to be very little | ||
24 | * This can be turned up by using apic=verbose for more | ||
25 | * information and apic=debug for _lots_ of information. | ||
26 | * apic_verbosity is defined in apic.c | ||
27 | */ | ||
28 | #define apic_printk(v, s, a...) do { \ | ||
29 | if ((v) <= apic_verbosity) \ | ||
30 | printk(s, ##a); \ | ||
31 | } while (0) | ||
32 | |||
33 | |||
34 | extern void generic_apic_probe(void); | ||
35 | |||
36 | #ifdef CONFIG_X86_LOCAL_APIC | ||
37 | |||
38 | /* | ||
39 | * Basic functions accessing APICs. | ||
40 | */ | ||
41 | #ifdef CONFIG_PARAVIRT | ||
42 | #include <asm/paravirt.h> | ||
43 | #else | ||
44 | #define apic_write native_apic_write | ||
45 | #define apic_write_atomic native_apic_write_atomic | ||
46 | #define apic_read native_apic_read | ||
47 | #define setup_boot_clock setup_boot_APIC_clock | ||
48 | #define setup_secondary_clock setup_secondary_APIC_clock | ||
49 | #endif | ||
50 | |||
51 | static __inline fastcall void native_apic_write(unsigned long reg, | ||
52 | unsigned long v) | ||
53 | { | ||
54 | *((volatile unsigned long *)(APIC_BASE+reg)) = v; | ||
55 | } | ||
56 | |||
57 | static __inline fastcall void native_apic_write_atomic(unsigned long reg, | ||
58 | unsigned long v) | ||
59 | { | ||
60 | xchg((volatile unsigned long *)(APIC_BASE+reg), v); | ||
61 | } | ||
62 | |||
63 | static __inline fastcall unsigned long native_apic_read(unsigned long reg) | ||
64 | { | ||
65 | return *((volatile unsigned long *)(APIC_BASE+reg)); | ||
66 | } | ||
67 | |||
68 | void apic_wait_icr_idle(void); | ||
69 | unsigned long safe_apic_wait_icr_idle(void); | ||
70 | int get_physical_broadcast(void); | ||
71 | |||
72 | #ifdef CONFIG_X86_GOOD_APIC | ||
73 | # define FORCE_READ_AROUND_WRITE 0 | ||
74 | # define apic_read_around(x) | ||
75 | # define apic_write_around(x,y) apic_write((x),(y)) | ||
76 | #else | ||
77 | # define FORCE_READ_AROUND_WRITE 1 | ||
78 | # define apic_read_around(x) apic_read(x) | ||
79 | # define apic_write_around(x,y) apic_write_atomic((x),(y)) | ||
80 | #endif | ||
81 | |||
82 | static inline void ack_APIC_irq(void) | ||
83 | { | ||
84 | /* | ||
85 | * ack_APIC_irq() actually gets compiled as a single instruction: | ||
86 | * - a single rmw on Pentium/82489DX | ||
87 | * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC) | ||
88 | * ... yummie. | ||
89 | */ | ||
90 | |||
91 | /* Docs say use 0 for future compatibility */ | ||
92 | apic_write_around(APIC_EOI, 0); | ||
93 | } | ||
94 | |||
95 | extern int lapic_get_maxlvt(void); | ||
96 | extern void clear_local_APIC(void); | ||
97 | extern void connect_bsp_APIC (void); | ||
98 | extern void disconnect_bsp_APIC (int virt_wire_setup); | ||
99 | extern void disable_local_APIC (void); | ||
100 | extern void lapic_shutdown (void); | ||
101 | extern int verify_local_APIC (void); | ||
102 | extern void cache_APIC_registers (void); | ||
103 | extern void sync_Arb_IDs (void); | ||
104 | extern void init_bsp_APIC (void); | ||
105 | extern void setup_local_APIC (void); | ||
106 | extern void init_apic_mappings (void); | ||
107 | extern void smp_local_timer_interrupt (void); | ||
108 | extern void setup_boot_APIC_clock (void); | ||
109 | extern void setup_secondary_APIC_clock (void); | ||
110 | extern int APIC_init_uniprocessor (void); | ||
111 | |||
112 | extern void enable_NMI_through_LVT0 (void * dummy); | ||
113 | |||
114 | #define ARCH_APICTIMER_STOPS_ON_C3 1 | ||
115 | |||
116 | extern int timer_over_8254; | ||
117 | extern int local_apic_timer_c2_ok; | ||
118 | |||
119 | extern int local_apic_timer_disabled; | ||
120 | |||
121 | #else /* !CONFIG_X86_LOCAL_APIC */ | ||
122 | static inline void lapic_shutdown(void) { } | ||
123 | |||
124 | #endif /* !CONFIG_X86_LOCAL_APIC */ | ||
125 | |||
126 | #endif /* __ASM_APIC_H */ | ||
diff --git a/include/asm-x86/apic_64.h b/include/asm-x86/apic_64.h new file mode 100644 index 000000000000..85125ef3c414 --- /dev/null +++ b/include/asm-x86/apic_64.h | |||
@@ -0,0 +1,107 @@ | |||
1 | #ifndef __ASM_APIC_H | ||
2 | #define __ASM_APIC_H | ||
3 | |||
4 | #include <linux/pm.h> | ||
5 | #include <linux/delay.h> | ||
6 | #include <asm/fixmap.h> | ||
7 | #include <asm/apicdef.h> | ||
8 | #include <asm/system.h> | ||
9 | |||
10 | #define Dprintk(x...) | ||
11 | |||
12 | /* | ||
13 | * Debugging macros | ||
14 | */ | ||
15 | #define APIC_QUIET 0 | ||
16 | #define APIC_VERBOSE 1 | ||
17 | #define APIC_DEBUG 2 | ||
18 | |||
19 | extern int apic_verbosity; | ||
20 | extern int apic_runs_main_timer; | ||
21 | extern int ioapic_force; | ||
22 | extern int apic_mapped; | ||
23 | |||
24 | /* | ||
25 | * Define the default level of output to be very little | ||
26 | * This can be turned up by using apic=verbose for more | ||
27 | * information and apic=debug for _lots_ of information. | ||
28 | * apic_verbosity is defined in apic.c | ||
29 | */ | ||
30 | #define apic_printk(v, s, a...) do { \ | ||
31 | if ((v) <= apic_verbosity) \ | ||
32 | printk(s, ##a); \ | ||
33 | } while (0) | ||
34 | |||
35 | struct pt_regs; | ||
36 | |||
37 | /* | ||
38 | * Basic functions accessing APICs. | ||
39 | */ | ||
40 | |||
41 | static __inline void apic_write(unsigned long reg, unsigned int v) | ||
42 | { | ||
43 | *((volatile unsigned int *)(APIC_BASE+reg)) = v; | ||
44 | } | ||
45 | |||
46 | static __inline unsigned int apic_read(unsigned long reg) | ||
47 | { | ||
48 | return *((volatile unsigned int *)(APIC_BASE+reg)); | ||
49 | } | ||
50 | |||
51 | extern void apic_wait_icr_idle(void); | ||
52 | extern unsigned int safe_apic_wait_icr_idle(void); | ||
53 | |||
54 | static inline void ack_APIC_irq(void) | ||
55 | { | ||
56 | /* | ||
57 | * ack_APIC_irq() actually gets compiled as a single instruction: | ||
58 | * - a single rmw on Pentium/82489DX | ||
59 | * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC) | ||
60 | * ... yummie. | ||
61 | */ | ||
62 | |||
63 | /* Docs say use 0 for future compatibility */ | ||
64 | apic_write(APIC_EOI, 0); | ||
65 | } | ||
66 | |||
67 | extern int get_maxlvt (void); | ||
68 | extern void clear_local_APIC (void); | ||
69 | extern void connect_bsp_APIC (void); | ||
70 | extern void disconnect_bsp_APIC (int virt_wire_setup); | ||
71 | extern void disable_local_APIC (void); | ||
72 | extern int verify_local_APIC (void); | ||
73 | extern void cache_APIC_registers (void); | ||
74 | extern void sync_Arb_IDs (void); | ||
75 | extern void init_bsp_APIC (void); | ||
76 | extern void setup_local_APIC (void); | ||
77 | extern void init_apic_mappings (void); | ||
78 | extern void smp_local_timer_interrupt (void); | ||
79 | extern void setup_boot_APIC_clock (void); | ||
80 | extern void setup_secondary_APIC_clock (void); | ||
81 | extern int APIC_init_uniprocessor (void); | ||
82 | extern void disable_APIC_timer(void); | ||
83 | extern void enable_APIC_timer(void); | ||
84 | extern void setup_apic_routing(void); | ||
85 | |||
86 | extern void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector, | ||
87 | unsigned char msg_type, unsigned char mask); | ||
88 | |||
89 | extern int apic_is_clustered_box(void); | ||
90 | |||
91 | #define K8_APIC_EXT_LVT_BASE 0x500 | ||
92 | #define K8_APIC_EXT_INT_MSG_FIX 0x0 | ||
93 | #define K8_APIC_EXT_INT_MSG_SMI 0x2 | ||
94 | #define K8_APIC_EXT_INT_MSG_NMI 0x4 | ||
95 | #define K8_APIC_EXT_INT_MSG_EXT 0x7 | ||
96 | #define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0 | ||
97 | |||
98 | void smp_send_timer_broadcast_ipi(void); | ||
99 | void switch_APIC_timer_to_ipi(void *cpumask); | ||
100 | void switch_ipi_to_APIC_timer(void *cpumask); | ||
101 | |||
102 | #define ARCH_APICTIMER_STOPS_ON_C3 1 | ||
103 | |||
104 | extern unsigned boot_cpu_id; | ||
105 | extern int local_apic_timer_c2_ok; | ||
106 | |||
107 | #endif /* __ASM_APIC_H */ | ||
diff --git a/include/asm-x86/apicdef.h b/include/asm-x86/apicdef.h new file mode 100644 index 000000000000..4542c220bf4d --- /dev/null +++ b/include/asm-x86/apicdef.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "apicdef_32.h" | ||
3 | #else | ||
4 | # include "apicdef_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/apicdef_32.h b/include/asm-x86/apicdef_32.h new file mode 100644 index 000000000000..9f6995341fdc --- /dev/null +++ b/include/asm-x86/apicdef_32.h | |||
@@ -0,0 +1,375 @@ | |||
1 | #ifndef __ASM_APICDEF_H | ||
2 | #define __ASM_APICDEF_H | ||
3 | |||
4 | /* | ||
5 | * Constants for various Intel APICs. (local APIC, IOAPIC, etc.) | ||
6 | * | ||
7 | * Alan Cox <Alan.Cox@linux.org>, 1995. | ||
8 | * Ingo Molnar <mingo@redhat.com>, 1999, 2000 | ||
9 | */ | ||
10 | |||
11 | #define APIC_DEFAULT_PHYS_BASE 0xfee00000 | ||
12 | |||
13 | #define APIC_ID 0x20 | ||
14 | #define APIC_LVR 0x30 | ||
15 | #define APIC_LVR_MASK 0xFF00FF | ||
16 | #define GET_APIC_VERSION(x) ((x)&0xFF) | ||
17 | #define GET_APIC_MAXLVT(x) (((x)>>16)&0xFF) | ||
18 | #define APIC_INTEGRATED(x) ((x)&0xF0) | ||
19 | #define APIC_XAPIC(x) ((x) >= 0x14) | ||
20 | #define APIC_TASKPRI 0x80 | ||
21 | #define APIC_TPRI_MASK 0xFF | ||
22 | #define APIC_ARBPRI 0x90 | ||
23 | #define APIC_ARBPRI_MASK 0xFF | ||
24 | #define APIC_PROCPRI 0xA0 | ||
25 | #define APIC_EOI 0xB0 | ||
26 | #define APIC_EIO_ACK 0x0 /* Write this to the EOI register */ | ||
27 | #define APIC_RRR 0xC0 | ||
28 | #define APIC_LDR 0xD0 | ||
29 | #define APIC_LDR_MASK (0xFF<<24) | ||
30 | #define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFF) | ||
31 | #define SET_APIC_LOGICAL_ID(x) (((x)<<24)) | ||
32 | #define APIC_ALL_CPUS 0xFF | ||
33 | #define APIC_DFR 0xE0 | ||
34 | #define APIC_DFR_CLUSTER 0x0FFFFFFFul | ||
35 | #define APIC_DFR_FLAT 0xFFFFFFFFul | ||
36 | #define APIC_SPIV 0xF0 | ||
37 | #define APIC_SPIV_FOCUS_DISABLED (1<<9) | ||
38 | #define APIC_SPIV_APIC_ENABLED (1<<8) | ||
39 | #define APIC_ISR 0x100 | ||
40 | #define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */ | ||
41 | #define APIC_TMR 0x180 | ||
42 | #define APIC_IRR 0x200 | ||
43 | #define APIC_ESR 0x280 | ||
44 | #define APIC_ESR_SEND_CS 0x00001 | ||
45 | #define APIC_ESR_RECV_CS 0x00002 | ||
46 | #define APIC_ESR_SEND_ACC 0x00004 | ||
47 | #define APIC_ESR_RECV_ACC 0x00008 | ||
48 | #define APIC_ESR_SENDILL 0x00020 | ||
49 | #define APIC_ESR_RECVILL 0x00040 | ||
50 | #define APIC_ESR_ILLREGA 0x00080 | ||
51 | #define APIC_ICR 0x300 | ||
52 | #define APIC_DEST_SELF 0x40000 | ||
53 | #define APIC_DEST_ALLINC 0x80000 | ||
54 | #define APIC_DEST_ALLBUT 0xC0000 | ||
55 | #define APIC_ICR_RR_MASK 0x30000 | ||
56 | #define APIC_ICR_RR_INVALID 0x00000 | ||
57 | #define APIC_ICR_RR_INPROG 0x10000 | ||
58 | #define APIC_ICR_RR_VALID 0x20000 | ||
59 | #define APIC_INT_LEVELTRIG 0x08000 | ||
60 | #define APIC_INT_ASSERT 0x04000 | ||
61 | #define APIC_ICR_BUSY 0x01000 | ||
62 | #define APIC_DEST_LOGICAL 0x00800 | ||
63 | #define APIC_DM_FIXED 0x00000 | ||
64 | #define APIC_DM_LOWEST 0x00100 | ||
65 | #define APIC_DM_SMI 0x00200 | ||
66 | #define APIC_DM_REMRD 0x00300 | ||
67 | #define APIC_DM_NMI 0x00400 | ||
68 | #define APIC_DM_INIT 0x00500 | ||
69 | #define APIC_DM_STARTUP 0x00600 | ||
70 | #define APIC_DM_EXTINT 0x00700 | ||
71 | #define APIC_VECTOR_MASK 0x000FF | ||
72 | #define APIC_ICR2 0x310 | ||
73 | #define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF) | ||
74 | #define SET_APIC_DEST_FIELD(x) ((x)<<24) | ||
75 | #define APIC_LVTT 0x320 | ||
76 | #define APIC_LVTTHMR 0x330 | ||
77 | #define APIC_LVTPC 0x340 | ||
78 | #define APIC_LVT0 0x350 | ||
79 | #define APIC_LVT_TIMER_BASE_MASK (0x3<<18) | ||
80 | #define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3) | ||
81 | #define SET_APIC_TIMER_BASE(x) (((x)<<18)) | ||
82 | #define APIC_TIMER_BASE_CLKIN 0x0 | ||
83 | #define APIC_TIMER_BASE_TMBASE 0x1 | ||
84 | #define APIC_TIMER_BASE_DIV 0x2 | ||
85 | #define APIC_LVT_TIMER_PERIODIC (1<<17) | ||
86 | #define APIC_LVT_MASKED (1<<16) | ||
87 | #define APIC_LVT_LEVEL_TRIGGER (1<<15) | ||
88 | #define APIC_LVT_REMOTE_IRR (1<<14) | ||
89 | #define APIC_INPUT_POLARITY (1<<13) | ||
90 | #define APIC_SEND_PENDING (1<<12) | ||
91 | #define APIC_MODE_MASK 0x700 | ||
92 | #define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7) | ||
93 | #define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8)) | ||
94 | #define APIC_MODE_FIXED 0x0 | ||
95 | #define APIC_MODE_NMI 0x4 | ||
96 | #define APIC_MODE_EXTINT 0x7 | ||
97 | #define APIC_LVT1 0x360 | ||
98 | #define APIC_LVTERR 0x370 | ||
99 | #define APIC_TMICT 0x380 | ||
100 | #define APIC_TMCCT 0x390 | ||
101 | #define APIC_TDCR 0x3E0 | ||
102 | #define APIC_TDR_DIV_TMBASE (1<<2) | ||
103 | #define APIC_TDR_DIV_1 0xB | ||
104 | #define APIC_TDR_DIV_2 0x0 | ||
105 | #define APIC_TDR_DIV_4 0x1 | ||
106 | #define APIC_TDR_DIV_8 0x2 | ||
107 | #define APIC_TDR_DIV_16 0x3 | ||
108 | #define APIC_TDR_DIV_32 0x8 | ||
109 | #define APIC_TDR_DIV_64 0x9 | ||
110 | #define APIC_TDR_DIV_128 0xA | ||
111 | |||
112 | #define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) | ||
113 | |||
114 | #define MAX_IO_APICS 64 | ||
115 | |||
116 | /* | ||
117 | * the local APIC register structure, memory mapped. Not terribly well | ||
118 | * tested, but we might eventually use this one in the future - the | ||
119 | * problem why we cannot use it right now is the P5 APIC, it has an | ||
120 | * errata which cannot take 8-bit reads and writes, only 32-bit ones ... | ||
121 | */ | ||
122 | #define u32 unsigned int | ||
123 | |||
124 | |||
125 | struct local_apic { | ||
126 | |||
127 | /*000*/ struct { u32 __reserved[4]; } __reserved_01; | ||
128 | |||
129 | /*010*/ struct { u32 __reserved[4]; } __reserved_02; | ||
130 | |||
131 | /*020*/ struct { /* APIC ID Register */ | ||
132 | u32 __reserved_1 : 24, | ||
133 | phys_apic_id : 4, | ||
134 | __reserved_2 : 4; | ||
135 | u32 __reserved[3]; | ||
136 | } id; | ||
137 | |||
138 | /*030*/ const | ||
139 | struct { /* APIC Version Register */ | ||
140 | u32 version : 8, | ||
141 | __reserved_1 : 8, | ||
142 | max_lvt : 8, | ||
143 | __reserved_2 : 8; | ||
144 | u32 __reserved[3]; | ||
145 | } version; | ||
146 | |||
147 | /*040*/ struct { u32 __reserved[4]; } __reserved_03; | ||
148 | |||
149 | /*050*/ struct { u32 __reserved[4]; } __reserved_04; | ||
150 | |||
151 | /*060*/ struct { u32 __reserved[4]; } __reserved_05; | ||
152 | |||
153 | /*070*/ struct { u32 __reserved[4]; } __reserved_06; | ||
154 | |||
155 | /*080*/ struct { /* Task Priority Register */ | ||
156 | u32 priority : 8, | ||
157 | __reserved_1 : 24; | ||
158 | u32 __reserved_2[3]; | ||
159 | } tpr; | ||
160 | |||
161 | /*090*/ const | ||
162 | struct { /* Arbitration Priority Register */ | ||
163 | u32 priority : 8, | ||
164 | __reserved_1 : 24; | ||
165 | u32 __reserved_2[3]; | ||
166 | } apr; | ||
167 | |||
168 | /*0A0*/ const | ||
169 | struct { /* Processor Priority Register */ | ||
170 | u32 priority : 8, | ||
171 | __reserved_1 : 24; | ||
172 | u32 __reserved_2[3]; | ||
173 | } ppr; | ||
174 | |||
175 | /*0B0*/ struct { /* End Of Interrupt Register */ | ||
176 | u32 eoi; | ||
177 | u32 __reserved[3]; | ||
178 | } eoi; | ||
179 | |||
180 | /*0C0*/ struct { u32 __reserved[4]; } __reserved_07; | ||
181 | |||
182 | /*0D0*/ struct { /* Logical Destination Register */ | ||
183 | u32 __reserved_1 : 24, | ||
184 | logical_dest : 8; | ||
185 | u32 __reserved_2[3]; | ||
186 | } ldr; | ||
187 | |||
188 | /*0E0*/ struct { /* Destination Format Register */ | ||
189 | u32 __reserved_1 : 28, | ||
190 | model : 4; | ||
191 | u32 __reserved_2[3]; | ||
192 | } dfr; | ||
193 | |||
194 | /*0F0*/ struct { /* Spurious Interrupt Vector Register */ | ||
195 | u32 spurious_vector : 8, | ||
196 | apic_enabled : 1, | ||
197 | focus_cpu : 1, | ||
198 | __reserved_2 : 22; | ||
199 | u32 __reserved_3[3]; | ||
200 | } svr; | ||
201 | |||
202 | /*100*/ struct { /* In Service Register */ | ||
203 | /*170*/ u32 bitfield; | ||
204 | u32 __reserved[3]; | ||
205 | } isr [8]; | ||
206 | |||
207 | /*180*/ struct { /* Trigger Mode Register */ | ||
208 | /*1F0*/ u32 bitfield; | ||
209 | u32 __reserved[3]; | ||
210 | } tmr [8]; | ||
211 | |||
212 | /*200*/ struct { /* Interrupt Request Register */ | ||
213 | /*270*/ u32 bitfield; | ||
214 | u32 __reserved[3]; | ||
215 | } irr [8]; | ||
216 | |||
217 | /*280*/ union { /* Error Status Register */ | ||
218 | struct { | ||
219 | u32 send_cs_error : 1, | ||
220 | receive_cs_error : 1, | ||
221 | send_accept_error : 1, | ||
222 | receive_accept_error : 1, | ||
223 | __reserved_1 : 1, | ||
224 | send_illegal_vector : 1, | ||
225 | receive_illegal_vector : 1, | ||
226 | illegal_register_address : 1, | ||
227 | __reserved_2 : 24; | ||
228 | u32 __reserved_3[3]; | ||
229 | } error_bits; | ||
230 | struct { | ||
231 | u32 errors; | ||
232 | u32 __reserved_3[3]; | ||
233 | } all_errors; | ||
234 | } esr; | ||
235 | |||
236 | /*290*/ struct { u32 __reserved[4]; } __reserved_08; | ||
237 | |||
238 | /*2A0*/ struct { u32 __reserved[4]; } __reserved_09; | ||
239 | |||
240 | /*2B0*/ struct { u32 __reserved[4]; } __reserved_10; | ||
241 | |||
242 | /*2C0*/ struct { u32 __reserved[4]; } __reserved_11; | ||
243 | |||
244 | /*2D0*/ struct { u32 __reserved[4]; } __reserved_12; | ||
245 | |||
246 | /*2E0*/ struct { u32 __reserved[4]; } __reserved_13; | ||
247 | |||
248 | /*2F0*/ struct { u32 __reserved[4]; } __reserved_14; | ||
249 | |||
250 | /*300*/ struct { /* Interrupt Command Register 1 */ | ||
251 | u32 vector : 8, | ||
252 | delivery_mode : 3, | ||
253 | destination_mode : 1, | ||
254 | delivery_status : 1, | ||
255 | __reserved_1 : 1, | ||
256 | level : 1, | ||
257 | trigger : 1, | ||
258 | __reserved_2 : 2, | ||
259 | shorthand : 2, | ||
260 | __reserved_3 : 12; | ||
261 | u32 __reserved_4[3]; | ||
262 | } icr1; | ||
263 | |||
264 | /*310*/ struct { /* Interrupt Command Register 2 */ | ||
265 | union { | ||
266 | u32 __reserved_1 : 24, | ||
267 | phys_dest : 4, | ||
268 | __reserved_2 : 4; | ||
269 | u32 __reserved_3 : 24, | ||
270 | logical_dest : 8; | ||
271 | } dest; | ||
272 | u32 __reserved_4[3]; | ||
273 | } icr2; | ||
274 | |||
275 | /*320*/ struct { /* LVT - Timer */ | ||
276 | u32 vector : 8, | ||
277 | __reserved_1 : 4, | ||
278 | delivery_status : 1, | ||
279 | __reserved_2 : 3, | ||
280 | mask : 1, | ||
281 | timer_mode : 1, | ||
282 | __reserved_3 : 14; | ||
283 | u32 __reserved_4[3]; | ||
284 | } lvt_timer; | ||
285 | |||
286 | /*330*/ struct { /* LVT - Thermal Sensor */ | ||
287 | u32 vector : 8, | ||
288 | delivery_mode : 3, | ||
289 | __reserved_1 : 1, | ||
290 | delivery_status : 1, | ||
291 | __reserved_2 : 3, | ||
292 | mask : 1, | ||
293 | __reserved_3 : 15; | ||
294 | u32 __reserved_4[3]; | ||
295 | } lvt_thermal; | ||
296 | |||
297 | /*340*/ struct { /* LVT - Performance Counter */ | ||
298 | u32 vector : 8, | ||
299 | delivery_mode : 3, | ||
300 | __reserved_1 : 1, | ||
301 | delivery_status : 1, | ||
302 | __reserved_2 : 3, | ||
303 | mask : 1, | ||
304 | __reserved_3 : 15; | ||
305 | u32 __reserved_4[3]; | ||
306 | } lvt_pc; | ||
307 | |||
308 | /*350*/ struct { /* LVT - LINT0 */ | ||
309 | u32 vector : 8, | ||
310 | delivery_mode : 3, | ||
311 | __reserved_1 : 1, | ||
312 | delivery_status : 1, | ||
313 | polarity : 1, | ||
314 | remote_irr : 1, | ||
315 | trigger : 1, | ||
316 | mask : 1, | ||
317 | __reserved_2 : 15; | ||
318 | u32 __reserved_3[3]; | ||
319 | } lvt_lint0; | ||
320 | |||
321 | /*360*/ struct { /* LVT - LINT1 */ | ||
322 | u32 vector : 8, | ||
323 | delivery_mode : 3, | ||
324 | __reserved_1 : 1, | ||
325 | delivery_status : 1, | ||
326 | polarity : 1, | ||
327 | remote_irr : 1, | ||
328 | trigger : 1, | ||
329 | mask : 1, | ||
330 | __reserved_2 : 15; | ||
331 | u32 __reserved_3[3]; | ||
332 | } lvt_lint1; | ||
333 | |||
334 | /*370*/ struct { /* LVT - Error */ | ||
335 | u32 vector : 8, | ||
336 | __reserved_1 : 4, | ||
337 | delivery_status : 1, | ||
338 | __reserved_2 : 3, | ||
339 | mask : 1, | ||
340 | __reserved_3 : 15; | ||
341 | u32 __reserved_4[3]; | ||
342 | } lvt_error; | ||
343 | |||
344 | /*380*/ struct { /* Timer Initial Count Register */ | ||
345 | u32 initial_count; | ||
346 | u32 __reserved_2[3]; | ||
347 | } timer_icr; | ||
348 | |||
349 | /*390*/ const | ||
350 | struct { /* Timer Current Count Register */ | ||
351 | u32 curr_count; | ||
352 | u32 __reserved_2[3]; | ||
353 | } timer_ccr; | ||
354 | |||
355 | /*3A0*/ struct { u32 __reserved[4]; } __reserved_16; | ||
356 | |||
357 | /*3B0*/ struct { u32 __reserved[4]; } __reserved_17; | ||
358 | |||
359 | /*3C0*/ struct { u32 __reserved[4]; } __reserved_18; | ||
360 | |||
361 | /*3D0*/ struct { u32 __reserved[4]; } __reserved_19; | ||
362 | |||
363 | /*3E0*/ struct { /* Timer Divide Configuration Register */ | ||
364 | u32 divisor : 4, | ||
365 | __reserved_1 : 28; | ||
366 | u32 __reserved_2[3]; | ||
367 | } timer_dcr; | ||
368 | |||
369 | /*3F0*/ struct { u32 __reserved[4]; } __reserved_20; | ||
370 | |||
371 | } __attribute__ ((packed)); | ||
372 | |||
373 | #undef u32 | ||
374 | |||
375 | #endif | ||
diff --git a/include/asm-x86/apicdef_64.h b/include/asm-x86/apicdef_64.h new file mode 100644 index 000000000000..1dd40067c67c --- /dev/null +++ b/include/asm-x86/apicdef_64.h | |||
@@ -0,0 +1,392 @@ | |||
1 | #ifndef __ASM_APICDEF_H | ||
2 | #define __ASM_APICDEF_H | ||
3 | |||
4 | /* | ||
5 | * Constants for various Intel APICs. (local APIC, IOAPIC, etc.) | ||
6 | * | ||
7 | * Alan Cox <Alan.Cox@linux.org>, 1995. | ||
8 | * Ingo Molnar <mingo@redhat.com>, 1999, 2000 | ||
9 | */ | ||
10 | |||
11 | #define APIC_DEFAULT_PHYS_BASE 0xfee00000 | ||
12 | |||
13 | #define APIC_ID 0x20 | ||
14 | #define APIC_ID_MASK (0xFFu<<24) | ||
15 | #define GET_APIC_ID(x) (((x)>>24)&0xFFu) | ||
16 | #define SET_APIC_ID(x) (((x)<<24)) | ||
17 | #define APIC_LVR 0x30 | ||
18 | #define APIC_LVR_MASK 0xFF00FF | ||
19 | #define GET_APIC_VERSION(x) ((x)&0xFFu) | ||
20 | #define GET_APIC_MAXLVT(x) (((x)>>16)&0xFFu) | ||
21 | #define APIC_INTEGRATED(x) ((x)&0xF0u) | ||
22 | #define APIC_TASKPRI 0x80 | ||
23 | #define APIC_TPRI_MASK 0xFFu | ||
24 | #define APIC_ARBPRI 0x90 | ||
25 | #define APIC_ARBPRI_MASK 0xFFu | ||
26 | #define APIC_PROCPRI 0xA0 | ||
27 | #define APIC_EOI 0xB0 | ||
28 | #define APIC_EIO_ACK 0x0 /* Write this to the EOI register */ | ||
29 | #define APIC_RRR 0xC0 | ||
30 | #define APIC_LDR 0xD0 | ||
31 | #define APIC_LDR_MASK (0xFFu<<24) | ||
32 | #define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFFu) | ||
33 | #define SET_APIC_LOGICAL_ID(x) (((x)<<24)) | ||
34 | #define APIC_ALL_CPUS 0xFFu | ||
35 | #define APIC_DFR 0xE0 | ||
36 | #define APIC_DFR_CLUSTER 0x0FFFFFFFul | ||
37 | #define APIC_DFR_FLAT 0xFFFFFFFFul | ||
38 | #define APIC_SPIV 0xF0 | ||
39 | #define APIC_SPIV_FOCUS_DISABLED (1<<9) | ||
40 | #define APIC_SPIV_APIC_ENABLED (1<<8) | ||
41 | #define APIC_ISR 0x100 | ||
42 | #define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */ | ||
43 | #define APIC_TMR 0x180 | ||
44 | #define APIC_IRR 0x200 | ||
45 | #define APIC_ESR 0x280 | ||
46 | #define APIC_ESR_SEND_CS 0x00001 | ||
47 | #define APIC_ESR_RECV_CS 0x00002 | ||
48 | #define APIC_ESR_SEND_ACC 0x00004 | ||
49 | #define APIC_ESR_RECV_ACC 0x00008 | ||
50 | #define APIC_ESR_SENDILL 0x00020 | ||
51 | #define APIC_ESR_RECVILL 0x00040 | ||
52 | #define APIC_ESR_ILLREGA 0x00080 | ||
53 | #define APIC_ICR 0x300 | ||
54 | #define APIC_DEST_SELF 0x40000 | ||
55 | #define APIC_DEST_ALLINC 0x80000 | ||
56 | #define APIC_DEST_ALLBUT 0xC0000 | ||
57 | #define APIC_ICR_RR_MASK 0x30000 | ||
58 | #define APIC_ICR_RR_INVALID 0x00000 | ||
59 | #define APIC_ICR_RR_INPROG 0x10000 | ||
60 | #define APIC_ICR_RR_VALID 0x20000 | ||
61 | #define APIC_INT_LEVELTRIG 0x08000 | ||
62 | #define APIC_INT_ASSERT 0x04000 | ||
63 | #define APIC_ICR_BUSY 0x01000 | ||
64 | #define APIC_DEST_LOGICAL 0x00800 | ||
65 | #define APIC_DEST_PHYSICAL 0x00000 | ||
66 | #define APIC_DM_FIXED 0x00000 | ||
67 | #define APIC_DM_LOWEST 0x00100 | ||
68 | #define APIC_DM_SMI 0x00200 | ||
69 | #define APIC_DM_REMRD 0x00300 | ||
70 | #define APIC_DM_NMI 0x00400 | ||
71 | #define APIC_DM_INIT 0x00500 | ||
72 | #define APIC_DM_STARTUP 0x00600 | ||
73 | #define APIC_DM_EXTINT 0x00700 | ||
74 | #define APIC_VECTOR_MASK 0x000FF | ||
75 | #define APIC_ICR2 0x310 | ||
76 | #define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF) | ||
77 | #define SET_APIC_DEST_FIELD(x) ((x)<<24) | ||
78 | #define APIC_LVTT 0x320 | ||
79 | #define APIC_LVTTHMR 0x330 | ||
80 | #define APIC_LVTPC 0x340 | ||
81 | #define APIC_LVT0 0x350 | ||
82 | #define APIC_LVT_TIMER_BASE_MASK (0x3<<18) | ||
83 | #define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3) | ||
84 | #define SET_APIC_TIMER_BASE(x) (((x)<<18)) | ||
85 | #define APIC_TIMER_BASE_CLKIN 0x0 | ||
86 | #define APIC_TIMER_BASE_TMBASE 0x1 | ||
87 | #define APIC_TIMER_BASE_DIV 0x2 | ||
88 | #define APIC_LVT_TIMER_PERIODIC (1<<17) | ||
89 | #define APIC_LVT_MASKED (1<<16) | ||
90 | #define APIC_LVT_LEVEL_TRIGGER (1<<15) | ||
91 | #define APIC_LVT_REMOTE_IRR (1<<14) | ||
92 | #define APIC_INPUT_POLARITY (1<<13) | ||
93 | #define APIC_SEND_PENDING (1<<12) | ||
94 | #define APIC_MODE_MASK 0x700 | ||
95 | #define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7) | ||
96 | #define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8)) | ||
97 | #define APIC_MODE_FIXED 0x0 | ||
98 | #define APIC_MODE_NMI 0x4 | ||
99 | #define APIC_MODE_EXTINT 0x7 | ||
100 | #define APIC_LVT1 0x360 | ||
101 | #define APIC_LVTERR 0x370 | ||
102 | #define APIC_TMICT 0x380 | ||
103 | #define APIC_TMCCT 0x390 | ||
104 | #define APIC_TDCR 0x3E0 | ||
105 | #define APIC_TDR_DIV_TMBASE (1<<2) | ||
106 | #define APIC_TDR_DIV_1 0xB | ||
107 | #define APIC_TDR_DIV_2 0x0 | ||
108 | #define APIC_TDR_DIV_4 0x1 | ||
109 | #define APIC_TDR_DIV_8 0x2 | ||
110 | #define APIC_TDR_DIV_16 0x3 | ||
111 | #define APIC_TDR_DIV_32 0x8 | ||
112 | #define APIC_TDR_DIV_64 0x9 | ||
113 | #define APIC_TDR_DIV_128 0xA | ||
114 | |||
115 | #define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) | ||
116 | |||
117 | #define MAX_IO_APICS 128 | ||
118 | #define MAX_LOCAL_APIC 256 | ||
119 | |||
120 | /* | ||
121 | * All x86-64 systems are xAPIC compatible. | ||
122 | * In the following, "apicid" is a physical APIC ID. | ||
123 | */ | ||
124 | #define XAPIC_DEST_CPUS_SHIFT 4 | ||
125 | #define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1) | ||
126 | #define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT) | ||
127 | #define APIC_CLUSTER(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK) | ||
128 | #define APIC_CLUSTERID(apicid) (APIC_CLUSTER(apicid) >> XAPIC_DEST_CPUS_SHIFT) | ||
129 | #define APIC_CPUID(apicid) ((apicid) & XAPIC_DEST_CPUS_MASK) | ||
130 | #define NUM_APIC_CLUSTERS ((BAD_APICID + 1) >> XAPIC_DEST_CPUS_SHIFT) | ||
131 | |||
132 | /* | ||
133 | * the local APIC register structure, memory mapped. Not terribly well | ||
134 | * tested, but we might eventually use this one in the future - the | ||
135 | * problem why we cannot use it right now is the P5 APIC, it has an | ||
136 | * errata which cannot take 8-bit reads and writes, only 32-bit ones ... | ||
137 | */ | ||
138 | #define u32 unsigned int | ||
139 | |||
140 | struct local_apic { | ||
141 | |||
142 | /*000*/ struct { u32 __reserved[4]; } __reserved_01; | ||
143 | |||
144 | /*010*/ struct { u32 __reserved[4]; } __reserved_02; | ||
145 | |||
146 | /*020*/ struct { /* APIC ID Register */ | ||
147 | u32 __reserved_1 : 24, | ||
148 | phys_apic_id : 4, | ||
149 | __reserved_2 : 4; | ||
150 | u32 __reserved[3]; | ||
151 | } id; | ||
152 | |||
153 | /*030*/ const | ||
154 | struct { /* APIC Version Register */ | ||
155 | u32 version : 8, | ||
156 | __reserved_1 : 8, | ||
157 | max_lvt : 8, | ||
158 | __reserved_2 : 8; | ||
159 | u32 __reserved[3]; | ||
160 | } version; | ||
161 | |||
162 | /*040*/ struct { u32 __reserved[4]; } __reserved_03; | ||
163 | |||
164 | /*050*/ struct { u32 __reserved[4]; } __reserved_04; | ||
165 | |||
166 | /*060*/ struct { u32 __reserved[4]; } __reserved_05; | ||
167 | |||
168 | /*070*/ struct { u32 __reserved[4]; } __reserved_06; | ||
169 | |||
170 | /*080*/ struct { /* Task Priority Register */ | ||
171 | u32 priority : 8, | ||
172 | __reserved_1 : 24; | ||
173 | u32 __reserved_2[3]; | ||
174 | } tpr; | ||
175 | |||
176 | /*090*/ const | ||
177 | struct { /* Arbitration Priority Register */ | ||
178 | u32 priority : 8, | ||
179 | __reserved_1 : 24; | ||
180 | u32 __reserved_2[3]; | ||
181 | } apr; | ||
182 | |||
183 | /*0A0*/ const | ||
184 | struct { /* Processor Priority Register */ | ||
185 | u32 priority : 8, | ||
186 | __reserved_1 : 24; | ||
187 | u32 __reserved_2[3]; | ||
188 | } ppr; | ||
189 | |||
190 | /*0B0*/ struct { /* End Of Interrupt Register */ | ||
191 | u32 eoi; | ||
192 | u32 __reserved[3]; | ||
193 | } eoi; | ||
194 | |||
195 | /*0C0*/ struct { u32 __reserved[4]; } __reserved_07; | ||
196 | |||
197 | /*0D0*/ struct { /* Logical Destination Register */ | ||
198 | u32 __reserved_1 : 24, | ||
199 | logical_dest : 8; | ||
200 | u32 __reserved_2[3]; | ||
201 | } ldr; | ||
202 | |||
203 | /*0E0*/ struct { /* Destination Format Register */ | ||
204 | u32 __reserved_1 : 28, | ||
205 | model : 4; | ||
206 | u32 __reserved_2[3]; | ||
207 | } dfr; | ||
208 | |||
209 | /*0F0*/ struct { /* Spurious Interrupt Vector Register */ | ||
210 | u32 spurious_vector : 8, | ||
211 | apic_enabled : 1, | ||
212 | focus_cpu : 1, | ||
213 | __reserved_2 : 22; | ||
214 | u32 __reserved_3[3]; | ||
215 | } svr; | ||
216 | |||
217 | /*100*/ struct { /* In Service Register */ | ||
218 | /*170*/ u32 bitfield; | ||
219 | u32 __reserved[3]; | ||
220 | } isr [8]; | ||
221 | |||
222 | /*180*/ struct { /* Trigger Mode Register */ | ||
223 | /*1F0*/ u32 bitfield; | ||
224 | u32 __reserved[3]; | ||
225 | } tmr [8]; | ||
226 | |||
227 | /*200*/ struct { /* Interrupt Request Register */ | ||
228 | /*270*/ u32 bitfield; | ||
229 | u32 __reserved[3]; | ||
230 | } irr [8]; | ||
231 | |||
232 | /*280*/ union { /* Error Status Register */ | ||
233 | struct { | ||
234 | u32 send_cs_error : 1, | ||
235 | receive_cs_error : 1, | ||
236 | send_accept_error : 1, | ||
237 | receive_accept_error : 1, | ||
238 | __reserved_1 : 1, | ||
239 | send_illegal_vector : 1, | ||
240 | receive_illegal_vector : 1, | ||
241 | illegal_register_address : 1, | ||
242 | __reserved_2 : 24; | ||
243 | u32 __reserved_3[3]; | ||
244 | } error_bits; | ||
245 | struct { | ||
246 | u32 errors; | ||
247 | u32 __reserved_3[3]; | ||
248 | } all_errors; | ||
249 | } esr; | ||
250 | |||
251 | /*290*/ struct { u32 __reserved[4]; } __reserved_08; | ||
252 | |||
253 | /*2A0*/ struct { u32 __reserved[4]; } __reserved_09; | ||
254 | |||
255 | /*2B0*/ struct { u32 __reserved[4]; } __reserved_10; | ||
256 | |||
257 | /*2C0*/ struct { u32 __reserved[4]; } __reserved_11; | ||
258 | |||
259 | /*2D0*/ struct { u32 __reserved[4]; } __reserved_12; | ||
260 | |||
261 | /*2E0*/ struct { u32 __reserved[4]; } __reserved_13; | ||
262 | |||
263 | /*2F0*/ struct { u32 __reserved[4]; } __reserved_14; | ||
264 | |||
265 | /*300*/ struct { /* Interrupt Command Register 1 */ | ||
266 | u32 vector : 8, | ||
267 | delivery_mode : 3, | ||
268 | destination_mode : 1, | ||
269 | delivery_status : 1, | ||
270 | __reserved_1 : 1, | ||
271 | level : 1, | ||
272 | trigger : 1, | ||
273 | __reserved_2 : 2, | ||
274 | shorthand : 2, | ||
275 | __reserved_3 : 12; | ||
276 | u32 __reserved_4[3]; | ||
277 | } icr1; | ||
278 | |||
279 | /*310*/ struct { /* Interrupt Command Register 2 */ | ||
280 | union { | ||
281 | u32 __reserved_1 : 24, | ||
282 | phys_dest : 4, | ||
283 | __reserved_2 : 4; | ||
284 | u32 __reserved_3 : 24, | ||
285 | logical_dest : 8; | ||
286 | } dest; | ||
287 | u32 __reserved_4[3]; | ||
288 | } icr2; | ||
289 | |||
290 | /*320*/ struct { /* LVT - Timer */ | ||
291 | u32 vector : 8, | ||
292 | __reserved_1 : 4, | ||
293 | delivery_status : 1, | ||
294 | __reserved_2 : 3, | ||
295 | mask : 1, | ||
296 | timer_mode : 1, | ||
297 | __reserved_3 : 14; | ||
298 | u32 __reserved_4[3]; | ||
299 | } lvt_timer; | ||
300 | |||
301 | /*330*/ struct { /* LVT - Thermal Sensor */ | ||
302 | u32 vector : 8, | ||
303 | delivery_mode : 3, | ||
304 | __reserved_1 : 1, | ||
305 | delivery_status : 1, | ||
306 | __reserved_2 : 3, | ||
307 | mask : 1, | ||
308 | __reserved_3 : 15; | ||
309 | u32 __reserved_4[3]; | ||
310 | } lvt_thermal; | ||
311 | |||
312 | /*340*/ struct { /* LVT - Performance Counter */ | ||
313 | u32 vector : 8, | ||
314 | delivery_mode : 3, | ||
315 | __reserved_1 : 1, | ||
316 | delivery_status : 1, | ||
317 | __reserved_2 : 3, | ||
318 | mask : 1, | ||
319 | __reserved_3 : 15; | ||
320 | u32 __reserved_4[3]; | ||
321 | } lvt_pc; | ||
322 | |||
323 | /*350*/ struct { /* LVT - LINT0 */ | ||
324 | u32 vector : 8, | ||
325 | delivery_mode : 3, | ||
326 | __reserved_1 : 1, | ||
327 | delivery_status : 1, | ||
328 | polarity : 1, | ||
329 | remote_irr : 1, | ||
330 | trigger : 1, | ||
331 | mask : 1, | ||
332 | __reserved_2 : 15; | ||
333 | u32 __reserved_3[3]; | ||
334 | } lvt_lint0; | ||
335 | |||
336 | /*360*/ struct { /* LVT - LINT1 */ | ||
337 | u32 vector : 8, | ||
338 | delivery_mode : 3, | ||
339 | __reserved_1 : 1, | ||
340 | delivery_status : 1, | ||
341 | polarity : 1, | ||
342 | remote_irr : 1, | ||
343 | trigger : 1, | ||
344 | mask : 1, | ||
345 | __reserved_2 : 15; | ||
346 | u32 __reserved_3[3]; | ||
347 | } lvt_lint1; | ||
348 | |||
349 | /*370*/ struct { /* LVT - Error */ | ||
350 | u32 vector : 8, | ||
351 | __reserved_1 : 4, | ||
352 | delivery_status : 1, | ||
353 | __reserved_2 : 3, | ||
354 | mask : 1, | ||
355 | __reserved_3 : 15; | ||
356 | u32 __reserved_4[3]; | ||
357 | } lvt_error; | ||
358 | |||
359 | /*380*/ struct { /* Timer Initial Count Register */ | ||
360 | u32 initial_count; | ||
361 | u32 __reserved_2[3]; | ||
362 | } timer_icr; | ||
363 | |||
364 | /*390*/ const | ||
365 | struct { /* Timer Current Count Register */ | ||
366 | u32 curr_count; | ||
367 | u32 __reserved_2[3]; | ||
368 | } timer_ccr; | ||
369 | |||
370 | /*3A0*/ struct { u32 __reserved[4]; } __reserved_16; | ||
371 | |||
372 | /*3B0*/ struct { u32 __reserved[4]; } __reserved_17; | ||
373 | |||
374 | /*3C0*/ struct { u32 __reserved[4]; } __reserved_18; | ||
375 | |||
376 | /*3D0*/ struct { u32 __reserved[4]; } __reserved_19; | ||
377 | |||
378 | /*3E0*/ struct { /* Timer Divide Configuration Register */ | ||
379 | u32 divisor : 4, | ||
380 | __reserved_1 : 28; | ||
381 | u32 __reserved_2[3]; | ||
382 | } timer_dcr; | ||
383 | |||
384 | /*3F0*/ struct { u32 __reserved[4]; } __reserved_20; | ||
385 | |||
386 | } __attribute__ ((packed)); | ||
387 | |||
388 | #undef u32 | ||
389 | |||
390 | #define BAD_APICID 0xFFu | ||
391 | |||
392 | #endif | ||
diff --git a/include/asm-x86/arch_hooks.h b/include/asm-x86/arch_hooks.h new file mode 100644 index 000000000000..a8c1fca9726d --- /dev/null +++ b/include/asm-x86/arch_hooks.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef _ASM_ARCH_HOOKS_H | ||
2 | #define _ASM_ARCH_HOOKS_H | ||
3 | |||
4 | #include <linux/interrupt.h> | ||
5 | |||
6 | /* | ||
7 | * linux/include/asm/arch_hooks.h | ||
8 | * | ||
9 | * define the architecture specific hooks | ||
10 | */ | ||
11 | |||
12 | /* these aren't arch hooks, they are generic routines | ||
13 | * that can be used by the hooks */ | ||
14 | extern void init_ISA_irqs(void); | ||
15 | extern void apic_intr_init(void); | ||
16 | extern void smp_intr_init(void); | ||
17 | extern irqreturn_t timer_interrupt(int irq, void *dev_id); | ||
18 | |||
19 | /* these are the defined hooks */ | ||
20 | extern void intr_init_hook(void); | ||
21 | extern void pre_intr_init_hook(void); | ||
22 | extern void pre_setup_arch_hook(void); | ||
23 | extern void trap_init_hook(void); | ||
24 | extern void time_init_hook(void); | ||
25 | extern void mca_nmi_hook(void); | ||
26 | |||
27 | extern int setup_early_printk(char *); | ||
28 | extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2))); | ||
29 | |||
30 | #endif | ||
diff --git a/include/asm-x86/atomic.h b/include/asm-x86/atomic.h new file mode 100644 index 000000000000..4e1b8873c474 --- /dev/null +++ b/include/asm-x86/atomic.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "atomic_32.h" | ||
3 | #else | ||
4 | # include "atomic_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/atomic_32.h b/include/asm-x86/atomic_32.h new file mode 100644 index 000000000000..437aac801711 --- /dev/null +++ b/include/asm-x86/atomic_32.h | |||
@@ -0,0 +1,266 @@ | |||
1 | #ifndef __ARCH_I386_ATOMIC__ | ||
2 | #define __ARCH_I386_ATOMIC__ | ||
3 | |||
4 | #include <linux/compiler.h> | ||
5 | #include <asm/processor.h> | ||
6 | #include <asm/cmpxchg.h> | ||
7 | |||
8 | /* | ||
9 | * Atomic operations that C can't guarantee us. Useful for | ||
10 | * resource counting etc.. | ||
11 | */ | ||
12 | |||
13 | /* | ||
14 | * Make sure gcc doesn't try to be clever and move things around | ||
15 | * on us. We need to use _exactly_ the address the user gave us, | ||
16 | * not some alias that contains the same information. | ||
17 | */ | ||
18 | typedef struct { int counter; } atomic_t; | ||
19 | |||
20 | #define ATOMIC_INIT(i) { (i) } | ||
21 | |||
22 | /** | ||
23 | * atomic_read - read atomic variable | ||
24 | * @v: pointer of type atomic_t | ||
25 | * | ||
26 | * Atomically reads the value of @v. | ||
27 | */ | ||
28 | #define atomic_read(v) ((v)->counter) | ||
29 | |||
30 | /** | ||
31 | * atomic_set - set atomic variable | ||
32 | * @v: pointer of type atomic_t | ||
33 | * @i: required value | ||
34 | * | ||
35 | * Atomically sets the value of @v to @i. | ||
36 | */ | ||
37 | #define atomic_set(v,i) (((v)->counter) = (i)) | ||
38 | |||
39 | /** | ||
40 | * atomic_add - add integer to atomic variable | ||
41 | * @i: integer value to add | ||
42 | * @v: pointer of type atomic_t | ||
43 | * | ||
44 | * Atomically adds @i to @v. | ||
45 | */ | ||
46 | static __inline__ void atomic_add(int i, atomic_t *v) | ||
47 | { | ||
48 | __asm__ __volatile__( | ||
49 | LOCK_PREFIX "addl %1,%0" | ||
50 | :"+m" (v->counter) | ||
51 | :"ir" (i)); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * atomic_sub - subtract integer from atomic variable | ||
56 | * @i: integer value to subtract | ||
57 | * @v: pointer of type atomic_t | ||
58 | * | ||
59 | * Atomically subtracts @i from @v. | ||
60 | */ | ||
61 | static __inline__ void atomic_sub(int i, atomic_t *v) | ||
62 | { | ||
63 | __asm__ __volatile__( | ||
64 | LOCK_PREFIX "subl %1,%0" | ||
65 | :"+m" (v->counter) | ||
66 | :"ir" (i)); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * atomic_sub_and_test - subtract value from variable and test result | ||
71 | * @i: integer value to subtract | ||
72 | * @v: pointer of type atomic_t | ||
73 | * | ||
74 | * Atomically subtracts @i from @v and returns | ||
75 | * true if the result is zero, or false for all | ||
76 | * other cases. | ||
77 | */ | ||
78 | static __inline__ int atomic_sub_and_test(int i, atomic_t *v) | ||
79 | { | ||
80 | unsigned char c; | ||
81 | |||
82 | __asm__ __volatile__( | ||
83 | LOCK_PREFIX "subl %2,%0; sete %1" | ||
84 | :"+m" (v->counter), "=qm" (c) | ||
85 | :"ir" (i) : "memory"); | ||
86 | return c; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * atomic_inc - increment atomic variable | ||
91 | * @v: pointer of type atomic_t | ||
92 | * | ||
93 | * Atomically increments @v by 1. | ||
94 | */ | ||
95 | static __inline__ void atomic_inc(atomic_t *v) | ||
96 | { | ||
97 | __asm__ __volatile__( | ||
98 | LOCK_PREFIX "incl %0" | ||
99 | :"+m" (v->counter)); | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * atomic_dec - decrement atomic variable | ||
104 | * @v: pointer of type atomic_t | ||
105 | * | ||
106 | * Atomically decrements @v by 1. | ||
107 | */ | ||
108 | static __inline__ void atomic_dec(atomic_t *v) | ||
109 | { | ||
110 | __asm__ __volatile__( | ||
111 | LOCK_PREFIX "decl %0" | ||
112 | :"+m" (v->counter)); | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * atomic_dec_and_test - decrement and test | ||
117 | * @v: pointer of type atomic_t | ||
118 | * | ||
119 | * Atomically decrements @v by 1 and | ||
120 | * returns true if the result is 0, or false for all other | ||
121 | * cases. | ||
122 | */ | ||
123 | static __inline__ int atomic_dec_and_test(atomic_t *v) | ||
124 | { | ||
125 | unsigned char c; | ||
126 | |||
127 | __asm__ __volatile__( | ||
128 | LOCK_PREFIX "decl %0; sete %1" | ||
129 | :"+m" (v->counter), "=qm" (c) | ||
130 | : : "memory"); | ||
131 | return c != 0; | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * atomic_inc_and_test - increment and test | ||
136 | * @v: pointer of type atomic_t | ||
137 | * | ||
138 | * Atomically increments @v by 1 | ||
139 | * and returns true if the result is zero, or false for all | ||
140 | * other cases. | ||
141 | */ | ||
142 | static __inline__ int atomic_inc_and_test(atomic_t *v) | ||
143 | { | ||
144 | unsigned char c; | ||
145 | |||
146 | __asm__ __volatile__( | ||
147 | LOCK_PREFIX "incl %0; sete %1" | ||
148 | :"+m" (v->counter), "=qm" (c) | ||
149 | : : "memory"); | ||
150 | return c != 0; | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * atomic_add_negative - add and test if negative | ||
155 | * @v: pointer of type atomic_t | ||
156 | * @i: integer value to add | ||
157 | * | ||
158 | * Atomically adds @i to @v and returns true | ||
159 | * if the result is negative, or false when | ||
160 | * result is greater than or equal to zero. | ||
161 | */ | ||
162 | static __inline__ int atomic_add_negative(int i, atomic_t *v) | ||
163 | { | ||
164 | unsigned char c; | ||
165 | |||
166 | __asm__ __volatile__( | ||
167 | LOCK_PREFIX "addl %2,%0; sets %1" | ||
168 | :"+m" (v->counter), "=qm" (c) | ||
169 | :"ir" (i) : "memory"); | ||
170 | return c; | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * atomic_add_return - add integer and return | ||
175 | * @v: pointer of type atomic_t | ||
176 | * @i: integer value to add | ||
177 | * | ||
178 | * Atomically adds @i to @v and returns @i + @v | ||
179 | */ | ||
180 | static __inline__ int atomic_add_return(int i, atomic_t *v) | ||
181 | { | ||
182 | int __i; | ||
183 | #ifdef CONFIG_M386 | ||
184 | unsigned long flags; | ||
185 | if(unlikely(boot_cpu_data.x86 <= 3)) | ||
186 | goto no_xadd; | ||
187 | #endif | ||
188 | /* Modern 486+ processor */ | ||
189 | __i = i; | ||
190 | __asm__ __volatile__( | ||
191 | LOCK_PREFIX "xaddl %0, %1" | ||
192 | :"+r" (i), "+m" (v->counter) | ||
193 | : : "memory"); | ||
194 | return i + __i; | ||
195 | |||
196 | #ifdef CONFIG_M386 | ||
197 | no_xadd: /* Legacy 386 processor */ | ||
198 | local_irq_save(flags); | ||
199 | __i = atomic_read(v); | ||
200 | atomic_set(v, i + __i); | ||
201 | local_irq_restore(flags); | ||
202 | return i + __i; | ||
203 | #endif | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * atomic_sub_return - subtract integer and return | ||
208 | * @v: pointer of type atomic_t | ||
209 | * @i: integer value to subtract | ||
210 | * | ||
211 | * Atomically subtracts @i from @v and returns @v - @i | ||
212 | */ | ||
213 | static __inline__ int atomic_sub_return(int i, atomic_t *v) | ||
214 | { | ||
215 | return atomic_add_return(-i,v); | ||
216 | } | ||
217 | |||
218 | #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) | ||
219 | #define atomic_xchg(v, new) (xchg(&((v)->counter), (new))) | ||
220 | |||
221 | /** | ||
222 | * atomic_add_unless - add unless the number is already a given value | ||
223 | * @v: pointer of type atomic_t | ||
224 | * @a: the amount to add to v... | ||
225 | * @u: ...unless v is equal to u. | ||
226 | * | ||
227 | * Atomically adds @a to @v, so long as @v was not already @u. | ||
228 | * Returns non-zero if @v was not @u, and zero otherwise. | ||
229 | */ | ||
230 | static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) | ||
231 | { | ||
232 | int c, old; | ||
233 | c = atomic_read(v); | ||
234 | for (;;) { | ||
235 | if (unlikely(c == (u))) | ||
236 | break; | ||
237 | old = atomic_cmpxchg((v), c, c + (a)); | ||
238 | if (likely(old == c)) | ||
239 | break; | ||
240 | c = old; | ||
241 | } | ||
242 | return c != (u); | ||
243 | } | ||
244 | |||
245 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | ||
246 | |||
247 | #define atomic_inc_return(v) (atomic_add_return(1,v)) | ||
248 | #define atomic_dec_return(v) (atomic_sub_return(1,v)) | ||
249 | |||
250 | /* These are x86-specific, used by some header files */ | ||
251 | #define atomic_clear_mask(mask, addr) \ | ||
252 | __asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \ | ||
253 | : : "r" (~(mask)),"m" (*addr) : "memory") | ||
254 | |||
255 | #define atomic_set_mask(mask, addr) \ | ||
256 | __asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \ | ||
257 | : : "r" (mask),"m" (*(addr)) : "memory") | ||
258 | |||
259 | /* Atomic operations are already serializing on x86 */ | ||
260 | #define smp_mb__before_atomic_dec() barrier() | ||
261 | #define smp_mb__after_atomic_dec() barrier() | ||
262 | #define smp_mb__before_atomic_inc() barrier() | ||
263 | #define smp_mb__after_atomic_inc() barrier() | ||
264 | |||
265 | #include <asm-generic/atomic.h> | ||
266 | #endif | ||
diff --git a/include/asm-x86/atomic_64.h b/include/asm-x86/atomic_64.h new file mode 100644 index 000000000000..f2e64634fa48 --- /dev/null +++ b/include/asm-x86/atomic_64.h | |||
@@ -0,0 +1,466 @@ | |||
1 | #ifndef __ARCH_X86_64_ATOMIC__ | ||
2 | #define __ARCH_X86_64_ATOMIC__ | ||
3 | |||
4 | #include <asm/alternative.h> | ||
5 | #include <asm/cmpxchg.h> | ||
6 | |||
7 | /* atomic_t should be 32 bit signed type */ | ||
8 | |||
9 | /* | ||
10 | * Atomic operations that C can't guarantee us. Useful for | ||
11 | * resource counting etc.. | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_SMP | ||
15 | #define LOCK "lock ; " | ||
16 | #else | ||
17 | #define LOCK "" | ||
18 | #endif | ||
19 | |||
20 | /* | ||
21 | * Make sure gcc doesn't try to be clever and move things around | ||
22 | * on us. We need to use _exactly_ the address the user gave us, | ||
23 | * not some alias that contains the same information. | ||
24 | */ | ||
25 | typedef struct { int counter; } atomic_t; | ||
26 | |||
27 | #define ATOMIC_INIT(i) { (i) } | ||
28 | |||
29 | /** | ||
30 | * atomic_read - read atomic variable | ||
31 | * @v: pointer of type atomic_t | ||
32 | * | ||
33 | * Atomically reads the value of @v. | ||
34 | */ | ||
35 | #define atomic_read(v) ((v)->counter) | ||
36 | |||
37 | /** | ||
38 | * atomic_set - set atomic variable | ||
39 | * @v: pointer of type atomic_t | ||
40 | * @i: required value | ||
41 | * | ||
42 | * Atomically sets the value of @v to @i. | ||
43 | */ | ||
44 | #define atomic_set(v,i) (((v)->counter) = (i)) | ||
45 | |||
46 | /** | ||
47 | * atomic_add - add integer to atomic variable | ||
48 | * @i: integer value to add | ||
49 | * @v: pointer of type atomic_t | ||
50 | * | ||
51 | * Atomically adds @i to @v. | ||
52 | */ | ||
53 | static __inline__ void atomic_add(int i, atomic_t *v) | ||
54 | { | ||
55 | __asm__ __volatile__( | ||
56 | LOCK_PREFIX "addl %1,%0" | ||
57 | :"=m" (v->counter) | ||
58 | :"ir" (i), "m" (v->counter)); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * atomic_sub - subtract the atomic variable | ||
63 | * @i: integer value to subtract | ||
64 | * @v: pointer of type atomic_t | ||
65 | * | ||
66 | * Atomically subtracts @i from @v. | ||
67 | */ | ||
68 | static __inline__ void atomic_sub(int i, atomic_t *v) | ||
69 | { | ||
70 | __asm__ __volatile__( | ||
71 | LOCK_PREFIX "subl %1,%0" | ||
72 | :"=m" (v->counter) | ||
73 | :"ir" (i), "m" (v->counter)); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * atomic_sub_and_test - subtract value from variable and test result | ||
78 | * @i: integer value to subtract | ||
79 | * @v: pointer of type atomic_t | ||
80 | * | ||
81 | * Atomically subtracts @i from @v and returns | ||
82 | * true if the result is zero, or false for all | ||
83 | * other cases. | ||
84 | */ | ||
85 | static __inline__ int atomic_sub_and_test(int i, atomic_t *v) | ||
86 | { | ||
87 | unsigned char c; | ||
88 | |||
89 | __asm__ __volatile__( | ||
90 | LOCK_PREFIX "subl %2,%0; sete %1" | ||
91 | :"=m" (v->counter), "=qm" (c) | ||
92 | :"ir" (i), "m" (v->counter) : "memory"); | ||
93 | return c; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * atomic_inc - increment atomic variable | ||
98 | * @v: pointer of type atomic_t | ||
99 | * | ||
100 | * Atomically increments @v by 1. | ||
101 | */ | ||
102 | static __inline__ void atomic_inc(atomic_t *v) | ||
103 | { | ||
104 | __asm__ __volatile__( | ||
105 | LOCK_PREFIX "incl %0" | ||
106 | :"=m" (v->counter) | ||
107 | :"m" (v->counter)); | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * atomic_dec - decrement atomic variable | ||
112 | * @v: pointer of type atomic_t | ||
113 | * | ||
114 | * Atomically decrements @v by 1. | ||
115 | */ | ||
116 | static __inline__ void atomic_dec(atomic_t *v) | ||
117 | { | ||
118 | __asm__ __volatile__( | ||
119 | LOCK_PREFIX "decl %0" | ||
120 | :"=m" (v->counter) | ||
121 | :"m" (v->counter)); | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * atomic_dec_and_test - decrement and test | ||
126 | * @v: pointer of type atomic_t | ||
127 | * | ||
128 | * Atomically decrements @v by 1 and | ||
129 | * returns true if the result is 0, or false for all other | ||
130 | * cases. | ||
131 | */ | ||
132 | static __inline__ int atomic_dec_and_test(atomic_t *v) | ||
133 | { | ||
134 | unsigned char c; | ||
135 | |||
136 | __asm__ __volatile__( | ||
137 | LOCK_PREFIX "decl %0; sete %1" | ||
138 | :"=m" (v->counter), "=qm" (c) | ||
139 | :"m" (v->counter) : "memory"); | ||
140 | return c != 0; | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * atomic_inc_and_test - increment and test | ||
145 | * @v: pointer of type atomic_t | ||
146 | * | ||
147 | * Atomically increments @v by 1 | ||
148 | * and returns true if the result is zero, or false for all | ||
149 | * other cases. | ||
150 | */ | ||
151 | static __inline__ int atomic_inc_and_test(atomic_t *v) | ||
152 | { | ||
153 | unsigned char c; | ||
154 | |||
155 | __asm__ __volatile__( | ||
156 | LOCK_PREFIX "incl %0; sete %1" | ||
157 | :"=m" (v->counter), "=qm" (c) | ||
158 | :"m" (v->counter) : "memory"); | ||
159 | return c != 0; | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * atomic_add_negative - add and test if negative | ||
164 | * @i: integer value to add | ||
165 | * @v: pointer of type atomic_t | ||
166 | * | ||
167 | * Atomically adds @i to @v and returns true | ||
168 | * if the result is negative, or false when | ||
169 | * result is greater than or equal to zero. | ||
170 | */ | ||
171 | static __inline__ int atomic_add_negative(int i, atomic_t *v) | ||
172 | { | ||
173 | unsigned char c; | ||
174 | |||
175 | __asm__ __volatile__( | ||
176 | LOCK_PREFIX "addl %2,%0; sets %1" | ||
177 | :"=m" (v->counter), "=qm" (c) | ||
178 | :"ir" (i), "m" (v->counter) : "memory"); | ||
179 | return c; | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * atomic_add_return - add and return | ||
184 | * @i: integer value to add | ||
185 | * @v: pointer of type atomic_t | ||
186 | * | ||
187 | * Atomically adds @i to @v and returns @i + @v | ||
188 | */ | ||
189 | static __inline__ int atomic_add_return(int i, atomic_t *v) | ||
190 | { | ||
191 | int __i = i; | ||
192 | __asm__ __volatile__( | ||
193 | LOCK_PREFIX "xaddl %0, %1" | ||
194 | :"+r" (i), "+m" (v->counter) | ||
195 | : : "memory"); | ||
196 | return i + __i; | ||
197 | } | ||
198 | |||
199 | static __inline__ int atomic_sub_return(int i, atomic_t *v) | ||
200 | { | ||
201 | return atomic_add_return(-i,v); | ||
202 | } | ||
203 | |||
204 | #define atomic_inc_return(v) (atomic_add_return(1,v)) | ||
205 | #define atomic_dec_return(v) (atomic_sub_return(1,v)) | ||
206 | |||
207 | /* An 64bit atomic type */ | ||
208 | |||
209 | typedef struct { volatile long counter; } atomic64_t; | ||
210 | |||
211 | #define ATOMIC64_INIT(i) { (i) } | ||
212 | |||
213 | /** | ||
214 | * atomic64_read - read atomic64 variable | ||
215 | * @v: pointer of type atomic64_t | ||
216 | * | ||
217 | * Atomically reads the value of @v. | ||
218 | * Doesn't imply a read memory barrier. | ||
219 | */ | ||
220 | #define atomic64_read(v) ((v)->counter) | ||
221 | |||
222 | /** | ||
223 | * atomic64_set - set atomic64 variable | ||
224 | * @v: pointer to type atomic64_t | ||
225 | * @i: required value | ||
226 | * | ||
227 | * Atomically sets the value of @v to @i. | ||
228 | */ | ||
229 | #define atomic64_set(v,i) (((v)->counter) = (i)) | ||
230 | |||
231 | /** | ||
232 | * atomic64_add - add integer to atomic64 variable | ||
233 | * @i: integer value to add | ||
234 | * @v: pointer to type atomic64_t | ||
235 | * | ||
236 | * Atomically adds @i to @v. | ||
237 | */ | ||
238 | static __inline__ void atomic64_add(long i, atomic64_t *v) | ||
239 | { | ||
240 | __asm__ __volatile__( | ||
241 | LOCK_PREFIX "addq %1,%0" | ||
242 | :"=m" (v->counter) | ||
243 | :"ir" (i), "m" (v->counter)); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * atomic64_sub - subtract the atomic64 variable | ||
248 | * @i: integer value to subtract | ||
249 | * @v: pointer to type atomic64_t | ||
250 | * | ||
251 | * Atomically subtracts @i from @v. | ||
252 | */ | ||
253 | static __inline__ void atomic64_sub(long i, atomic64_t *v) | ||
254 | { | ||
255 | __asm__ __volatile__( | ||
256 | LOCK_PREFIX "subq %1,%0" | ||
257 | :"=m" (v->counter) | ||
258 | :"ir" (i), "m" (v->counter)); | ||
259 | } | ||
260 | |||
261 | /** | ||
262 | * atomic64_sub_and_test - subtract value from variable and test result | ||
263 | * @i: integer value to subtract | ||
264 | * @v: pointer to type atomic64_t | ||
265 | * | ||
266 | * Atomically subtracts @i from @v and returns | ||
267 | * true if the result is zero, or false for all | ||
268 | * other cases. | ||
269 | */ | ||
270 | static __inline__ int atomic64_sub_and_test(long i, atomic64_t *v) | ||
271 | { | ||
272 | unsigned char c; | ||
273 | |||
274 | __asm__ __volatile__( | ||
275 | LOCK_PREFIX "subq %2,%0; sete %1" | ||
276 | :"=m" (v->counter), "=qm" (c) | ||
277 | :"ir" (i), "m" (v->counter) : "memory"); | ||
278 | return c; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * atomic64_inc - increment atomic64 variable | ||
283 | * @v: pointer to type atomic64_t | ||
284 | * | ||
285 | * Atomically increments @v by 1. | ||
286 | */ | ||
287 | static __inline__ void atomic64_inc(atomic64_t *v) | ||
288 | { | ||
289 | __asm__ __volatile__( | ||
290 | LOCK_PREFIX "incq %0" | ||
291 | :"=m" (v->counter) | ||
292 | :"m" (v->counter)); | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * atomic64_dec - decrement atomic64 variable | ||
297 | * @v: pointer to type atomic64_t | ||
298 | * | ||
299 | * Atomically decrements @v by 1. | ||
300 | */ | ||
301 | static __inline__ void atomic64_dec(atomic64_t *v) | ||
302 | { | ||
303 | __asm__ __volatile__( | ||
304 | LOCK_PREFIX "decq %0" | ||
305 | :"=m" (v->counter) | ||
306 | :"m" (v->counter)); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * atomic64_dec_and_test - decrement and test | ||
311 | * @v: pointer to type atomic64_t | ||
312 | * | ||
313 | * Atomically decrements @v by 1 and | ||
314 | * returns true if the result is 0, or false for all other | ||
315 | * cases. | ||
316 | */ | ||
317 | static __inline__ int atomic64_dec_and_test(atomic64_t *v) | ||
318 | { | ||
319 | unsigned char c; | ||
320 | |||
321 | __asm__ __volatile__( | ||
322 | LOCK_PREFIX "decq %0; sete %1" | ||
323 | :"=m" (v->counter), "=qm" (c) | ||
324 | :"m" (v->counter) : "memory"); | ||
325 | return c != 0; | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * atomic64_inc_and_test - increment and test | ||
330 | * @v: pointer to type atomic64_t | ||
331 | * | ||
332 | * Atomically increments @v by 1 | ||
333 | * and returns true if the result is zero, or false for all | ||
334 | * other cases. | ||
335 | */ | ||
336 | static __inline__ int atomic64_inc_and_test(atomic64_t *v) | ||
337 | { | ||
338 | unsigned char c; | ||
339 | |||
340 | __asm__ __volatile__( | ||
341 | LOCK_PREFIX "incq %0; sete %1" | ||
342 | :"=m" (v->counter), "=qm" (c) | ||
343 | :"m" (v->counter) : "memory"); | ||
344 | return c != 0; | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * atomic64_add_negative - add and test if negative | ||
349 | * @i: integer value to add | ||
350 | * @v: pointer to type atomic64_t | ||
351 | * | ||
352 | * Atomically adds @i to @v and returns true | ||
353 | * if the result is negative, or false when | ||
354 | * result is greater than or equal to zero. | ||
355 | */ | ||
356 | static __inline__ int atomic64_add_negative(long i, atomic64_t *v) | ||
357 | { | ||
358 | unsigned char c; | ||
359 | |||
360 | __asm__ __volatile__( | ||
361 | LOCK_PREFIX "addq %2,%0; sets %1" | ||
362 | :"=m" (v->counter), "=qm" (c) | ||
363 | :"ir" (i), "m" (v->counter) : "memory"); | ||
364 | return c; | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * atomic64_add_return - add and return | ||
369 | * @i: integer value to add | ||
370 | * @v: pointer to type atomic64_t | ||
371 | * | ||
372 | * Atomically adds @i to @v and returns @i + @v | ||
373 | */ | ||
374 | static __inline__ long atomic64_add_return(long i, atomic64_t *v) | ||
375 | { | ||
376 | long __i = i; | ||
377 | __asm__ __volatile__( | ||
378 | LOCK_PREFIX "xaddq %0, %1;" | ||
379 | :"+r" (i), "+m" (v->counter) | ||
380 | : : "memory"); | ||
381 | return i + __i; | ||
382 | } | ||
383 | |||
384 | static __inline__ long atomic64_sub_return(long i, atomic64_t *v) | ||
385 | { | ||
386 | return atomic64_add_return(-i,v); | ||
387 | } | ||
388 | |||
389 | #define atomic64_inc_return(v) (atomic64_add_return(1,v)) | ||
390 | #define atomic64_dec_return(v) (atomic64_sub_return(1,v)) | ||
391 | |||
392 | #define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) | ||
393 | #define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) | ||
394 | |||
395 | #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) | ||
396 | #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) | ||
397 | |||
398 | /** | ||
399 | * atomic_add_unless - add unless the number is a given value | ||
400 | * @v: pointer of type atomic_t | ||
401 | * @a: the amount to add to v... | ||
402 | * @u: ...unless v is equal to u. | ||
403 | * | ||
404 | * Atomically adds @a to @v, so long as it was not @u. | ||
405 | * Returns non-zero if @v was not @u, and zero otherwise. | ||
406 | */ | ||
407 | static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) | ||
408 | { | ||
409 | int c, old; | ||
410 | c = atomic_read(v); | ||
411 | for (;;) { | ||
412 | if (unlikely(c == (u))) | ||
413 | break; | ||
414 | old = atomic_cmpxchg((v), c, c + (a)); | ||
415 | if (likely(old == c)) | ||
416 | break; | ||
417 | c = old; | ||
418 | } | ||
419 | return c != (u); | ||
420 | } | ||
421 | |||
422 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | ||
423 | |||
424 | /** | ||
425 | * atomic64_add_unless - add unless the number is a given value | ||
426 | * @v: pointer of type atomic64_t | ||
427 | * @a: the amount to add to v... | ||
428 | * @u: ...unless v is equal to u. | ||
429 | * | ||
430 | * Atomically adds @a to @v, so long as it was not @u. | ||
431 | * Returns non-zero if @v was not @u, and zero otherwise. | ||
432 | */ | ||
433 | static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) | ||
434 | { | ||
435 | long c, old; | ||
436 | c = atomic64_read(v); | ||
437 | for (;;) { | ||
438 | if (unlikely(c == (u))) | ||
439 | break; | ||
440 | old = atomic64_cmpxchg((v), c, c + (a)); | ||
441 | if (likely(old == c)) | ||
442 | break; | ||
443 | c = old; | ||
444 | } | ||
445 | return c != (u); | ||
446 | } | ||
447 | |||
448 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) | ||
449 | |||
450 | /* These are x86-specific, used by some header files */ | ||
451 | #define atomic_clear_mask(mask, addr) \ | ||
452 | __asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \ | ||
453 | : : "r" (~(mask)),"m" (*addr) : "memory") | ||
454 | |||
455 | #define atomic_set_mask(mask, addr) \ | ||
456 | __asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \ | ||
457 | : : "r" ((unsigned)mask),"m" (*(addr)) : "memory") | ||
458 | |||
459 | /* Atomic operations are already serializing on x86 */ | ||
460 | #define smp_mb__before_atomic_dec() barrier() | ||
461 | #define smp_mb__after_atomic_dec() barrier() | ||
462 | #define smp_mb__before_atomic_inc() barrier() | ||
463 | #define smp_mb__after_atomic_inc() barrier() | ||
464 | |||
465 | #include <asm-generic/atomic.h> | ||
466 | #endif | ||
diff --git a/include/asm-x86/auxvec.h b/include/asm-x86/auxvec.h new file mode 100644 index 000000000000..7ff866f829ca --- /dev/null +++ b/include/asm-x86/auxvec.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "auxvec_32.h" | ||
4 | # else | ||
5 | # include "auxvec_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "auxvec_32.h" | ||
10 | # else | ||
11 | # include "auxvec_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/auxvec_32.h b/include/asm-x86/auxvec_32.h new file mode 100644 index 000000000000..395e13016bfb --- /dev/null +++ b/include/asm-x86/auxvec_32.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __ASMi386_AUXVEC_H | ||
2 | #define __ASMi386_AUXVEC_H | ||
3 | |||
4 | /* | ||
5 | * Architecture-neutral AT_ values in 0-17, leave some room | ||
6 | * for more of them, start the x86-specific ones at 32. | ||
7 | */ | ||
8 | #define AT_SYSINFO 32 | ||
9 | #define AT_SYSINFO_EHDR 33 | ||
10 | |||
11 | #endif | ||
diff --git a/include/asm-x86/auxvec_64.h b/include/asm-x86/auxvec_64.h new file mode 100644 index 000000000000..1d5ab0d03950 --- /dev/null +++ b/include/asm-x86/auxvec_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_X86_64_AUXVEC_H | ||
2 | #define __ASM_X86_64_AUXVEC_H | ||
3 | |||
4 | #define AT_SYSINFO_EHDR 33 | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h new file mode 100644 index 000000000000..07e3f6d4fe47 --- /dev/null +++ b/include/asm-x86/bitops.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "bitops_32.h" | ||
3 | #else | ||
4 | # include "bitops_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/bitops_32.h b/include/asm-x86/bitops_32.h new file mode 100644 index 000000000000..a20fe9822f60 --- /dev/null +++ b/include/asm-x86/bitops_32.h | |||
@@ -0,0 +1,423 @@ | |||
1 | #ifndef _I386_BITOPS_H | ||
2 | #define _I386_BITOPS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 1992, Linus Torvalds. | ||
6 | */ | ||
7 | |||
8 | #include <linux/compiler.h> | ||
9 | #include <asm/alternative.h> | ||
10 | |||
11 | /* | ||
12 | * These have to be done with inline assembly: that way the bit-setting | ||
13 | * is guaranteed to be atomic. All bit operations return 0 if the bit | ||
14 | * was cleared before the operation and != 0 if it was not. | ||
15 | * | ||
16 | * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). | ||
17 | */ | ||
18 | |||
19 | #define ADDR (*(volatile long *) addr) | ||
20 | |||
21 | /** | ||
22 | * set_bit - Atomically set a bit in memory | ||
23 | * @nr: the bit to set | ||
24 | * @addr: the address to start counting from | ||
25 | * | ||
26 | * This function is atomic and may not be reordered. See __set_bit() | ||
27 | * if you do not require the atomic guarantees. | ||
28 | * | ||
29 | * Note: there are no guarantees that this function will not be reordered | ||
30 | * on non x86 architectures, so if you are writing portable code, | ||
31 | * make sure not to rely on its reordering guarantees. | ||
32 | * | ||
33 | * Note that @nr may be almost arbitrarily large; this function is not | ||
34 | * restricted to acting on a single-word quantity. | ||
35 | */ | ||
36 | static inline void set_bit(int nr, volatile unsigned long * addr) | ||
37 | { | ||
38 | __asm__ __volatile__( LOCK_PREFIX | ||
39 | "btsl %1,%0" | ||
40 | :"+m" (ADDR) | ||
41 | :"Ir" (nr)); | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * __set_bit - Set a bit in memory | ||
46 | * @nr: the bit to set | ||
47 | * @addr: the address to start counting from | ||
48 | * | ||
49 | * Unlike set_bit(), this function is non-atomic and may be reordered. | ||
50 | * If it's called on the same region of memory simultaneously, the effect | ||
51 | * may be that only one operation succeeds. | ||
52 | */ | ||
53 | static inline void __set_bit(int nr, volatile unsigned long * addr) | ||
54 | { | ||
55 | __asm__( | ||
56 | "btsl %1,%0" | ||
57 | :"+m" (ADDR) | ||
58 | :"Ir" (nr)); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * clear_bit - Clears a bit in memory | ||
63 | * @nr: Bit to clear | ||
64 | * @addr: Address to start counting from | ||
65 | * | ||
66 | * clear_bit() is atomic and may not be reordered. However, it does | ||
67 | * not contain a memory barrier, so if it is used for locking purposes, | ||
68 | * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() | ||
69 | * in order to ensure changes are visible on other processors. | ||
70 | */ | ||
71 | static inline void clear_bit(int nr, volatile unsigned long * addr) | ||
72 | { | ||
73 | __asm__ __volatile__( LOCK_PREFIX | ||
74 | "btrl %1,%0" | ||
75 | :"+m" (ADDR) | ||
76 | :"Ir" (nr)); | ||
77 | } | ||
78 | |||
79 | static inline void __clear_bit(int nr, volatile unsigned long * addr) | ||
80 | { | ||
81 | __asm__ __volatile__( | ||
82 | "btrl %1,%0" | ||
83 | :"+m" (ADDR) | ||
84 | :"Ir" (nr)); | ||
85 | } | ||
86 | #define smp_mb__before_clear_bit() barrier() | ||
87 | #define smp_mb__after_clear_bit() barrier() | ||
88 | |||
89 | /** | ||
90 | * __change_bit - Toggle a bit in memory | ||
91 | * @nr: the bit to change | ||
92 | * @addr: the address to start counting from | ||
93 | * | ||
94 | * Unlike change_bit(), this function is non-atomic and may be reordered. | ||
95 | * If it's called on the same region of memory simultaneously, the effect | ||
96 | * may be that only one operation succeeds. | ||
97 | */ | ||
98 | static inline void __change_bit(int nr, volatile unsigned long * addr) | ||
99 | { | ||
100 | __asm__ __volatile__( | ||
101 | "btcl %1,%0" | ||
102 | :"+m" (ADDR) | ||
103 | :"Ir" (nr)); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * change_bit - Toggle a bit in memory | ||
108 | * @nr: Bit to change | ||
109 | * @addr: Address to start counting from | ||
110 | * | ||
111 | * change_bit() is atomic and may not be reordered. It may be | ||
112 | * reordered on other architectures than x86. | ||
113 | * Note that @nr may be almost arbitrarily large; this function is not | ||
114 | * restricted to acting on a single-word quantity. | ||
115 | */ | ||
116 | static inline void change_bit(int nr, volatile unsigned long * addr) | ||
117 | { | ||
118 | __asm__ __volatile__( LOCK_PREFIX | ||
119 | "btcl %1,%0" | ||
120 | :"+m" (ADDR) | ||
121 | :"Ir" (nr)); | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * test_and_set_bit - Set a bit and return its old value | ||
126 | * @nr: Bit to set | ||
127 | * @addr: Address to count from | ||
128 | * | ||
129 | * This operation is atomic and cannot be reordered. | ||
130 | * It may be reordered on other architectures than x86. | ||
131 | * It also implies a memory barrier. | ||
132 | */ | ||
133 | static inline int test_and_set_bit(int nr, volatile unsigned long * addr) | ||
134 | { | ||
135 | int oldbit; | ||
136 | |||
137 | __asm__ __volatile__( LOCK_PREFIX | ||
138 | "btsl %2,%1\n\tsbbl %0,%0" | ||
139 | :"=r" (oldbit),"+m" (ADDR) | ||
140 | :"Ir" (nr) : "memory"); | ||
141 | return oldbit; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * __test_and_set_bit - Set a bit and return its old value | ||
146 | * @nr: Bit to set | ||
147 | * @addr: Address to count from | ||
148 | * | ||
149 | * This operation is non-atomic and can be reordered. | ||
150 | * If two examples of this operation race, one can appear to succeed | ||
151 | * but actually fail. You must protect multiple accesses with a lock. | ||
152 | */ | ||
153 | static inline int __test_and_set_bit(int nr, volatile unsigned long * addr) | ||
154 | { | ||
155 | int oldbit; | ||
156 | |||
157 | __asm__( | ||
158 | "btsl %2,%1\n\tsbbl %0,%0" | ||
159 | :"=r" (oldbit),"+m" (ADDR) | ||
160 | :"Ir" (nr)); | ||
161 | return oldbit; | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * test_and_clear_bit - Clear a bit and return its old value | ||
166 | * @nr: Bit to clear | ||
167 | * @addr: Address to count from | ||
168 | * | ||
169 | * This operation is atomic and cannot be reordered. | ||
170 | * It can be reorderdered on other architectures other than x86. | ||
171 | * It also implies a memory barrier. | ||
172 | */ | ||
173 | static inline int test_and_clear_bit(int nr, volatile unsigned long * addr) | ||
174 | { | ||
175 | int oldbit; | ||
176 | |||
177 | __asm__ __volatile__( LOCK_PREFIX | ||
178 | "btrl %2,%1\n\tsbbl %0,%0" | ||
179 | :"=r" (oldbit),"+m" (ADDR) | ||
180 | :"Ir" (nr) : "memory"); | ||
181 | return oldbit; | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * __test_and_clear_bit - Clear a bit and return its old value | ||
186 | * @nr: Bit to clear | ||
187 | * @addr: Address to count from | ||
188 | * | ||
189 | * This operation is non-atomic and can be reordered. | ||
190 | * If two examples of this operation race, one can appear to succeed | ||
191 | * but actually fail. You must protect multiple accesses with a lock. | ||
192 | */ | ||
193 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | ||
194 | { | ||
195 | int oldbit; | ||
196 | |||
197 | __asm__( | ||
198 | "btrl %2,%1\n\tsbbl %0,%0" | ||
199 | :"=r" (oldbit),"+m" (ADDR) | ||
200 | :"Ir" (nr)); | ||
201 | return oldbit; | ||
202 | } | ||
203 | |||
204 | /* WARNING: non atomic and it can be reordered! */ | ||
205 | static inline int __test_and_change_bit(int nr, volatile unsigned long *addr) | ||
206 | { | ||
207 | int oldbit; | ||
208 | |||
209 | __asm__ __volatile__( | ||
210 | "btcl %2,%1\n\tsbbl %0,%0" | ||
211 | :"=r" (oldbit),"+m" (ADDR) | ||
212 | :"Ir" (nr) : "memory"); | ||
213 | return oldbit; | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * test_and_change_bit - Change a bit and return its old value | ||
218 | * @nr: Bit to change | ||
219 | * @addr: Address to count from | ||
220 | * | ||
221 | * This operation is atomic and cannot be reordered. | ||
222 | * It also implies a memory barrier. | ||
223 | */ | ||
224 | static inline int test_and_change_bit(int nr, volatile unsigned long* addr) | ||
225 | { | ||
226 | int oldbit; | ||
227 | |||
228 | __asm__ __volatile__( LOCK_PREFIX | ||
229 | "btcl %2,%1\n\tsbbl %0,%0" | ||
230 | :"=r" (oldbit),"+m" (ADDR) | ||
231 | :"Ir" (nr) : "memory"); | ||
232 | return oldbit; | ||
233 | } | ||
234 | |||
235 | #if 0 /* Fool kernel-doc since it doesn't do macros yet */ | ||
236 | /** | ||
237 | * test_bit - Determine whether a bit is set | ||
238 | * @nr: bit number to test | ||
239 | * @addr: Address to start counting from | ||
240 | */ | ||
241 | static int test_bit(int nr, const volatile void * addr); | ||
242 | #endif | ||
243 | |||
244 | static __always_inline int constant_test_bit(int nr, const volatile unsigned long *addr) | ||
245 | { | ||
246 | return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0; | ||
247 | } | ||
248 | |||
249 | static inline int variable_test_bit(int nr, const volatile unsigned long * addr) | ||
250 | { | ||
251 | int oldbit; | ||
252 | |||
253 | __asm__ __volatile__( | ||
254 | "btl %2,%1\n\tsbbl %0,%0" | ||
255 | :"=r" (oldbit) | ||
256 | :"m" (ADDR),"Ir" (nr)); | ||
257 | return oldbit; | ||
258 | } | ||
259 | |||
260 | #define test_bit(nr,addr) \ | ||
261 | (__builtin_constant_p(nr) ? \ | ||
262 | constant_test_bit((nr),(addr)) : \ | ||
263 | variable_test_bit((nr),(addr))) | ||
264 | |||
265 | #undef ADDR | ||
266 | |||
267 | /** | ||
268 | * find_first_zero_bit - find the first zero bit in a memory region | ||
269 | * @addr: The address to start the search at | ||
270 | * @size: The maximum size to search | ||
271 | * | ||
272 | * Returns the bit-number of the first zero bit, not the number of the byte | ||
273 | * containing a bit. | ||
274 | */ | ||
275 | static inline int find_first_zero_bit(const unsigned long *addr, unsigned size) | ||
276 | { | ||
277 | int d0, d1, d2; | ||
278 | int res; | ||
279 | |||
280 | if (!size) | ||
281 | return 0; | ||
282 | /* This looks at memory. Mark it volatile to tell gcc not to move it around */ | ||
283 | __asm__ __volatile__( | ||
284 | "movl $-1,%%eax\n\t" | ||
285 | "xorl %%edx,%%edx\n\t" | ||
286 | "repe; scasl\n\t" | ||
287 | "je 1f\n\t" | ||
288 | "xorl -4(%%edi),%%eax\n\t" | ||
289 | "subl $4,%%edi\n\t" | ||
290 | "bsfl %%eax,%%edx\n" | ||
291 | "1:\tsubl %%ebx,%%edi\n\t" | ||
292 | "shll $3,%%edi\n\t" | ||
293 | "addl %%edi,%%edx" | ||
294 | :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2) | ||
295 | :"1" ((size + 31) >> 5), "2" (addr), "b" (addr) : "memory"); | ||
296 | return res; | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * find_next_zero_bit - find the first zero bit in a memory region | ||
301 | * @addr: The address to base the search on | ||
302 | * @offset: The bitnumber to start searching at | ||
303 | * @size: The maximum size to search | ||
304 | */ | ||
305 | int find_next_zero_bit(const unsigned long *addr, int size, int offset); | ||
306 | |||
307 | /** | ||
308 | * __ffs - find first bit in word. | ||
309 | * @word: The word to search | ||
310 | * | ||
311 | * Undefined if no bit exists, so code should check against 0 first. | ||
312 | */ | ||
313 | static inline unsigned long __ffs(unsigned long word) | ||
314 | { | ||
315 | __asm__("bsfl %1,%0" | ||
316 | :"=r" (word) | ||
317 | :"rm" (word)); | ||
318 | return word; | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * find_first_bit - find the first set bit in a memory region | ||
323 | * @addr: The address to start the search at | ||
324 | * @size: The maximum size to search | ||
325 | * | ||
326 | * Returns the bit-number of the first set bit, not the number of the byte | ||
327 | * containing a bit. | ||
328 | */ | ||
329 | static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) | ||
330 | { | ||
331 | unsigned x = 0; | ||
332 | |||
333 | while (x < size) { | ||
334 | unsigned long val = *addr++; | ||
335 | if (val) | ||
336 | return __ffs(val) + x; | ||
337 | x += (sizeof(*addr)<<3); | ||
338 | } | ||
339 | return x; | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * find_next_bit - find the first set bit in a memory region | ||
344 | * @addr: The address to base the search on | ||
345 | * @offset: The bitnumber to start searching at | ||
346 | * @size: The maximum size to search | ||
347 | */ | ||
348 | int find_next_bit(const unsigned long *addr, int size, int offset); | ||
349 | |||
350 | /** | ||
351 | * ffz - find first zero in word. | ||
352 | * @word: The word to search | ||
353 | * | ||
354 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
355 | */ | ||
356 | static inline unsigned long ffz(unsigned long word) | ||
357 | { | ||
358 | __asm__("bsfl %1,%0" | ||
359 | :"=r" (word) | ||
360 | :"r" (~word)); | ||
361 | return word; | ||
362 | } | ||
363 | |||
364 | #ifdef __KERNEL__ | ||
365 | |||
366 | #include <asm-generic/bitops/sched.h> | ||
367 | |||
368 | /** | ||
369 | * ffs - find first bit set | ||
370 | * @x: the word to search | ||
371 | * | ||
372 | * This is defined the same way as | ||
373 | * the libc and compiler builtin ffs routines, therefore | ||
374 | * differs in spirit from the above ffz() (man ffs). | ||
375 | */ | ||
376 | static inline int ffs(int x) | ||
377 | { | ||
378 | int r; | ||
379 | |||
380 | __asm__("bsfl %1,%0\n\t" | ||
381 | "jnz 1f\n\t" | ||
382 | "movl $-1,%0\n" | ||
383 | "1:" : "=r" (r) : "rm" (x)); | ||
384 | return r+1; | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * fls - find last bit set | ||
389 | * @x: the word to search | ||
390 | * | ||
391 | * This is defined the same way as ffs(). | ||
392 | */ | ||
393 | static inline int fls(int x) | ||
394 | { | ||
395 | int r; | ||
396 | |||
397 | __asm__("bsrl %1,%0\n\t" | ||
398 | "jnz 1f\n\t" | ||
399 | "movl $-1,%0\n" | ||
400 | "1:" : "=r" (r) : "rm" (x)); | ||
401 | return r+1; | ||
402 | } | ||
403 | |||
404 | #include <asm-generic/bitops/hweight.h> | ||
405 | |||
406 | #endif /* __KERNEL__ */ | ||
407 | |||
408 | #include <asm-generic/bitops/fls64.h> | ||
409 | |||
410 | #ifdef __KERNEL__ | ||
411 | |||
412 | #include <asm-generic/bitops/ext2-non-atomic.h> | ||
413 | |||
414 | #define ext2_set_bit_atomic(lock,nr,addr) \ | ||
415 | test_and_set_bit((nr),(unsigned long*)addr) | ||
416 | #define ext2_clear_bit_atomic(lock,nr, addr) \ | ||
417 | test_and_clear_bit((nr),(unsigned long*)addr) | ||
418 | |||
419 | #include <asm-generic/bitops/minix.h> | ||
420 | |||
421 | #endif /* __KERNEL__ */ | ||
422 | |||
423 | #endif /* _I386_BITOPS_H */ | ||
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h new file mode 100644 index 000000000000..d4dbbe5f7bd9 --- /dev/null +++ b/include/asm-x86/bitops_64.h | |||
@@ -0,0 +1,427 @@ | |||
1 | #ifndef _X86_64_BITOPS_H | ||
2 | #define _X86_64_BITOPS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 1992, Linus Torvalds. | ||
6 | */ | ||
7 | |||
8 | #include <asm/alternative.h> | ||
9 | |||
10 | #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) | ||
11 | /* Technically wrong, but this avoids compilation errors on some gcc | ||
12 | versions. */ | ||
13 | #define ADDR "=m" (*(volatile long *) addr) | ||
14 | #else | ||
15 | #define ADDR "+m" (*(volatile long *) addr) | ||
16 | #endif | ||
17 | |||
18 | /** | ||
19 | * set_bit - Atomically set a bit in memory | ||
20 | * @nr: the bit to set | ||
21 | * @addr: the address to start counting from | ||
22 | * | ||
23 | * This function is atomic and may not be reordered. See __set_bit() | ||
24 | * if you do not require the atomic guarantees. | ||
25 | * Note that @nr may be almost arbitrarily large; this function is not | ||
26 | * restricted to acting on a single-word quantity. | ||
27 | */ | ||
28 | static __inline__ void set_bit(int nr, volatile void * addr) | ||
29 | { | ||
30 | __asm__ __volatile__( LOCK_PREFIX | ||
31 | "btsl %1,%0" | ||
32 | :ADDR | ||
33 | :"dIr" (nr) : "memory"); | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * __set_bit - Set a bit in memory | ||
38 | * @nr: the bit to set | ||
39 | * @addr: the address to start counting from | ||
40 | * | ||
41 | * Unlike set_bit(), this function is non-atomic and may be reordered. | ||
42 | * If it's called on the same region of memory simultaneously, the effect | ||
43 | * may be that only one operation succeeds. | ||
44 | */ | ||
45 | static __inline__ void __set_bit(int nr, volatile void * addr) | ||
46 | { | ||
47 | __asm__ volatile( | ||
48 | "btsl %1,%0" | ||
49 | :ADDR | ||
50 | :"dIr" (nr) : "memory"); | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * clear_bit - Clears a bit in memory | ||
55 | * @nr: Bit to clear | ||
56 | * @addr: Address to start counting from | ||
57 | * | ||
58 | * clear_bit() is atomic and may not be reordered. However, it does | ||
59 | * not contain a memory barrier, so if it is used for locking purposes, | ||
60 | * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() | ||
61 | * in order to ensure changes are visible on other processors. | ||
62 | */ | ||
63 | static __inline__ void clear_bit(int nr, volatile void * addr) | ||
64 | { | ||
65 | __asm__ __volatile__( LOCK_PREFIX | ||
66 | "btrl %1,%0" | ||
67 | :ADDR | ||
68 | :"dIr" (nr)); | ||
69 | } | ||
70 | |||
71 | static __inline__ void __clear_bit(int nr, volatile void * addr) | ||
72 | { | ||
73 | __asm__ __volatile__( | ||
74 | "btrl %1,%0" | ||
75 | :ADDR | ||
76 | :"dIr" (nr)); | ||
77 | } | ||
78 | |||
79 | #define smp_mb__before_clear_bit() barrier() | ||
80 | #define smp_mb__after_clear_bit() barrier() | ||
81 | |||
82 | /** | ||
83 | * __change_bit - Toggle a bit in memory | ||
84 | * @nr: the bit to change | ||
85 | * @addr: the address to start counting from | ||
86 | * | ||
87 | * Unlike change_bit(), this function is non-atomic and may be reordered. | ||
88 | * If it's called on the same region of memory simultaneously, the effect | ||
89 | * may be that only one operation succeeds. | ||
90 | */ | ||
91 | static __inline__ void __change_bit(int nr, volatile void * addr) | ||
92 | { | ||
93 | __asm__ __volatile__( | ||
94 | "btcl %1,%0" | ||
95 | :ADDR | ||
96 | :"dIr" (nr)); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * change_bit - Toggle a bit in memory | ||
101 | * @nr: Bit to change | ||
102 | * @addr: Address to start counting from | ||
103 | * | ||
104 | * change_bit() is atomic and may not be reordered. | ||
105 | * Note that @nr may be almost arbitrarily large; this function is not | ||
106 | * restricted to acting on a single-word quantity. | ||
107 | */ | ||
108 | static __inline__ void change_bit(int nr, volatile void * addr) | ||
109 | { | ||
110 | __asm__ __volatile__( LOCK_PREFIX | ||
111 | "btcl %1,%0" | ||
112 | :ADDR | ||
113 | :"dIr" (nr)); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * test_and_set_bit - Set a bit and return its old value | ||
118 | * @nr: Bit to set | ||
119 | * @addr: Address to count from | ||
120 | * | ||
121 | * This operation is atomic and cannot be reordered. | ||
122 | * It also implies a memory barrier. | ||
123 | */ | ||
124 | static __inline__ int test_and_set_bit(int nr, volatile void * addr) | ||
125 | { | ||
126 | int oldbit; | ||
127 | |||
128 | __asm__ __volatile__( LOCK_PREFIX | ||
129 | "btsl %2,%1\n\tsbbl %0,%0" | ||
130 | :"=r" (oldbit),ADDR | ||
131 | :"dIr" (nr) : "memory"); | ||
132 | return oldbit; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * __test_and_set_bit - Set a bit and return its old value | ||
137 | * @nr: Bit to set | ||
138 | * @addr: Address to count from | ||
139 | * | ||
140 | * This operation is non-atomic and can be reordered. | ||
141 | * If two examples of this operation race, one can appear to succeed | ||
142 | * but actually fail. You must protect multiple accesses with a lock. | ||
143 | */ | ||
144 | static __inline__ int __test_and_set_bit(int nr, volatile void * addr) | ||
145 | { | ||
146 | int oldbit; | ||
147 | |||
148 | __asm__( | ||
149 | "btsl %2,%1\n\tsbbl %0,%0" | ||
150 | :"=r" (oldbit),ADDR | ||
151 | :"dIr" (nr)); | ||
152 | return oldbit; | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * test_and_clear_bit - Clear a bit and return its old value | ||
157 | * @nr: Bit to clear | ||
158 | * @addr: Address to count from | ||
159 | * | ||
160 | * This operation is atomic and cannot be reordered. | ||
161 | * It also implies a memory barrier. | ||
162 | */ | ||
163 | static __inline__ int test_and_clear_bit(int nr, volatile void * addr) | ||
164 | { | ||
165 | int oldbit; | ||
166 | |||
167 | __asm__ __volatile__( LOCK_PREFIX | ||
168 | "btrl %2,%1\n\tsbbl %0,%0" | ||
169 | :"=r" (oldbit),ADDR | ||
170 | :"dIr" (nr) : "memory"); | ||
171 | return oldbit; | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * __test_and_clear_bit - Clear a bit and return its old value | ||
176 | * @nr: Bit to clear | ||
177 | * @addr: Address to count from | ||
178 | * | ||
179 | * This operation is non-atomic and can be reordered. | ||
180 | * If two examples of this operation race, one can appear to succeed | ||
181 | * but actually fail. You must protect multiple accesses with a lock. | ||
182 | */ | ||
183 | static __inline__ int __test_and_clear_bit(int nr, volatile void * addr) | ||
184 | { | ||
185 | int oldbit; | ||
186 | |||
187 | __asm__( | ||
188 | "btrl %2,%1\n\tsbbl %0,%0" | ||
189 | :"=r" (oldbit),ADDR | ||
190 | :"dIr" (nr)); | ||
191 | return oldbit; | ||
192 | } | ||
193 | |||
194 | /* WARNING: non atomic and it can be reordered! */ | ||
195 | static __inline__ int __test_and_change_bit(int nr, volatile void * addr) | ||
196 | { | ||
197 | int oldbit; | ||
198 | |||
199 | __asm__ __volatile__( | ||
200 | "btcl %2,%1\n\tsbbl %0,%0" | ||
201 | :"=r" (oldbit),ADDR | ||
202 | :"dIr" (nr) : "memory"); | ||
203 | return oldbit; | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * test_and_change_bit - Change a bit and return its old value | ||
208 | * @nr: Bit to change | ||
209 | * @addr: Address to count from | ||
210 | * | ||
211 | * This operation is atomic and cannot be reordered. | ||
212 | * It also implies a memory barrier. | ||
213 | */ | ||
214 | static __inline__ int test_and_change_bit(int nr, volatile void * addr) | ||
215 | { | ||
216 | int oldbit; | ||
217 | |||
218 | __asm__ __volatile__( LOCK_PREFIX | ||
219 | "btcl %2,%1\n\tsbbl %0,%0" | ||
220 | :"=r" (oldbit),ADDR | ||
221 | :"dIr" (nr) : "memory"); | ||
222 | return oldbit; | ||
223 | } | ||
224 | |||
225 | #if 0 /* Fool kernel-doc since it doesn't do macros yet */ | ||
226 | /** | ||
227 | * test_bit - Determine whether a bit is set | ||
228 | * @nr: bit number to test | ||
229 | * @addr: Address to start counting from | ||
230 | */ | ||
231 | static int test_bit(int nr, const volatile void * addr); | ||
232 | #endif | ||
233 | |||
234 | static __inline__ int constant_test_bit(int nr, const volatile void * addr) | ||
235 | { | ||
236 | return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0; | ||
237 | } | ||
238 | |||
239 | static __inline__ int variable_test_bit(int nr, volatile const void * addr) | ||
240 | { | ||
241 | int oldbit; | ||
242 | |||
243 | __asm__ __volatile__( | ||
244 | "btl %2,%1\n\tsbbl %0,%0" | ||
245 | :"=r" (oldbit) | ||
246 | :"m" (*(volatile long *)addr),"dIr" (nr)); | ||
247 | return oldbit; | ||
248 | } | ||
249 | |||
250 | #define test_bit(nr,addr) \ | ||
251 | (__builtin_constant_p(nr) ? \ | ||
252 | constant_test_bit((nr),(addr)) : \ | ||
253 | variable_test_bit((nr),(addr))) | ||
254 | |||
255 | #undef ADDR | ||
256 | |||
257 | extern long find_first_zero_bit(const unsigned long * addr, unsigned long size); | ||
258 | extern long find_next_zero_bit (const unsigned long * addr, long size, long offset); | ||
259 | extern long find_first_bit(const unsigned long * addr, unsigned long size); | ||
260 | extern long find_next_bit(const unsigned long * addr, long size, long offset); | ||
261 | |||
262 | /* return index of first bet set in val or max when no bit is set */ | ||
263 | static inline unsigned long __scanbit(unsigned long val, unsigned long max) | ||
264 | { | ||
265 | asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max)); | ||
266 | return val; | ||
267 | } | ||
268 | |||
269 | #define find_first_bit(addr,size) \ | ||
270 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
271 | (__scanbit(*(unsigned long *)addr,(size))) : \ | ||
272 | find_first_bit(addr,size))) | ||
273 | |||
274 | #define find_next_bit(addr,size,off) \ | ||
275 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
276 | ((off) + (__scanbit((*(unsigned long *)addr) >> (off),(size)-(off)))) : \ | ||
277 | find_next_bit(addr,size,off))) | ||
278 | |||
279 | #define find_first_zero_bit(addr,size) \ | ||
280 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
281 | (__scanbit(~*(unsigned long *)addr,(size))) : \ | ||
282 | find_first_zero_bit(addr,size))) | ||
283 | |||
284 | #define find_next_zero_bit(addr,size,off) \ | ||
285 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
286 | ((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off)),(size)-(off)))) : \ | ||
287 | find_next_zero_bit(addr,size,off))) | ||
288 | |||
289 | /* | ||
290 | * Find string of zero bits in a bitmap. -1 when not found. | ||
291 | */ | ||
292 | extern unsigned long | ||
293 | find_next_zero_string(unsigned long *bitmap, long start, long nbits, int len); | ||
294 | |||
295 | static inline void set_bit_string(unsigned long *bitmap, unsigned long i, | ||
296 | int len) | ||
297 | { | ||
298 | unsigned long end = i + len; | ||
299 | while (i < end) { | ||
300 | __set_bit(i, bitmap); | ||
301 | i++; | ||
302 | } | ||
303 | } | ||
304 | |||
305 | static inline void __clear_bit_string(unsigned long *bitmap, unsigned long i, | ||
306 | int len) | ||
307 | { | ||
308 | unsigned long end = i + len; | ||
309 | while (i < end) { | ||
310 | __clear_bit(i, bitmap); | ||
311 | i++; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * ffz - find first zero in word. | ||
317 | * @word: The word to search | ||
318 | * | ||
319 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
320 | */ | ||
321 | static __inline__ unsigned long ffz(unsigned long word) | ||
322 | { | ||
323 | __asm__("bsfq %1,%0" | ||
324 | :"=r" (word) | ||
325 | :"r" (~word)); | ||
326 | return word; | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * __ffs - find first bit in word. | ||
331 | * @word: The word to search | ||
332 | * | ||
333 | * Undefined if no bit exists, so code should check against 0 first. | ||
334 | */ | ||
335 | static __inline__ unsigned long __ffs(unsigned long word) | ||
336 | { | ||
337 | __asm__("bsfq %1,%0" | ||
338 | :"=r" (word) | ||
339 | :"rm" (word)); | ||
340 | return word; | ||
341 | } | ||
342 | |||
343 | /* | ||
344 | * __fls: find last bit set. | ||
345 | * @word: The word to search | ||
346 | * | ||
347 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
348 | */ | ||
349 | static __inline__ unsigned long __fls(unsigned long word) | ||
350 | { | ||
351 | __asm__("bsrq %1,%0" | ||
352 | :"=r" (word) | ||
353 | :"rm" (word)); | ||
354 | return word; | ||
355 | } | ||
356 | |||
357 | #ifdef __KERNEL__ | ||
358 | |||
359 | #include <asm-generic/bitops/sched.h> | ||
360 | |||
361 | /** | ||
362 | * ffs - find first bit set | ||
363 | * @x: the word to search | ||
364 | * | ||
365 | * This is defined the same way as | ||
366 | * the libc and compiler builtin ffs routines, therefore | ||
367 | * differs in spirit from the above ffz (man ffs). | ||
368 | */ | ||
369 | static __inline__ int ffs(int x) | ||
370 | { | ||
371 | int r; | ||
372 | |||
373 | __asm__("bsfl %1,%0\n\t" | ||
374 | "cmovzl %2,%0" | ||
375 | : "=r" (r) : "rm" (x), "r" (-1)); | ||
376 | return r+1; | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * fls64 - find last bit set in 64 bit word | ||
381 | * @x: the word to search | ||
382 | * | ||
383 | * This is defined the same way as fls. | ||
384 | */ | ||
385 | static __inline__ int fls64(__u64 x) | ||
386 | { | ||
387 | if (x == 0) | ||
388 | return 0; | ||
389 | return __fls(x) + 1; | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * fls - find last bit set | ||
394 | * @x: the word to search | ||
395 | * | ||
396 | * This is defined the same way as ffs. | ||
397 | */ | ||
398 | static __inline__ int fls(int x) | ||
399 | { | ||
400 | int r; | ||
401 | |||
402 | __asm__("bsrl %1,%0\n\t" | ||
403 | "cmovzl %2,%0" | ||
404 | : "=&r" (r) : "rm" (x), "rm" (-1)); | ||
405 | return r+1; | ||
406 | } | ||
407 | |||
408 | #define ARCH_HAS_FAST_MULTIPLIER 1 | ||
409 | |||
410 | #include <asm-generic/bitops/hweight.h> | ||
411 | |||
412 | #endif /* __KERNEL__ */ | ||
413 | |||
414 | #ifdef __KERNEL__ | ||
415 | |||
416 | #include <asm-generic/bitops/ext2-non-atomic.h> | ||
417 | |||
418 | #define ext2_set_bit_atomic(lock,nr,addr) \ | ||
419 | test_and_set_bit((nr),(unsigned long*)addr) | ||
420 | #define ext2_clear_bit_atomic(lock,nr,addr) \ | ||
421 | test_and_clear_bit((nr),(unsigned long*)addr) | ||
422 | |||
423 | #include <asm-generic/bitops/minix.h> | ||
424 | |||
425 | #endif /* __KERNEL__ */ | ||
426 | |||
427 | #endif /* _X86_64_BITOPS_H */ | ||
diff --git a/include/asm-x86/boot.h b/include/asm-x86/boot.h new file mode 100644 index 000000000000..ed8affbf96cb --- /dev/null +++ b/include/asm-x86/boot.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_BOOT_H | ||
2 | #define _ASM_BOOT_H | ||
3 | |||
4 | /* Don't touch these, unless you really know what you're doing. */ | ||
5 | #define DEF_INITSEG 0x9000 | ||
6 | #define DEF_SYSSEG 0x1000 | ||
7 | #define DEF_SETUPSEG 0x9020 | ||
8 | #define DEF_SYSSIZE 0x7F00 | ||
9 | |||
10 | /* Internal svga startup constants */ | ||
11 | #define NORMAL_VGA 0xffff /* 80x25 mode */ | ||
12 | #define EXTENDED_VGA 0xfffe /* 80x50 mode */ | ||
13 | #define ASK_VGA 0xfffd /* ask for it at bootup */ | ||
14 | |||
15 | /* Physical address where kernel should be loaded. */ | ||
16 | #define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \ | ||
17 | + (CONFIG_PHYSICAL_ALIGN - 1)) \ | ||
18 | & ~(CONFIG_PHYSICAL_ALIGN - 1)) | ||
19 | |||
20 | #endif /* _ASM_BOOT_H */ | ||
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h new file mode 100644 index 000000000000..b91b01783e4b --- /dev/null +++ b/include/asm-x86/bootparam.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef _ASM_BOOTPARAM_H | ||
2 | #define _ASM_BOOTPARAM_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/screen_info.h> | ||
6 | #include <linux/apm_bios.h> | ||
7 | #include <linux/edd.h> | ||
8 | #include <asm/e820.h> | ||
9 | #include <asm/ist.h> | ||
10 | #include <video/edid.h> | ||
11 | |||
12 | struct setup_header { | ||
13 | u8 setup_sects; | ||
14 | u16 root_flags; | ||
15 | u32 syssize; | ||
16 | u16 ram_size; | ||
17 | u16 vid_mode; | ||
18 | u16 root_dev; | ||
19 | u16 boot_flag; | ||
20 | u16 jump; | ||
21 | u32 header; | ||
22 | u16 version; | ||
23 | u32 realmode_swtch; | ||
24 | u16 start_sys; | ||
25 | u16 kernel_version; | ||
26 | u8 type_of_loader; | ||
27 | u8 loadflags; | ||
28 | #define LOADED_HIGH 0x01 | ||
29 | #define CAN_USE_HEAP 0x80 | ||
30 | u16 setup_move_size; | ||
31 | u32 code32_start; | ||
32 | u32 ramdisk_image; | ||
33 | u32 ramdisk_size; | ||
34 | u32 bootsect_kludge; | ||
35 | u16 heap_end_ptr; | ||
36 | u16 _pad1; | ||
37 | u32 cmd_line_ptr; | ||
38 | u32 initrd_addr_max; | ||
39 | u32 kernel_alignment; | ||
40 | u8 relocatable_kernel; | ||
41 | } __attribute__((packed)); | ||
42 | |||
43 | struct sys_desc_table { | ||
44 | u16 length; | ||
45 | u8 table[14]; | ||
46 | }; | ||
47 | |||
48 | struct efi_info { | ||
49 | u32 _pad1; | ||
50 | u32 efi_systab; | ||
51 | u32 efi_memdesc_size; | ||
52 | u32 efi_memdesc_version; | ||
53 | u32 efi_memmap; | ||
54 | u32 efi_memmap_size; | ||
55 | u32 _pad2[2]; | ||
56 | }; | ||
57 | |||
58 | /* The so-called "zeropage" */ | ||
59 | struct boot_params { | ||
60 | struct screen_info screen_info; /* 0x000 */ | ||
61 | struct apm_bios_info apm_bios_info; /* 0x040 */ | ||
62 | u8 _pad2[12]; /* 0x054 */ | ||
63 | struct ist_info ist_info; /* 0x060 */ | ||
64 | u8 _pad3[16]; /* 0x070 */ | ||
65 | u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ | ||
66 | u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ | ||
67 | struct sys_desc_table sys_desc_table; /* 0x0a0 */ | ||
68 | u8 _pad4[144]; /* 0x0b0 */ | ||
69 | struct edid_info edid_info; /* 0x140 */ | ||
70 | struct efi_info efi_info; /* 0x1c0 */ | ||
71 | u32 alt_mem_k; /* 0x1e0 */ | ||
72 | u32 scratch; /* Scratch field! */ /* 0x1e4 */ | ||
73 | u8 e820_entries; /* 0x1e8 */ | ||
74 | u8 eddbuf_entries; /* 0x1e9 */ | ||
75 | u8 edd_mbr_sig_buf_entries; /* 0x1ea */ | ||
76 | u8 _pad6[6]; /* 0x1eb */ | ||
77 | struct setup_header hdr; /* setup header */ /* 0x1f1 */ | ||
78 | u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; | ||
79 | u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ | ||
80 | struct e820entry e820_map[E820MAX]; /* 0x2d0 */ | ||
81 | u8 _pad8[48]; /* 0xcd0 */ | ||
82 | struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ | ||
83 | u8 _pad9[276]; /* 0xeec */ | ||
84 | } __attribute__((packed)); | ||
85 | |||
86 | #endif /* _ASM_BOOTPARAM_H */ | ||
diff --git a/include/asm-x86/bootsetup.h b/include/asm-x86/bootsetup.h new file mode 100644 index 000000000000..7b1c3ad155fd --- /dev/null +++ b/include/asm-x86/bootsetup.h | |||
@@ -0,0 +1,40 @@ | |||
1 | |||
2 | #ifndef _X86_64_BOOTSETUP_H | ||
3 | #define _X86_64_BOOTSETUP_H 1 | ||
4 | |||
5 | #define BOOT_PARAM_SIZE 4096 | ||
6 | extern char x86_boot_params[BOOT_PARAM_SIZE]; | ||
7 | |||
8 | /* | ||
9 | * This is set up by the setup-routine at boot-time | ||
10 | */ | ||
11 | #define PARAM ((unsigned char *)x86_boot_params) | ||
12 | #define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) | ||
13 | #define EXT_MEM_K (*(unsigned short *) (PARAM+2)) | ||
14 | #define ALT_MEM_K (*(unsigned int *) (PARAM+0x1e0)) | ||
15 | #define E820_MAP_NR (*(char*) (PARAM+E820NR)) | ||
16 | #define E820_MAP ((struct e820entry *) (PARAM+E820MAP)) | ||
17 | #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40)) | ||
18 | #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80)) | ||
19 | #define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0)) | ||
20 | #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2)) | ||
21 | #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8)) | ||
22 | #define SAVED_VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA)) | ||
23 | #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC)) | ||
24 | #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF)) | ||
25 | #define LOADER_TYPE (*(unsigned char *) (PARAM+0x210)) | ||
26 | #define KERNEL_START (*(unsigned int *) (PARAM+0x214)) | ||
27 | #define INITRD_START (*(unsigned int *) (PARAM+0x218)) | ||
28 | #define INITRD_SIZE (*(unsigned int *) (PARAM+0x21c)) | ||
29 | #define EDID_INFO (*(struct edid_info *) (PARAM+0x140)) | ||
30 | #define EDD_NR (*(unsigned char *) (PARAM+EDDNR)) | ||
31 | #define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF)) | ||
32 | #define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF)) | ||
33 | #define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF)) | ||
34 | #define COMMAND_LINE boot_command_line | ||
35 | |||
36 | #define RAMDISK_IMAGE_START_MASK 0x07FF | ||
37 | #define RAMDISK_PROMPT_FLAG 0x8000 | ||
38 | #define RAMDISK_LOAD_FLAG 0x4000 | ||
39 | |||
40 | #endif | ||
diff --git a/include/asm-x86/bug.h b/include/asm-x86/bug.h new file mode 100644 index 000000000000..c655d7f3a5e0 --- /dev/null +++ b/include/asm-x86/bug.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "bug_32.h" | ||
3 | #else | ||
4 | # include "bug_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/bug_32.h b/include/asm-x86/bug_32.h new file mode 100644 index 000000000000..b0fd78ca2619 --- /dev/null +++ b/include/asm-x86/bug_32.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef _I386_BUG_H | ||
2 | #define _I386_BUG_H | ||
3 | |||
4 | |||
5 | /* | ||
6 | * Tell the user there is some problem. | ||
7 | * The offending file and line are encoded encoded in the __bug_table section. | ||
8 | */ | ||
9 | |||
10 | #ifdef CONFIG_BUG | ||
11 | #define HAVE_ARCH_BUG | ||
12 | |||
13 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
14 | #define BUG() \ | ||
15 | do { \ | ||
16 | asm volatile("1:\tud2\n" \ | ||
17 | ".pushsection __bug_table,\"a\"\n" \ | ||
18 | "2:\t.long 1b, %c0\n" \ | ||
19 | "\t.word %c1, 0\n" \ | ||
20 | "\t.org 2b+%c2\n" \ | ||
21 | ".popsection" \ | ||
22 | : : "i" (__FILE__), "i" (__LINE__), \ | ||
23 | "i" (sizeof(struct bug_entry))); \ | ||
24 | for(;;) ; \ | ||
25 | } while(0) | ||
26 | |||
27 | #else | ||
28 | #define BUG() \ | ||
29 | do { \ | ||
30 | asm volatile("ud2"); \ | ||
31 | for(;;) ; \ | ||
32 | } while(0) | ||
33 | #endif | ||
34 | #endif | ||
35 | |||
36 | #include <asm-generic/bug.h> | ||
37 | #endif | ||
diff --git a/include/asm-x86/bug_64.h b/include/asm-x86/bug_64.h new file mode 100644 index 000000000000..682606414913 --- /dev/null +++ b/include/asm-x86/bug_64.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef __ASM_X8664_BUG_H | ||
2 | #define __ASM_X8664_BUG_H 1 | ||
3 | |||
4 | #ifdef CONFIG_BUG | ||
5 | #define HAVE_ARCH_BUG | ||
6 | |||
7 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
8 | #define BUG() \ | ||
9 | do { \ | ||
10 | asm volatile("1:\tud2\n" \ | ||
11 | ".pushsection __bug_table,\"a\"\n" \ | ||
12 | "2:\t.quad 1b, %c0\n" \ | ||
13 | "\t.word %c1, 0\n" \ | ||
14 | "\t.org 2b+%c2\n" \ | ||
15 | ".popsection" \ | ||
16 | : : "i" (__FILE__), "i" (__LINE__), \ | ||
17 | "i" (sizeof(struct bug_entry))); \ | ||
18 | for(;;) ; \ | ||
19 | } while(0) | ||
20 | #else | ||
21 | #define BUG() \ | ||
22 | do { \ | ||
23 | asm volatile("ud2"); \ | ||
24 | for(;;) ; \ | ||
25 | } while(0) | ||
26 | #endif | ||
27 | |||
28 | void out_of_line_bug(void); | ||
29 | #else | ||
30 | static inline void out_of_line_bug(void) { } | ||
31 | #endif | ||
32 | |||
33 | #include <asm-generic/bug.h> | ||
34 | #endif | ||
diff --git a/include/asm-x86/bugs.h b/include/asm-x86/bugs.h new file mode 100644 index 000000000000..ddf42d36dd50 --- /dev/null +++ b/include/asm-x86/bugs.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "bugs_32.h" | ||
3 | #else | ||
4 | # include "bugs_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/bugs_32.h b/include/asm-x86/bugs_32.h new file mode 100644 index 000000000000..d28979ff73be --- /dev/null +++ b/include/asm-x86/bugs_32.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* | ||
2 | * This is included by init/main.c to check for architecture-dependent bugs. | ||
3 | * | ||
4 | * Needs: | ||
5 | * void check_bugs(void); | ||
6 | */ | ||
7 | #ifndef _ASM_I386_BUG_H | ||
8 | #define _ASM_I386_BUG_H | ||
9 | |||
10 | void check_bugs(void); | ||
11 | |||
12 | #endif /* _ASM_I386_BUG_H */ | ||
diff --git a/include/asm-x86/bugs_64.h b/include/asm-x86/bugs_64.h new file mode 100644 index 000000000000..b33dc04d8f42 --- /dev/null +++ b/include/asm-x86/bugs_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_X86_64_BUGS_H | ||
2 | #define _ASM_X86_64_BUGS_H | ||
3 | |||
4 | void check_bugs(void); | ||
5 | |||
6 | #endif /* _ASM_X86_64_BUGS_H */ | ||
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h new file mode 100644 index 000000000000..eb14b1870ed7 --- /dev/null +++ b/include/asm-x86/byteorder.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "byteorder_32.h" | ||
4 | # else | ||
5 | # include "byteorder_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "byteorder_32.h" | ||
10 | # else | ||
11 | # include "byteorder_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/byteorder_32.h b/include/asm-x86/byteorder_32.h new file mode 100644 index 000000000000..a45470a8b74a --- /dev/null +++ b/include/asm-x86/byteorder_32.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef _I386_BYTEORDER_H | ||
2 | #define _I386_BYTEORDER_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | #ifdef __GNUC__ | ||
8 | |||
9 | /* For avoiding bswap on i386 */ | ||
10 | #ifdef __KERNEL__ | ||
11 | #endif | ||
12 | |||
13 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
14 | { | ||
15 | #ifdef CONFIG_X86_BSWAP | ||
16 | __asm__("bswap %0" : "=r" (x) : "0" (x)); | ||
17 | #else | ||
18 | __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ | ||
19 | "rorl $16,%0\n\t" /* swap words */ | ||
20 | "xchgb %b0,%h0" /* swap higher bytes */ | ||
21 | :"=q" (x) | ||
22 | : "0" (x)); | ||
23 | #endif | ||
24 | return x; | ||
25 | } | ||
26 | |||
27 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) | ||
28 | { | ||
29 | union { | ||
30 | struct { __u32 a,b; } s; | ||
31 | __u64 u; | ||
32 | } v; | ||
33 | v.u = val; | ||
34 | #ifdef CONFIG_X86_BSWAP | ||
35 | asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" | ||
36 | : "=r" (v.s.a), "=r" (v.s.b) | ||
37 | : "0" (v.s.a), "1" (v.s.b)); | ||
38 | #else | ||
39 | v.s.a = ___arch__swab32(v.s.a); | ||
40 | v.s.b = ___arch__swab32(v.s.b); | ||
41 | asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); | ||
42 | #endif | ||
43 | return v.u; | ||
44 | } | ||
45 | |||
46 | /* Do not define swab16. Gcc is smart enough to recognize "C" version and | ||
47 | convert it into rotation or exhange. */ | ||
48 | |||
49 | #define __arch__swab64(x) ___arch__swab64(x) | ||
50 | #define __arch__swab32(x) ___arch__swab32(x) | ||
51 | |||
52 | #define __BYTEORDER_HAS_U64__ | ||
53 | |||
54 | #endif /* __GNUC__ */ | ||
55 | |||
56 | #include <linux/byteorder/little_endian.h> | ||
57 | |||
58 | #endif /* _I386_BYTEORDER_H */ | ||
diff --git a/include/asm-x86/byteorder_64.h b/include/asm-x86/byteorder_64.h new file mode 100644 index 000000000000..5e86c868c75e --- /dev/null +++ b/include/asm-x86/byteorder_64.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _X86_64_BYTEORDER_H | ||
2 | #define _X86_64_BYTEORDER_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | #ifdef __GNUC__ | ||
8 | |||
9 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) | ||
10 | { | ||
11 | __asm__("bswapq %0" : "=r" (x) : "0" (x)); | ||
12 | return x; | ||
13 | } | ||
14 | |||
15 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
16 | { | ||
17 | __asm__("bswapl %0" : "=r" (x) : "0" (x)); | ||
18 | return x; | ||
19 | } | ||
20 | |||
21 | /* Do not define swab16. Gcc is smart enough to recognize "C" version and | ||
22 | convert it into rotation or exhange. */ | ||
23 | |||
24 | #define __arch__swab32(x) ___arch__swab32(x) | ||
25 | #define __arch__swab64(x) ___arch__swab64(x) | ||
26 | |||
27 | #endif /* __GNUC__ */ | ||
28 | |||
29 | #define __BYTEORDER_HAS_U64__ | ||
30 | |||
31 | #include <linux/byteorder/little_endian.h> | ||
32 | |||
33 | #endif /* _X86_64_BYTEORDER_H */ | ||
diff --git a/include/asm-x86/cache.h b/include/asm-x86/cache.h new file mode 100644 index 000000000000..c36d190ac9d8 --- /dev/null +++ b/include/asm-x86/cache.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "cache_32.h" | ||
3 | #else | ||
4 | # include "cache_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/cache_32.h b/include/asm-x86/cache_32.h new file mode 100644 index 000000000000..57c62f414158 --- /dev/null +++ b/include/asm-x86/cache_32.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * include/asm-i386/cache.h | ||
3 | */ | ||
4 | #ifndef __ARCH_I386_CACHE_H | ||
5 | #define __ARCH_I386_CACHE_H | ||
6 | |||
7 | |||
8 | /* L1 cache line size */ | ||
9 | #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) | ||
10 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) | ||
11 | |||
12 | #define __read_mostly __attribute__((__section__(".data.read_mostly"))) | ||
13 | |||
14 | #endif | ||
diff --git a/include/asm-x86/cache_64.h b/include/asm-x86/cache_64.h new file mode 100644 index 000000000000..052df758ae61 --- /dev/null +++ b/include/asm-x86/cache_64.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/cache.h | ||
3 | */ | ||
4 | #ifndef __ARCH_X8664_CACHE_H | ||
5 | #define __ARCH_X8664_CACHE_H | ||
6 | |||
7 | |||
8 | /* L1 cache line size */ | ||
9 | #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) | ||
10 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) | ||
11 | |||
12 | #ifdef CONFIG_X86_VSMP | ||
13 | |||
14 | /* vSMP Internode cacheline shift */ | ||
15 | #define INTERNODE_CACHE_SHIFT (12) | ||
16 | #ifdef CONFIG_SMP | ||
17 | #define __cacheline_aligned_in_smp \ | ||
18 | __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT)))) \ | ||
19 | __attribute__((__section__(".data.page_aligned"))) | ||
20 | #endif | ||
21 | |||
22 | #endif | ||
23 | |||
24 | #define __read_mostly __attribute__((__section__(".data.read_mostly"))) | ||
25 | |||
26 | #endif | ||
diff --git a/include/asm-x86/cacheflush.h b/include/asm-x86/cacheflush.h new file mode 100644 index 000000000000..e2df3b55034a --- /dev/null +++ b/include/asm-x86/cacheflush.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "cacheflush_32.h" | ||
3 | #else | ||
4 | # include "cacheflush_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/cacheflush_32.h b/include/asm-x86/cacheflush_32.h new file mode 100644 index 000000000000..74e03c8f2e51 --- /dev/null +++ b/include/asm-x86/cacheflush_32.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef _I386_CACHEFLUSH_H | ||
2 | #define _I386_CACHEFLUSH_H | ||
3 | |||
4 | /* Keep includes the same across arches. */ | ||
5 | #include <linux/mm.h> | ||
6 | |||
7 | /* Caches aren't brain-dead on the intel. */ | ||
8 | #define flush_cache_all() do { } while (0) | ||
9 | #define flush_cache_mm(mm) do { } while (0) | ||
10 | #define flush_cache_dup_mm(mm) do { } while (0) | ||
11 | #define flush_cache_range(vma, start, end) do { } while (0) | ||
12 | #define flush_cache_page(vma, vmaddr, pfn) do { } while (0) | ||
13 | #define flush_dcache_page(page) do { } while (0) | ||
14 | #define flush_dcache_mmap_lock(mapping) do { } while (0) | ||
15 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) | ||
16 | #define flush_icache_range(start, end) do { } while (0) | ||
17 | #define flush_icache_page(vma,pg) do { } while (0) | ||
18 | #define flush_icache_user_range(vma,pg,adr,len) do { } while (0) | ||
19 | #define flush_cache_vmap(start, end) do { } while (0) | ||
20 | #define flush_cache_vunmap(start, end) do { } while (0) | ||
21 | |||
22 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ | ||
23 | memcpy(dst, src, len) | ||
24 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ | ||
25 | memcpy(dst, src, len) | ||
26 | |||
27 | void global_flush_tlb(void); | ||
28 | int change_page_attr(struct page *page, int numpages, pgprot_t prot); | ||
29 | |||
30 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
31 | /* internal debugging function */ | ||
32 | void kernel_map_pages(struct page *page, int numpages, int enable); | ||
33 | #endif | ||
34 | |||
35 | #ifdef CONFIG_DEBUG_RODATA | ||
36 | void mark_rodata_ro(void); | ||
37 | #endif | ||
38 | |||
39 | #endif /* _I386_CACHEFLUSH_H */ | ||
diff --git a/include/asm-x86/cacheflush_64.h b/include/asm-x86/cacheflush_64.h new file mode 100644 index 000000000000..ab1cb5c7dc92 --- /dev/null +++ b/include/asm-x86/cacheflush_64.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef _X8664_CACHEFLUSH_H | ||
2 | #define _X8664_CACHEFLUSH_H | ||
3 | |||
4 | /* Keep includes the same across arches. */ | ||
5 | #include <linux/mm.h> | ||
6 | |||
7 | /* Caches aren't brain-dead on the intel. */ | ||
8 | #define flush_cache_all() do { } while (0) | ||
9 | #define flush_cache_mm(mm) do { } while (0) | ||
10 | #define flush_cache_dup_mm(mm) do { } while (0) | ||
11 | #define flush_cache_range(vma, start, end) do { } while (0) | ||
12 | #define flush_cache_page(vma, vmaddr, pfn) do { } while (0) | ||
13 | #define flush_dcache_page(page) do { } while (0) | ||
14 | #define flush_dcache_mmap_lock(mapping) do { } while (0) | ||
15 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) | ||
16 | #define flush_icache_range(start, end) do { } while (0) | ||
17 | #define flush_icache_page(vma,pg) do { } while (0) | ||
18 | #define flush_icache_user_range(vma,pg,adr,len) do { } while (0) | ||
19 | #define flush_cache_vmap(start, end) do { } while (0) | ||
20 | #define flush_cache_vunmap(start, end) do { } while (0) | ||
21 | |||
22 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ | ||
23 | memcpy(dst, src, len) | ||
24 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ | ||
25 | memcpy(dst, src, len) | ||
26 | |||
27 | void global_flush_tlb(void); | ||
28 | int change_page_attr(struct page *page, int numpages, pgprot_t prot); | ||
29 | int change_page_attr_addr(unsigned long addr, int numpages, pgprot_t prot); | ||
30 | |||
31 | #ifdef CONFIG_DEBUG_RODATA | ||
32 | void mark_rodata_ro(void); | ||
33 | #endif | ||
34 | |||
35 | #endif /* _X8664_CACHEFLUSH_H */ | ||
diff --git a/include/asm-x86/calgary.h b/include/asm-x86/calgary.h new file mode 100644 index 000000000000..67f60406e2d8 --- /dev/null +++ b/include/asm-x86/calgary.h | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Derived from include/asm-powerpc/iommu.h | ||
3 | * | ||
4 | * Copyright IBM Corporation, 2006-2007 | ||
5 | * | ||
6 | * Author: Jon Mason <jdmason@us.ibm.com> | ||
7 | * Author: Muli Ben-Yehuda <muli@il.ibm.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #ifndef _ASM_X86_64_CALGARY_H | ||
25 | #define _ASM_X86_64_CALGARY_H | ||
26 | |||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <linux/dma-mapping.h> | ||
30 | #include <linux/timer.h> | ||
31 | #include <asm/types.h> | ||
32 | |||
33 | struct iommu_table { | ||
34 | struct cal_chipset_ops *chip_ops; /* chipset specific funcs */ | ||
35 | unsigned long it_base; /* mapped address of tce table */ | ||
36 | unsigned long it_hint; /* Hint for next alloc */ | ||
37 | unsigned long *it_map; /* A simple allocation bitmap for now */ | ||
38 | void __iomem *bbar; /* Bridge BAR */ | ||
39 | u64 tar_val; /* Table Address Register */ | ||
40 | struct timer_list watchdog_timer; | ||
41 | spinlock_t it_lock; /* Protects it_map */ | ||
42 | unsigned int it_size; /* Size of iommu table in entries */ | ||
43 | unsigned char it_busno; /* Bus number this table belongs to */ | ||
44 | }; | ||
45 | |||
46 | struct cal_chipset_ops { | ||
47 | void (*handle_quirks)(struct iommu_table *tbl, struct pci_dev *dev); | ||
48 | void (*tce_cache_blast)(struct iommu_table *tbl); | ||
49 | void (*dump_error_regs)(struct iommu_table *tbl); | ||
50 | }; | ||
51 | |||
52 | #define TCE_TABLE_SIZE_UNSPECIFIED ~0 | ||
53 | #define TCE_TABLE_SIZE_64K 0 | ||
54 | #define TCE_TABLE_SIZE_128K 1 | ||
55 | #define TCE_TABLE_SIZE_256K 2 | ||
56 | #define TCE_TABLE_SIZE_512K 3 | ||
57 | #define TCE_TABLE_SIZE_1M 4 | ||
58 | #define TCE_TABLE_SIZE_2M 5 | ||
59 | #define TCE_TABLE_SIZE_4M 6 | ||
60 | #define TCE_TABLE_SIZE_8M 7 | ||
61 | |||
62 | extern int use_calgary; | ||
63 | |||
64 | #ifdef CONFIG_CALGARY_IOMMU | ||
65 | extern int calgary_iommu_init(void); | ||
66 | extern void detect_calgary(void); | ||
67 | #else | ||
68 | static inline int calgary_iommu_init(void) { return 1; } | ||
69 | static inline void detect_calgary(void) { return; } | ||
70 | #endif | ||
71 | |||
72 | #endif /* _ASM_X86_64_CALGARY_H */ | ||
diff --git a/include/asm-x86/calling.h b/include/asm-x86/calling.h new file mode 100644 index 000000000000..6f4f63af96e1 --- /dev/null +++ b/include/asm-x86/calling.h | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * Some macros to handle stack frames in assembly. | ||
3 | */ | ||
4 | |||
5 | |||
6 | #define R15 0 | ||
7 | #define R14 8 | ||
8 | #define R13 16 | ||
9 | #define R12 24 | ||
10 | #define RBP 32 | ||
11 | #define RBX 40 | ||
12 | /* arguments: interrupts/non tracing syscalls only save upto here*/ | ||
13 | #define R11 48 | ||
14 | #define R10 56 | ||
15 | #define R9 64 | ||
16 | #define R8 72 | ||
17 | #define RAX 80 | ||
18 | #define RCX 88 | ||
19 | #define RDX 96 | ||
20 | #define RSI 104 | ||
21 | #define RDI 112 | ||
22 | #define ORIG_RAX 120 /* + error_code */ | ||
23 | /* end of arguments */ | ||
24 | /* cpu exception frame or undefined in case of fast syscall. */ | ||
25 | #define RIP 128 | ||
26 | #define CS 136 | ||
27 | #define EFLAGS 144 | ||
28 | #define RSP 152 | ||
29 | #define SS 160 | ||
30 | #define ARGOFFSET R11 | ||
31 | #define SWFRAME ORIG_RAX | ||
32 | |||
33 | .macro SAVE_ARGS addskip=0,norcx=0,nor891011=0 | ||
34 | subq $9*8+\addskip,%rsp | ||
35 | CFI_ADJUST_CFA_OFFSET 9*8+\addskip | ||
36 | movq %rdi,8*8(%rsp) | ||
37 | CFI_REL_OFFSET rdi,8*8 | ||
38 | movq %rsi,7*8(%rsp) | ||
39 | CFI_REL_OFFSET rsi,7*8 | ||
40 | movq %rdx,6*8(%rsp) | ||
41 | CFI_REL_OFFSET rdx,6*8 | ||
42 | .if \norcx | ||
43 | .else | ||
44 | movq %rcx,5*8(%rsp) | ||
45 | CFI_REL_OFFSET rcx,5*8 | ||
46 | .endif | ||
47 | movq %rax,4*8(%rsp) | ||
48 | CFI_REL_OFFSET rax,4*8 | ||
49 | .if \nor891011 | ||
50 | .else | ||
51 | movq %r8,3*8(%rsp) | ||
52 | CFI_REL_OFFSET r8,3*8 | ||
53 | movq %r9,2*8(%rsp) | ||
54 | CFI_REL_OFFSET r9,2*8 | ||
55 | movq %r10,1*8(%rsp) | ||
56 | CFI_REL_OFFSET r10,1*8 | ||
57 | movq %r11,(%rsp) | ||
58 | CFI_REL_OFFSET r11,0*8 | ||
59 | .endif | ||
60 | .endm | ||
61 | |||
62 | #define ARG_SKIP 9*8 | ||
63 | .macro RESTORE_ARGS skiprax=0,addskip=0,skiprcx=0,skipr11=0,skipr8910=0,skiprdx=0 | ||
64 | .if \skipr11 | ||
65 | .else | ||
66 | movq (%rsp),%r11 | ||
67 | CFI_RESTORE r11 | ||
68 | .endif | ||
69 | .if \skipr8910 | ||
70 | .else | ||
71 | movq 1*8(%rsp),%r10 | ||
72 | CFI_RESTORE r10 | ||
73 | movq 2*8(%rsp),%r9 | ||
74 | CFI_RESTORE r9 | ||
75 | movq 3*8(%rsp),%r8 | ||
76 | CFI_RESTORE r8 | ||
77 | .endif | ||
78 | .if \skiprax | ||
79 | .else | ||
80 | movq 4*8(%rsp),%rax | ||
81 | CFI_RESTORE rax | ||
82 | .endif | ||
83 | .if \skiprcx | ||
84 | .else | ||
85 | movq 5*8(%rsp),%rcx | ||
86 | CFI_RESTORE rcx | ||
87 | .endif | ||
88 | .if \skiprdx | ||
89 | .else | ||
90 | movq 6*8(%rsp),%rdx | ||
91 | CFI_RESTORE rdx | ||
92 | .endif | ||
93 | movq 7*8(%rsp),%rsi | ||
94 | CFI_RESTORE rsi | ||
95 | movq 8*8(%rsp),%rdi | ||
96 | CFI_RESTORE rdi | ||
97 | .if ARG_SKIP+\addskip > 0 | ||
98 | addq $ARG_SKIP+\addskip,%rsp | ||
99 | CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip) | ||
100 | .endif | ||
101 | .endm | ||
102 | |||
103 | .macro LOAD_ARGS offset | ||
104 | movq \offset(%rsp),%r11 | ||
105 | movq \offset+8(%rsp),%r10 | ||
106 | movq \offset+16(%rsp),%r9 | ||
107 | movq \offset+24(%rsp),%r8 | ||
108 | movq \offset+40(%rsp),%rcx | ||
109 | movq \offset+48(%rsp),%rdx | ||
110 | movq \offset+56(%rsp),%rsi | ||
111 | movq \offset+64(%rsp),%rdi | ||
112 | movq \offset+72(%rsp),%rax | ||
113 | .endm | ||
114 | |||
115 | #define REST_SKIP 6*8 | ||
116 | .macro SAVE_REST | ||
117 | subq $REST_SKIP,%rsp | ||
118 | CFI_ADJUST_CFA_OFFSET REST_SKIP | ||
119 | movq %rbx,5*8(%rsp) | ||
120 | CFI_REL_OFFSET rbx,5*8 | ||
121 | movq %rbp,4*8(%rsp) | ||
122 | CFI_REL_OFFSET rbp,4*8 | ||
123 | movq %r12,3*8(%rsp) | ||
124 | CFI_REL_OFFSET r12,3*8 | ||
125 | movq %r13,2*8(%rsp) | ||
126 | CFI_REL_OFFSET r13,2*8 | ||
127 | movq %r14,1*8(%rsp) | ||
128 | CFI_REL_OFFSET r14,1*8 | ||
129 | movq %r15,(%rsp) | ||
130 | CFI_REL_OFFSET r15,0*8 | ||
131 | .endm | ||
132 | |||
133 | .macro RESTORE_REST | ||
134 | movq (%rsp),%r15 | ||
135 | CFI_RESTORE r15 | ||
136 | movq 1*8(%rsp),%r14 | ||
137 | CFI_RESTORE r14 | ||
138 | movq 2*8(%rsp),%r13 | ||
139 | CFI_RESTORE r13 | ||
140 | movq 3*8(%rsp),%r12 | ||
141 | CFI_RESTORE r12 | ||
142 | movq 4*8(%rsp),%rbp | ||
143 | CFI_RESTORE rbp | ||
144 | movq 5*8(%rsp),%rbx | ||
145 | CFI_RESTORE rbx | ||
146 | addq $REST_SKIP,%rsp | ||
147 | CFI_ADJUST_CFA_OFFSET -(REST_SKIP) | ||
148 | .endm | ||
149 | |||
150 | .macro SAVE_ALL | ||
151 | SAVE_ARGS | ||
152 | SAVE_REST | ||
153 | .endm | ||
154 | |||
155 | .macro RESTORE_ALL addskip=0 | ||
156 | RESTORE_REST | ||
157 | RESTORE_ARGS 0,\addskip | ||
158 | .endm | ||
159 | |||
160 | .macro icebp | ||
161 | .byte 0xf1 | ||
162 | .endm | ||
diff --git a/include/asm-x86/checksum.h b/include/asm-x86/checksum.h new file mode 100644 index 000000000000..848850fd7d62 --- /dev/null +++ b/include/asm-x86/checksum.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "checksum_32.h" | ||
3 | #else | ||
4 | # include "checksum_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/checksum_32.h b/include/asm-x86/checksum_32.h new file mode 100644 index 000000000000..75194abbe8ee --- /dev/null +++ b/include/asm-x86/checksum_32.h | |||
@@ -0,0 +1,191 @@ | |||
1 | #ifndef _I386_CHECKSUM_H | ||
2 | #define _I386_CHECKSUM_H | ||
3 | |||
4 | #include <linux/in6.h> | ||
5 | |||
6 | #include <asm/uaccess.h> | ||
7 | |||
8 | /* | ||
9 | * computes the checksum of a memory block at buff, length len, | ||
10 | * and adds in "sum" (32-bit) | ||
11 | * | ||
12 | * returns a 32-bit number suitable for feeding into itself | ||
13 | * or csum_tcpudp_magic | ||
14 | * | ||
15 | * this function must be called with even lengths, except | ||
16 | * for the last fragment, which may be odd | ||
17 | * | ||
18 | * it's best to have buff aligned on a 32-bit boundary | ||
19 | */ | ||
20 | asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum); | ||
21 | |||
22 | /* | ||
23 | * the same as csum_partial, but copies from src while it | ||
24 | * checksums, and handles user-space pointer exceptions correctly, when needed. | ||
25 | * | ||
26 | * here even more important to align src and dst on a 32-bit (or even | ||
27 | * better 64-bit) boundary | ||
28 | */ | ||
29 | |||
30 | asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, | ||
31 | int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr); | ||
32 | |||
33 | /* | ||
34 | * Note: when you get a NULL pointer exception here this means someone | ||
35 | * passed in an incorrect kernel address to one of these functions. | ||
36 | * | ||
37 | * If you use these functions directly please don't forget the | ||
38 | * access_ok(). | ||
39 | */ | ||
40 | static __inline__ | ||
41 | __wsum csum_partial_copy_nocheck (const void *src, void *dst, | ||
42 | int len, __wsum sum) | ||
43 | { | ||
44 | return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); | ||
45 | } | ||
46 | |||
47 | static __inline__ | ||
48 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, | ||
49 | int len, __wsum sum, int *err_ptr) | ||
50 | { | ||
51 | might_sleep(); | ||
52 | return csum_partial_copy_generic((__force void *)src, dst, | ||
53 | len, sum, err_ptr, NULL); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
58 | * which always checksum on 4 octet boundaries. | ||
59 | * | ||
60 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by | ||
61 | * Arnt Gulbrandsen. | ||
62 | */ | ||
63 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) | ||
64 | { | ||
65 | unsigned int sum; | ||
66 | |||
67 | __asm__ __volatile__( | ||
68 | "movl (%1), %0 ;\n" | ||
69 | "subl $4, %2 ;\n" | ||
70 | "jbe 2f ;\n" | ||
71 | "addl 4(%1), %0 ;\n" | ||
72 | "adcl 8(%1), %0 ;\n" | ||
73 | "adcl 12(%1), %0 ;\n" | ||
74 | "1: adcl 16(%1), %0 ;\n" | ||
75 | "lea 4(%1), %1 ;\n" | ||
76 | "decl %2 ;\n" | ||
77 | "jne 1b ;\n" | ||
78 | "adcl $0, %0 ;\n" | ||
79 | "movl %0, %2 ;\n" | ||
80 | "shrl $16, %0 ;\n" | ||
81 | "addw %w2, %w0 ;\n" | ||
82 | "adcl $0, %0 ;\n" | ||
83 | "notl %0 ;\n" | ||
84 | "2: ;\n" | ||
85 | /* Since the input registers which are loaded with iph and ihl | ||
86 | are modified, we must also specify them as outputs, or gcc | ||
87 | will assume they contain their original values. */ | ||
88 | : "=r" (sum), "=r" (iph), "=r" (ihl) | ||
89 | : "1" (iph), "2" (ihl) | ||
90 | : "memory"); | ||
91 | return (__force __sum16)sum; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Fold a partial checksum | ||
96 | */ | ||
97 | |||
98 | static inline __sum16 csum_fold(__wsum sum) | ||
99 | { | ||
100 | __asm__( | ||
101 | "addl %1, %0 ;\n" | ||
102 | "adcl $0xffff, %0 ;\n" | ||
103 | : "=r" (sum) | ||
104 | : "r" ((__force u32)sum << 16), | ||
105 | "0" ((__force u32)sum & 0xffff0000) | ||
106 | ); | ||
107 | return (__force __sum16)(~(__force u32)sum >> 16); | ||
108 | } | ||
109 | |||
110 | static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, | ||
111 | unsigned short len, | ||
112 | unsigned short proto, | ||
113 | __wsum sum) | ||
114 | { | ||
115 | __asm__( | ||
116 | "addl %1, %0 ;\n" | ||
117 | "adcl %2, %0 ;\n" | ||
118 | "adcl %3, %0 ;\n" | ||
119 | "adcl $0, %0 ;\n" | ||
120 | : "=r" (sum) | ||
121 | : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); | ||
122 | return sum; | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * computes the checksum of the TCP/UDP pseudo-header | ||
127 | * returns a 16-bit checksum, already complemented | ||
128 | */ | ||
129 | static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, | ||
130 | unsigned short len, | ||
131 | unsigned short proto, | ||
132 | __wsum sum) | ||
133 | { | ||
134 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * this routine is used for miscellaneous IP-like checksums, mainly | ||
139 | * in icmp.c | ||
140 | */ | ||
141 | |||
142 | static inline __sum16 ip_compute_csum(const void *buff, int len) | ||
143 | { | ||
144 | return csum_fold (csum_partial(buff, len, 0)); | ||
145 | } | ||
146 | |||
147 | #define _HAVE_ARCH_IPV6_CSUM | ||
148 | static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | ||
149 | const struct in6_addr *daddr, | ||
150 | __u32 len, unsigned short proto, | ||
151 | __wsum sum) | ||
152 | { | ||
153 | __asm__( | ||
154 | "addl 0(%1), %0 ;\n" | ||
155 | "adcl 4(%1), %0 ;\n" | ||
156 | "adcl 8(%1), %0 ;\n" | ||
157 | "adcl 12(%1), %0 ;\n" | ||
158 | "adcl 0(%2), %0 ;\n" | ||
159 | "adcl 4(%2), %0 ;\n" | ||
160 | "adcl 8(%2), %0 ;\n" | ||
161 | "adcl 12(%2), %0 ;\n" | ||
162 | "adcl %3, %0 ;\n" | ||
163 | "adcl %4, %0 ;\n" | ||
164 | "adcl $0, %0 ;\n" | ||
165 | : "=&r" (sum) | ||
166 | : "r" (saddr), "r" (daddr), | ||
167 | "r"(htonl(len)), "r"(htonl(proto)), "0"(sum)); | ||
168 | |||
169 | return csum_fold(sum); | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Copy and checksum to user | ||
174 | */ | ||
175 | #define HAVE_CSUM_COPY_USER | ||
176 | static __inline__ __wsum csum_and_copy_to_user(const void *src, | ||
177 | void __user *dst, | ||
178 | int len, __wsum sum, | ||
179 | int *err_ptr) | ||
180 | { | ||
181 | might_sleep(); | ||
182 | if (access_ok(VERIFY_WRITE, dst, len)) | ||
183 | return csum_partial_copy_generic(src, (__force void *)dst, len, sum, NULL, err_ptr); | ||
184 | |||
185 | if (len) | ||
186 | *err_ptr = -EFAULT; | ||
187 | |||
188 | return (__force __wsum)-1; /* invalid checksum */ | ||
189 | } | ||
190 | |||
191 | #endif | ||
diff --git a/include/asm-x86/checksum_64.h b/include/asm-x86/checksum_64.h new file mode 100644 index 000000000000..419fe88a0342 --- /dev/null +++ b/include/asm-x86/checksum_64.h | |||
@@ -0,0 +1,195 @@ | |||
1 | #ifndef _X86_64_CHECKSUM_H | ||
2 | #define _X86_64_CHECKSUM_H | ||
3 | |||
4 | /* | ||
5 | * Checksums for x86-64 | ||
6 | * Copyright 2002 by Andi Kleen, SuSE Labs | ||
7 | * with some code from asm-i386/checksum.h | ||
8 | */ | ||
9 | |||
10 | #include <linux/compiler.h> | ||
11 | #include <asm/uaccess.h> | ||
12 | #include <asm/byteorder.h> | ||
13 | |||
14 | /** | ||
15 | * csum_fold - Fold and invert a 32bit checksum. | ||
16 | * sum: 32bit unfolded sum | ||
17 | * | ||
18 | * Fold a 32bit running checksum to 16bit and invert it. This is usually | ||
19 | * the last step before putting a checksum into a packet. | ||
20 | * Make sure not to mix with 64bit checksums. | ||
21 | */ | ||
22 | static inline __sum16 csum_fold(__wsum sum) | ||
23 | { | ||
24 | __asm__( | ||
25 | " addl %1,%0\n" | ||
26 | " adcl $0xffff,%0" | ||
27 | : "=r" (sum) | ||
28 | : "r" ((__force u32)sum << 16), | ||
29 | "0" ((__force u32)sum & 0xffff0000) | ||
30 | ); | ||
31 | return (__force __sum16)(~(__force u32)sum >> 16); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
36 | * which always checksum on 4 octet boundaries. | ||
37 | * | ||
38 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by | ||
39 | * Arnt Gulbrandsen. | ||
40 | */ | ||
41 | |||
42 | /** | ||
43 | * ip_fast_csum - Compute the IPv4 header checksum efficiently. | ||
44 | * iph: ipv4 header | ||
45 | * ihl: length of header / 4 | ||
46 | */ | ||
47 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) | ||
48 | { | ||
49 | unsigned int sum; | ||
50 | |||
51 | asm( " movl (%1), %0\n" | ||
52 | " subl $4, %2\n" | ||
53 | " jbe 2f\n" | ||
54 | " addl 4(%1), %0\n" | ||
55 | " adcl 8(%1), %0\n" | ||
56 | " adcl 12(%1), %0\n" | ||
57 | "1: adcl 16(%1), %0\n" | ||
58 | " lea 4(%1), %1\n" | ||
59 | " decl %2\n" | ||
60 | " jne 1b\n" | ||
61 | " adcl $0, %0\n" | ||
62 | " movl %0, %2\n" | ||
63 | " shrl $16, %0\n" | ||
64 | " addw %w2, %w0\n" | ||
65 | " adcl $0, %0\n" | ||
66 | " notl %0\n" | ||
67 | "2:" | ||
68 | /* Since the input registers which are loaded with iph and ihl | ||
69 | are modified, we must also specify them as outputs, or gcc | ||
70 | will assume they contain their original values. */ | ||
71 | : "=r" (sum), "=r" (iph), "=r" (ihl) | ||
72 | : "1" (iph), "2" (ihl) | ||
73 | : "memory"); | ||
74 | return (__force __sum16)sum; | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum. | ||
79 | * @saddr: source address | ||
80 | * @daddr: destination address | ||
81 | * @len: length of packet | ||
82 | * @proto: ip protocol of packet | ||
83 | * @sum: initial sum to be added in (32bit unfolded) | ||
84 | * | ||
85 | * Returns the pseudo header checksum the input data. Result is | ||
86 | * 32bit unfolded. | ||
87 | */ | ||
88 | static inline __wsum | ||
89 | csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, | ||
90 | unsigned short proto, __wsum sum) | ||
91 | { | ||
92 | asm(" addl %1, %0\n" | ||
93 | " adcl %2, %0\n" | ||
94 | " adcl %3, %0\n" | ||
95 | " adcl $0, %0\n" | ||
96 | : "=r" (sum) | ||
97 | : "g" (daddr), "g" (saddr), | ||
98 | "g" ((len + proto)<<8), "0" (sum)); | ||
99 | return sum; | ||
100 | } | ||
101 | |||
102 | |||
103 | /** | ||
104 | * csum_tcpup_magic - Compute an IPv4 pseudo header checksum. | ||
105 | * @saddr: source address | ||
106 | * @daddr: destination address | ||
107 | * @len: length of packet | ||
108 | * @proto: ip protocol of packet | ||
109 | * @sum: initial sum to be added in (32bit unfolded) | ||
110 | * | ||
111 | * Returns the 16bit pseudo header checksum the input data already | ||
112 | * complemented and ready to be filled in. | ||
113 | */ | ||
114 | static inline __sum16 | ||
115 | csum_tcpudp_magic(__be32 saddr, __be32 daddr, | ||
116 | unsigned short len, unsigned short proto, __wsum sum) | ||
117 | { | ||
118 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * csum_partial - Compute an internet checksum. | ||
123 | * @buff: buffer to be checksummed | ||
124 | * @len: length of buffer. | ||
125 | * @sum: initial sum to be added in (32bit unfolded) | ||
126 | * | ||
127 | * Returns the 32bit unfolded internet checksum of the buffer. | ||
128 | * Before filling it in it needs to be csum_fold()'ed. | ||
129 | * buff should be aligned to a 64bit boundary if possible. | ||
130 | */ | ||
131 | extern __wsum csum_partial(const void *buff, int len, __wsum sum); | ||
132 | |||
133 | #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 | ||
134 | #define HAVE_CSUM_COPY_USER 1 | ||
135 | |||
136 | |||
137 | /* Do not call this directly. Use the wrappers below */ | ||
138 | extern __wsum csum_partial_copy_generic(const void *src, const void *dst, | ||
139 | int len, | ||
140 | __wsum sum, | ||
141 | int *src_err_ptr, int *dst_err_ptr); | ||
142 | |||
143 | |||
144 | extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst, | ||
145 | int len, __wsum isum, int *errp); | ||
146 | extern __wsum csum_partial_copy_to_user(const void *src, void __user *dst, | ||
147 | int len, __wsum isum, int *errp); | ||
148 | extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, | ||
149 | __wsum sum); | ||
150 | |||
151 | /* Old names. To be removed. */ | ||
152 | #define csum_and_copy_to_user csum_partial_copy_to_user | ||
153 | #define csum_and_copy_from_user csum_partial_copy_from_user | ||
154 | |||
155 | /** | ||
156 | * ip_compute_csum - Compute an 16bit IP checksum. | ||
157 | * @buff: buffer address. | ||
158 | * @len: length of buffer. | ||
159 | * | ||
160 | * Returns the 16bit folded/inverted checksum of the passed buffer. | ||
161 | * Ready to fill in. | ||
162 | */ | ||
163 | extern __sum16 ip_compute_csum(const void *buff, int len); | ||
164 | |||
165 | /** | ||
166 | * csum_ipv6_magic - Compute checksum of an IPv6 pseudo header. | ||
167 | * @saddr: source address | ||
168 | * @daddr: destination address | ||
169 | * @len: length of packet | ||
170 | * @proto: protocol of packet | ||
171 | * @sum: initial sum (32bit unfolded) to be added in | ||
172 | * | ||
173 | * Computes an IPv6 pseudo header checksum. This sum is added the checksum | ||
174 | * into UDP/TCP packets and contains some link layer information. | ||
175 | * Returns the unfolded 32bit checksum. | ||
176 | */ | ||
177 | |||
178 | struct in6_addr; | ||
179 | |||
180 | #define _HAVE_ARCH_IPV6_CSUM 1 | ||
181 | extern __sum16 | ||
182 | csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, | ||
183 | __u32 len, unsigned short proto, __wsum sum); | ||
184 | |||
185 | static inline unsigned add32_with_carry(unsigned a, unsigned b) | ||
186 | { | ||
187 | asm("addl %2,%0\n\t" | ||
188 | "adcl $0,%0" | ||
189 | : "=r" (a) | ||
190 | : "0" (a), "r" (b)); | ||
191 | return a; | ||
192 | } | ||
193 | |||
194 | #endif | ||
195 | |||
diff --git a/include/asm-x86/cmpxchg.h b/include/asm-x86/cmpxchg.h new file mode 100644 index 000000000000..a460fa088d4c --- /dev/null +++ b/include/asm-x86/cmpxchg.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "cmpxchg_32.h" | ||
3 | #else | ||
4 | # include "cmpxchg_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/cmpxchg_32.h b/include/asm-x86/cmpxchg_32.h new file mode 100644 index 000000000000..f86ede28f6dc --- /dev/null +++ b/include/asm-x86/cmpxchg_32.h | |||
@@ -0,0 +1,289 @@ | |||
1 | #ifndef __ASM_CMPXCHG_H | ||
2 | #define __ASM_CMPXCHG_H | ||
3 | |||
4 | #include <linux/bitops.h> /* for LOCK_PREFIX */ | ||
5 | |||
6 | /* | ||
7 | * Note: if you use set64_bit(), __cmpxchg64(), or their variants, you | ||
8 | * you need to test for the feature in boot_cpu_data. | ||
9 | */ | ||
10 | |||
11 | #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) | ||
12 | |||
13 | struct __xchg_dummy { unsigned long a[100]; }; | ||
14 | #define __xg(x) ((struct __xchg_dummy *)(x)) | ||
15 | |||
16 | /* | ||
17 | * The semantics of XCHGCMP8B are a bit strange, this is why | ||
18 | * there is a loop and the loading of %%eax and %%edx has to | ||
19 | * be inside. This inlines well in most cases, the cached | ||
20 | * cost is around ~38 cycles. (in the future we might want | ||
21 | * to do an SIMD/3DNOW!/MMX/FPU 64-bit store here, but that | ||
22 | * might have an implicit FPU-save as a cost, so it's not | ||
23 | * clear which path to go.) | ||
24 | * | ||
25 | * cmpxchg8b must be used with the lock prefix here to allow | ||
26 | * the instruction to be executed atomically, see page 3-102 | ||
27 | * of the instruction set reference 24319102.pdf. We need | ||
28 | * the reader side to see the coherent 64bit value. | ||
29 | */ | ||
30 | static inline void __set_64bit (unsigned long long * ptr, | ||
31 | unsigned int low, unsigned int high) | ||
32 | { | ||
33 | __asm__ __volatile__ ( | ||
34 | "\n1:\t" | ||
35 | "movl (%0), %%eax\n\t" | ||
36 | "movl 4(%0), %%edx\n\t" | ||
37 | LOCK_PREFIX "cmpxchg8b (%0)\n\t" | ||
38 | "jnz 1b" | ||
39 | : /* no outputs */ | ||
40 | : "D"(ptr), | ||
41 | "b"(low), | ||
42 | "c"(high) | ||
43 | : "ax","dx","memory"); | ||
44 | } | ||
45 | |||
46 | static inline void __set_64bit_constant (unsigned long long *ptr, | ||
47 | unsigned long long value) | ||
48 | { | ||
49 | __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL)); | ||
50 | } | ||
51 | #define ll_low(x) *(((unsigned int*)&(x))+0) | ||
52 | #define ll_high(x) *(((unsigned int*)&(x))+1) | ||
53 | |||
54 | static inline void __set_64bit_var (unsigned long long *ptr, | ||
55 | unsigned long long value) | ||
56 | { | ||
57 | __set_64bit(ptr,ll_low(value), ll_high(value)); | ||
58 | } | ||
59 | |||
60 | #define set_64bit(ptr,value) \ | ||
61 | (__builtin_constant_p(value) ? \ | ||
62 | __set_64bit_constant(ptr, value) : \ | ||
63 | __set_64bit_var(ptr, value) ) | ||
64 | |||
65 | #define _set_64bit(ptr,value) \ | ||
66 | (__builtin_constant_p(value) ? \ | ||
67 | __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \ | ||
68 | __set_64bit(ptr, ll_low(value), ll_high(value)) ) | ||
69 | |||
70 | /* | ||
71 | * Note: no "lock" prefix even on SMP: xchg always implies lock anyway | ||
72 | * Note 2: xchg has side effect, so that attribute volatile is necessary, | ||
73 | * but generally the primitive is invalid, *ptr is output argument. --ANK | ||
74 | */ | ||
75 | static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) | ||
76 | { | ||
77 | switch (size) { | ||
78 | case 1: | ||
79 | __asm__ __volatile__("xchgb %b0,%1" | ||
80 | :"=q" (x) | ||
81 | :"m" (*__xg(ptr)), "0" (x) | ||
82 | :"memory"); | ||
83 | break; | ||
84 | case 2: | ||
85 | __asm__ __volatile__("xchgw %w0,%1" | ||
86 | :"=r" (x) | ||
87 | :"m" (*__xg(ptr)), "0" (x) | ||
88 | :"memory"); | ||
89 | break; | ||
90 | case 4: | ||
91 | __asm__ __volatile__("xchgl %0,%1" | ||
92 | :"=r" (x) | ||
93 | :"m" (*__xg(ptr)), "0" (x) | ||
94 | :"memory"); | ||
95 | break; | ||
96 | } | ||
97 | return x; | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | ||
102 | * store NEW in MEM. Return the initial value in MEM. Success is | ||
103 | * indicated by comparing RETURN with OLD. | ||
104 | */ | ||
105 | |||
106 | #ifdef CONFIG_X86_CMPXCHG | ||
107 | #define __HAVE_ARCH_CMPXCHG 1 | ||
108 | #define cmpxchg(ptr,o,n)\ | ||
109 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | ||
110 | (unsigned long)(n),sizeof(*(ptr)))) | ||
111 | #define sync_cmpxchg(ptr,o,n)\ | ||
112 | ((__typeof__(*(ptr)))__sync_cmpxchg((ptr),(unsigned long)(o),\ | ||
113 | (unsigned long)(n),sizeof(*(ptr)))) | ||
114 | #define cmpxchg_local(ptr,o,n)\ | ||
115 | ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\ | ||
116 | (unsigned long)(n),sizeof(*(ptr)))) | ||
117 | #endif | ||
118 | |||
119 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | ||
120 | unsigned long new, int size) | ||
121 | { | ||
122 | unsigned long prev; | ||
123 | switch (size) { | ||
124 | case 1: | ||
125 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" | ||
126 | : "=a"(prev) | ||
127 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
128 | : "memory"); | ||
129 | return prev; | ||
130 | case 2: | ||
131 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" | ||
132 | : "=a"(prev) | ||
133 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
134 | : "memory"); | ||
135 | return prev; | ||
136 | case 4: | ||
137 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2" | ||
138 | : "=a"(prev) | ||
139 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
140 | : "memory"); | ||
141 | return prev; | ||
142 | } | ||
143 | return old; | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * Always use locked operations when touching memory shared with a | ||
148 | * hypervisor, since the system may be SMP even if the guest kernel | ||
149 | * isn't. | ||
150 | */ | ||
151 | static inline unsigned long __sync_cmpxchg(volatile void *ptr, | ||
152 | unsigned long old, | ||
153 | unsigned long new, int size) | ||
154 | { | ||
155 | unsigned long prev; | ||
156 | switch (size) { | ||
157 | case 1: | ||
158 | __asm__ __volatile__("lock; cmpxchgb %b1,%2" | ||
159 | : "=a"(prev) | ||
160 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
161 | : "memory"); | ||
162 | return prev; | ||
163 | case 2: | ||
164 | __asm__ __volatile__("lock; cmpxchgw %w1,%2" | ||
165 | : "=a"(prev) | ||
166 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
167 | : "memory"); | ||
168 | return prev; | ||
169 | case 4: | ||
170 | __asm__ __volatile__("lock; cmpxchgl %1,%2" | ||
171 | : "=a"(prev) | ||
172 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
173 | : "memory"); | ||
174 | return prev; | ||
175 | } | ||
176 | return old; | ||
177 | } | ||
178 | |||
179 | static inline unsigned long __cmpxchg_local(volatile void *ptr, | ||
180 | unsigned long old, unsigned long new, int size) | ||
181 | { | ||
182 | unsigned long prev; | ||
183 | switch (size) { | ||
184 | case 1: | ||
185 | __asm__ __volatile__("cmpxchgb %b1,%2" | ||
186 | : "=a"(prev) | ||
187 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
188 | : "memory"); | ||
189 | return prev; | ||
190 | case 2: | ||
191 | __asm__ __volatile__("cmpxchgw %w1,%2" | ||
192 | : "=a"(prev) | ||
193 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
194 | : "memory"); | ||
195 | return prev; | ||
196 | case 4: | ||
197 | __asm__ __volatile__("cmpxchgl %1,%2" | ||
198 | : "=a"(prev) | ||
199 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
200 | : "memory"); | ||
201 | return prev; | ||
202 | } | ||
203 | return old; | ||
204 | } | ||
205 | |||
206 | #ifndef CONFIG_X86_CMPXCHG | ||
207 | /* | ||
208 | * Building a kernel capable running on 80386. It may be necessary to | ||
209 | * simulate the cmpxchg on the 80386 CPU. For that purpose we define | ||
210 | * a function for each of the sizes we support. | ||
211 | */ | ||
212 | |||
213 | extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8); | ||
214 | extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16); | ||
215 | extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32); | ||
216 | |||
217 | static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old, | ||
218 | unsigned long new, int size) | ||
219 | { | ||
220 | switch (size) { | ||
221 | case 1: | ||
222 | return cmpxchg_386_u8(ptr, old, new); | ||
223 | case 2: | ||
224 | return cmpxchg_386_u16(ptr, old, new); | ||
225 | case 4: | ||
226 | return cmpxchg_386_u32(ptr, old, new); | ||
227 | } | ||
228 | return old; | ||
229 | } | ||
230 | |||
231 | #define cmpxchg(ptr,o,n) \ | ||
232 | ({ \ | ||
233 | __typeof__(*(ptr)) __ret; \ | ||
234 | if (likely(boot_cpu_data.x86 > 3)) \ | ||
235 | __ret = __cmpxchg((ptr), (unsigned long)(o), \ | ||
236 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
237 | else \ | ||
238 | __ret = cmpxchg_386((ptr), (unsigned long)(o), \ | ||
239 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
240 | __ret; \ | ||
241 | }) | ||
242 | #define cmpxchg_local(ptr,o,n) \ | ||
243 | ({ \ | ||
244 | __typeof__(*(ptr)) __ret; \ | ||
245 | if (likely(boot_cpu_data.x86 > 3)) \ | ||
246 | __ret = __cmpxchg_local((ptr), (unsigned long)(o), \ | ||
247 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
248 | else \ | ||
249 | __ret = cmpxchg_386((ptr), (unsigned long)(o), \ | ||
250 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
251 | __ret; \ | ||
252 | }) | ||
253 | #endif | ||
254 | |||
255 | static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long long old, | ||
256 | unsigned long long new) | ||
257 | { | ||
258 | unsigned long long prev; | ||
259 | __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3" | ||
260 | : "=A"(prev) | ||
261 | : "b"((unsigned long)new), | ||
262 | "c"((unsigned long)(new >> 32)), | ||
263 | "m"(*__xg(ptr)), | ||
264 | "0"(old) | ||
265 | : "memory"); | ||
266 | return prev; | ||
267 | } | ||
268 | |||
269 | static inline unsigned long long __cmpxchg64_local(volatile void *ptr, | ||
270 | unsigned long long old, unsigned long long new) | ||
271 | { | ||
272 | unsigned long long prev; | ||
273 | __asm__ __volatile__("cmpxchg8b %3" | ||
274 | : "=A"(prev) | ||
275 | : "b"((unsigned long)new), | ||
276 | "c"((unsigned long)(new >> 32)), | ||
277 | "m"(*__xg(ptr)), | ||
278 | "0"(old) | ||
279 | : "memory"); | ||
280 | return prev; | ||
281 | } | ||
282 | |||
283 | #define cmpxchg64(ptr,o,n)\ | ||
284 | ((__typeof__(*(ptr)))__cmpxchg64((ptr),(unsigned long long)(o),\ | ||
285 | (unsigned long long)(n))) | ||
286 | #define cmpxchg64_local(ptr,o,n)\ | ||
287 | ((__typeof__(*(ptr)))__cmpxchg64_local((ptr),(unsigned long long)(o),\ | ||
288 | (unsigned long long)(n))) | ||
289 | #endif | ||
diff --git a/include/asm-x86/cmpxchg_64.h b/include/asm-x86/cmpxchg_64.h new file mode 100644 index 000000000000..5e182062e6ec --- /dev/null +++ b/include/asm-x86/cmpxchg_64.h | |||
@@ -0,0 +1,134 @@ | |||
1 | #ifndef __ASM_CMPXCHG_H | ||
2 | #define __ASM_CMPXCHG_H | ||
3 | |||
4 | #include <asm/alternative.h> /* Provides LOCK_PREFIX */ | ||
5 | |||
6 | #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) | ||
7 | |||
8 | #define __xg(x) ((volatile long *)(x)) | ||
9 | |||
10 | static inline void set_64bit(volatile unsigned long *ptr, unsigned long val) | ||
11 | { | ||
12 | *ptr = val; | ||
13 | } | ||
14 | |||
15 | #define _set_64bit set_64bit | ||
16 | |||
17 | /* | ||
18 | * Note: no "lock" prefix even on SMP: xchg always implies lock anyway | ||
19 | * Note 2: xchg has side effect, so that attribute volatile is necessary, | ||
20 | * but generally the primitive is invalid, *ptr is output argument. --ANK | ||
21 | */ | ||
22 | static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) | ||
23 | { | ||
24 | switch (size) { | ||
25 | case 1: | ||
26 | __asm__ __volatile__("xchgb %b0,%1" | ||
27 | :"=q" (x) | ||
28 | :"m" (*__xg(ptr)), "0" (x) | ||
29 | :"memory"); | ||
30 | break; | ||
31 | case 2: | ||
32 | __asm__ __volatile__("xchgw %w0,%1" | ||
33 | :"=r" (x) | ||
34 | :"m" (*__xg(ptr)), "0" (x) | ||
35 | :"memory"); | ||
36 | break; | ||
37 | case 4: | ||
38 | __asm__ __volatile__("xchgl %k0,%1" | ||
39 | :"=r" (x) | ||
40 | :"m" (*__xg(ptr)), "0" (x) | ||
41 | :"memory"); | ||
42 | break; | ||
43 | case 8: | ||
44 | __asm__ __volatile__("xchgq %0,%1" | ||
45 | :"=r" (x) | ||
46 | :"m" (*__xg(ptr)), "0" (x) | ||
47 | :"memory"); | ||
48 | break; | ||
49 | } | ||
50 | return x; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | ||
55 | * store NEW in MEM. Return the initial value in MEM. Success is | ||
56 | * indicated by comparing RETURN with OLD. | ||
57 | */ | ||
58 | |||
59 | #define __HAVE_ARCH_CMPXCHG 1 | ||
60 | |||
61 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | ||
62 | unsigned long new, int size) | ||
63 | { | ||
64 | unsigned long prev; | ||
65 | switch (size) { | ||
66 | case 1: | ||
67 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" | ||
68 | : "=a"(prev) | ||
69 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
70 | : "memory"); | ||
71 | return prev; | ||
72 | case 2: | ||
73 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" | ||
74 | : "=a"(prev) | ||
75 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
76 | : "memory"); | ||
77 | return prev; | ||
78 | case 4: | ||
79 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2" | ||
80 | : "=a"(prev) | ||
81 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
82 | : "memory"); | ||
83 | return prev; | ||
84 | case 8: | ||
85 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2" | ||
86 | : "=a"(prev) | ||
87 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
88 | : "memory"); | ||
89 | return prev; | ||
90 | } | ||
91 | return old; | ||
92 | } | ||
93 | |||
94 | static inline unsigned long __cmpxchg_local(volatile void *ptr, | ||
95 | unsigned long old, unsigned long new, int size) | ||
96 | { | ||
97 | unsigned long prev; | ||
98 | switch (size) { | ||
99 | case 1: | ||
100 | __asm__ __volatile__("cmpxchgb %b1,%2" | ||
101 | : "=a"(prev) | ||
102 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
103 | : "memory"); | ||
104 | return prev; | ||
105 | case 2: | ||
106 | __asm__ __volatile__("cmpxchgw %w1,%2" | ||
107 | : "=a"(prev) | ||
108 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
109 | : "memory"); | ||
110 | return prev; | ||
111 | case 4: | ||
112 | __asm__ __volatile__("cmpxchgl %k1,%2" | ||
113 | : "=a"(prev) | ||
114 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
115 | : "memory"); | ||
116 | return prev; | ||
117 | case 8: | ||
118 | __asm__ __volatile__("cmpxchgq %1,%2" | ||
119 | : "=a"(prev) | ||
120 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
121 | : "memory"); | ||
122 | return prev; | ||
123 | } | ||
124 | return old; | ||
125 | } | ||
126 | |||
127 | #define cmpxchg(ptr,o,n)\ | ||
128 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | ||
129 | (unsigned long)(n),sizeof(*(ptr)))) | ||
130 | #define cmpxchg_local(ptr,o,n)\ | ||
131 | ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\ | ||
132 | (unsigned long)(n),sizeof(*(ptr)))) | ||
133 | |||
134 | #endif | ||
diff --git a/include/asm-x86/compat.h b/include/asm-x86/compat.h new file mode 100644 index 000000000000..53cb96b68a62 --- /dev/null +++ b/include/asm-x86/compat.h | |||
@@ -0,0 +1,212 @@ | |||
1 | #ifndef _ASM_X86_64_COMPAT_H | ||
2 | #define _ASM_X86_64_COMPAT_H | ||
3 | |||
4 | /* | ||
5 | * Architecture specific compatibility types | ||
6 | */ | ||
7 | #include <linux/types.h> | ||
8 | #include <linux/sched.h> | ||
9 | |||
10 | #define COMPAT_USER_HZ 100 | ||
11 | |||
12 | typedef u32 compat_size_t; | ||
13 | typedef s32 compat_ssize_t; | ||
14 | typedef s32 compat_time_t; | ||
15 | typedef s32 compat_clock_t; | ||
16 | typedef s32 compat_pid_t; | ||
17 | typedef u16 __compat_uid_t; | ||
18 | typedef u16 __compat_gid_t; | ||
19 | typedef u32 __compat_uid32_t; | ||
20 | typedef u32 __compat_gid32_t; | ||
21 | typedef u16 compat_mode_t; | ||
22 | typedef u32 compat_ino_t; | ||
23 | typedef u16 compat_dev_t; | ||
24 | typedef s32 compat_off_t; | ||
25 | typedef s64 compat_loff_t; | ||
26 | typedef u16 compat_nlink_t; | ||
27 | typedef u16 compat_ipc_pid_t; | ||
28 | typedef s32 compat_daddr_t; | ||
29 | typedef u32 compat_caddr_t; | ||
30 | typedef __kernel_fsid_t compat_fsid_t; | ||
31 | typedef s32 compat_timer_t; | ||
32 | typedef s32 compat_key_t; | ||
33 | |||
34 | typedef s32 compat_int_t; | ||
35 | typedef s32 compat_long_t; | ||
36 | typedef s64 __attribute__((aligned(4))) compat_s64; | ||
37 | typedef u32 compat_uint_t; | ||
38 | typedef u32 compat_ulong_t; | ||
39 | typedef u64 __attribute__((aligned(4))) compat_u64; | ||
40 | |||
41 | struct compat_timespec { | ||
42 | compat_time_t tv_sec; | ||
43 | s32 tv_nsec; | ||
44 | }; | ||
45 | |||
46 | struct compat_timeval { | ||
47 | compat_time_t tv_sec; | ||
48 | s32 tv_usec; | ||
49 | }; | ||
50 | |||
51 | struct compat_stat { | ||
52 | compat_dev_t st_dev; | ||
53 | u16 __pad1; | ||
54 | compat_ino_t st_ino; | ||
55 | compat_mode_t st_mode; | ||
56 | compat_nlink_t st_nlink; | ||
57 | __compat_uid_t st_uid; | ||
58 | __compat_gid_t st_gid; | ||
59 | compat_dev_t st_rdev; | ||
60 | u16 __pad2; | ||
61 | u32 st_size; | ||
62 | u32 st_blksize; | ||
63 | u32 st_blocks; | ||
64 | u32 st_atime; | ||
65 | u32 st_atime_nsec; | ||
66 | u32 st_mtime; | ||
67 | u32 st_mtime_nsec; | ||
68 | u32 st_ctime; | ||
69 | u32 st_ctime_nsec; | ||
70 | u32 __unused4; | ||
71 | u32 __unused5; | ||
72 | }; | ||
73 | |||
74 | struct compat_flock { | ||
75 | short l_type; | ||
76 | short l_whence; | ||
77 | compat_off_t l_start; | ||
78 | compat_off_t l_len; | ||
79 | compat_pid_t l_pid; | ||
80 | }; | ||
81 | |||
82 | #define F_GETLK64 12 /* using 'struct flock64' */ | ||
83 | #define F_SETLK64 13 | ||
84 | #define F_SETLKW64 14 | ||
85 | |||
86 | /* | ||
87 | * IA32 uses 4 byte alignment for 64 bit quantities, | ||
88 | * so we need to pack this structure. | ||
89 | */ | ||
90 | struct compat_flock64 { | ||
91 | short l_type; | ||
92 | short l_whence; | ||
93 | compat_loff_t l_start; | ||
94 | compat_loff_t l_len; | ||
95 | compat_pid_t l_pid; | ||
96 | } __attribute__((packed)); | ||
97 | |||
98 | struct compat_statfs { | ||
99 | int f_type; | ||
100 | int f_bsize; | ||
101 | int f_blocks; | ||
102 | int f_bfree; | ||
103 | int f_bavail; | ||
104 | int f_files; | ||
105 | int f_ffree; | ||
106 | compat_fsid_t f_fsid; | ||
107 | int f_namelen; /* SunOS ignores this field. */ | ||
108 | int f_frsize; | ||
109 | int f_spare[5]; | ||
110 | }; | ||
111 | |||
112 | #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff | ||
113 | #define COMPAT_RLIM_INFINITY 0xffffffff | ||
114 | |||
115 | typedef u32 compat_old_sigset_t; /* at least 32 bits */ | ||
116 | |||
117 | #define _COMPAT_NSIG 64 | ||
118 | #define _COMPAT_NSIG_BPW 32 | ||
119 | |||
120 | typedef u32 compat_sigset_word; | ||
121 | |||
122 | #define COMPAT_OFF_T_MAX 0x7fffffff | ||
123 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | ||
124 | |||
125 | struct compat_ipc64_perm { | ||
126 | compat_key_t key; | ||
127 | __compat_uid32_t uid; | ||
128 | __compat_gid32_t gid; | ||
129 | __compat_uid32_t cuid; | ||
130 | __compat_gid32_t cgid; | ||
131 | unsigned short mode; | ||
132 | unsigned short __pad1; | ||
133 | unsigned short seq; | ||
134 | unsigned short __pad2; | ||
135 | compat_ulong_t unused1; | ||
136 | compat_ulong_t unused2; | ||
137 | }; | ||
138 | |||
139 | struct compat_semid64_ds { | ||
140 | struct compat_ipc64_perm sem_perm; | ||
141 | compat_time_t sem_otime; | ||
142 | compat_ulong_t __unused1; | ||
143 | compat_time_t sem_ctime; | ||
144 | compat_ulong_t __unused2; | ||
145 | compat_ulong_t sem_nsems; | ||
146 | compat_ulong_t __unused3; | ||
147 | compat_ulong_t __unused4; | ||
148 | }; | ||
149 | |||
150 | struct compat_msqid64_ds { | ||
151 | struct compat_ipc64_perm msg_perm; | ||
152 | compat_time_t msg_stime; | ||
153 | compat_ulong_t __unused1; | ||
154 | compat_time_t msg_rtime; | ||
155 | compat_ulong_t __unused2; | ||
156 | compat_time_t msg_ctime; | ||
157 | compat_ulong_t __unused3; | ||
158 | compat_ulong_t msg_cbytes; | ||
159 | compat_ulong_t msg_qnum; | ||
160 | compat_ulong_t msg_qbytes; | ||
161 | compat_pid_t msg_lspid; | ||
162 | compat_pid_t msg_lrpid; | ||
163 | compat_ulong_t __unused4; | ||
164 | compat_ulong_t __unused5; | ||
165 | }; | ||
166 | |||
167 | struct compat_shmid64_ds { | ||
168 | struct compat_ipc64_perm shm_perm; | ||
169 | compat_size_t shm_segsz; | ||
170 | compat_time_t shm_atime; | ||
171 | compat_ulong_t __unused1; | ||
172 | compat_time_t shm_dtime; | ||
173 | compat_ulong_t __unused2; | ||
174 | compat_time_t shm_ctime; | ||
175 | compat_ulong_t __unused3; | ||
176 | compat_pid_t shm_cpid; | ||
177 | compat_pid_t shm_lpid; | ||
178 | compat_ulong_t shm_nattch; | ||
179 | compat_ulong_t __unused4; | ||
180 | compat_ulong_t __unused5; | ||
181 | }; | ||
182 | |||
183 | /* | ||
184 | * A pointer passed in from user mode. This should not | ||
185 | * be used for syscall parameters, just declare them | ||
186 | * as pointers because the syscall entry code will have | ||
187 | * appropriately comverted them already. | ||
188 | */ | ||
189 | typedef u32 compat_uptr_t; | ||
190 | |||
191 | static inline void __user *compat_ptr(compat_uptr_t uptr) | ||
192 | { | ||
193 | return (void __user *)(unsigned long)uptr; | ||
194 | } | ||
195 | |||
196 | static inline compat_uptr_t ptr_to_compat(void __user *uptr) | ||
197 | { | ||
198 | return (u32)(unsigned long)uptr; | ||
199 | } | ||
200 | |||
201 | static __inline__ void __user *compat_alloc_user_space(long len) | ||
202 | { | ||
203 | struct pt_regs *regs = task_pt_regs(current); | ||
204 | return (void __user *)regs->rsp - len; | ||
205 | } | ||
206 | |||
207 | static inline int is_compat_task(void) | ||
208 | { | ||
209 | return current_thread_info()->status & TS_COMPAT; | ||
210 | } | ||
211 | |||
212 | #endif /* _ASM_X86_64_COMPAT_H */ | ||
diff --git a/include/asm-x86/cpu.h b/include/asm-x86/cpu.h new file mode 100644 index 000000000000..9d914e1e4aad --- /dev/null +++ b/include/asm-x86/cpu.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef _ASM_I386_CPU_H_ | ||
2 | #define _ASM_I386_CPU_H_ | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/cpu.h> | ||
6 | #include <linux/topology.h> | ||
7 | #include <linux/nodemask.h> | ||
8 | #include <linux/percpu.h> | ||
9 | |||
10 | struct i386_cpu { | ||
11 | struct cpu cpu; | ||
12 | }; | ||
13 | extern int arch_register_cpu(int num); | ||
14 | #ifdef CONFIG_HOTPLUG_CPU | ||
15 | extern void arch_unregister_cpu(int); | ||
16 | extern int enable_cpu_hotplug; | ||
17 | #else | ||
18 | #define enable_cpu_hotplug 0 | ||
19 | #endif | ||
20 | |||
21 | DECLARE_PER_CPU(int, cpu_state); | ||
22 | #endif /* _ASM_I386_CPU_H_ */ | ||
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h new file mode 100644 index 000000000000..b7160a4598d7 --- /dev/null +++ b/include/asm-x86/cpufeature.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "cpufeature_32.h" | ||
3 | #else | ||
4 | # include "cpufeature_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/cpufeature_32.h b/include/asm-x86/cpufeature_32.h new file mode 100644 index 000000000000..7b3aa28ebc6e --- /dev/null +++ b/include/asm-x86/cpufeature_32.h | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | * cpufeature.h | ||
3 | * | ||
4 | * Defines x86 CPU feature bits | ||
5 | */ | ||
6 | |||
7 | #ifndef __ASM_I386_CPUFEATURE_H | ||
8 | #define __ASM_I386_CPUFEATURE_H | ||
9 | |||
10 | #ifndef __ASSEMBLY__ | ||
11 | #include <linux/bitops.h> | ||
12 | #endif | ||
13 | #include <asm/required-features.h> | ||
14 | |||
15 | #define NCAPINTS 8 /* N 32-bit words worth of info */ | ||
16 | |||
17 | /* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */ | ||
18 | #define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */ | ||
19 | #define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */ | ||
20 | #define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */ | ||
21 | #define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */ | ||
22 | #define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */ | ||
23 | #define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */ | ||
24 | #define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */ | ||
25 | #define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */ | ||
26 | #define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */ | ||
27 | #define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */ | ||
28 | #define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */ | ||
29 | #define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */ | ||
30 | #define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */ | ||
31 | #define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */ | ||
32 | #define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */ | ||
33 | #define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */ | ||
34 | #define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */ | ||
35 | #define X86_FEATURE_PN (0*32+18) /* Processor serial number */ | ||
36 | #define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */ | ||
37 | #define X86_FEATURE_DS (0*32+21) /* Debug Store */ | ||
38 | #define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */ | ||
39 | #define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ | ||
40 | #define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */ | ||
41 | /* of FPU context), and CR4.OSFXSR available */ | ||
42 | #define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */ | ||
43 | #define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */ | ||
44 | #define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */ | ||
45 | #define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */ | ||
46 | #define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */ | ||
47 | #define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */ | ||
48 | |||
49 | /* AMD-defined CPU features, CPUID level 0x80000001, word 1 */ | ||
50 | /* Don't duplicate feature flags which are redundant with Intel! */ | ||
51 | #define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */ | ||
52 | #define X86_FEATURE_MP (1*32+19) /* MP Capable. */ | ||
53 | #define X86_FEATURE_NX (1*32+20) /* Execute Disable */ | ||
54 | #define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ | ||
55 | #define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */ | ||
56 | #define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */ | ||
57 | #define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */ | ||
58 | #define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */ | ||
59 | |||
60 | /* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */ | ||
61 | #define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */ | ||
62 | #define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */ | ||
63 | #define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */ | ||
64 | |||
65 | /* Other features, Linux-defined mapping, word 3 */ | ||
66 | /* This range is used for feature bits which conflict or are synthesized */ | ||
67 | #define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */ | ||
68 | #define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */ | ||
69 | #define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */ | ||
70 | #define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */ | ||
71 | /* cpu types for specific tunings: */ | ||
72 | #define X86_FEATURE_K8 (3*32+ 4) /* Opteron, Athlon64 */ | ||
73 | #define X86_FEATURE_K7 (3*32+ 5) /* Athlon */ | ||
74 | #define X86_FEATURE_P3 (3*32+ 6) /* P3 */ | ||
75 | #define X86_FEATURE_P4 (3*32+ 7) /* P4 */ | ||
76 | #define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */ | ||
77 | #define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */ | ||
78 | #define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */ | ||
79 | #define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */ | ||
80 | #define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */ | ||
81 | #define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */ | ||
82 | /* 14 free */ | ||
83 | #define X86_FEATURE_SYNC_RDTSC (3*32+15) /* RDTSC synchronizes the CPU */ | ||
84 | #define X86_FEATURE_REP_GOOD (3*32+16) /* rep microcode works well on this CPU */ | ||
85 | |||
86 | /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ | ||
87 | #define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */ | ||
88 | #define X86_FEATURE_MWAIT (4*32+ 3) /* Monitor/Mwait support */ | ||
89 | #define X86_FEATURE_DSCPL (4*32+ 4) /* CPL Qualified Debug Store */ | ||
90 | #define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */ | ||
91 | #define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */ | ||
92 | #define X86_FEATURE_CID (4*32+10) /* Context ID */ | ||
93 | #define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */ | ||
94 | #define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */ | ||
95 | |||
96 | /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */ | ||
97 | #define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */ | ||
98 | #define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */ | ||
99 | #define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */ | ||
100 | #define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */ | ||
101 | #define X86_FEATURE_ACE2 (5*32+ 8) /* Advanced Cryptography Engine v2 */ | ||
102 | #define X86_FEATURE_ACE2_EN (5*32+ 9) /* ACE v2 enabled */ | ||
103 | #define X86_FEATURE_PHE (5*32+ 10) /* PadLock Hash Engine */ | ||
104 | #define X86_FEATURE_PHE_EN (5*32+ 11) /* PHE enabled */ | ||
105 | #define X86_FEATURE_PMM (5*32+ 12) /* PadLock Montgomery Multiplier */ | ||
106 | #define X86_FEATURE_PMM_EN (5*32+ 13) /* PMM enabled */ | ||
107 | |||
108 | /* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */ | ||
109 | #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */ | ||
110 | #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */ | ||
111 | |||
112 | /* | ||
113 | * Auxiliary flags: Linux defined - For features scattered in various | ||
114 | * CPUID levels like 0x6, 0xA etc | ||
115 | */ | ||
116 | #define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */ | ||
117 | |||
118 | #define cpu_has(c, bit) \ | ||
119 | (__builtin_constant_p(bit) && \ | ||
120 | ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \ | ||
121 | (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \ | ||
122 | (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \ | ||
123 | (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \ | ||
124 | (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \ | ||
125 | (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \ | ||
126 | (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \ | ||
127 | (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \ | ||
128 | ? 1 : \ | ||
129 | test_bit(bit, (c)->x86_capability)) | ||
130 | #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit) | ||
131 | |||
132 | #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU) | ||
133 | #define cpu_has_vme boot_cpu_has(X86_FEATURE_VME) | ||
134 | #define cpu_has_de boot_cpu_has(X86_FEATURE_DE) | ||
135 | #define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE) | ||
136 | #define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC) | ||
137 | #define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE) | ||
138 | #define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE) | ||
139 | #define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC) | ||
140 | #define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP) | ||
141 | #define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR) | ||
142 | #define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX) | ||
143 | #define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR) | ||
144 | #define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM) | ||
145 | #define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2) | ||
146 | #define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3) | ||
147 | #define cpu_has_ht boot_cpu_has(X86_FEATURE_HT) | ||
148 | #define cpu_has_mp boot_cpu_has(X86_FEATURE_MP) | ||
149 | #define cpu_has_nx boot_cpu_has(X86_FEATURE_NX) | ||
150 | #define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR) | ||
151 | #define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR) | ||
152 | #define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR) | ||
153 | #define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE) | ||
154 | #define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN) | ||
155 | #define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT) | ||
156 | #define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN) | ||
157 | #define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2) | ||
158 | #define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN) | ||
159 | #define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE) | ||
160 | #define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN) | ||
161 | #define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM) | ||
162 | #define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN) | ||
163 | #define cpu_has_ds boot_cpu_has(X86_FEATURE_DS) | ||
164 | #define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS) | ||
165 | #define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH) | ||
166 | #define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS) | ||
167 | |||
168 | #endif /* __ASM_I386_CPUFEATURE_H */ | ||
169 | |||
170 | /* | ||
171 | * Local Variables: | ||
172 | * mode:c | ||
173 | * comment-column:42 | ||
174 | * End: | ||
175 | */ | ||
diff --git a/include/asm-x86/cpufeature_64.h b/include/asm-x86/cpufeature_64.h new file mode 100644 index 000000000000..2983501e8b3e --- /dev/null +++ b/include/asm-x86/cpufeature_64.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * cpufeature_32.h | ||
3 | * | ||
4 | * Defines x86 CPU feature bits | ||
5 | */ | ||
6 | |||
7 | #ifndef __ASM_X8664_CPUFEATURE_H | ||
8 | #define __ASM_X8664_CPUFEATURE_H | ||
9 | |||
10 | #include <asm/cpufeature_32.h> | ||
11 | |||
12 | #undef cpu_has_vme | ||
13 | #define cpu_has_vme 0 | ||
14 | |||
15 | #undef cpu_has_pae | ||
16 | #define cpu_has_pae ___BUG___ | ||
17 | |||
18 | #undef cpu_has_mp | ||
19 | #define cpu_has_mp 1 /* XXX */ | ||
20 | |||
21 | #undef cpu_has_k6_mtrr | ||
22 | #define cpu_has_k6_mtrr 0 | ||
23 | |||
24 | #undef cpu_has_cyrix_arr | ||
25 | #define cpu_has_cyrix_arr 0 | ||
26 | |||
27 | #undef cpu_has_centaur_mcr | ||
28 | #define cpu_has_centaur_mcr 0 | ||
29 | |||
30 | #endif /* __ASM_X8664_CPUFEATURE_H */ | ||
diff --git a/include/asm-x86/cputime.h b/include/asm-x86/cputime.h new file mode 100644 index 000000000000..87c37cf6b707 --- /dev/null +++ b/include/asm-x86/cputime.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "cputime_32.h" | ||
3 | #else | ||
4 | # include "cputime_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/cputime_32.h b/include/asm-x86/cputime_32.h new file mode 100644 index 000000000000..398ed7cd171d --- /dev/null +++ b/include/asm-x86/cputime_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __I386_CPUTIME_H | ||
2 | #define __I386_CPUTIME_H | ||
3 | |||
4 | #include <asm-generic/cputime.h> | ||
5 | |||
6 | #endif /* __I386_CPUTIME_H */ | ||
diff --git a/include/asm-x86/cputime_64.h b/include/asm-x86/cputime_64.h new file mode 100644 index 000000000000..a07012dc5a3c --- /dev/null +++ b/include/asm-x86/cputime_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __X86_64_CPUTIME_H | ||
2 | #define __X86_64_CPUTIME_H | ||
3 | |||
4 | #include <asm-generic/cputime.h> | ||
5 | |||
6 | #endif /* __X86_64_CPUTIME_H */ | ||
diff --git a/include/asm-x86/current.h b/include/asm-x86/current.h new file mode 100644 index 000000000000..d2526d3f7346 --- /dev/null +++ b/include/asm-x86/current.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "current_32.h" | ||
3 | #else | ||
4 | # include "current_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/current_32.h b/include/asm-x86/current_32.h new file mode 100644 index 000000000000..d35248539912 --- /dev/null +++ b/include/asm-x86/current_32.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _I386_CURRENT_H | ||
2 | #define _I386_CURRENT_H | ||
3 | |||
4 | #include <linux/compiler.h> | ||
5 | #include <asm/percpu.h> | ||
6 | |||
7 | struct task_struct; | ||
8 | |||
9 | DECLARE_PER_CPU(struct task_struct *, current_task); | ||
10 | static __always_inline struct task_struct *get_current(void) | ||
11 | { | ||
12 | return x86_read_percpu(current_task); | ||
13 | } | ||
14 | |||
15 | #define current get_current() | ||
16 | |||
17 | #endif /* !(_I386_CURRENT_H) */ | ||
diff --git a/include/asm-x86/current_64.h b/include/asm-x86/current_64.h new file mode 100644 index 000000000000..bc8adecee66d --- /dev/null +++ b/include/asm-x86/current_64.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef _X86_64_CURRENT_H | ||
2 | #define _X86_64_CURRENT_H | ||
3 | |||
4 | #if !defined(__ASSEMBLY__) | ||
5 | struct task_struct; | ||
6 | |||
7 | #include <asm/pda.h> | ||
8 | |||
9 | static inline struct task_struct *get_current(void) | ||
10 | { | ||
11 | struct task_struct *t = read_pda(pcurrent); | ||
12 | return t; | ||
13 | } | ||
14 | |||
15 | #define current get_current() | ||
16 | |||
17 | #else | ||
18 | |||
19 | #ifndef ASM_OFFSET_H | ||
20 | #include <asm/asm-offsets.h> | ||
21 | #endif | ||
22 | |||
23 | #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg | ||
24 | |||
25 | #endif | ||
26 | |||
27 | #endif /* !(_X86_64_CURRENT_H) */ | ||
diff --git a/include/asm-x86/debugreg.h b/include/asm-x86/debugreg.h new file mode 100644 index 000000000000..b6ce7e4fa002 --- /dev/null +++ b/include/asm-x86/debugreg.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "debugreg_32.h" | ||
4 | # else | ||
5 | # include "debugreg_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "debugreg_32.h" | ||
10 | # else | ||
11 | # include "debugreg_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/debugreg_32.h b/include/asm-x86/debugreg_32.h new file mode 100644 index 000000000000..f0b2b06ae0f7 --- /dev/null +++ b/include/asm-x86/debugreg_32.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _I386_DEBUGREG_H | ||
2 | #define _I386_DEBUGREG_H | ||
3 | |||
4 | |||
5 | /* Indicate the register numbers for a number of the specific | ||
6 | debug registers. Registers 0-3 contain the addresses we wish to trap on */ | ||
7 | #define DR_FIRSTADDR 0 /* u_debugreg[DR_FIRSTADDR] */ | ||
8 | #define DR_LASTADDR 3 /* u_debugreg[DR_LASTADDR] */ | ||
9 | |||
10 | #define DR_STATUS 6 /* u_debugreg[DR_STATUS] */ | ||
11 | #define DR_CONTROL 7 /* u_debugreg[DR_CONTROL] */ | ||
12 | |||
13 | /* Define a few things for the status register. We can use this to determine | ||
14 | which debugging register was responsible for the trap. The other bits | ||
15 | are either reserved or not of interest to us. */ | ||
16 | |||
17 | #define DR_TRAP0 (0x1) /* db0 */ | ||
18 | #define DR_TRAP1 (0x2) /* db1 */ | ||
19 | #define DR_TRAP2 (0x4) /* db2 */ | ||
20 | #define DR_TRAP3 (0x8) /* db3 */ | ||
21 | |||
22 | #define DR_STEP (0x4000) /* single-step */ | ||
23 | #define DR_SWITCH (0x8000) /* task switch */ | ||
24 | |||
25 | /* Now define a bunch of things for manipulating the control register. | ||
26 | The top two bytes of the control register consist of 4 fields of 4 | ||
27 | bits - each field corresponds to one of the four debug registers, | ||
28 | and indicates what types of access we trap on, and how large the data | ||
29 | field is that we are looking at */ | ||
30 | |||
31 | #define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */ | ||
32 | #define DR_CONTROL_SIZE 4 /* 4 control bits per register */ | ||
33 | |||
34 | #define DR_RW_EXECUTE (0x0) /* Settings for the access types to trap on */ | ||
35 | #define DR_RW_WRITE (0x1) | ||
36 | #define DR_RW_READ (0x3) | ||
37 | |||
38 | #define DR_LEN_1 (0x0) /* Settings for data length to trap on */ | ||
39 | #define DR_LEN_2 (0x4) | ||
40 | #define DR_LEN_4 (0xC) | ||
41 | |||
42 | /* The low byte to the control register determine which registers are | ||
43 | enabled. There are 4 fields of two bits. One bit is "local", meaning | ||
44 | that the processor will reset the bit after a task switch and the other | ||
45 | is global meaning that we have to explicitly reset the bit. With linux, | ||
46 | you can use either one, since we explicitly zero the register when we enter | ||
47 | kernel mode. */ | ||
48 | |||
49 | #define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit */ | ||
50 | #define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit */ | ||
51 | #define DR_ENABLE_SIZE 2 /* 2 enable bits per register */ | ||
52 | |||
53 | #define DR_LOCAL_ENABLE_MASK (0x55) /* Set local bits for all 4 regs */ | ||
54 | #define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */ | ||
55 | |||
56 | /* The second byte to the control register has a few special things. | ||
57 | We can slow the instruction pipeline for instructions coming via the | ||
58 | gdt or the ldt if we want to. I am not sure why this is an advantage */ | ||
59 | |||
60 | #define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */ | ||
61 | #define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */ | ||
62 | #define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */ | ||
63 | |||
64 | #endif | ||
diff --git a/include/asm-x86/debugreg_64.h b/include/asm-x86/debugreg_64.h new file mode 100644 index 000000000000..bd1aab1d8c4a --- /dev/null +++ b/include/asm-x86/debugreg_64.h | |||
@@ -0,0 +1,65 @@ | |||
1 | #ifndef _X86_64_DEBUGREG_H | ||
2 | #define _X86_64_DEBUGREG_H | ||
3 | |||
4 | |||
5 | /* Indicate the register numbers for a number of the specific | ||
6 | debug registers. Registers 0-3 contain the addresses we wish to trap on */ | ||
7 | #define DR_FIRSTADDR 0 /* u_debugreg[DR_FIRSTADDR] */ | ||
8 | #define DR_LASTADDR 3 /* u_debugreg[DR_LASTADDR] */ | ||
9 | |||
10 | #define DR_STATUS 6 /* u_debugreg[DR_STATUS] */ | ||
11 | #define DR_CONTROL 7 /* u_debugreg[DR_CONTROL] */ | ||
12 | |||
13 | /* Define a few things for the status register. We can use this to determine | ||
14 | which debugging register was responsible for the trap. The other bits | ||
15 | are either reserved or not of interest to us. */ | ||
16 | |||
17 | #define DR_TRAP0 (0x1) /* db0 */ | ||
18 | #define DR_TRAP1 (0x2) /* db1 */ | ||
19 | #define DR_TRAP2 (0x4) /* db2 */ | ||
20 | #define DR_TRAP3 (0x8) /* db3 */ | ||
21 | |||
22 | #define DR_STEP (0x4000) /* single-step */ | ||
23 | #define DR_SWITCH (0x8000) /* task switch */ | ||
24 | |||
25 | /* Now define a bunch of things for manipulating the control register. | ||
26 | The top two bytes of the control register consist of 4 fields of 4 | ||
27 | bits - each field corresponds to one of the four debug registers, | ||
28 | and indicates what types of access we trap on, and how large the data | ||
29 | field is that we are looking at */ | ||
30 | |||
31 | #define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */ | ||
32 | #define DR_CONTROL_SIZE 4 /* 4 control bits per register */ | ||
33 | |||
34 | #define DR_RW_EXECUTE (0x0) /* Settings for the access types to trap on */ | ||
35 | #define DR_RW_WRITE (0x1) | ||
36 | #define DR_RW_READ (0x3) | ||
37 | |||
38 | #define DR_LEN_1 (0x0) /* Settings for data length to trap on */ | ||
39 | #define DR_LEN_2 (0x4) | ||
40 | #define DR_LEN_4 (0xC) | ||
41 | #define DR_LEN_8 (0x8) | ||
42 | |||
43 | /* The low byte to the control register determine which registers are | ||
44 | enabled. There are 4 fields of two bits. One bit is "local", meaning | ||
45 | that the processor will reset the bit after a task switch and the other | ||
46 | is global meaning that we have to explicitly reset the bit. With linux, | ||
47 | you can use either one, since we explicitly zero the register when we enter | ||
48 | kernel mode. */ | ||
49 | |||
50 | #define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit */ | ||
51 | #define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit */ | ||
52 | #define DR_ENABLE_SIZE 2 /* 2 enable bits per register */ | ||
53 | |||
54 | #define DR_LOCAL_ENABLE_MASK (0x55) /* Set local bits for all 4 regs */ | ||
55 | #define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */ | ||
56 | |||
57 | /* The second byte to the control register has a few special things. | ||
58 | We can slow the instruction pipeline for instructions coming via the | ||
59 | gdt or the ldt if we want to. I am not sure why this is an advantage */ | ||
60 | |||
61 | #define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL) /* Reserved */ | ||
62 | #define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */ | ||
63 | #define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */ | ||
64 | |||
65 | #endif | ||
diff --git a/include/asm-x86/delay.h b/include/asm-x86/delay.h new file mode 100644 index 000000000000..10f2c71d622b --- /dev/null +++ b/include/asm-x86/delay.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "delay_32.h" | ||
3 | #else | ||
4 | # include "delay_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/delay_32.h b/include/asm-x86/delay_32.h new file mode 100644 index 000000000000..9ae5e3782ed8 --- /dev/null +++ b/include/asm-x86/delay_32.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _I386_DELAY_H | ||
2 | #define _I386_DELAY_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 1993 Linus Torvalds | ||
6 | * | ||
7 | * Delay routines calling functions in arch/i386/lib/delay.c | ||
8 | */ | ||
9 | |||
10 | /* Undefined functions to get compile-time errors */ | ||
11 | extern void __bad_udelay(void); | ||
12 | extern void __bad_ndelay(void); | ||
13 | |||
14 | extern void __udelay(unsigned long usecs); | ||
15 | extern void __ndelay(unsigned long nsecs); | ||
16 | extern void __const_udelay(unsigned long usecs); | ||
17 | extern void __delay(unsigned long loops); | ||
18 | |||
19 | /* 0x10c7 is 2**32 / 1000000 (rounded up) */ | ||
20 | #define udelay(n) (__builtin_constant_p(n) ? \ | ||
21 | ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \ | ||
22 | __udelay(n)) | ||
23 | |||
24 | /* 0x5 is 2**32 / 1000000000 (rounded up) */ | ||
25 | #define ndelay(n) (__builtin_constant_p(n) ? \ | ||
26 | ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ | ||
27 | __ndelay(n)) | ||
28 | |||
29 | void use_tsc_delay(void); | ||
30 | |||
31 | #endif /* defined(_I386_DELAY_H) */ | ||
diff --git a/include/asm-x86/delay_64.h b/include/asm-x86/delay_64.h new file mode 100644 index 000000000000..c2669f1f5529 --- /dev/null +++ b/include/asm-x86/delay_64.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef _X8664_DELAY_H | ||
2 | #define _X8664_DELAY_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 1993 Linus Torvalds | ||
6 | * | ||
7 | * Delay routines calling functions in arch/x86_64/lib/delay.c | ||
8 | */ | ||
9 | |||
10 | /* Undefined functions to get compile-time errors */ | ||
11 | extern void __bad_udelay(void); | ||
12 | extern void __bad_ndelay(void); | ||
13 | |||
14 | extern void __udelay(unsigned long usecs); | ||
15 | extern void __ndelay(unsigned long nsecs); | ||
16 | extern void __const_udelay(unsigned long usecs); | ||
17 | extern void __delay(unsigned long loops); | ||
18 | |||
19 | /* 0x10c7 is 2**32 / 1000000 (rounded up) */ | ||
20 | #define udelay(n) (__builtin_constant_p(n) ? \ | ||
21 | ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \ | ||
22 | __udelay(n)) | ||
23 | |||
24 | /* 0x5 is 2**32 / 1000000000 (rounded up) */ | ||
25 | #define ndelay(n) (__builtin_constant_p(n) ? \ | ||
26 | ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ | ||
27 | __ndelay(n)) | ||
28 | |||
29 | |||
30 | #endif /* defined(_X8664_DELAY_H) */ | ||
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h new file mode 100644 index 000000000000..6065c5092265 --- /dev/null +++ b/include/asm-x86/desc.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "desc_32.h" | ||
3 | #else | ||
4 | # include "desc_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/desc_32.h b/include/asm-x86/desc_32.h new file mode 100644 index 000000000000..c547403f341d --- /dev/null +++ b/include/asm-x86/desc_32.h | |||
@@ -0,0 +1,244 @@ | |||
1 | #ifndef __ARCH_DESC_H | ||
2 | #define __ARCH_DESC_H | ||
3 | |||
4 | #include <asm/ldt.h> | ||
5 | #include <asm/segment.h> | ||
6 | |||
7 | #ifndef __ASSEMBLY__ | ||
8 | |||
9 | #include <linux/preempt.h> | ||
10 | #include <linux/smp.h> | ||
11 | #include <linux/percpu.h> | ||
12 | |||
13 | #include <asm/mmu.h> | ||
14 | |||
15 | struct Xgt_desc_struct { | ||
16 | unsigned short size; | ||
17 | unsigned long address __attribute__((packed)); | ||
18 | unsigned short pad; | ||
19 | } __attribute__ ((packed)); | ||
20 | |||
21 | struct gdt_page | ||
22 | { | ||
23 | struct desc_struct gdt[GDT_ENTRIES]; | ||
24 | } __attribute__((aligned(PAGE_SIZE))); | ||
25 | DECLARE_PER_CPU(struct gdt_page, gdt_page); | ||
26 | |||
27 | static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu) | ||
28 | { | ||
29 | return per_cpu(gdt_page, cpu).gdt; | ||
30 | } | ||
31 | |||
32 | extern struct Xgt_desc_struct idt_descr; | ||
33 | extern struct desc_struct idt_table[]; | ||
34 | extern void set_intr_gate(unsigned int irq, void * addr); | ||
35 | |||
36 | static inline void pack_descriptor(__u32 *a, __u32 *b, | ||
37 | unsigned long base, unsigned long limit, unsigned char type, unsigned char flags) | ||
38 | { | ||
39 | *a = ((base & 0xffff) << 16) | (limit & 0xffff); | ||
40 | *b = (base & 0xff000000) | ((base & 0xff0000) >> 16) | | ||
41 | (limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20); | ||
42 | } | ||
43 | |||
44 | static inline void pack_gate(__u32 *a, __u32 *b, | ||
45 | unsigned long base, unsigned short seg, unsigned char type, unsigned char flags) | ||
46 | { | ||
47 | *a = (seg << 16) | (base & 0xffff); | ||
48 | *b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff); | ||
49 | } | ||
50 | |||
51 | #define DESCTYPE_LDT 0x82 /* present, system, DPL-0, LDT */ | ||
52 | #define DESCTYPE_TSS 0x89 /* present, system, DPL-0, 32-bit TSS */ | ||
53 | #define DESCTYPE_TASK 0x85 /* present, system, DPL-0, task gate */ | ||
54 | #define DESCTYPE_INT 0x8e /* present, system, DPL-0, interrupt gate */ | ||
55 | #define DESCTYPE_TRAP 0x8f /* present, system, DPL-0, trap gate */ | ||
56 | #define DESCTYPE_DPL3 0x60 /* DPL-3 */ | ||
57 | #define DESCTYPE_S 0x10 /* !system */ | ||
58 | |||
59 | #ifdef CONFIG_PARAVIRT | ||
60 | #include <asm/paravirt.h> | ||
61 | #else | ||
62 | #define load_TR_desc() native_load_tr_desc() | ||
63 | #define load_gdt(dtr) native_load_gdt(dtr) | ||
64 | #define load_idt(dtr) native_load_idt(dtr) | ||
65 | #define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr)) | ||
66 | #define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt)) | ||
67 | |||
68 | #define store_gdt(dtr) native_store_gdt(dtr) | ||
69 | #define store_idt(dtr) native_store_idt(dtr) | ||
70 | #define store_tr(tr) (tr = native_store_tr()) | ||
71 | #define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt)) | ||
72 | |||
73 | #define load_TLS(t, cpu) native_load_tls(t, cpu) | ||
74 | #define set_ldt native_set_ldt | ||
75 | |||
76 | #define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) | ||
77 | #define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) | ||
78 | #define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) | ||
79 | #endif | ||
80 | |||
81 | static inline void write_dt_entry(struct desc_struct *dt, | ||
82 | int entry, u32 entry_low, u32 entry_high) | ||
83 | { | ||
84 | dt[entry].a = entry_low; | ||
85 | dt[entry].b = entry_high; | ||
86 | } | ||
87 | |||
88 | static inline void native_set_ldt(const void *addr, unsigned int entries) | ||
89 | { | ||
90 | if (likely(entries == 0)) | ||
91 | __asm__ __volatile__("lldt %w0"::"q" (0)); | ||
92 | else { | ||
93 | unsigned cpu = smp_processor_id(); | ||
94 | __u32 a, b; | ||
95 | |||
96 | pack_descriptor(&a, &b, (unsigned long)addr, | ||
97 | entries * sizeof(struct desc_struct) - 1, | ||
98 | DESCTYPE_LDT, 0); | ||
99 | write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b); | ||
100 | __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | |||
105 | static inline void native_load_tr_desc(void) | ||
106 | { | ||
107 | asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8)); | ||
108 | } | ||
109 | |||
110 | static inline void native_load_gdt(const struct Xgt_desc_struct *dtr) | ||
111 | { | ||
112 | asm volatile("lgdt %0"::"m" (*dtr)); | ||
113 | } | ||
114 | |||
115 | static inline void native_load_idt(const struct Xgt_desc_struct *dtr) | ||
116 | { | ||
117 | asm volatile("lidt %0"::"m" (*dtr)); | ||
118 | } | ||
119 | |||
120 | static inline void native_store_gdt(struct Xgt_desc_struct *dtr) | ||
121 | { | ||
122 | asm ("sgdt %0":"=m" (*dtr)); | ||
123 | } | ||
124 | |||
125 | static inline void native_store_idt(struct Xgt_desc_struct *dtr) | ||
126 | { | ||
127 | asm ("sidt %0":"=m" (*dtr)); | ||
128 | } | ||
129 | |||
130 | static inline unsigned long native_store_tr(void) | ||
131 | { | ||
132 | unsigned long tr; | ||
133 | asm ("str %0":"=r" (tr)); | ||
134 | return tr; | ||
135 | } | ||
136 | |||
137 | static inline void native_load_tls(struct thread_struct *t, unsigned int cpu) | ||
138 | { | ||
139 | unsigned int i; | ||
140 | struct desc_struct *gdt = get_cpu_gdt_table(cpu); | ||
141 | |||
142 | for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++) | ||
143 | gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]; | ||
144 | } | ||
145 | |||
146 | static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg) | ||
147 | { | ||
148 | __u32 a, b; | ||
149 | pack_gate(&a, &b, (unsigned long)addr, seg, type, 0); | ||
150 | write_idt_entry(idt_table, gate, a, b); | ||
151 | } | ||
152 | |||
153 | static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr) | ||
154 | { | ||
155 | __u32 a, b; | ||
156 | pack_descriptor(&a, &b, (unsigned long)addr, | ||
157 | offsetof(struct tss_struct, __cacheline_filler) - 1, | ||
158 | DESCTYPE_TSS, 0); | ||
159 | write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b); | ||
160 | } | ||
161 | |||
162 | |||
163 | #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) | ||
164 | |||
165 | #define LDT_entry_a(info) \ | ||
166 | ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) | ||
167 | |||
168 | #define LDT_entry_b(info) \ | ||
169 | (((info)->base_addr & 0xff000000) | \ | ||
170 | (((info)->base_addr & 0x00ff0000) >> 16) | \ | ||
171 | ((info)->limit & 0xf0000) | \ | ||
172 | (((info)->read_exec_only ^ 1) << 9) | \ | ||
173 | ((info)->contents << 10) | \ | ||
174 | (((info)->seg_not_present ^ 1) << 15) | \ | ||
175 | ((info)->seg_32bit << 22) | \ | ||
176 | ((info)->limit_in_pages << 23) | \ | ||
177 | ((info)->useable << 20) | \ | ||
178 | 0x7000) | ||
179 | |||
180 | #define LDT_empty(info) (\ | ||
181 | (info)->base_addr == 0 && \ | ||
182 | (info)->limit == 0 && \ | ||
183 | (info)->contents == 0 && \ | ||
184 | (info)->read_exec_only == 1 && \ | ||
185 | (info)->seg_32bit == 0 && \ | ||
186 | (info)->limit_in_pages == 0 && \ | ||
187 | (info)->seg_not_present == 1 && \ | ||
188 | (info)->useable == 0 ) | ||
189 | |||
190 | static inline void clear_LDT(void) | ||
191 | { | ||
192 | set_ldt(NULL, 0); | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * load one particular LDT into the current CPU | ||
197 | */ | ||
198 | static inline void load_LDT_nolock(mm_context_t *pc) | ||
199 | { | ||
200 | set_ldt(pc->ldt, pc->size); | ||
201 | } | ||
202 | |||
203 | static inline void load_LDT(mm_context_t *pc) | ||
204 | { | ||
205 | preempt_disable(); | ||
206 | load_LDT_nolock(pc); | ||
207 | preempt_enable(); | ||
208 | } | ||
209 | |||
210 | static inline unsigned long get_desc_base(unsigned long *desc) | ||
211 | { | ||
212 | unsigned long base; | ||
213 | base = ((desc[0] >> 16) & 0x0000ffff) | | ||
214 | ((desc[1] << 16) & 0x00ff0000) | | ||
215 | (desc[1] & 0xff000000); | ||
216 | return base; | ||
217 | } | ||
218 | |||
219 | #else /* __ASSEMBLY__ */ | ||
220 | |||
221 | /* | ||
222 | * GET_DESC_BASE reads the descriptor base of the specified segment. | ||
223 | * | ||
224 | * Args: | ||
225 | * idx - descriptor index | ||
226 | * gdt - GDT pointer | ||
227 | * base - 32bit register to which the base will be written | ||
228 | * lo_w - lo word of the "base" register | ||
229 | * lo_b - lo byte of the "base" register | ||
230 | * hi_b - hi byte of the low word of the "base" register | ||
231 | * | ||
232 | * Example: | ||
233 | * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah) | ||
234 | * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax. | ||
235 | */ | ||
236 | #define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \ | ||
237 | movb idx*8+4(gdt), lo_b; \ | ||
238 | movb idx*8+7(gdt), hi_b; \ | ||
239 | shll $16, base; \ | ||
240 | movw idx*8+2(gdt), lo_w; | ||
241 | |||
242 | #endif /* !__ASSEMBLY__ */ | ||
243 | |||
244 | #endif | ||
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h new file mode 100644 index 000000000000..ac991b5ca0fd --- /dev/null +++ b/include/asm-x86/desc_64.h | |||
@@ -0,0 +1,174 @@ | |||
1 | /* Written 2000 by Andi Kleen */ | ||
2 | #ifndef __ARCH_DESC_H | ||
3 | #define __ARCH_DESC_H | ||
4 | |||
5 | #include <linux/threads.h> | ||
6 | #include <asm/ldt.h> | ||
7 | |||
8 | #ifndef __ASSEMBLY__ | ||
9 | |||
10 | #include <linux/string.h> | ||
11 | #include <linux/smp.h> | ||
12 | #include <asm/desc_defs.h> | ||
13 | |||
14 | #include <asm/segment.h> | ||
15 | #include <asm/mmu.h> | ||
16 | |||
17 | extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; | ||
18 | |||
19 | #define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8)) | ||
20 | #define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8)) | ||
21 | #define clear_LDT() asm volatile("lldt %w0"::"r" (0)) | ||
22 | |||
23 | /* | ||
24 | * This is the ldt that every process will get unless we need | ||
25 | * something other than this. | ||
26 | */ | ||
27 | extern struct desc_struct default_ldt[]; | ||
28 | extern struct gate_struct idt_table[]; | ||
29 | extern struct desc_ptr cpu_gdt_descr[]; | ||
30 | |||
31 | /* the cpu gdt accessor */ | ||
32 | #define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address) | ||
33 | |||
34 | static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist) | ||
35 | { | ||
36 | struct gate_struct s; | ||
37 | s.offset_low = PTR_LOW(func); | ||
38 | s.segment = __KERNEL_CS; | ||
39 | s.ist = ist; | ||
40 | s.p = 1; | ||
41 | s.dpl = dpl; | ||
42 | s.zero0 = 0; | ||
43 | s.zero1 = 0; | ||
44 | s.type = type; | ||
45 | s.offset_middle = PTR_MIDDLE(func); | ||
46 | s.offset_high = PTR_HIGH(func); | ||
47 | /* does not need to be atomic because it is only done once at setup time */ | ||
48 | memcpy(adr, &s, 16); | ||
49 | } | ||
50 | |||
51 | static inline void set_intr_gate(int nr, void *func) | ||
52 | { | ||
53 | BUG_ON((unsigned)nr > 0xFF); | ||
54 | _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, 0); | ||
55 | } | ||
56 | |||
57 | static inline void set_intr_gate_ist(int nr, void *func, unsigned ist) | ||
58 | { | ||
59 | BUG_ON((unsigned)nr > 0xFF); | ||
60 | _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, ist); | ||
61 | } | ||
62 | |||
63 | static inline void set_system_gate(int nr, void *func) | ||
64 | { | ||
65 | BUG_ON((unsigned)nr > 0xFF); | ||
66 | _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, 0); | ||
67 | } | ||
68 | |||
69 | static inline void set_system_gate_ist(int nr, void *func, unsigned ist) | ||
70 | { | ||
71 | _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist); | ||
72 | } | ||
73 | |||
74 | static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type, | ||
75 | unsigned size) | ||
76 | { | ||
77 | struct ldttss_desc d; | ||
78 | memset(&d,0,sizeof(d)); | ||
79 | d.limit0 = size & 0xFFFF; | ||
80 | d.base0 = PTR_LOW(tss); | ||
81 | d.base1 = PTR_MIDDLE(tss) & 0xFF; | ||
82 | d.type = type; | ||
83 | d.p = 1; | ||
84 | d.limit1 = (size >> 16) & 0xF; | ||
85 | d.base2 = (PTR_MIDDLE(tss) >> 8) & 0xFF; | ||
86 | d.base3 = PTR_HIGH(tss); | ||
87 | memcpy(ptr, &d, 16); | ||
88 | } | ||
89 | |||
90 | static inline void set_tss_desc(unsigned cpu, void *addr) | ||
91 | { | ||
92 | /* | ||
93 | * sizeof(unsigned long) coming from an extra "long" at the end | ||
94 | * of the iobitmap. See tss_struct definition in processor.h | ||
95 | * | ||
96 | * -1? seg base+limit should be pointing to the address of the | ||
97 | * last valid byte | ||
98 | */ | ||
99 | set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_TSS], | ||
100 | (unsigned long)addr, DESC_TSS, | ||
101 | IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1); | ||
102 | } | ||
103 | |||
104 | static inline void set_ldt_desc(unsigned cpu, void *addr, int size) | ||
105 | { | ||
106 | set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_LDT], (unsigned long)addr, | ||
107 | DESC_LDT, size * 8 - 1); | ||
108 | } | ||
109 | |||
110 | #define LDT_entry_a(info) \ | ||
111 | ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) | ||
112 | /* Don't allow setting of the lm bit. It is useless anyways because | ||
113 | 64bit system calls require __USER_CS. */ | ||
114 | #define LDT_entry_b(info) \ | ||
115 | (((info)->base_addr & 0xff000000) | \ | ||
116 | (((info)->base_addr & 0x00ff0000) >> 16) | \ | ||
117 | ((info)->limit & 0xf0000) | \ | ||
118 | (((info)->read_exec_only ^ 1) << 9) | \ | ||
119 | ((info)->contents << 10) | \ | ||
120 | (((info)->seg_not_present ^ 1) << 15) | \ | ||
121 | ((info)->seg_32bit << 22) | \ | ||
122 | ((info)->limit_in_pages << 23) | \ | ||
123 | ((info)->useable << 20) | \ | ||
124 | /* ((info)->lm << 21) | */ \ | ||
125 | 0x7000) | ||
126 | |||
127 | #define LDT_empty(info) (\ | ||
128 | (info)->base_addr == 0 && \ | ||
129 | (info)->limit == 0 && \ | ||
130 | (info)->contents == 0 && \ | ||
131 | (info)->read_exec_only == 1 && \ | ||
132 | (info)->seg_32bit == 0 && \ | ||
133 | (info)->limit_in_pages == 0 && \ | ||
134 | (info)->seg_not_present == 1 && \ | ||
135 | (info)->useable == 0 && \ | ||
136 | (info)->lm == 0) | ||
137 | |||
138 | static inline void load_TLS(struct thread_struct *t, unsigned int cpu) | ||
139 | { | ||
140 | unsigned int i; | ||
141 | u64 *gdt = (u64 *)(cpu_gdt(cpu) + GDT_ENTRY_TLS_MIN); | ||
142 | |||
143 | for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++) | ||
144 | gdt[i] = t->tls_array[i]; | ||
145 | } | ||
146 | |||
147 | /* | ||
148 | * load one particular LDT into the current CPU | ||
149 | */ | ||
150 | static inline void load_LDT_nolock (mm_context_t *pc, int cpu) | ||
151 | { | ||
152 | int count = pc->size; | ||
153 | |||
154 | if (likely(!count)) { | ||
155 | clear_LDT(); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | set_ldt_desc(cpu, pc->ldt, count); | ||
160 | load_LDT_desc(); | ||
161 | } | ||
162 | |||
163 | static inline void load_LDT(mm_context_t *pc) | ||
164 | { | ||
165 | int cpu = get_cpu(); | ||
166 | load_LDT_nolock(pc, cpu); | ||
167 | put_cpu(); | ||
168 | } | ||
169 | |||
170 | extern struct desc_ptr idt_descr; | ||
171 | |||
172 | #endif /* !__ASSEMBLY__ */ | ||
173 | |||
174 | #endif | ||
diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h new file mode 100644 index 000000000000..089004070099 --- /dev/null +++ b/include/asm-x86/desc_defs.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* Written 2000 by Andi Kleen */ | ||
2 | #ifndef __ARCH_DESC_DEFS_H | ||
3 | #define __ARCH_DESC_DEFS_H | ||
4 | |||
5 | /* | ||
6 | * Segment descriptor structure definitions, usable from both x86_64 and i386 | ||
7 | * archs. | ||
8 | */ | ||
9 | |||
10 | #ifndef __ASSEMBLY__ | ||
11 | |||
12 | #include <linux/types.h> | ||
13 | |||
14 | // 8 byte segment descriptor | ||
15 | struct desc_struct { | ||
16 | u16 limit0; | ||
17 | u16 base0; | ||
18 | unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1; | ||
19 | unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8; | ||
20 | } __attribute__((packed)); | ||
21 | |||
22 | struct n_desc_struct { | ||
23 | unsigned int a,b; | ||
24 | }; | ||
25 | |||
26 | enum { | ||
27 | GATE_INTERRUPT = 0xE, | ||
28 | GATE_TRAP = 0xF, | ||
29 | GATE_CALL = 0xC, | ||
30 | }; | ||
31 | |||
32 | // 16byte gate | ||
33 | struct gate_struct { | ||
34 | u16 offset_low; | ||
35 | u16 segment; | ||
36 | unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1; | ||
37 | u16 offset_middle; | ||
38 | u32 offset_high; | ||
39 | u32 zero1; | ||
40 | } __attribute__((packed)); | ||
41 | |||
42 | #define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF) | ||
43 | #define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF) | ||
44 | #define PTR_HIGH(x) ((unsigned long)(x) >> 32) | ||
45 | |||
46 | enum { | ||
47 | DESC_TSS = 0x9, | ||
48 | DESC_LDT = 0x2, | ||
49 | }; | ||
50 | |||
51 | // LDT or TSS descriptor in the GDT. 16 bytes. | ||
52 | struct ldttss_desc { | ||
53 | u16 limit0; | ||
54 | u16 base0; | ||
55 | unsigned base1 : 8, type : 5, dpl : 2, p : 1; | ||
56 | unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8; | ||
57 | u32 base3; | ||
58 | u32 zero1; | ||
59 | } __attribute__((packed)); | ||
60 | |||
61 | struct desc_ptr { | ||
62 | unsigned short size; | ||
63 | unsigned long address; | ||
64 | } __attribute__((packed)) ; | ||
65 | |||
66 | |||
67 | #endif /* !__ASSEMBLY__ */ | ||
68 | |||
69 | #endif | ||
diff --git a/include/asm-x86/device.h b/include/asm-x86/device.h new file mode 100644 index 000000000000..e2bcf7c7dcee --- /dev/null +++ b/include/asm-x86/device.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "device_32.h" | ||
3 | #else | ||
4 | # include "device_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/device_32.h b/include/asm-x86/device_32.h new file mode 100644 index 000000000000..849604c70e6b --- /dev/null +++ b/include/asm-x86/device_32.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Arch specific extensions to struct device | ||
3 | * | ||
4 | * This file is released under the GPLv2 | ||
5 | */ | ||
6 | #ifndef _ASM_I386_DEVICE_H | ||
7 | #define _ASM_I386_DEVICE_H | ||
8 | |||
9 | struct dev_archdata { | ||
10 | #ifdef CONFIG_ACPI | ||
11 | void *acpi_handle; | ||
12 | #endif | ||
13 | }; | ||
14 | |||
15 | #endif /* _ASM_I386_DEVICE_H */ | ||
diff --git a/include/asm-x86/device_64.h b/include/asm-x86/device_64.h new file mode 100644 index 000000000000..3afa03f33a36 --- /dev/null +++ b/include/asm-x86/device_64.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Arch specific extensions to struct device | ||
3 | * | ||
4 | * This file is released under the GPLv2 | ||
5 | */ | ||
6 | #ifndef _ASM_X86_64_DEVICE_H | ||
7 | #define _ASM_X86_64_DEVICE_H | ||
8 | |||
9 | struct dev_archdata { | ||
10 | #ifdef CONFIG_ACPI | ||
11 | void *acpi_handle; | ||
12 | #endif | ||
13 | }; | ||
14 | |||
15 | #endif /* _ASM_X86_64_DEVICE_H */ | ||
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h new file mode 100644 index 000000000000..8ac7da6ca284 --- /dev/null +++ b/include/asm-x86/div64.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "div64_32.h" | ||
3 | #else | ||
4 | # include "div64_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/div64_32.h b/include/asm-x86/div64_32.h new file mode 100644 index 000000000000..438e980068bd --- /dev/null +++ b/include/asm-x86/div64_32.h | |||
@@ -0,0 +1,52 @@ | |||
1 | #ifndef __I386_DIV64 | ||
2 | #define __I386_DIV64 | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | /* | ||
7 | * do_div() is NOT a C function. It wants to return | ||
8 | * two values (the quotient and the remainder), but | ||
9 | * since that doesn't work very well in C, what it | ||
10 | * does is: | ||
11 | * | ||
12 | * - modifies the 64-bit dividend _in_place_ | ||
13 | * - returns the 32-bit remainder | ||
14 | * | ||
15 | * This ends up being the most efficient "calling | ||
16 | * convention" on x86. | ||
17 | */ | ||
18 | #define do_div(n,base) ({ \ | ||
19 | unsigned long __upper, __low, __high, __mod, __base; \ | ||
20 | __base = (base); \ | ||
21 | asm("":"=a" (__low), "=d" (__high):"A" (n)); \ | ||
22 | __upper = __high; \ | ||
23 | if (__high) { \ | ||
24 | __upper = __high % (__base); \ | ||
25 | __high = __high / (__base); \ | ||
26 | } \ | ||
27 | asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \ | ||
28 | asm("":"=A" (n):"a" (__low),"d" (__high)); \ | ||
29 | __mod; \ | ||
30 | }) | ||
31 | |||
32 | /* | ||
33 | * (long)X = ((long long)divs) / (long)div | ||
34 | * (long)rem = ((long long)divs) % (long)div | ||
35 | * | ||
36 | * Warning, this will do an exception if X overflows. | ||
37 | */ | ||
38 | #define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c) | ||
39 | |||
40 | static inline long | ||
41 | div_ll_X_l_rem(long long divs, long div, long *rem) | ||
42 | { | ||
43 | long dum2; | ||
44 | __asm__("divl %2":"=a"(dum2), "=d"(*rem) | ||
45 | : "rm"(div), "A"(divs)); | ||
46 | |||
47 | return dum2; | ||
48 | |||
49 | } | ||
50 | |||
51 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
52 | #endif | ||
diff --git a/include/asm-x86/div64_64.h b/include/asm-x86/div64_64.h new file mode 100644 index 000000000000..6cd978cefb28 --- /dev/null +++ b/include/asm-x86/div64_64.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/div64.h> | |||
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h new file mode 100644 index 000000000000..58f790f4df52 --- /dev/null +++ b/include/asm-x86/dma-mapping.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "dma-mapping_32.h" | ||
3 | #else | ||
4 | # include "dma-mapping_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h new file mode 100644 index 000000000000..f1d72d177f68 --- /dev/null +++ b/include/asm-x86/dma-mapping_32.h | |||
@@ -0,0 +1,186 @@ | |||
1 | #ifndef _ASM_I386_DMA_MAPPING_H | ||
2 | #define _ASM_I386_DMA_MAPPING_H | ||
3 | |||
4 | #include <linux/mm.h> | ||
5 | |||
6 | #include <asm/cache.h> | ||
7 | #include <asm/io.h> | ||
8 | #include <asm/scatterlist.h> | ||
9 | #include <asm/bug.h> | ||
10 | |||
11 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | ||
12 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | ||
13 | |||
14 | void *dma_alloc_coherent(struct device *dev, size_t size, | ||
15 | dma_addr_t *dma_handle, gfp_t flag); | ||
16 | |||
17 | void dma_free_coherent(struct device *dev, size_t size, | ||
18 | void *vaddr, dma_addr_t dma_handle); | ||
19 | |||
20 | static inline dma_addr_t | ||
21 | dma_map_single(struct device *dev, void *ptr, size_t size, | ||
22 | enum dma_data_direction direction) | ||
23 | { | ||
24 | BUG_ON(!valid_dma_direction(direction)); | ||
25 | WARN_ON(size == 0); | ||
26 | flush_write_buffers(); | ||
27 | return virt_to_phys(ptr); | ||
28 | } | ||
29 | |||
30 | static inline void | ||
31 | dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | ||
32 | enum dma_data_direction direction) | ||
33 | { | ||
34 | BUG_ON(!valid_dma_direction(direction)); | ||
35 | } | ||
36 | |||
37 | static inline int | ||
38 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | ||
39 | enum dma_data_direction direction) | ||
40 | { | ||
41 | int i; | ||
42 | |||
43 | BUG_ON(!valid_dma_direction(direction)); | ||
44 | WARN_ON(nents == 0 || sg[0].length == 0); | ||
45 | |||
46 | for (i = 0; i < nents; i++ ) { | ||
47 | BUG_ON(!sg[i].page); | ||
48 | |||
49 | sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset; | ||
50 | } | ||
51 | |||
52 | flush_write_buffers(); | ||
53 | return nents; | ||
54 | } | ||
55 | |||
56 | static inline dma_addr_t | ||
57 | dma_map_page(struct device *dev, struct page *page, unsigned long offset, | ||
58 | size_t size, enum dma_data_direction direction) | ||
59 | { | ||
60 | BUG_ON(!valid_dma_direction(direction)); | ||
61 | return page_to_phys(page) + offset; | ||
62 | } | ||
63 | |||
64 | static inline void | ||
65 | dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, | ||
66 | enum dma_data_direction direction) | ||
67 | { | ||
68 | BUG_ON(!valid_dma_direction(direction)); | ||
69 | } | ||
70 | |||
71 | |||
72 | static inline void | ||
73 | dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, | ||
74 | enum dma_data_direction direction) | ||
75 | { | ||
76 | BUG_ON(!valid_dma_direction(direction)); | ||
77 | } | ||
78 | |||
79 | static inline void | ||
80 | dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, | ||
81 | enum dma_data_direction direction) | ||
82 | { | ||
83 | } | ||
84 | |||
85 | static inline void | ||
86 | dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, | ||
87 | enum dma_data_direction direction) | ||
88 | { | ||
89 | flush_write_buffers(); | ||
90 | } | ||
91 | |||
92 | static inline void | ||
93 | dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, | ||
94 | unsigned long offset, size_t size, | ||
95 | enum dma_data_direction direction) | ||
96 | { | ||
97 | } | ||
98 | |||
99 | static inline void | ||
100 | dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, | ||
101 | unsigned long offset, size_t size, | ||
102 | enum dma_data_direction direction) | ||
103 | { | ||
104 | flush_write_buffers(); | ||
105 | } | ||
106 | |||
107 | static inline void | ||
108 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, | ||
109 | enum dma_data_direction direction) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | static inline void | ||
114 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, | ||
115 | enum dma_data_direction direction) | ||
116 | { | ||
117 | flush_write_buffers(); | ||
118 | } | ||
119 | |||
120 | static inline int | ||
121 | dma_mapping_error(dma_addr_t dma_addr) | ||
122 | { | ||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | extern int forbid_dac; | ||
127 | |||
128 | static inline int | ||
129 | dma_supported(struct device *dev, u64 mask) | ||
130 | { | ||
131 | /* | ||
132 | * we fall back to GFP_DMA when the mask isn't all 1s, | ||
133 | * so we can't guarantee allocations that must be | ||
134 | * within a tighter range than GFP_DMA.. | ||
135 | */ | ||
136 | if(mask < 0x00ffffff) | ||
137 | return 0; | ||
138 | |||
139 | /* Work around chipset bugs */ | ||
140 | if (forbid_dac > 0 && mask > 0xffffffffULL) | ||
141 | return 0; | ||
142 | |||
143 | return 1; | ||
144 | } | ||
145 | |||
146 | static inline int | ||
147 | dma_set_mask(struct device *dev, u64 mask) | ||
148 | { | ||
149 | if(!dev->dma_mask || !dma_supported(dev, mask)) | ||
150 | return -EIO; | ||
151 | |||
152 | *dev->dma_mask = mask; | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static inline int | ||
158 | dma_get_cache_alignment(void) | ||
159 | { | ||
160 | /* no easy way to get cache size on all x86, so return the | ||
161 | * maximum possible, to be safe */ | ||
162 | return (1 << INTERNODE_CACHE_SHIFT); | ||
163 | } | ||
164 | |||
165 | #define dma_is_consistent(d, h) (1) | ||
166 | |||
167 | static inline void | ||
168 | dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
169 | enum dma_data_direction direction) | ||
170 | { | ||
171 | flush_write_buffers(); | ||
172 | } | ||
173 | |||
174 | #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY | ||
175 | extern int | ||
176 | dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, | ||
177 | dma_addr_t device_addr, size_t size, int flags); | ||
178 | |||
179 | extern void | ||
180 | dma_release_declared_memory(struct device *dev); | ||
181 | |||
182 | extern void * | ||
183 | dma_mark_declared_memory_occupied(struct device *dev, | ||
184 | dma_addr_t device_addr, size_t size); | ||
185 | |||
186 | #endif | ||
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h new file mode 100644 index 000000000000..6897e2a436e5 --- /dev/null +++ b/include/asm-x86/dma-mapping_64.h | |||
@@ -0,0 +1,203 @@ | |||
1 | #ifndef _X8664_DMA_MAPPING_H | ||
2 | #define _X8664_DMA_MAPPING_H 1 | ||
3 | |||
4 | /* | ||
5 | * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for | ||
6 | * documentation. | ||
7 | */ | ||
8 | |||
9 | |||
10 | #include <asm/scatterlist.h> | ||
11 | #include <asm/io.h> | ||
12 | #include <asm/swiotlb.h> | ||
13 | |||
14 | struct dma_mapping_ops { | ||
15 | int (*mapping_error)(dma_addr_t dma_addr); | ||
16 | void* (*alloc_coherent)(struct device *dev, size_t size, | ||
17 | dma_addr_t *dma_handle, gfp_t gfp); | ||
18 | void (*free_coherent)(struct device *dev, size_t size, | ||
19 | void *vaddr, dma_addr_t dma_handle); | ||
20 | dma_addr_t (*map_single)(struct device *hwdev, void *ptr, | ||
21 | size_t size, int direction); | ||
22 | /* like map_single, but doesn't check the device mask */ | ||
23 | dma_addr_t (*map_simple)(struct device *hwdev, char *ptr, | ||
24 | size_t size, int direction); | ||
25 | void (*unmap_single)(struct device *dev, dma_addr_t addr, | ||
26 | size_t size, int direction); | ||
27 | void (*sync_single_for_cpu)(struct device *hwdev, | ||
28 | dma_addr_t dma_handle, size_t size, | ||
29 | int direction); | ||
30 | void (*sync_single_for_device)(struct device *hwdev, | ||
31 | dma_addr_t dma_handle, size_t size, | ||
32 | int direction); | ||
33 | void (*sync_single_range_for_cpu)(struct device *hwdev, | ||
34 | dma_addr_t dma_handle, unsigned long offset, | ||
35 | size_t size, int direction); | ||
36 | void (*sync_single_range_for_device)(struct device *hwdev, | ||
37 | dma_addr_t dma_handle, unsigned long offset, | ||
38 | size_t size, int direction); | ||
39 | void (*sync_sg_for_cpu)(struct device *hwdev, | ||
40 | struct scatterlist *sg, int nelems, | ||
41 | int direction); | ||
42 | void (*sync_sg_for_device)(struct device *hwdev, | ||
43 | struct scatterlist *sg, int nelems, | ||
44 | int direction); | ||
45 | int (*map_sg)(struct device *hwdev, struct scatterlist *sg, | ||
46 | int nents, int direction); | ||
47 | void (*unmap_sg)(struct device *hwdev, | ||
48 | struct scatterlist *sg, int nents, | ||
49 | int direction); | ||
50 | int (*dma_supported)(struct device *hwdev, u64 mask); | ||
51 | int is_phys; | ||
52 | }; | ||
53 | |||
54 | extern dma_addr_t bad_dma_address; | ||
55 | extern const struct dma_mapping_ops* dma_ops; | ||
56 | extern int iommu_merge; | ||
57 | |||
58 | static inline int dma_mapping_error(dma_addr_t dma_addr) | ||
59 | { | ||
60 | if (dma_ops->mapping_error) | ||
61 | return dma_ops->mapping_error(dma_addr); | ||
62 | |||
63 | return (dma_addr == bad_dma_address); | ||
64 | } | ||
65 | |||
66 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | ||
67 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | ||
68 | |||
69 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | ||
70 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | ||
71 | |||
72 | extern void *dma_alloc_coherent(struct device *dev, size_t size, | ||
73 | dma_addr_t *dma_handle, gfp_t gfp); | ||
74 | extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr, | ||
75 | dma_addr_t dma_handle); | ||
76 | |||
77 | static inline dma_addr_t | ||
78 | dma_map_single(struct device *hwdev, void *ptr, size_t size, | ||
79 | int direction) | ||
80 | { | ||
81 | BUG_ON(!valid_dma_direction(direction)); | ||
82 | return dma_ops->map_single(hwdev, ptr, size, direction); | ||
83 | } | ||
84 | |||
85 | static inline void | ||
86 | dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size, | ||
87 | int direction) | ||
88 | { | ||
89 | BUG_ON(!valid_dma_direction(direction)); | ||
90 | dma_ops->unmap_single(dev, addr, size, direction); | ||
91 | } | ||
92 | |||
93 | #define dma_map_page(dev,page,offset,size,dir) \ | ||
94 | dma_map_single((dev), page_address(page)+(offset), (size), (dir)) | ||
95 | |||
96 | #define dma_unmap_page dma_unmap_single | ||
97 | |||
98 | static inline void | ||
99 | dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle, | ||
100 | size_t size, int direction) | ||
101 | { | ||
102 | BUG_ON(!valid_dma_direction(direction)); | ||
103 | if (dma_ops->sync_single_for_cpu) | ||
104 | dma_ops->sync_single_for_cpu(hwdev, dma_handle, size, | ||
105 | direction); | ||
106 | flush_write_buffers(); | ||
107 | } | ||
108 | |||
109 | static inline void | ||
110 | dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle, | ||
111 | size_t size, int direction) | ||
112 | { | ||
113 | BUG_ON(!valid_dma_direction(direction)); | ||
114 | if (dma_ops->sync_single_for_device) | ||
115 | dma_ops->sync_single_for_device(hwdev, dma_handle, size, | ||
116 | direction); | ||
117 | flush_write_buffers(); | ||
118 | } | ||
119 | |||
120 | static inline void | ||
121 | dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle, | ||
122 | unsigned long offset, size_t size, int direction) | ||
123 | { | ||
124 | BUG_ON(!valid_dma_direction(direction)); | ||
125 | if (dma_ops->sync_single_range_for_cpu) { | ||
126 | dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset, size, direction); | ||
127 | } | ||
128 | |||
129 | flush_write_buffers(); | ||
130 | } | ||
131 | |||
132 | static inline void | ||
133 | dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle, | ||
134 | unsigned long offset, size_t size, int direction) | ||
135 | { | ||
136 | BUG_ON(!valid_dma_direction(direction)); | ||
137 | if (dma_ops->sync_single_range_for_device) | ||
138 | dma_ops->sync_single_range_for_device(hwdev, dma_handle, | ||
139 | offset, size, direction); | ||
140 | |||
141 | flush_write_buffers(); | ||
142 | } | ||
143 | |||
144 | static inline void | ||
145 | dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, | ||
146 | int nelems, int direction) | ||
147 | { | ||
148 | BUG_ON(!valid_dma_direction(direction)); | ||
149 | if (dma_ops->sync_sg_for_cpu) | ||
150 | dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction); | ||
151 | flush_write_buffers(); | ||
152 | } | ||
153 | |||
154 | static inline void | ||
155 | dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, | ||
156 | int nelems, int direction) | ||
157 | { | ||
158 | BUG_ON(!valid_dma_direction(direction)); | ||
159 | if (dma_ops->sync_sg_for_device) { | ||
160 | dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction); | ||
161 | } | ||
162 | |||
163 | flush_write_buffers(); | ||
164 | } | ||
165 | |||
166 | static inline int | ||
167 | dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction) | ||
168 | { | ||
169 | BUG_ON(!valid_dma_direction(direction)); | ||
170 | return dma_ops->map_sg(hwdev, sg, nents, direction); | ||
171 | } | ||
172 | |||
173 | static inline void | ||
174 | dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, | ||
175 | int direction) | ||
176 | { | ||
177 | BUG_ON(!valid_dma_direction(direction)); | ||
178 | dma_ops->unmap_sg(hwdev, sg, nents, direction); | ||
179 | } | ||
180 | |||
181 | extern int dma_supported(struct device *hwdev, u64 mask); | ||
182 | |||
183 | /* same for gart, swiotlb, and nommu */ | ||
184 | static inline int dma_get_cache_alignment(void) | ||
185 | { | ||
186 | return boot_cpu_data.x86_clflush_size; | ||
187 | } | ||
188 | |||
189 | #define dma_is_consistent(d, h) 1 | ||
190 | |||
191 | extern int dma_set_mask(struct device *dev, u64 mask); | ||
192 | |||
193 | static inline void | ||
194 | dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
195 | enum dma_data_direction dir) | ||
196 | { | ||
197 | flush_write_buffers(); | ||
198 | } | ||
199 | |||
200 | extern struct device fallback_dev; | ||
201 | extern int panic_on_overflow; | ||
202 | |||
203 | #endif /* _X8664_DMA_MAPPING_H */ | ||
diff --git a/include/asm-x86/dma.h b/include/asm-x86/dma.h new file mode 100644 index 000000000000..9f936c61a4e5 --- /dev/null +++ b/include/asm-x86/dma.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "dma_32.h" | ||
3 | #else | ||
4 | # include "dma_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/dma_32.h b/include/asm-x86/dma_32.h new file mode 100644 index 000000000000..d23aac8e1a50 --- /dev/null +++ b/include/asm-x86/dma_32.h | |||
@@ -0,0 +1,297 @@ | |||
1 | /* $Id: dma.h,v 1.7 1992/12/14 00:29:34 root Exp root $ | ||
2 | * linux/include/asm/dma.h: Defines for using and allocating dma channels. | ||
3 | * Written by Hennus Bergman, 1992. | ||
4 | * High DMA channel support & info by Hannu Savolainen | ||
5 | * and John Boyd, Nov. 1992. | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_DMA_H | ||
9 | #define _ASM_DMA_H | ||
10 | |||
11 | #include <linux/spinlock.h> /* And spinlocks */ | ||
12 | #include <asm/io.h> /* need byte IO */ | ||
13 | #include <linux/delay.h> | ||
14 | |||
15 | |||
16 | #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER | ||
17 | #define dma_outb outb_p | ||
18 | #else | ||
19 | #define dma_outb outb | ||
20 | #endif | ||
21 | |||
22 | #define dma_inb inb | ||
23 | |||
24 | /* | ||
25 | * NOTES about DMA transfers: | ||
26 | * | ||
27 | * controller 1: channels 0-3, byte operations, ports 00-1F | ||
28 | * controller 2: channels 4-7, word operations, ports C0-DF | ||
29 | * | ||
30 | * - ALL registers are 8 bits only, regardless of transfer size | ||
31 | * - channel 4 is not used - cascades 1 into 2. | ||
32 | * - channels 0-3 are byte - addresses/counts are for physical bytes | ||
33 | * - channels 5-7 are word - addresses/counts are for physical words | ||
34 | * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries | ||
35 | * - transfer count loaded to registers is 1 less than actual count | ||
36 | * - controller 2 offsets are all even (2x offsets for controller 1) | ||
37 | * - page registers for 5-7 don't use data bit 0, represent 128K pages | ||
38 | * - page registers for 0-3 use bit 0, represent 64K pages | ||
39 | * | ||
40 | * DMA transfers are limited to the lower 16MB of _physical_ memory. | ||
41 | * Note that addresses loaded into registers must be _physical_ addresses, | ||
42 | * not logical addresses (which may differ if paging is active). | ||
43 | * | ||
44 | * Address mapping for channels 0-3: | ||
45 | * | ||
46 | * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses) | ||
47 | * | ... | | ... | | ... | | ||
48 | * | ... | | ... | | ... | | ||
49 | * | ... | | ... | | ... | | ||
50 | * P7 ... P0 A7 ... A0 A7 ... A0 | ||
51 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
52 | * | ||
53 | * Address mapping for channels 5-7: | ||
54 | * | ||
55 | * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses) | ||
56 | * | ... | \ \ ... \ \ \ ... \ \ | ||
57 | * | ... | \ \ ... \ \ \ ... \ (not used) | ||
58 | * | ... | \ \ ... \ \ \ ... \ | ||
59 | * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0 | ||
60 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
61 | * | ||
62 | * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses | ||
63 | * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at | ||
64 | * the hardware level, so odd-byte transfers aren't possible). | ||
65 | * | ||
66 | * Transfer count (_not # bytes_) is limited to 64K, represented as actual | ||
67 | * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more, | ||
68 | * and up to 128K bytes may be transferred on channels 5-7 in one operation. | ||
69 | * | ||
70 | */ | ||
71 | |||
72 | #define MAX_DMA_CHANNELS 8 | ||
73 | |||
74 | /* The maximum address that we can perform a DMA transfer to on this platform */ | ||
75 | #define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) | ||
76 | |||
77 | /* 8237 DMA controllers */ | ||
78 | #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ | ||
79 | #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ | ||
80 | |||
81 | /* DMA controller registers */ | ||
82 | #define DMA1_CMD_REG 0x08 /* command register (w) */ | ||
83 | #define DMA1_STAT_REG 0x08 /* status register (r) */ | ||
84 | #define DMA1_REQ_REG 0x09 /* request register (w) */ | ||
85 | #define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ | ||
86 | #define DMA1_MODE_REG 0x0B /* mode register (w) */ | ||
87 | #define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ | ||
88 | #define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ | ||
89 | #define DMA1_RESET_REG 0x0D /* Master Clear (w) */ | ||
90 | #define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ | ||
91 | #define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ | ||
92 | |||
93 | #define DMA2_CMD_REG 0xD0 /* command register (w) */ | ||
94 | #define DMA2_STAT_REG 0xD0 /* status register (r) */ | ||
95 | #define DMA2_REQ_REG 0xD2 /* request register (w) */ | ||
96 | #define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ | ||
97 | #define DMA2_MODE_REG 0xD6 /* mode register (w) */ | ||
98 | #define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ | ||
99 | #define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ | ||
100 | #define DMA2_RESET_REG 0xDA /* Master Clear (w) */ | ||
101 | #define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ | ||
102 | #define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ | ||
103 | |||
104 | #define DMA_ADDR_0 0x00 /* DMA address registers */ | ||
105 | #define DMA_ADDR_1 0x02 | ||
106 | #define DMA_ADDR_2 0x04 | ||
107 | #define DMA_ADDR_3 0x06 | ||
108 | #define DMA_ADDR_4 0xC0 | ||
109 | #define DMA_ADDR_5 0xC4 | ||
110 | #define DMA_ADDR_6 0xC8 | ||
111 | #define DMA_ADDR_7 0xCC | ||
112 | |||
113 | #define DMA_CNT_0 0x01 /* DMA count registers */ | ||
114 | #define DMA_CNT_1 0x03 | ||
115 | #define DMA_CNT_2 0x05 | ||
116 | #define DMA_CNT_3 0x07 | ||
117 | #define DMA_CNT_4 0xC2 | ||
118 | #define DMA_CNT_5 0xC6 | ||
119 | #define DMA_CNT_6 0xCA | ||
120 | #define DMA_CNT_7 0xCE | ||
121 | |||
122 | #define DMA_PAGE_0 0x87 /* DMA page registers */ | ||
123 | #define DMA_PAGE_1 0x83 | ||
124 | #define DMA_PAGE_2 0x81 | ||
125 | #define DMA_PAGE_3 0x82 | ||
126 | #define DMA_PAGE_5 0x8B | ||
127 | #define DMA_PAGE_6 0x89 | ||
128 | #define DMA_PAGE_7 0x8A | ||
129 | |||
130 | #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ | ||
131 | #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ | ||
132 | #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ | ||
133 | |||
134 | #define DMA_AUTOINIT 0x10 | ||
135 | |||
136 | |||
137 | extern spinlock_t dma_spin_lock; | ||
138 | |||
139 | static __inline__ unsigned long claim_dma_lock(void) | ||
140 | { | ||
141 | unsigned long flags; | ||
142 | spin_lock_irqsave(&dma_spin_lock, flags); | ||
143 | return flags; | ||
144 | } | ||
145 | |||
146 | static __inline__ void release_dma_lock(unsigned long flags) | ||
147 | { | ||
148 | spin_unlock_irqrestore(&dma_spin_lock, flags); | ||
149 | } | ||
150 | |||
151 | /* enable/disable a specific DMA channel */ | ||
152 | static __inline__ void enable_dma(unsigned int dmanr) | ||
153 | { | ||
154 | if (dmanr<=3) | ||
155 | dma_outb(dmanr, DMA1_MASK_REG); | ||
156 | else | ||
157 | dma_outb(dmanr & 3, DMA2_MASK_REG); | ||
158 | } | ||
159 | |||
160 | static __inline__ void disable_dma(unsigned int dmanr) | ||
161 | { | ||
162 | if (dmanr<=3) | ||
163 | dma_outb(dmanr | 4, DMA1_MASK_REG); | ||
164 | else | ||
165 | dma_outb((dmanr & 3) | 4, DMA2_MASK_REG); | ||
166 | } | ||
167 | |||
168 | /* Clear the 'DMA Pointer Flip Flop'. | ||
169 | * Write 0 for LSB/MSB, 1 for MSB/LSB access. | ||
170 | * Use this once to initialize the FF to a known state. | ||
171 | * After that, keep track of it. :-) | ||
172 | * --- In order to do that, the DMA routines below should --- | ||
173 | * --- only be used while holding the DMA lock ! --- | ||
174 | */ | ||
175 | static __inline__ void clear_dma_ff(unsigned int dmanr) | ||
176 | { | ||
177 | if (dmanr<=3) | ||
178 | dma_outb(0, DMA1_CLEAR_FF_REG); | ||
179 | else | ||
180 | dma_outb(0, DMA2_CLEAR_FF_REG); | ||
181 | } | ||
182 | |||
183 | /* set mode (above) for a specific DMA channel */ | ||
184 | static __inline__ void set_dma_mode(unsigned int dmanr, char mode) | ||
185 | { | ||
186 | if (dmanr<=3) | ||
187 | dma_outb(mode | dmanr, DMA1_MODE_REG); | ||
188 | else | ||
189 | dma_outb(mode | (dmanr&3), DMA2_MODE_REG); | ||
190 | } | ||
191 | |||
192 | /* Set only the page register bits of the transfer address. | ||
193 | * This is used for successive transfers when we know the contents of | ||
194 | * the lower 16 bits of the DMA current address register, but a 64k boundary | ||
195 | * may have been crossed. | ||
196 | */ | ||
197 | static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) | ||
198 | { | ||
199 | switch(dmanr) { | ||
200 | case 0: | ||
201 | dma_outb(pagenr, DMA_PAGE_0); | ||
202 | break; | ||
203 | case 1: | ||
204 | dma_outb(pagenr, DMA_PAGE_1); | ||
205 | break; | ||
206 | case 2: | ||
207 | dma_outb(pagenr, DMA_PAGE_2); | ||
208 | break; | ||
209 | case 3: | ||
210 | dma_outb(pagenr, DMA_PAGE_3); | ||
211 | break; | ||
212 | case 5: | ||
213 | dma_outb(pagenr & 0xfe, DMA_PAGE_5); | ||
214 | break; | ||
215 | case 6: | ||
216 | dma_outb(pagenr & 0xfe, DMA_PAGE_6); | ||
217 | break; | ||
218 | case 7: | ||
219 | dma_outb(pagenr & 0xfe, DMA_PAGE_7); | ||
220 | break; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | |||
225 | /* Set transfer address & page bits for specific DMA channel. | ||
226 | * Assumes dma flipflop is clear. | ||
227 | */ | ||
228 | static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) | ||
229 | { | ||
230 | set_dma_page(dmanr, a>>16); | ||
231 | if (dmanr <= 3) { | ||
232 | dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); | ||
233 | dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); | ||
234 | } else { | ||
235 | dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); | ||
236 | dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | |||
241 | /* Set transfer size (max 64k for DMA0..3, 128k for DMA5..7) for | ||
242 | * a specific DMA channel. | ||
243 | * You must ensure the parameters are valid. | ||
244 | * NOTE: from a manual: "the number of transfers is one more | ||
245 | * than the initial word count"! This is taken into account. | ||
246 | * Assumes dma flip-flop is clear. | ||
247 | * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. | ||
248 | */ | ||
249 | static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) | ||
250 | { | ||
251 | count--; | ||
252 | if (dmanr <= 3) { | ||
253 | dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); | ||
254 | dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); | ||
255 | } else { | ||
256 | dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); | ||
257 | dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | |||
262 | /* Get DMA residue count. After a DMA transfer, this | ||
263 | * should return zero. Reading this while a DMA transfer is | ||
264 | * still in progress will return unpredictable results. | ||
265 | * If called before the channel has been used, it may return 1. | ||
266 | * Otherwise, it returns the number of _bytes_ left to transfer. | ||
267 | * | ||
268 | * Assumes DMA flip-flop is clear. | ||
269 | */ | ||
270 | static __inline__ int get_dma_residue(unsigned int dmanr) | ||
271 | { | ||
272 | unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE | ||
273 | : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE; | ||
274 | |||
275 | /* using short to get 16-bit wrap around */ | ||
276 | unsigned short count; | ||
277 | |||
278 | count = 1 + dma_inb(io_port); | ||
279 | count += dma_inb(io_port) << 8; | ||
280 | |||
281 | return (dmanr<=3)? count : (count<<1); | ||
282 | } | ||
283 | |||
284 | |||
285 | /* These are in kernel/dma.c: */ | ||
286 | extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */ | ||
287 | extern void free_dma(unsigned int dmanr); /* release it again */ | ||
288 | |||
289 | /* From PCI */ | ||
290 | |||
291 | #ifdef CONFIG_PCI | ||
292 | extern int isa_dma_bridge_buggy; | ||
293 | #else | ||
294 | #define isa_dma_bridge_buggy (0) | ||
295 | #endif | ||
296 | |||
297 | #endif /* _ASM_DMA_H */ | ||
diff --git a/include/asm-x86/dma_64.h b/include/asm-x86/dma_64.h new file mode 100644 index 000000000000..a37c16f06289 --- /dev/null +++ b/include/asm-x86/dma_64.h | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * linux/include/asm/dma.h: Defines for using and allocating dma channels. | ||
3 | * Written by Hennus Bergman, 1992. | ||
4 | * High DMA channel support & info by Hannu Savolainen | ||
5 | * and John Boyd, Nov. 1992. | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_DMA_H | ||
9 | #define _ASM_DMA_H | ||
10 | |||
11 | #include <linux/spinlock.h> /* And spinlocks */ | ||
12 | #include <asm/io.h> /* need byte IO */ | ||
13 | #include <linux/delay.h> | ||
14 | |||
15 | |||
16 | #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER | ||
17 | #define dma_outb outb_p | ||
18 | #else | ||
19 | #define dma_outb outb | ||
20 | #endif | ||
21 | |||
22 | #define dma_inb inb | ||
23 | |||
24 | /* | ||
25 | * NOTES about DMA transfers: | ||
26 | * | ||
27 | * controller 1: channels 0-3, byte operations, ports 00-1F | ||
28 | * controller 2: channels 4-7, word operations, ports C0-DF | ||
29 | * | ||
30 | * - ALL registers are 8 bits only, regardless of transfer size | ||
31 | * - channel 4 is not used - cascades 1 into 2. | ||
32 | * - channels 0-3 are byte - addresses/counts are for physical bytes | ||
33 | * - channels 5-7 are word - addresses/counts are for physical words | ||
34 | * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries | ||
35 | * - transfer count loaded to registers is 1 less than actual count | ||
36 | * - controller 2 offsets are all even (2x offsets for controller 1) | ||
37 | * - page registers for 5-7 don't use data bit 0, represent 128K pages | ||
38 | * - page registers for 0-3 use bit 0, represent 64K pages | ||
39 | * | ||
40 | * DMA transfers are limited to the lower 16MB of _physical_ memory. | ||
41 | * Note that addresses loaded into registers must be _physical_ addresses, | ||
42 | * not logical addresses (which may differ if paging is active). | ||
43 | * | ||
44 | * Address mapping for channels 0-3: | ||
45 | * | ||
46 | * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses) | ||
47 | * | ... | | ... | | ... | | ||
48 | * | ... | | ... | | ... | | ||
49 | * | ... | | ... | | ... | | ||
50 | * P7 ... P0 A7 ... A0 A7 ... A0 | ||
51 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
52 | * | ||
53 | * Address mapping for channels 5-7: | ||
54 | * | ||
55 | * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses) | ||
56 | * | ... | \ \ ... \ \ \ ... \ \ | ||
57 | * | ... | \ \ ... \ \ \ ... \ (not used) | ||
58 | * | ... | \ \ ... \ \ \ ... \ | ||
59 | * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0 | ||
60 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
61 | * | ||
62 | * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses | ||
63 | * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at | ||
64 | * the hardware level, so odd-byte transfers aren't possible). | ||
65 | * | ||
66 | * Transfer count (_not # bytes_) is limited to 64K, represented as actual | ||
67 | * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more, | ||
68 | * and up to 128K bytes may be transferred on channels 5-7 in one operation. | ||
69 | * | ||
70 | */ | ||
71 | |||
72 | #define MAX_DMA_CHANNELS 8 | ||
73 | |||
74 | |||
75 | /* 16MB ISA DMA zone */ | ||
76 | #define MAX_DMA_PFN ((16*1024*1024) >> PAGE_SHIFT) | ||
77 | |||
78 | /* 4GB broken PCI/AGP hardware bus master zone */ | ||
79 | #define MAX_DMA32_PFN ((4UL*1024*1024*1024) >> PAGE_SHIFT) | ||
80 | |||
81 | /* Compat define for old dma zone */ | ||
82 | #define MAX_DMA_ADDRESS ((unsigned long)__va(MAX_DMA_PFN << PAGE_SHIFT)) | ||
83 | |||
84 | /* 8237 DMA controllers */ | ||
85 | #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ | ||
86 | #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ | ||
87 | |||
88 | /* DMA controller registers */ | ||
89 | #define DMA1_CMD_REG 0x08 /* command register (w) */ | ||
90 | #define DMA1_STAT_REG 0x08 /* status register (r) */ | ||
91 | #define DMA1_REQ_REG 0x09 /* request register (w) */ | ||
92 | #define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ | ||
93 | #define DMA1_MODE_REG 0x0B /* mode register (w) */ | ||
94 | #define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ | ||
95 | #define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ | ||
96 | #define DMA1_RESET_REG 0x0D /* Master Clear (w) */ | ||
97 | #define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ | ||
98 | #define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ | ||
99 | |||
100 | #define DMA2_CMD_REG 0xD0 /* command register (w) */ | ||
101 | #define DMA2_STAT_REG 0xD0 /* status register (r) */ | ||
102 | #define DMA2_REQ_REG 0xD2 /* request register (w) */ | ||
103 | #define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ | ||
104 | #define DMA2_MODE_REG 0xD6 /* mode register (w) */ | ||
105 | #define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ | ||
106 | #define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ | ||
107 | #define DMA2_RESET_REG 0xDA /* Master Clear (w) */ | ||
108 | #define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ | ||
109 | #define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ | ||
110 | |||
111 | #define DMA_ADDR_0 0x00 /* DMA address registers */ | ||
112 | #define DMA_ADDR_1 0x02 | ||
113 | #define DMA_ADDR_2 0x04 | ||
114 | #define DMA_ADDR_3 0x06 | ||
115 | #define DMA_ADDR_4 0xC0 | ||
116 | #define DMA_ADDR_5 0xC4 | ||
117 | #define DMA_ADDR_6 0xC8 | ||
118 | #define DMA_ADDR_7 0xCC | ||
119 | |||
120 | #define DMA_CNT_0 0x01 /* DMA count registers */ | ||
121 | #define DMA_CNT_1 0x03 | ||
122 | #define DMA_CNT_2 0x05 | ||
123 | #define DMA_CNT_3 0x07 | ||
124 | #define DMA_CNT_4 0xC2 | ||
125 | #define DMA_CNT_5 0xC6 | ||
126 | #define DMA_CNT_6 0xCA | ||
127 | #define DMA_CNT_7 0xCE | ||
128 | |||
129 | #define DMA_PAGE_0 0x87 /* DMA page registers */ | ||
130 | #define DMA_PAGE_1 0x83 | ||
131 | #define DMA_PAGE_2 0x81 | ||
132 | #define DMA_PAGE_3 0x82 | ||
133 | #define DMA_PAGE_5 0x8B | ||
134 | #define DMA_PAGE_6 0x89 | ||
135 | #define DMA_PAGE_7 0x8A | ||
136 | |||
137 | #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ | ||
138 | #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ | ||
139 | #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ | ||
140 | |||
141 | #define DMA_AUTOINIT 0x10 | ||
142 | |||
143 | |||
144 | extern spinlock_t dma_spin_lock; | ||
145 | |||
146 | static __inline__ unsigned long claim_dma_lock(void) | ||
147 | { | ||
148 | unsigned long flags; | ||
149 | spin_lock_irqsave(&dma_spin_lock, flags); | ||
150 | return flags; | ||
151 | } | ||
152 | |||
153 | static __inline__ void release_dma_lock(unsigned long flags) | ||
154 | { | ||
155 | spin_unlock_irqrestore(&dma_spin_lock, flags); | ||
156 | } | ||
157 | |||
158 | /* enable/disable a specific DMA channel */ | ||
159 | static __inline__ void enable_dma(unsigned int dmanr) | ||
160 | { | ||
161 | if (dmanr<=3) | ||
162 | dma_outb(dmanr, DMA1_MASK_REG); | ||
163 | else | ||
164 | dma_outb(dmanr & 3, DMA2_MASK_REG); | ||
165 | } | ||
166 | |||
167 | static __inline__ void disable_dma(unsigned int dmanr) | ||
168 | { | ||
169 | if (dmanr<=3) | ||
170 | dma_outb(dmanr | 4, DMA1_MASK_REG); | ||
171 | else | ||
172 | dma_outb((dmanr & 3) | 4, DMA2_MASK_REG); | ||
173 | } | ||
174 | |||
175 | /* Clear the 'DMA Pointer Flip Flop'. | ||
176 | * Write 0 for LSB/MSB, 1 for MSB/LSB access. | ||
177 | * Use this once to initialize the FF to a known state. | ||
178 | * After that, keep track of it. :-) | ||
179 | * --- In order to do that, the DMA routines below should --- | ||
180 | * --- only be used while holding the DMA lock ! --- | ||
181 | */ | ||
182 | static __inline__ void clear_dma_ff(unsigned int dmanr) | ||
183 | { | ||
184 | if (dmanr<=3) | ||
185 | dma_outb(0, DMA1_CLEAR_FF_REG); | ||
186 | else | ||
187 | dma_outb(0, DMA2_CLEAR_FF_REG); | ||
188 | } | ||
189 | |||
190 | /* set mode (above) for a specific DMA channel */ | ||
191 | static __inline__ void set_dma_mode(unsigned int dmanr, char mode) | ||
192 | { | ||
193 | if (dmanr<=3) | ||
194 | dma_outb(mode | dmanr, DMA1_MODE_REG); | ||
195 | else | ||
196 | dma_outb(mode | (dmanr&3), DMA2_MODE_REG); | ||
197 | } | ||
198 | |||
199 | /* Set only the page register bits of the transfer address. | ||
200 | * This is used for successive transfers when we know the contents of | ||
201 | * the lower 16 bits of the DMA current address register, but a 64k boundary | ||
202 | * may have been crossed. | ||
203 | */ | ||
204 | static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) | ||
205 | { | ||
206 | switch(dmanr) { | ||
207 | case 0: | ||
208 | dma_outb(pagenr, DMA_PAGE_0); | ||
209 | break; | ||
210 | case 1: | ||
211 | dma_outb(pagenr, DMA_PAGE_1); | ||
212 | break; | ||
213 | case 2: | ||
214 | dma_outb(pagenr, DMA_PAGE_2); | ||
215 | break; | ||
216 | case 3: | ||
217 | dma_outb(pagenr, DMA_PAGE_3); | ||
218 | break; | ||
219 | case 5: | ||
220 | dma_outb(pagenr & 0xfe, DMA_PAGE_5); | ||
221 | break; | ||
222 | case 6: | ||
223 | dma_outb(pagenr & 0xfe, DMA_PAGE_6); | ||
224 | break; | ||
225 | case 7: | ||
226 | dma_outb(pagenr & 0xfe, DMA_PAGE_7); | ||
227 | break; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | |||
232 | /* Set transfer address & page bits for specific DMA channel. | ||
233 | * Assumes dma flipflop is clear. | ||
234 | */ | ||
235 | static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) | ||
236 | { | ||
237 | set_dma_page(dmanr, a>>16); | ||
238 | if (dmanr <= 3) { | ||
239 | dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); | ||
240 | dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); | ||
241 | } else { | ||
242 | dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); | ||
243 | dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | |||
248 | /* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for | ||
249 | * a specific DMA channel. | ||
250 | * You must ensure the parameters are valid. | ||
251 | * NOTE: from a manual: "the number of transfers is one more | ||
252 | * than the initial word count"! This is taken into account. | ||
253 | * Assumes dma flip-flop is clear. | ||
254 | * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. | ||
255 | */ | ||
256 | static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) | ||
257 | { | ||
258 | count--; | ||
259 | if (dmanr <= 3) { | ||
260 | dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); | ||
261 | dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); | ||
262 | } else { | ||
263 | dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); | ||
264 | dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | |||
269 | /* Get DMA residue count. After a DMA transfer, this | ||
270 | * should return zero. Reading this while a DMA transfer is | ||
271 | * still in progress will return unpredictable results. | ||
272 | * If called before the channel has been used, it may return 1. | ||
273 | * Otherwise, it returns the number of _bytes_ left to transfer. | ||
274 | * | ||
275 | * Assumes DMA flip-flop is clear. | ||
276 | */ | ||
277 | static __inline__ int get_dma_residue(unsigned int dmanr) | ||
278 | { | ||
279 | unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE | ||
280 | : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE; | ||
281 | |||
282 | /* using short to get 16-bit wrap around */ | ||
283 | unsigned short count; | ||
284 | |||
285 | count = 1 + dma_inb(io_port); | ||
286 | count += dma_inb(io_port) << 8; | ||
287 | |||
288 | return (dmanr<=3)? count : (count<<1); | ||
289 | } | ||
290 | |||
291 | |||
292 | /* These are in kernel/dma.c: */ | ||
293 | extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */ | ||
294 | extern void free_dma(unsigned int dmanr); /* release it again */ | ||
295 | |||
296 | /* From PCI */ | ||
297 | |||
298 | #ifdef CONFIG_PCI | ||
299 | extern int isa_dma_bridge_buggy; | ||
300 | #else | ||
301 | #define isa_dma_bridge_buggy (0) | ||
302 | #endif | ||
303 | |||
304 | #endif /* _ASM_DMA_H */ | ||
diff --git a/include/asm-x86/dmi.h b/include/asm-x86/dmi.h new file mode 100644 index 000000000000..c9e4e8ebc270 --- /dev/null +++ b/include/asm-x86/dmi.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "dmi_32.h" | ||
3 | #else | ||
4 | # include "dmi_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/dmi_32.h b/include/asm-x86/dmi_32.h new file mode 100644 index 000000000000..38d4eeb7fc7e --- /dev/null +++ b/include/asm-x86/dmi_32.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _ASM_DMI_H | ||
2 | #define _ASM_DMI_H 1 | ||
3 | |||
4 | #include <asm/io.h> | ||
5 | |||
6 | /* Use early IO mappings for DMI because it's initialized early */ | ||
7 | #define dmi_ioremap bt_ioremap | ||
8 | #define dmi_iounmap bt_iounmap | ||
9 | #define dmi_alloc alloc_bootmem | ||
10 | |||
11 | #endif | ||
diff --git a/include/asm-x86/dmi_64.h b/include/asm-x86/dmi_64.h new file mode 100644 index 000000000000..d02e32e3c3f0 --- /dev/null +++ b/include/asm-x86/dmi_64.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef _ASM_DMI_H | ||
2 | #define _ASM_DMI_H 1 | ||
3 | |||
4 | #include <asm/io.h> | ||
5 | |||
6 | #define DMI_MAX_DATA 2048 | ||
7 | |||
8 | extern int dmi_alloc_index; | ||
9 | extern char dmi_alloc_data[DMI_MAX_DATA]; | ||
10 | |||
11 | /* This is so early that there is no good way to allocate dynamic memory. | ||
12 | Allocate data in an BSS array. */ | ||
13 | static inline void *dmi_alloc(unsigned len) | ||
14 | { | ||
15 | int idx = dmi_alloc_index; | ||
16 | if ((dmi_alloc_index += len) > DMI_MAX_DATA) | ||
17 | return NULL; | ||
18 | return dmi_alloc_data + idx; | ||
19 | } | ||
20 | |||
21 | #define dmi_ioremap early_ioremap | ||
22 | #define dmi_iounmap early_iounmap | ||
23 | |||
24 | #endif | ||
diff --git a/include/asm-x86/dwarf2.h b/include/asm-x86/dwarf2.h new file mode 100644 index 000000000000..b3cbb0ccae18 --- /dev/null +++ b/include/asm-x86/dwarf2.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "dwarf2_32.h" | ||
3 | #else | ||
4 | # include "dwarf2_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/dwarf2_32.h b/include/asm-x86/dwarf2_32.h new file mode 100644 index 000000000000..6d66398a307d --- /dev/null +++ b/include/asm-x86/dwarf2_32.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifndef _DWARF2_H | ||
2 | #define _DWARF2_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | #warning "asm/dwarf2.h should be only included in pure assembly files" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | Macros for dwarf2 CFI unwind table entries. | ||
10 | See "as.info" for details on these pseudo ops. Unfortunately | ||
11 | they are only supported in very new binutils, so define them | ||
12 | away for older version. | ||
13 | */ | ||
14 | |||
15 | #ifdef CONFIG_UNWIND_INFO | ||
16 | |||
17 | #define CFI_STARTPROC .cfi_startproc | ||
18 | #define CFI_ENDPROC .cfi_endproc | ||
19 | #define CFI_DEF_CFA .cfi_def_cfa | ||
20 | #define CFI_DEF_CFA_REGISTER .cfi_def_cfa_register | ||
21 | #define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset | ||
22 | #define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset | ||
23 | #define CFI_OFFSET .cfi_offset | ||
24 | #define CFI_REL_OFFSET .cfi_rel_offset | ||
25 | #define CFI_REGISTER .cfi_register | ||
26 | #define CFI_RESTORE .cfi_restore | ||
27 | #define CFI_REMEMBER_STATE .cfi_remember_state | ||
28 | #define CFI_RESTORE_STATE .cfi_restore_state | ||
29 | #define CFI_UNDEFINED .cfi_undefined | ||
30 | |||
31 | #ifdef CONFIG_AS_CFI_SIGNAL_FRAME | ||
32 | #define CFI_SIGNAL_FRAME .cfi_signal_frame | ||
33 | #else | ||
34 | #define CFI_SIGNAL_FRAME | ||
35 | #endif | ||
36 | |||
37 | #else | ||
38 | |||
39 | /* Due to the structure of pre-exisiting code, don't use assembler line | ||
40 | comment character # to ignore the arguments. Instead, use a dummy macro. */ | ||
41 | .macro ignore a=0, b=0, c=0, d=0 | ||
42 | .endm | ||
43 | |||
44 | #define CFI_STARTPROC ignore | ||
45 | #define CFI_ENDPROC ignore | ||
46 | #define CFI_DEF_CFA ignore | ||
47 | #define CFI_DEF_CFA_REGISTER ignore | ||
48 | #define CFI_DEF_CFA_OFFSET ignore | ||
49 | #define CFI_ADJUST_CFA_OFFSET ignore | ||
50 | #define CFI_OFFSET ignore | ||
51 | #define CFI_REL_OFFSET ignore | ||
52 | #define CFI_REGISTER ignore | ||
53 | #define CFI_RESTORE ignore | ||
54 | #define CFI_REMEMBER_STATE ignore | ||
55 | #define CFI_RESTORE_STATE ignore | ||
56 | #define CFI_UNDEFINED ignore | ||
57 | #define CFI_SIGNAL_FRAME ignore | ||
58 | |||
59 | #endif | ||
60 | |||
61 | #endif | ||
diff --git a/include/asm-x86/dwarf2_64.h b/include/asm-x86/dwarf2_64.h new file mode 100644 index 000000000000..eedc08526b0b --- /dev/null +++ b/include/asm-x86/dwarf2_64.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef _DWARF2_H | ||
2 | #define _DWARF2_H 1 | ||
3 | |||
4 | |||
5 | #ifndef __ASSEMBLY__ | ||
6 | #warning "asm/dwarf2.h should be only included in pure assembly files" | ||
7 | #endif | ||
8 | |||
9 | /* | ||
10 | Macros for dwarf2 CFI unwind table entries. | ||
11 | See "as.info" for details on these pseudo ops. Unfortunately | ||
12 | they are only supported in very new binutils, so define them | ||
13 | away for older version. | ||
14 | */ | ||
15 | |||
16 | #ifdef CONFIG_AS_CFI | ||
17 | |||
18 | #define CFI_STARTPROC .cfi_startproc | ||
19 | #define CFI_ENDPROC .cfi_endproc | ||
20 | #define CFI_DEF_CFA .cfi_def_cfa | ||
21 | #define CFI_DEF_CFA_REGISTER .cfi_def_cfa_register | ||
22 | #define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset | ||
23 | #define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset | ||
24 | #define CFI_OFFSET .cfi_offset | ||
25 | #define CFI_REL_OFFSET .cfi_rel_offset | ||
26 | #define CFI_REGISTER .cfi_register | ||
27 | #define CFI_RESTORE .cfi_restore | ||
28 | #define CFI_REMEMBER_STATE .cfi_remember_state | ||
29 | #define CFI_RESTORE_STATE .cfi_restore_state | ||
30 | #define CFI_UNDEFINED .cfi_undefined | ||
31 | #ifdef CONFIG_AS_CFI_SIGNAL_FRAME | ||
32 | #define CFI_SIGNAL_FRAME .cfi_signal_frame | ||
33 | #else | ||
34 | #define CFI_SIGNAL_FRAME | ||
35 | #endif | ||
36 | |||
37 | #else | ||
38 | |||
39 | /* use assembler line comment character # to ignore the arguments. */ | ||
40 | #define CFI_STARTPROC # | ||
41 | #define CFI_ENDPROC # | ||
42 | #define CFI_DEF_CFA # | ||
43 | #define CFI_DEF_CFA_REGISTER # | ||
44 | #define CFI_DEF_CFA_OFFSET # | ||
45 | #define CFI_ADJUST_CFA_OFFSET # | ||
46 | #define CFI_OFFSET # | ||
47 | #define CFI_REL_OFFSET # | ||
48 | #define CFI_REGISTER # | ||
49 | #define CFI_RESTORE # | ||
50 | #define CFI_REMEMBER_STATE # | ||
51 | #define CFI_RESTORE_STATE # | ||
52 | #define CFI_UNDEFINED # | ||
53 | #define CFI_SIGNAL_FRAME # | ||
54 | |||
55 | #endif | ||
56 | |||
57 | #endif | ||
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h new file mode 100644 index 000000000000..5d4d2183e5db --- /dev/null +++ b/include/asm-x86/e820.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "e820_32.h" | ||
3 | #else | ||
4 | # include "e820_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/e820_32.h b/include/asm-x86/e820_32.h new file mode 100644 index 000000000000..cf67dbb1db79 --- /dev/null +++ b/include/asm-x86/e820_32.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * structures and definitions for the int 15, ax=e820 memory map | ||
3 | * scheme. | ||
4 | * | ||
5 | * In a nutshell, arch/i386/boot/setup.S populates a scratch table | ||
6 | * in the empty_zero_block that contains a list of usable address/size | ||
7 | * duples. In arch/i386/kernel/setup.c, this information is | ||
8 | * transferred into the e820map, and in arch/i386/mm/init.c, that | ||
9 | * new information is used to mark pages reserved or not. | ||
10 | * | ||
11 | */ | ||
12 | #ifndef __E820_HEADER | ||
13 | #define __E820_HEADER | ||
14 | |||
15 | #define E820MAP 0x2d0 /* our map */ | ||
16 | #define E820MAX 128 /* number of entries in E820MAP */ | ||
17 | #define E820NR 0x1e8 /* # entries in E820MAP */ | ||
18 | |||
19 | #define E820_RAM 1 | ||
20 | #define E820_RESERVED 2 | ||
21 | #define E820_ACPI 3 | ||
22 | #define E820_NVS 4 | ||
23 | |||
24 | #define HIGH_MEMORY (1024*1024) | ||
25 | |||
26 | #ifndef __ASSEMBLY__ | ||
27 | |||
28 | struct e820entry { | ||
29 | u64 addr; /* start of memory segment */ | ||
30 | u64 size; /* size of memory segment */ | ||
31 | u32 type; /* type of memory segment */ | ||
32 | } __attribute__((packed)); | ||
33 | |||
34 | struct e820map { | ||
35 | u32 nr_map; | ||
36 | struct e820entry map[E820MAX]; | ||
37 | }; | ||
38 | |||
39 | extern struct e820map e820; | ||
40 | |||
41 | extern int e820_all_mapped(unsigned long start, unsigned long end, | ||
42 | unsigned type); | ||
43 | extern int e820_any_mapped(u64 start, u64 end, unsigned type); | ||
44 | extern void find_max_pfn(void); | ||
45 | extern void register_bootmem_low_pages(unsigned long max_low_pfn); | ||
46 | extern void e820_register_memory(void); | ||
47 | extern void limit_regions(unsigned long long size); | ||
48 | extern void print_memory_map(char *who); | ||
49 | |||
50 | #if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION) | ||
51 | extern void e820_mark_nosave_regions(void); | ||
52 | #else | ||
53 | static inline void e820_mark_nosave_regions(void) | ||
54 | { | ||
55 | } | ||
56 | #endif | ||
57 | |||
58 | #endif/*!__ASSEMBLY__*/ | ||
59 | |||
60 | #endif/*__E820_HEADER*/ | ||
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h new file mode 100644 index 000000000000..3486e701bd86 --- /dev/null +++ b/include/asm-x86/e820_64.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * structures and definitions for the int 15, ax=e820 memory map | ||
3 | * scheme. | ||
4 | * | ||
5 | * In a nutshell, setup.S populates a scratch table in the | ||
6 | * empty_zero_block that contains a list of usable address/size | ||
7 | * duples. setup.c, this information is transferred into the e820map, | ||
8 | * and in init.c/numa.c, that new information is used to mark pages | ||
9 | * reserved or not. | ||
10 | */ | ||
11 | #ifndef __E820_HEADER | ||
12 | #define __E820_HEADER | ||
13 | |||
14 | #define E820MAP 0x2d0 /* our map */ | ||
15 | #define E820MAX 128 /* number of entries in E820MAP */ | ||
16 | #define E820NR 0x1e8 /* # entries in E820MAP */ | ||
17 | |||
18 | #define E820_RAM 1 | ||
19 | #define E820_RESERVED 2 | ||
20 | #define E820_ACPI 3 | ||
21 | #define E820_NVS 4 | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | ||
24 | struct e820entry { | ||
25 | u64 addr; /* start of memory segment */ | ||
26 | u64 size; /* size of memory segment */ | ||
27 | u32 type; /* type of memory segment */ | ||
28 | } __attribute__((packed)); | ||
29 | |||
30 | struct e820map { | ||
31 | u32 nr_map; | ||
32 | struct e820entry map[E820MAX]; | ||
33 | }; | ||
34 | |||
35 | extern unsigned long find_e820_area(unsigned long start, unsigned long end, | ||
36 | unsigned size); | ||
37 | extern void add_memory_region(unsigned long start, unsigned long size, | ||
38 | int type); | ||
39 | extern void setup_memory_region(void); | ||
40 | extern void contig_e820_setup(void); | ||
41 | extern unsigned long e820_end_of_ram(void); | ||
42 | extern void e820_reserve_resources(void); | ||
43 | extern void e820_mark_nosave_regions(void); | ||
44 | extern void e820_print_map(char *who); | ||
45 | extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type); | ||
46 | extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type); | ||
47 | extern unsigned long e820_hole_size(unsigned long start, unsigned long end); | ||
48 | |||
49 | extern void e820_setup_gap(void); | ||
50 | extern void e820_register_active_regions(int nid, | ||
51 | unsigned long start_pfn, unsigned long end_pfn); | ||
52 | |||
53 | extern void finish_e820_parsing(void); | ||
54 | |||
55 | extern struct e820map e820; | ||
56 | |||
57 | extern unsigned ebda_addr, ebda_size; | ||
58 | extern unsigned long nodemap_addr, nodemap_size; | ||
59 | #endif/*!__ASSEMBLY__*/ | ||
60 | |||
61 | #endif/*__E820_HEADER*/ | ||
diff --git a/include/asm-x86/edac.h b/include/asm-x86/edac.h new file mode 100644 index 000000000000..f8b888e140b0 --- /dev/null +++ b/include/asm-x86/edac.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "edac_32.h" | ||
3 | #else | ||
4 | # include "edac_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/edac_32.h b/include/asm-x86/edac_32.h new file mode 100644 index 000000000000..3e7dd0ab68ce --- /dev/null +++ b/include/asm-x86/edac_32.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef ASM_EDAC_H | ||
2 | #define ASM_EDAC_H | ||
3 | |||
4 | /* ECC atomic, DMA, SMP and interrupt safe scrub function */ | ||
5 | |||
6 | static __inline__ void atomic_scrub(void *va, u32 size) | ||
7 | { | ||
8 | unsigned long *virt_addr = va; | ||
9 | u32 i; | ||
10 | |||
11 | for (i = 0; i < size / 4; i++, virt_addr++) | ||
12 | /* Very carefully read and write to memory atomically | ||
13 | * so we are interrupt, DMA and SMP safe. | ||
14 | */ | ||
15 | __asm__ __volatile__("lock; addl $0, %0"::"m"(*virt_addr)); | ||
16 | } | ||
17 | |||
18 | #endif | ||
diff --git a/include/asm-x86/edac_64.h b/include/asm-x86/edac_64.h new file mode 100644 index 000000000000..cad1cd42b4ee --- /dev/null +++ b/include/asm-x86/edac_64.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef ASM_EDAC_H | ||
2 | #define ASM_EDAC_H | ||
3 | |||
4 | /* ECC atomic, DMA, SMP and interrupt safe scrub function */ | ||
5 | |||
6 | static __inline__ void atomic_scrub(void *va, u32 size) | ||
7 | { | ||
8 | unsigned int *virt_addr = va; | ||
9 | u32 i; | ||
10 | |||
11 | for (i = 0; i < size / 4; i++, virt_addr++) | ||
12 | /* Very carefully read and write to memory atomically | ||
13 | * so we are interrupt, DMA and SMP safe. | ||
14 | */ | ||
15 | __asm__ __volatile__("lock; addl $0, %0"::"m"(*virt_addr)); | ||
16 | } | ||
17 | |||
18 | #endif | ||
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h new file mode 100644 index 000000000000..ed6bb6e546b9 --- /dev/null +++ b/include/asm-x86/elf.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "elf_32.h" | ||
4 | # else | ||
5 | # include "elf_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "elf_32.h" | ||
10 | # else | ||
11 | # include "elf_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/elf_32.h b/include/asm-x86/elf_32.h new file mode 100644 index 000000000000..b32df3a332da --- /dev/null +++ b/include/asm-x86/elf_32.h | |||
@@ -0,0 +1,163 @@ | |||
1 | #ifndef __ASMi386_ELF_H | ||
2 | #define __ASMi386_ELF_H | ||
3 | |||
4 | /* | ||
5 | * ELF register definitions.. | ||
6 | */ | ||
7 | |||
8 | #include <asm/ptrace.h> | ||
9 | #include <asm/user.h> | ||
10 | #include <asm/auxvec.h> | ||
11 | |||
12 | #define R_386_NONE 0 | ||
13 | #define R_386_32 1 | ||
14 | #define R_386_PC32 2 | ||
15 | #define R_386_GOT32 3 | ||
16 | #define R_386_PLT32 4 | ||
17 | #define R_386_COPY 5 | ||
18 | #define R_386_GLOB_DAT 6 | ||
19 | #define R_386_JMP_SLOT 7 | ||
20 | #define R_386_RELATIVE 8 | ||
21 | #define R_386_GOTOFF 9 | ||
22 | #define R_386_GOTPC 10 | ||
23 | #define R_386_NUM 11 | ||
24 | |||
25 | typedef unsigned long elf_greg_t; | ||
26 | |||
27 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) | ||
28 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | ||
29 | |||
30 | typedef struct user_i387_struct elf_fpregset_t; | ||
31 | typedef struct user_fxsr_struct elf_fpxregset_t; | ||
32 | |||
33 | /* | ||
34 | * This is used to ensure we don't load something for the wrong architecture. | ||
35 | */ | ||
36 | #define elf_check_arch(x) \ | ||
37 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) | ||
38 | |||
39 | /* | ||
40 | * These are used to set parameters in the core dumps. | ||
41 | */ | ||
42 | #define ELF_CLASS ELFCLASS32 | ||
43 | #define ELF_DATA ELFDATA2LSB | ||
44 | #define ELF_ARCH EM_386 | ||
45 | |||
46 | #ifdef __KERNEL__ | ||
47 | |||
48 | #include <asm/processor.h> | ||
49 | #include <asm/system.h> /* for savesegment */ | ||
50 | #include <asm/desc.h> | ||
51 | |||
52 | /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx | ||
53 | contains a pointer to a function which might be registered using `atexit'. | ||
54 | This provides a mean for the dynamic linker to call DT_FINI functions for | ||
55 | shared libraries that have been loaded before the code runs. | ||
56 | |||
57 | A value of 0 tells we have no such handler. | ||
58 | |||
59 | We might as well make sure everything else is cleared too (except for %esp), | ||
60 | just to make things more deterministic. | ||
61 | */ | ||
62 | #define ELF_PLAT_INIT(_r, load_addr) do { \ | ||
63 | _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ | ||
64 | _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ | ||
65 | _r->eax = 0; \ | ||
66 | } while (0) | ||
67 | |||
68 | #define USE_ELF_CORE_DUMP | ||
69 | #define ELF_EXEC_PAGESIZE 4096 | ||
70 | |||
71 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | ||
72 | use of this is to invoke "./ld.so someprog" to test out a new version of | ||
73 | the loader. We need to make sure that it is out of the way of the program | ||
74 | that it will "exec", and that there is sufficient room for the brk. */ | ||
75 | |||
76 | #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) | ||
77 | |||
78 | /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is | ||
79 | now struct_user_regs, they are different) */ | ||
80 | |||
81 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ | ||
82 | pr_reg[0] = regs->ebx; \ | ||
83 | pr_reg[1] = regs->ecx; \ | ||
84 | pr_reg[2] = regs->edx; \ | ||
85 | pr_reg[3] = regs->esi; \ | ||
86 | pr_reg[4] = regs->edi; \ | ||
87 | pr_reg[5] = regs->ebp; \ | ||
88 | pr_reg[6] = regs->eax; \ | ||
89 | pr_reg[7] = regs->xds & 0xffff; \ | ||
90 | pr_reg[8] = regs->xes & 0xffff; \ | ||
91 | pr_reg[9] = regs->xfs & 0xffff; \ | ||
92 | savesegment(gs,pr_reg[10]); \ | ||
93 | pr_reg[11] = regs->orig_eax; \ | ||
94 | pr_reg[12] = regs->eip; \ | ||
95 | pr_reg[13] = regs->xcs & 0xffff; \ | ||
96 | pr_reg[14] = regs->eflags; \ | ||
97 | pr_reg[15] = regs->esp; \ | ||
98 | pr_reg[16] = regs->xss & 0xffff; | ||
99 | |||
100 | /* This yields a mask that user programs can use to figure out what | ||
101 | instruction set this CPU supports. This could be done in user space, | ||
102 | but it's not easy, and we've already done it here. */ | ||
103 | |||
104 | #define ELF_HWCAP (boot_cpu_data.x86_capability[0]) | ||
105 | |||
106 | /* This yields a string that ld.so will use to load implementation | ||
107 | specific libraries for optimization. This is more specific in | ||
108 | intent than poking at uname or /proc/cpuinfo. | ||
109 | |||
110 | For the moment, we have only optimizations for the Intel generations, | ||
111 | but that could change... */ | ||
112 | |||
113 | #define ELF_PLATFORM (utsname()->machine) | ||
114 | |||
115 | #define SET_PERSONALITY(ex, ibcs2) do { } while (0) | ||
116 | |||
117 | /* | ||
118 | * An executable for which elf_read_implies_exec() returns TRUE will | ||
119 | * have the READ_IMPLIES_EXEC personality flag set automatically. | ||
120 | */ | ||
121 | #define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X) | ||
122 | |||
123 | struct task_struct; | ||
124 | |||
125 | extern int dump_task_regs (struct task_struct *, elf_gregset_t *); | ||
126 | extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); | ||
127 | extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct *); | ||
128 | |||
129 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) | ||
130 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) | ||
131 | #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) | ||
132 | |||
133 | #define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) | ||
134 | #define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) | ||
135 | #define VDSO_PRELINK 0 | ||
136 | |||
137 | #define VDSO_SYM(x) \ | ||
138 | (VDSO_CURRENT_BASE + (unsigned long)(x) - VDSO_PRELINK) | ||
139 | |||
140 | #define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE) | ||
141 | #define VDSO_EHDR ((const struct elfhdr *) VDSO_CURRENT_BASE) | ||
142 | |||
143 | extern void __kernel_vsyscall; | ||
144 | |||
145 | #define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall) | ||
146 | |||
147 | struct linux_binprm; | ||
148 | |||
149 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES | ||
150 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, | ||
151 | int executable_stack); | ||
152 | |||
153 | extern unsigned int vdso_enabled; | ||
154 | |||
155 | #define ARCH_DLINFO \ | ||
156 | do if (vdso_enabled) { \ | ||
157 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ | ||
158 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ | ||
159 | } while (0) | ||
160 | |||
161 | #endif | ||
162 | |||
163 | #endif | ||
diff --git a/include/asm-x86/elf_64.h b/include/asm-x86/elf_64.h new file mode 100644 index 000000000000..b4fbe47f6ccd --- /dev/null +++ b/include/asm-x86/elf_64.h | |||
@@ -0,0 +1,180 @@ | |||
1 | #ifndef __ASM_X86_64_ELF_H | ||
2 | #define __ASM_X86_64_ELF_H | ||
3 | |||
4 | /* | ||
5 | * ELF register definitions.. | ||
6 | */ | ||
7 | |||
8 | #include <asm/ptrace.h> | ||
9 | #include <asm/user.h> | ||
10 | |||
11 | /* x86-64 relocation types */ | ||
12 | #define R_X86_64_NONE 0 /* No reloc */ | ||
13 | #define R_X86_64_64 1 /* Direct 64 bit */ | ||
14 | #define R_X86_64_PC32 2 /* PC relative 32 bit signed */ | ||
15 | #define R_X86_64_GOT32 3 /* 32 bit GOT entry */ | ||
16 | #define R_X86_64_PLT32 4 /* 32 bit PLT address */ | ||
17 | #define R_X86_64_COPY 5 /* Copy symbol at runtime */ | ||
18 | #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ | ||
19 | #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ | ||
20 | #define R_X86_64_RELATIVE 8 /* Adjust by program base */ | ||
21 | #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative | ||
22 | offset to GOT */ | ||
23 | #define R_X86_64_32 10 /* Direct 32 bit zero extended */ | ||
24 | #define R_X86_64_32S 11 /* Direct 32 bit sign extended */ | ||
25 | #define R_X86_64_16 12 /* Direct 16 bit zero extended */ | ||
26 | #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ | ||
27 | #define R_X86_64_8 14 /* Direct 8 bit sign extended */ | ||
28 | #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ | ||
29 | |||
30 | #define R_X86_64_NUM 16 | ||
31 | |||
32 | typedef unsigned long elf_greg_t; | ||
33 | |||
34 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) | ||
35 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | ||
36 | |||
37 | typedef struct user_i387_struct elf_fpregset_t; | ||
38 | |||
39 | /* | ||
40 | * These are used to set parameters in the core dumps. | ||
41 | */ | ||
42 | #define ELF_CLASS ELFCLASS64 | ||
43 | #define ELF_DATA ELFDATA2LSB | ||
44 | #define ELF_ARCH EM_X86_64 | ||
45 | |||
46 | #ifdef __KERNEL__ | ||
47 | #include <asm/processor.h> | ||
48 | |||
49 | /* | ||
50 | * This is used to ensure we don't load something for the wrong architecture. | ||
51 | */ | ||
52 | #define elf_check_arch(x) \ | ||
53 | ((x)->e_machine == EM_X86_64) | ||
54 | |||
55 | |||
56 | /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx | ||
57 | contains a pointer to a function which might be registered using `atexit'. | ||
58 | This provides a mean for the dynamic linker to call DT_FINI functions for | ||
59 | shared libraries that have been loaded before the code runs. | ||
60 | |||
61 | A value of 0 tells we have no such handler. | ||
62 | |||
63 | We might as well make sure everything else is cleared too (except for %esp), | ||
64 | just to make things more deterministic. | ||
65 | */ | ||
66 | #define ELF_PLAT_INIT(_r, load_addr) do { \ | ||
67 | struct task_struct *cur = current; \ | ||
68 | (_r)->rbx = 0; (_r)->rcx = 0; (_r)->rdx = 0; \ | ||
69 | (_r)->rsi = 0; (_r)->rdi = 0; (_r)->rbp = 0; \ | ||
70 | (_r)->rax = 0; \ | ||
71 | (_r)->r8 = 0; \ | ||
72 | (_r)->r9 = 0; \ | ||
73 | (_r)->r10 = 0; \ | ||
74 | (_r)->r11 = 0; \ | ||
75 | (_r)->r12 = 0; \ | ||
76 | (_r)->r13 = 0; \ | ||
77 | (_r)->r14 = 0; \ | ||
78 | (_r)->r15 = 0; \ | ||
79 | cur->thread.fs = 0; cur->thread.gs = 0; \ | ||
80 | cur->thread.fsindex = 0; cur->thread.gsindex = 0; \ | ||
81 | cur->thread.ds = 0; cur->thread.es = 0; \ | ||
82 | clear_thread_flag(TIF_IA32); \ | ||
83 | } while (0) | ||
84 | |||
85 | #define USE_ELF_CORE_DUMP | ||
86 | #define ELF_EXEC_PAGESIZE 4096 | ||
87 | |||
88 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | ||
89 | use of this is to invoke "./ld.so someprog" to test out a new version of | ||
90 | the loader. We need to make sure that it is out of the way of the program | ||
91 | that it will "exec", and that there is sufficient room for the brk. */ | ||
92 | |||
93 | #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) | ||
94 | |||
95 | /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is | ||
96 | now struct_user_regs, they are different). Assumes current is the process | ||
97 | getting dumped. */ | ||
98 | |||
99 | #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ | ||
100 | unsigned v; \ | ||
101 | (pr_reg)[0] = (regs)->r15; \ | ||
102 | (pr_reg)[1] = (regs)->r14; \ | ||
103 | (pr_reg)[2] = (regs)->r13; \ | ||
104 | (pr_reg)[3] = (regs)->r12; \ | ||
105 | (pr_reg)[4] = (regs)->rbp; \ | ||
106 | (pr_reg)[5] = (regs)->rbx; \ | ||
107 | (pr_reg)[6] = (regs)->r11; \ | ||
108 | (pr_reg)[7] = (regs)->r10; \ | ||
109 | (pr_reg)[8] = (regs)->r9; \ | ||
110 | (pr_reg)[9] = (regs)->r8; \ | ||
111 | (pr_reg)[10] = (regs)->rax; \ | ||
112 | (pr_reg)[11] = (regs)->rcx; \ | ||
113 | (pr_reg)[12] = (regs)->rdx; \ | ||
114 | (pr_reg)[13] = (regs)->rsi; \ | ||
115 | (pr_reg)[14] = (regs)->rdi; \ | ||
116 | (pr_reg)[15] = (regs)->orig_rax; \ | ||
117 | (pr_reg)[16] = (regs)->rip; \ | ||
118 | (pr_reg)[17] = (regs)->cs; \ | ||
119 | (pr_reg)[18] = (regs)->eflags; \ | ||
120 | (pr_reg)[19] = (regs)->rsp; \ | ||
121 | (pr_reg)[20] = (regs)->ss; \ | ||
122 | (pr_reg)[21] = current->thread.fs; \ | ||
123 | (pr_reg)[22] = current->thread.gs; \ | ||
124 | asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \ | ||
125 | asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ | ||
126 | asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ | ||
127 | asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \ | ||
128 | } while(0); | ||
129 | |||
130 | /* This yields a mask that user programs can use to figure out what | ||
131 | instruction set this CPU supports. This could be done in user space, | ||
132 | but it's not easy, and we've already done it here. */ | ||
133 | |||
134 | #define ELF_HWCAP (boot_cpu_data.x86_capability[0]) | ||
135 | |||
136 | /* This yields a string that ld.so will use to load implementation | ||
137 | specific libraries for optimization. This is more specific in | ||
138 | intent than poking at uname or /proc/cpuinfo. | ||
139 | |||
140 | For the moment, we have only optimizations for the Intel generations, | ||
141 | but that could change... */ | ||
142 | |||
143 | /* I'm not sure if we can use '-' here */ | ||
144 | #define ELF_PLATFORM ("x86_64") | ||
145 | |||
146 | extern void set_personality_64bit(void); | ||
147 | #define SET_PERSONALITY(ex, ibcs2) set_personality_64bit() | ||
148 | /* | ||
149 | * An executable for which elf_read_implies_exec() returns TRUE will | ||
150 | * have the READ_IMPLIES_EXEC personality flag set automatically. | ||
151 | */ | ||
152 | #define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X) | ||
153 | |||
154 | struct task_struct; | ||
155 | |||
156 | extern int dump_task_regs (struct task_struct *, elf_gregset_t *); | ||
157 | extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); | ||
158 | |||
159 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) | ||
160 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) | ||
161 | |||
162 | /* 1GB for 64bit, 8MB for 32bit */ | ||
163 | #define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) | ||
164 | |||
165 | |||
166 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 | ||
167 | struct linux_binprm; | ||
168 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, | ||
169 | int executable_stack); | ||
170 | |||
171 | extern int vdso_enabled; | ||
172 | |||
173 | #define ARCH_DLINFO \ | ||
174 | do if (vdso_enabled) { \ | ||
175 | NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ | ||
176 | } while (0) | ||
177 | |||
178 | #endif | ||
179 | |||
180 | #endif | ||
diff --git a/include/asm-x86/emergency-restart.h b/include/asm-x86/emergency-restart.h new file mode 100644 index 000000000000..680c39563345 --- /dev/null +++ b/include/asm-x86/emergency-restart.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_EMERGENCY_RESTART_H | ||
2 | #define _ASM_EMERGENCY_RESTART_H | ||
3 | |||
4 | extern void machine_emergency_restart(void); | ||
5 | |||
6 | #endif /* _ASM_EMERGENCY_RESTART_H */ | ||
diff --git a/include/asm-x86/errno.h b/include/asm-x86/errno.h new file mode 100644 index 000000000000..9d511be8e573 --- /dev/null +++ b/include/asm-x86/errno.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "errno_32.h" | ||
4 | # else | ||
5 | # include "errno_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "errno_32.h" | ||
10 | # else | ||
11 | # include "errno_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/errno_32.h b/include/asm-x86/errno_32.h new file mode 100644 index 000000000000..969b34374728 --- /dev/null +++ b/include/asm-x86/errno_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _I386_ERRNO_H | ||
2 | #define _I386_ERRNO_H | ||
3 | |||
4 | #include <asm-generic/errno.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/errno_64.h b/include/asm-x86/errno_64.h new file mode 100644 index 000000000000..311182129e32 --- /dev/null +++ b/include/asm-x86/errno_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _X8664_ERRNO_H | ||
2 | #define _X8664_ERRNO_H | ||
3 | |||
4 | #include <asm-generic/errno.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/fb.h b/include/asm-x86/fb.h new file mode 100644 index 000000000000..238c7ca45877 --- /dev/null +++ b/include/asm-x86/fb.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "fb_32.h" | ||
3 | #else | ||
4 | # include "fb_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/fb_32.h b/include/asm-x86/fb_32.h new file mode 100644 index 000000000000..d1c6297d4a61 --- /dev/null +++ b/include/asm-x86/fb_32.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _ASM_FB_H_ | ||
2 | #define _ASM_FB_H_ | ||
3 | |||
4 | #include <linux/fb.h> | ||
5 | #include <linux/fs.h> | ||
6 | #include <asm/page.h> | ||
7 | |||
8 | extern int fb_is_primary_device(struct fb_info *info); | ||
9 | |||
10 | static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, | ||
11 | unsigned long off) | ||
12 | { | ||
13 | if (boot_cpu_data.x86 > 3) | ||
14 | pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; | ||
15 | } | ||
16 | |||
17 | #endif /* _ASM_FB_H_ */ | ||
diff --git a/include/asm-x86/fb_64.h b/include/asm-x86/fb_64.h new file mode 100644 index 000000000000..60548e651d12 --- /dev/null +++ b/include/asm-x86/fb_64.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _ASM_FB_H_ | ||
2 | #define _ASM_FB_H_ | ||
3 | #include <linux/fb.h> | ||
4 | #include <linux/fs.h> | ||
5 | #include <asm/page.h> | ||
6 | |||
7 | static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, | ||
8 | unsigned long off) | ||
9 | { | ||
10 | if (boot_cpu_data.x86 > 3) | ||
11 | pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; | ||
12 | } | ||
13 | |||
14 | static inline int fb_is_primary_device(struct fb_info *info) | ||
15 | { | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | #endif /* _ASM_FB_H_ */ | ||
diff --git a/include/asm-x86/fcntl.h b/include/asm-x86/fcntl.h new file mode 100644 index 000000000000..46ab12db5739 --- /dev/null +++ b/include/asm-x86/fcntl.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/fcntl.h> | |||
diff --git a/include/asm-x86/fixmap.h b/include/asm-x86/fixmap.h new file mode 100644 index 000000000000..382eb271a892 --- /dev/null +++ b/include/asm-x86/fixmap.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "fixmap_32.h" | ||
3 | #else | ||
4 | # include "fixmap_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h new file mode 100644 index 000000000000..249e753ac805 --- /dev/null +++ b/include/asm-x86/fixmap_32.h | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * fixmap.h: compile-time virtual memory allocation | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1998 Ingo Molnar | ||
9 | * | ||
10 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 | ||
11 | */ | ||
12 | |||
13 | #ifndef _ASM_FIXMAP_H | ||
14 | #define _ASM_FIXMAP_H | ||
15 | |||
16 | |||
17 | /* used by vmalloc.c, vsyscall.lds.S. | ||
18 | * | ||
19 | * Leave one empty page between vmalloc'ed areas and | ||
20 | * the start of the fixmap. | ||
21 | */ | ||
22 | extern unsigned long __FIXADDR_TOP; | ||
23 | #define FIXADDR_USER_START __fix_to_virt(FIX_VDSO) | ||
24 | #define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1) | ||
25 | |||
26 | #ifndef __ASSEMBLY__ | ||
27 | #include <linux/kernel.h> | ||
28 | #include <asm/acpi.h> | ||
29 | #include <asm/apicdef.h> | ||
30 | #include <asm/page.h> | ||
31 | #ifdef CONFIG_HIGHMEM | ||
32 | #include <linux/threads.h> | ||
33 | #include <asm/kmap_types.h> | ||
34 | #endif | ||
35 | |||
36 | /* | ||
37 | * Here we define all the compile-time 'special' virtual | ||
38 | * addresses. The point is to have a constant address at | ||
39 | * compile time, but to set the physical address only | ||
40 | * in the boot process. We allocate these special addresses | ||
41 | * from the end of virtual memory (0xfffff000) backwards. | ||
42 | * Also this lets us do fail-safe vmalloc(), we | ||
43 | * can guarantee that these special addresses and | ||
44 | * vmalloc()-ed addresses never overlap. | ||
45 | * | ||
46 | * these 'compile-time allocated' memory buffers are | ||
47 | * fixed-size 4k pages. (or larger if used with an increment | ||
48 | * highger than 1) use fixmap_set(idx,phys) to associate | ||
49 | * physical memory with fixmap indices. | ||
50 | * | ||
51 | * TLB entries of such buffers will not be flushed across | ||
52 | * task switches. | ||
53 | */ | ||
54 | enum fixed_addresses { | ||
55 | FIX_HOLE, | ||
56 | FIX_VDSO, | ||
57 | FIX_DBGP_BASE, | ||
58 | FIX_EARLYCON_MEM_BASE, | ||
59 | #ifdef CONFIG_X86_LOCAL_APIC | ||
60 | FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ | ||
61 | #endif | ||
62 | #ifdef CONFIG_X86_IO_APIC | ||
63 | FIX_IO_APIC_BASE_0, | ||
64 | FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, | ||
65 | #endif | ||
66 | #ifdef CONFIG_X86_VISWS_APIC | ||
67 | FIX_CO_CPU, /* Cobalt timer */ | ||
68 | FIX_CO_APIC, /* Cobalt APIC Redirection Table */ | ||
69 | FIX_LI_PCIA, /* Lithium PCI Bridge A */ | ||
70 | FIX_LI_PCIB, /* Lithium PCI Bridge B */ | ||
71 | #endif | ||
72 | #ifdef CONFIG_X86_F00F_BUG | ||
73 | FIX_F00F_IDT, /* Virtual mapping for IDT */ | ||
74 | #endif | ||
75 | #ifdef CONFIG_X86_CYCLONE_TIMER | ||
76 | FIX_CYCLONE_TIMER, /*cyclone timer register*/ | ||
77 | #endif | ||
78 | #ifdef CONFIG_HIGHMEM | ||
79 | FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ | ||
80 | FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, | ||
81 | #endif | ||
82 | #ifdef CONFIG_ACPI | ||
83 | FIX_ACPI_BEGIN, | ||
84 | FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1, | ||
85 | #endif | ||
86 | #ifdef CONFIG_PCI_MMCONFIG | ||
87 | FIX_PCIE_MCFG, | ||
88 | #endif | ||
89 | #ifdef CONFIG_PARAVIRT | ||
90 | FIX_PARAVIRT_BOOTMAP, | ||
91 | #endif | ||
92 | __end_of_permanent_fixed_addresses, | ||
93 | /* temporary boot-time mappings, used before ioremap() is functional */ | ||
94 | #define NR_FIX_BTMAPS 16 | ||
95 | FIX_BTMAP_END = __end_of_permanent_fixed_addresses, | ||
96 | FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1, | ||
97 | FIX_WP_TEST, | ||
98 | __end_of_fixed_addresses | ||
99 | }; | ||
100 | |||
101 | extern void __set_fixmap (enum fixed_addresses idx, | ||
102 | unsigned long phys, pgprot_t flags); | ||
103 | extern void reserve_top_address(unsigned long reserve); | ||
104 | |||
105 | #define set_fixmap(idx, phys) \ | ||
106 | __set_fixmap(idx, phys, PAGE_KERNEL) | ||
107 | /* | ||
108 | * Some hardware wants to get fixmapped without caching. | ||
109 | */ | ||
110 | #define set_fixmap_nocache(idx, phys) \ | ||
111 | __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) | ||
112 | |||
113 | #define clear_fixmap(idx) \ | ||
114 | __set_fixmap(idx, 0, __pgprot(0)) | ||
115 | |||
116 | #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) | ||
117 | |||
118 | #define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) | ||
119 | #define __FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) | ||
120 | #define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE) | ||
121 | #define FIXADDR_BOOT_START (FIXADDR_TOP - __FIXADDR_BOOT_SIZE) | ||
122 | |||
123 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) | ||
124 | #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) | ||
125 | |||
126 | extern void __this_fixmap_does_not_exist(void); | ||
127 | |||
128 | /* | ||
129 | * 'index to address' translation. If anyone tries to use the idx | ||
130 | * directly without tranlation, we catch the bug with a NULL-deference | ||
131 | * kernel oops. Illegal ranges of incoming indices are caught too. | ||
132 | */ | ||
133 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) | ||
134 | { | ||
135 | /* | ||
136 | * this branch gets completely eliminated after inlining, | ||
137 | * except when someone tries to use fixaddr indices in an | ||
138 | * illegal way. (such as mixing up address types or using | ||
139 | * out-of-range indices). | ||
140 | * | ||
141 | * If it doesn't get removed, the linker will complain | ||
142 | * loudly with a reasonably clear error message.. | ||
143 | */ | ||
144 | if (idx >= __end_of_fixed_addresses) | ||
145 | __this_fixmap_does_not_exist(); | ||
146 | |||
147 | return __fix_to_virt(idx); | ||
148 | } | ||
149 | |||
150 | static inline unsigned long virt_to_fix(const unsigned long vaddr) | ||
151 | { | ||
152 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); | ||
153 | return __virt_to_fix(vaddr); | ||
154 | } | ||
155 | |||
156 | #endif /* !__ASSEMBLY__ */ | ||
157 | #endif | ||
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h new file mode 100644 index 000000000000..cdfbe4a6ae6f --- /dev/null +++ b/include/asm-x86/fixmap_64.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * fixmap.h: compile-time virtual memory allocation | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1998 Ingo Molnar | ||
9 | */ | ||
10 | |||
11 | #ifndef _ASM_FIXMAP_H | ||
12 | #define _ASM_FIXMAP_H | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <asm/apicdef.h> | ||
16 | #include <asm/page.h> | ||
17 | #include <asm/vsyscall.h> | ||
18 | |||
19 | /* | ||
20 | * Here we define all the compile-time 'special' virtual | ||
21 | * addresses. The point is to have a constant address at | ||
22 | * compile time, but to set the physical address only | ||
23 | * in the boot process. | ||
24 | * | ||
25 | * These 'compile-time allocated' memory buffers are | ||
26 | * fixed-size 4k pages (or larger if used with an increment | ||
27 | * higher than 1). Use set_fixmap(idx,phys) to associate | ||
28 | * physical memory with fixmap indices. | ||
29 | * | ||
30 | * TLB entries of such buffers will not be flushed across | ||
31 | * task switches. | ||
32 | */ | ||
33 | |||
34 | enum fixed_addresses { | ||
35 | VSYSCALL_LAST_PAGE, | ||
36 | VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1, | ||
37 | VSYSCALL_HPET, | ||
38 | FIX_DBGP_BASE, | ||
39 | FIX_EARLYCON_MEM_BASE, | ||
40 | FIX_HPET_BASE, | ||
41 | FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ | ||
42 | FIX_IO_APIC_BASE_0, | ||
43 | FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, | ||
44 | __end_of_fixed_addresses | ||
45 | }; | ||
46 | |||
47 | extern void __set_fixmap (enum fixed_addresses idx, | ||
48 | unsigned long phys, pgprot_t flags); | ||
49 | |||
50 | #define set_fixmap(idx, phys) \ | ||
51 | __set_fixmap(idx, phys, PAGE_KERNEL) | ||
52 | /* | ||
53 | * Some hardware wants to get fixmapped without caching. | ||
54 | */ | ||
55 | #define set_fixmap_nocache(idx, phys) \ | ||
56 | __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) | ||
57 | |||
58 | #define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE) | ||
59 | #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) | ||
60 | #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) | ||
61 | |||
62 | /* Only covers 32bit vsyscalls currently. Need another set for 64bit. */ | ||
63 | #define FIXADDR_USER_START ((unsigned long)VSYSCALL32_VSYSCALL) | ||
64 | #define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE) | ||
65 | |||
66 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) | ||
67 | |||
68 | extern void __this_fixmap_does_not_exist(void); | ||
69 | |||
70 | /* | ||
71 | * 'index to address' translation. If anyone tries to use the idx | ||
72 | * directly without translation, we catch the bug with a NULL-deference | ||
73 | * kernel oops. Illegal ranges of incoming indices are caught too. | ||
74 | */ | ||
75 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) | ||
76 | { | ||
77 | /* | ||
78 | * this branch gets completely eliminated after inlining, | ||
79 | * except when someone tries to use fixaddr indices in an | ||
80 | * illegal way. (such as mixing up address types or using | ||
81 | * out-of-range indices). | ||
82 | * | ||
83 | * If it doesn't get removed, the linker will complain | ||
84 | * loudly with a reasonably clear error message.. | ||
85 | */ | ||
86 | if (idx >= __end_of_fixed_addresses) | ||
87 | __this_fixmap_does_not_exist(); | ||
88 | |||
89 | return __fix_to_virt(idx); | ||
90 | } | ||
91 | |||
92 | #endif | ||
diff --git a/include/asm-x86/floppy.h b/include/asm-x86/floppy.h new file mode 100644 index 000000000000..aecbb6dca21d --- /dev/null +++ b/include/asm-x86/floppy.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "floppy_32.h" | ||
3 | #else | ||
4 | # include "floppy_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/floppy_32.h b/include/asm-x86/floppy_32.h new file mode 100644 index 000000000000..44ef2f55a8e9 --- /dev/null +++ b/include/asm-x86/floppy_32.h | |||
@@ -0,0 +1,284 @@ | |||
1 | /* | ||
2 | * Architecture specific parts of the Floppy driver | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1995 | ||
9 | */ | ||
10 | #ifndef __ASM_I386_FLOPPY_H | ||
11 | #define __ASM_I386_FLOPPY_H | ||
12 | |||
13 | #include <linux/vmalloc.h> | ||
14 | |||
15 | |||
16 | /* | ||
17 | * The DMA channel used by the floppy controller cannot access data at | ||
18 | * addresses >= 16MB | ||
19 | * | ||
20 | * Went back to the 1MB limit, as some people had problems with the floppy | ||
21 | * driver otherwise. It doesn't matter much for performance anyway, as most | ||
22 | * floppy accesses go through the track buffer. | ||
23 | */ | ||
24 | #define _CROSS_64KB(a,s,vdma) \ | ||
25 | (!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)) | ||
26 | |||
27 | #define CROSS_64KB(a,s) _CROSS_64KB(a,s,use_virtual_dma & 1) | ||
28 | |||
29 | |||
30 | #define SW fd_routine[use_virtual_dma&1] | ||
31 | #define CSW fd_routine[can_use_virtual_dma & 1] | ||
32 | |||
33 | |||
34 | #define fd_inb(port) inb_p(port) | ||
35 | #define fd_outb(value,port) outb_p(value,port) | ||
36 | |||
37 | #define fd_request_dma() CSW._request_dma(FLOPPY_DMA,"floppy") | ||
38 | #define fd_free_dma() CSW._free_dma(FLOPPY_DMA) | ||
39 | #define fd_enable_irq() enable_irq(FLOPPY_IRQ) | ||
40 | #define fd_disable_irq() disable_irq(FLOPPY_IRQ) | ||
41 | #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL) | ||
42 | #define fd_get_dma_residue() SW._get_dma_residue(FLOPPY_DMA) | ||
43 | #define fd_dma_mem_alloc(size) SW._dma_mem_alloc(size) | ||
44 | #define fd_dma_setup(addr, size, mode, io) SW._dma_setup(addr, size, mode, io) | ||
45 | |||
46 | #define FLOPPY_CAN_FALLBACK_ON_NODMA | ||
47 | |||
48 | static int virtual_dma_count; | ||
49 | static int virtual_dma_residue; | ||
50 | static char *virtual_dma_addr; | ||
51 | static int virtual_dma_mode; | ||
52 | static int doing_pdma; | ||
53 | |||
54 | static irqreturn_t floppy_hardint(int irq, void *dev_id) | ||
55 | { | ||
56 | register unsigned char st; | ||
57 | |||
58 | #undef TRACE_FLPY_INT | ||
59 | |||
60 | #ifdef TRACE_FLPY_INT | ||
61 | static int calls=0; | ||
62 | static int bytes=0; | ||
63 | static int dma_wait=0; | ||
64 | #endif | ||
65 | if (!doing_pdma) | ||
66 | return floppy_interrupt(irq, dev_id); | ||
67 | |||
68 | #ifdef TRACE_FLPY_INT | ||
69 | if(!calls) | ||
70 | bytes = virtual_dma_count; | ||
71 | #endif | ||
72 | |||
73 | { | ||
74 | register int lcount; | ||
75 | register char *lptr; | ||
76 | |||
77 | st = 1; | ||
78 | for(lcount=virtual_dma_count, lptr=virtual_dma_addr; | ||
79 | lcount; lcount--, lptr++) { | ||
80 | st=inb(virtual_dma_port+4) & 0xa0 ; | ||
81 | if(st != 0xa0) | ||
82 | break; | ||
83 | if(virtual_dma_mode) | ||
84 | outb_p(*lptr, virtual_dma_port+5); | ||
85 | else | ||
86 | *lptr = inb_p(virtual_dma_port+5); | ||
87 | } | ||
88 | virtual_dma_count = lcount; | ||
89 | virtual_dma_addr = lptr; | ||
90 | st = inb(virtual_dma_port+4); | ||
91 | } | ||
92 | |||
93 | #ifdef TRACE_FLPY_INT | ||
94 | calls++; | ||
95 | #endif | ||
96 | if(st == 0x20) | ||
97 | return IRQ_HANDLED; | ||
98 | if(!(st & 0x20)) { | ||
99 | virtual_dma_residue += virtual_dma_count; | ||
100 | virtual_dma_count=0; | ||
101 | #ifdef TRACE_FLPY_INT | ||
102 | printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", | ||
103 | virtual_dma_count, virtual_dma_residue, calls, bytes, | ||
104 | dma_wait); | ||
105 | calls = 0; | ||
106 | dma_wait=0; | ||
107 | #endif | ||
108 | doing_pdma = 0; | ||
109 | floppy_interrupt(irq, dev_id); | ||
110 | return IRQ_HANDLED; | ||
111 | } | ||
112 | #ifdef TRACE_FLPY_INT | ||
113 | if(!virtual_dma_count) | ||
114 | dma_wait++; | ||
115 | #endif | ||
116 | return IRQ_HANDLED; | ||
117 | } | ||
118 | |||
119 | static void fd_disable_dma(void) | ||
120 | { | ||
121 | if(! (can_use_virtual_dma & 1)) | ||
122 | disable_dma(FLOPPY_DMA); | ||
123 | doing_pdma = 0; | ||
124 | virtual_dma_residue += virtual_dma_count; | ||
125 | virtual_dma_count=0; | ||
126 | } | ||
127 | |||
128 | static int vdma_request_dma(unsigned int dmanr, const char * device_id) | ||
129 | { | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static void vdma_nop(unsigned int dummy) | ||
134 | { | ||
135 | } | ||
136 | |||
137 | |||
138 | static int vdma_get_dma_residue(unsigned int dummy) | ||
139 | { | ||
140 | return virtual_dma_count + virtual_dma_residue; | ||
141 | } | ||
142 | |||
143 | |||
144 | static int fd_request_irq(void) | ||
145 | { | ||
146 | if(can_use_virtual_dma) | ||
147 | return request_irq(FLOPPY_IRQ, floppy_hardint, | ||
148 | IRQF_DISABLED, "floppy", NULL); | ||
149 | else | ||
150 | return request_irq(FLOPPY_IRQ, floppy_interrupt, | ||
151 | IRQF_DISABLED, "floppy", NULL); | ||
152 | |||
153 | } | ||
154 | |||
155 | static unsigned long dma_mem_alloc(unsigned long size) | ||
156 | { | ||
157 | return __get_dma_pages(GFP_KERNEL,get_order(size)); | ||
158 | } | ||
159 | |||
160 | |||
161 | static unsigned long vdma_mem_alloc(unsigned long size) | ||
162 | { | ||
163 | return (unsigned long) vmalloc(size); | ||
164 | |||
165 | } | ||
166 | |||
167 | #define nodma_mem_alloc(size) vdma_mem_alloc(size) | ||
168 | |||
169 | static void _fd_dma_mem_free(unsigned long addr, unsigned long size) | ||
170 | { | ||
171 | if((unsigned int) addr >= (unsigned int) high_memory) | ||
172 | vfree((void *)addr); | ||
173 | else | ||
174 | free_pages(addr, get_order(size)); | ||
175 | } | ||
176 | |||
177 | #define fd_dma_mem_free(addr, size) _fd_dma_mem_free(addr, size) | ||
178 | |||
179 | static void _fd_chose_dma_mode(char *addr, unsigned long size) | ||
180 | { | ||
181 | if(can_use_virtual_dma == 2) { | ||
182 | if((unsigned int) addr >= (unsigned int) high_memory || | ||
183 | isa_virt_to_bus(addr) >= 0x1000000 || | ||
184 | _CROSS_64KB(addr, size, 0)) | ||
185 | use_virtual_dma = 1; | ||
186 | else | ||
187 | use_virtual_dma = 0; | ||
188 | } else { | ||
189 | use_virtual_dma = can_use_virtual_dma & 1; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | #define fd_chose_dma_mode(addr, size) _fd_chose_dma_mode(addr, size) | ||
194 | |||
195 | |||
196 | static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io) | ||
197 | { | ||
198 | doing_pdma = 1; | ||
199 | virtual_dma_port = io; | ||
200 | virtual_dma_mode = (mode == DMA_MODE_WRITE); | ||
201 | virtual_dma_addr = addr; | ||
202 | virtual_dma_count = size; | ||
203 | virtual_dma_residue = 0; | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static int hard_dma_setup(char *addr, unsigned long size, int mode, int io) | ||
208 | { | ||
209 | #ifdef FLOPPY_SANITY_CHECK | ||
210 | if (CROSS_64KB(addr, size)) { | ||
211 | printk("DMA crossing 64-K boundary %p-%p\n", addr, addr+size); | ||
212 | return -1; | ||
213 | } | ||
214 | #endif | ||
215 | /* actual, physical DMA */ | ||
216 | doing_pdma = 0; | ||
217 | clear_dma_ff(FLOPPY_DMA); | ||
218 | set_dma_mode(FLOPPY_DMA,mode); | ||
219 | set_dma_addr(FLOPPY_DMA,isa_virt_to_bus(addr)); | ||
220 | set_dma_count(FLOPPY_DMA,size); | ||
221 | enable_dma(FLOPPY_DMA); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static struct fd_routine_l { | ||
226 | int (*_request_dma)(unsigned int dmanr, const char * device_id); | ||
227 | void (*_free_dma)(unsigned int dmanr); | ||
228 | int (*_get_dma_residue)(unsigned int dummy); | ||
229 | unsigned long (*_dma_mem_alloc) (unsigned long size); | ||
230 | int (*_dma_setup)(char *addr, unsigned long size, int mode, int io); | ||
231 | } fd_routine[] = { | ||
232 | { | ||
233 | request_dma, | ||
234 | free_dma, | ||
235 | get_dma_residue, | ||
236 | dma_mem_alloc, | ||
237 | hard_dma_setup | ||
238 | }, | ||
239 | { | ||
240 | vdma_request_dma, | ||
241 | vdma_nop, | ||
242 | vdma_get_dma_residue, | ||
243 | vdma_mem_alloc, | ||
244 | vdma_dma_setup | ||
245 | } | ||
246 | }; | ||
247 | |||
248 | |||
249 | static int FDC1 = 0x3f0; | ||
250 | static int FDC2 = -1; | ||
251 | |||
252 | /* | ||
253 | * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock | ||
254 | * is needed to prevent corrupted CMOS RAM in case "insmod floppy" | ||
255 | * coincides with another rtc CMOS user. Paul G. | ||
256 | */ | ||
257 | #define FLOPPY0_TYPE ({ \ | ||
258 | unsigned long flags; \ | ||
259 | unsigned char val; \ | ||
260 | spin_lock_irqsave(&rtc_lock, flags); \ | ||
261 | val = (CMOS_READ(0x10) >> 4) & 15; \ | ||
262 | spin_unlock_irqrestore(&rtc_lock, flags); \ | ||
263 | val; \ | ||
264 | }) | ||
265 | |||
266 | #define FLOPPY1_TYPE ({ \ | ||
267 | unsigned long flags; \ | ||
268 | unsigned char val; \ | ||
269 | spin_lock_irqsave(&rtc_lock, flags); \ | ||
270 | val = CMOS_READ(0x10) & 15; \ | ||
271 | spin_unlock_irqrestore(&rtc_lock, flags); \ | ||
272 | val; \ | ||
273 | }) | ||
274 | |||
275 | #define N_FDC 2 | ||
276 | #define N_DRIVE 8 | ||
277 | |||
278 | #define FLOPPY_MOTOR_MASK 0xf0 | ||
279 | |||
280 | #define AUTO_DMA | ||
281 | |||
282 | #define EXTRA_FLOPPY_PARAMS | ||
283 | |||
284 | #endif /* __ASM_I386_FLOPPY_H */ | ||
diff --git a/include/asm-x86/floppy_64.h b/include/asm-x86/floppy_64.h new file mode 100644 index 000000000000..6ea13c3806f3 --- /dev/null +++ b/include/asm-x86/floppy_64.h | |||
@@ -0,0 +1,283 @@ | |||
1 | /* | ||
2 | * Architecture specific parts of the Floppy driver | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1995 | ||
9 | */ | ||
10 | #ifndef __ASM_X86_64_FLOPPY_H | ||
11 | #define __ASM_X86_64_FLOPPY_H | ||
12 | |||
13 | #include <linux/vmalloc.h> | ||
14 | |||
15 | |||
16 | /* | ||
17 | * The DMA channel used by the floppy controller cannot access data at | ||
18 | * addresses >= 16MB | ||
19 | * | ||
20 | * Went back to the 1MB limit, as some people had problems with the floppy | ||
21 | * driver otherwise. It doesn't matter much for performance anyway, as most | ||
22 | * floppy accesses go through the track buffer. | ||
23 | */ | ||
24 | #define _CROSS_64KB(a,s,vdma) \ | ||
25 | (!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)) | ||
26 | |||
27 | #define CROSS_64KB(a,s) _CROSS_64KB(a,s,use_virtual_dma & 1) | ||
28 | |||
29 | |||
30 | #define SW fd_routine[use_virtual_dma&1] | ||
31 | #define CSW fd_routine[can_use_virtual_dma & 1] | ||
32 | |||
33 | |||
34 | #define fd_inb(port) inb_p(port) | ||
35 | #define fd_outb(value,port) outb_p(value,port) | ||
36 | |||
37 | #define fd_request_dma() CSW._request_dma(FLOPPY_DMA,"floppy") | ||
38 | #define fd_free_dma() CSW._free_dma(FLOPPY_DMA) | ||
39 | #define fd_enable_irq() enable_irq(FLOPPY_IRQ) | ||
40 | #define fd_disable_irq() disable_irq(FLOPPY_IRQ) | ||
41 | #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL) | ||
42 | #define fd_get_dma_residue() SW._get_dma_residue(FLOPPY_DMA) | ||
43 | #define fd_dma_mem_alloc(size) SW._dma_mem_alloc(size) | ||
44 | #define fd_dma_setup(addr, size, mode, io) SW._dma_setup(addr, size, mode, io) | ||
45 | |||
46 | #define FLOPPY_CAN_FALLBACK_ON_NODMA | ||
47 | |||
48 | static int virtual_dma_count; | ||
49 | static int virtual_dma_residue; | ||
50 | static char *virtual_dma_addr; | ||
51 | static int virtual_dma_mode; | ||
52 | static int doing_pdma; | ||
53 | |||
54 | static irqreturn_t floppy_hardint(int irq, void *dev_id) | ||
55 | { | ||
56 | register unsigned char st; | ||
57 | |||
58 | #undef TRACE_FLPY_INT | ||
59 | |||
60 | #ifdef TRACE_FLPY_INT | ||
61 | static int calls=0; | ||
62 | static int bytes=0; | ||
63 | static int dma_wait=0; | ||
64 | #endif | ||
65 | if (!doing_pdma) | ||
66 | return floppy_interrupt(irq, dev_id); | ||
67 | |||
68 | #ifdef TRACE_FLPY_INT | ||
69 | if(!calls) | ||
70 | bytes = virtual_dma_count; | ||
71 | #endif | ||
72 | |||
73 | { | ||
74 | register int lcount; | ||
75 | register char *lptr; | ||
76 | |||
77 | st = 1; | ||
78 | for(lcount=virtual_dma_count, lptr=virtual_dma_addr; | ||
79 | lcount; lcount--, lptr++) { | ||
80 | st=inb(virtual_dma_port+4) & 0xa0 ; | ||
81 | if(st != 0xa0) | ||
82 | break; | ||
83 | if(virtual_dma_mode) | ||
84 | outb_p(*lptr, virtual_dma_port+5); | ||
85 | else | ||
86 | *lptr = inb_p(virtual_dma_port+5); | ||
87 | } | ||
88 | virtual_dma_count = lcount; | ||
89 | virtual_dma_addr = lptr; | ||
90 | st = inb(virtual_dma_port+4); | ||
91 | } | ||
92 | |||
93 | #ifdef TRACE_FLPY_INT | ||
94 | calls++; | ||
95 | #endif | ||
96 | if(st == 0x20) | ||
97 | return IRQ_HANDLED; | ||
98 | if(!(st & 0x20)) { | ||
99 | virtual_dma_residue += virtual_dma_count; | ||
100 | virtual_dma_count=0; | ||
101 | #ifdef TRACE_FLPY_INT | ||
102 | printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", | ||
103 | virtual_dma_count, virtual_dma_residue, calls, bytes, | ||
104 | dma_wait); | ||
105 | calls = 0; | ||
106 | dma_wait=0; | ||
107 | #endif | ||
108 | doing_pdma = 0; | ||
109 | floppy_interrupt(irq, dev_id); | ||
110 | return IRQ_HANDLED; | ||
111 | } | ||
112 | #ifdef TRACE_FLPY_INT | ||
113 | if(!virtual_dma_count) | ||
114 | dma_wait++; | ||
115 | #endif | ||
116 | return IRQ_HANDLED; | ||
117 | } | ||
118 | |||
119 | static void fd_disable_dma(void) | ||
120 | { | ||
121 | if(! (can_use_virtual_dma & 1)) | ||
122 | disable_dma(FLOPPY_DMA); | ||
123 | doing_pdma = 0; | ||
124 | virtual_dma_residue += virtual_dma_count; | ||
125 | virtual_dma_count=0; | ||
126 | } | ||
127 | |||
128 | static int vdma_request_dma(unsigned int dmanr, const char * device_id) | ||
129 | { | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static void vdma_nop(unsigned int dummy) | ||
134 | { | ||
135 | } | ||
136 | |||
137 | |||
138 | static int vdma_get_dma_residue(unsigned int dummy) | ||
139 | { | ||
140 | return virtual_dma_count + virtual_dma_residue; | ||
141 | } | ||
142 | |||
143 | |||
144 | static int fd_request_irq(void) | ||
145 | { | ||
146 | if(can_use_virtual_dma) | ||
147 | return request_irq(FLOPPY_IRQ, floppy_hardint, | ||
148 | IRQF_DISABLED, "floppy", NULL); | ||
149 | else | ||
150 | return request_irq(FLOPPY_IRQ, floppy_interrupt, | ||
151 | IRQF_DISABLED, "floppy", NULL); | ||
152 | } | ||
153 | |||
154 | static unsigned long dma_mem_alloc(unsigned long size) | ||
155 | { | ||
156 | return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY,get_order(size)); | ||
157 | } | ||
158 | |||
159 | |||
160 | static unsigned long vdma_mem_alloc(unsigned long size) | ||
161 | { | ||
162 | return (unsigned long) vmalloc(size); | ||
163 | |||
164 | } | ||
165 | |||
166 | #define nodma_mem_alloc(size) vdma_mem_alloc(size) | ||
167 | |||
168 | static void _fd_dma_mem_free(unsigned long addr, unsigned long size) | ||
169 | { | ||
170 | if((unsigned long) addr >= (unsigned long) high_memory) | ||
171 | vfree((void *)addr); | ||
172 | else | ||
173 | free_pages(addr, get_order(size)); | ||
174 | } | ||
175 | |||
176 | #define fd_dma_mem_free(addr, size) _fd_dma_mem_free(addr, size) | ||
177 | |||
178 | static void _fd_chose_dma_mode(char *addr, unsigned long size) | ||
179 | { | ||
180 | if(can_use_virtual_dma == 2) { | ||
181 | if((unsigned long) addr >= (unsigned long) high_memory || | ||
182 | isa_virt_to_bus(addr) >= 0x1000000 || | ||
183 | _CROSS_64KB(addr, size, 0)) | ||
184 | use_virtual_dma = 1; | ||
185 | else | ||
186 | use_virtual_dma = 0; | ||
187 | } else { | ||
188 | use_virtual_dma = can_use_virtual_dma & 1; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | #define fd_chose_dma_mode(addr, size) _fd_chose_dma_mode(addr, size) | ||
193 | |||
194 | |||
195 | static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io) | ||
196 | { | ||
197 | doing_pdma = 1; | ||
198 | virtual_dma_port = io; | ||
199 | virtual_dma_mode = (mode == DMA_MODE_WRITE); | ||
200 | virtual_dma_addr = addr; | ||
201 | virtual_dma_count = size; | ||
202 | virtual_dma_residue = 0; | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static int hard_dma_setup(char *addr, unsigned long size, int mode, int io) | ||
207 | { | ||
208 | #ifdef FLOPPY_SANITY_CHECK | ||
209 | if (CROSS_64KB(addr, size)) { | ||
210 | printk("DMA crossing 64-K boundary %p-%p\n", addr, addr+size); | ||
211 | return -1; | ||
212 | } | ||
213 | #endif | ||
214 | /* actual, physical DMA */ | ||
215 | doing_pdma = 0; | ||
216 | clear_dma_ff(FLOPPY_DMA); | ||
217 | set_dma_mode(FLOPPY_DMA,mode); | ||
218 | set_dma_addr(FLOPPY_DMA,isa_virt_to_bus(addr)); | ||
219 | set_dma_count(FLOPPY_DMA,size); | ||
220 | enable_dma(FLOPPY_DMA); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static struct fd_routine_l { | ||
225 | int (*_request_dma)(unsigned int dmanr, const char * device_id); | ||
226 | void (*_free_dma)(unsigned int dmanr); | ||
227 | int (*_get_dma_residue)(unsigned int dummy); | ||
228 | unsigned long (*_dma_mem_alloc) (unsigned long size); | ||
229 | int (*_dma_setup)(char *addr, unsigned long size, int mode, int io); | ||
230 | } fd_routine[] = { | ||
231 | { | ||
232 | request_dma, | ||
233 | free_dma, | ||
234 | get_dma_residue, | ||
235 | dma_mem_alloc, | ||
236 | hard_dma_setup | ||
237 | }, | ||
238 | { | ||
239 | vdma_request_dma, | ||
240 | vdma_nop, | ||
241 | vdma_get_dma_residue, | ||
242 | vdma_mem_alloc, | ||
243 | vdma_dma_setup | ||
244 | } | ||
245 | }; | ||
246 | |||
247 | |||
248 | static int FDC1 = 0x3f0; | ||
249 | static int FDC2 = -1; | ||
250 | |||
251 | /* | ||
252 | * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock | ||
253 | * is needed to prevent corrupted CMOS RAM in case "insmod floppy" | ||
254 | * coincides with another rtc CMOS user. Paul G. | ||
255 | */ | ||
256 | #define FLOPPY0_TYPE ({ \ | ||
257 | unsigned long flags; \ | ||
258 | unsigned char val; \ | ||
259 | spin_lock_irqsave(&rtc_lock, flags); \ | ||
260 | val = (CMOS_READ(0x10) >> 4) & 15; \ | ||
261 | spin_unlock_irqrestore(&rtc_lock, flags); \ | ||
262 | val; \ | ||
263 | }) | ||
264 | |||
265 | #define FLOPPY1_TYPE ({ \ | ||
266 | unsigned long flags; \ | ||
267 | unsigned char val; \ | ||
268 | spin_lock_irqsave(&rtc_lock, flags); \ | ||
269 | val = CMOS_READ(0x10) & 15; \ | ||
270 | spin_unlock_irqrestore(&rtc_lock, flags); \ | ||
271 | val; \ | ||
272 | }) | ||
273 | |||
274 | #define N_FDC 2 | ||
275 | #define N_DRIVE 8 | ||
276 | |||
277 | #define FLOPPY_MOTOR_MASK 0xf0 | ||
278 | |||
279 | #define AUTO_DMA | ||
280 | |||
281 | #define EXTRA_FLOPPY_PARAMS | ||
282 | |||
283 | #endif /* __ASM_X86_64_FLOPPY_H */ | ||
diff --git a/include/asm-x86/fpu32.h b/include/asm-x86/fpu32.h new file mode 100644 index 000000000000..4153db5c0c31 --- /dev/null +++ b/include/asm-x86/fpu32.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _FPU32_H | ||
2 | #define _FPU32_H 1 | ||
3 | |||
4 | struct _fpstate_ia32; | ||
5 | |||
6 | int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, int fsave); | ||
7 | int save_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, | ||
8 | struct pt_regs *regs, int fsave); | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/frame.i b/include/asm-x86/frame.i new file mode 100644 index 000000000000..03620251ae17 --- /dev/null +++ b/include/asm-x86/frame.i | |||
@@ -0,0 +1,23 @@ | |||
1 | #include <asm/dwarf2.h> | ||
2 | |||
3 | /* The annotation hides the frame from the unwinder and makes it look | ||
4 | like a ordinary ebp save/restore. This avoids some special cases for | ||
5 | frame pointer later */ | ||
6 | #ifdef CONFIG_FRAME_POINTER | ||
7 | .macro FRAME | ||
8 | pushl %ebp | ||
9 | CFI_ADJUST_CFA_OFFSET 4 | ||
10 | CFI_REL_OFFSET ebp,0 | ||
11 | movl %esp,%ebp | ||
12 | .endm | ||
13 | .macro ENDFRAME | ||
14 | popl %ebp | ||
15 | CFI_ADJUST_CFA_OFFSET -4 | ||
16 | CFI_RESTORE ebp | ||
17 | .endm | ||
18 | #else | ||
19 | .macro FRAME | ||
20 | .endm | ||
21 | .macro ENDFRAME | ||
22 | .endm | ||
23 | #endif | ||
diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h new file mode 100644 index 000000000000..1f4610e0c613 --- /dev/null +++ b/include/asm-x86/futex.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "futex_32.h" | ||
3 | #else | ||
4 | # include "futex_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/futex_32.h b/include/asm-x86/futex_32.h new file mode 100644 index 000000000000..438ef0ec7101 --- /dev/null +++ b/include/asm-x86/futex_32.h | |||
@@ -0,0 +1,135 @@ | |||
1 | #ifndef _ASM_FUTEX_H | ||
2 | #define _ASM_FUTEX_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/futex.h> | ||
7 | #include <asm/errno.h> | ||
8 | #include <asm/system.h> | ||
9 | #include <asm/processor.h> | ||
10 | #include <asm/uaccess.h> | ||
11 | |||
12 | #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ | ||
13 | __asm__ __volatile ( \ | ||
14 | "1: " insn "\n" \ | ||
15 | "2: .section .fixup,\"ax\"\n\ | ||
16 | 3: mov %3, %1\n\ | ||
17 | jmp 2b\n\ | ||
18 | .previous\n\ | ||
19 | .section __ex_table,\"a\"\n\ | ||
20 | .align 8\n\ | ||
21 | .long 1b,3b\n\ | ||
22 | .previous" \ | ||
23 | : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \ | ||
24 | : "i" (-EFAULT), "0" (oparg), "1" (0)) | ||
25 | |||
26 | #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \ | ||
27 | __asm__ __volatile ( \ | ||
28 | "1: movl %2, %0\n\ | ||
29 | movl %0, %3\n" \ | ||
30 | insn "\n" \ | ||
31 | "2: " LOCK_PREFIX "cmpxchgl %3, %2\n\ | ||
32 | jnz 1b\n\ | ||
33 | 3: .section .fixup,\"ax\"\n\ | ||
34 | 4: mov %5, %1\n\ | ||
35 | jmp 3b\n\ | ||
36 | .previous\n\ | ||
37 | .section __ex_table,\"a\"\n\ | ||
38 | .align 8\n\ | ||
39 | .long 1b,4b,2b,4b\n\ | ||
40 | .previous" \ | ||
41 | : "=&a" (oldval), "=&r" (ret), "+m" (*uaddr), \ | ||
42 | "=&r" (tem) \ | ||
43 | : "r" (oparg), "i" (-EFAULT), "1" (0)) | ||
44 | |||
45 | static inline int | ||
46 | futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | ||
47 | { | ||
48 | int op = (encoded_op >> 28) & 7; | ||
49 | int cmp = (encoded_op >> 24) & 15; | ||
50 | int oparg = (encoded_op << 8) >> 20; | ||
51 | int cmparg = (encoded_op << 20) >> 20; | ||
52 | int oldval = 0, ret, tem; | ||
53 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | ||
54 | oparg = 1 << oparg; | ||
55 | |||
56 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | ||
57 | return -EFAULT; | ||
58 | |||
59 | pagefault_disable(); | ||
60 | |||
61 | if (op == FUTEX_OP_SET) | ||
62 | __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg); | ||
63 | else { | ||
64 | #ifndef CONFIG_X86_BSWAP | ||
65 | if (boot_cpu_data.x86 == 3) | ||
66 | ret = -ENOSYS; | ||
67 | else | ||
68 | #endif | ||
69 | switch (op) { | ||
70 | case FUTEX_OP_ADD: | ||
71 | __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, | ||
72 | oldval, uaddr, oparg); | ||
73 | break; | ||
74 | case FUTEX_OP_OR: | ||
75 | __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr, | ||
76 | oparg); | ||
77 | break; | ||
78 | case FUTEX_OP_ANDN: | ||
79 | __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr, | ||
80 | ~oparg); | ||
81 | break; | ||
82 | case FUTEX_OP_XOR: | ||
83 | __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr, | ||
84 | oparg); | ||
85 | break; | ||
86 | default: | ||
87 | ret = -ENOSYS; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | pagefault_enable(); | ||
92 | |||
93 | if (!ret) { | ||
94 | switch (cmp) { | ||
95 | case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; | ||
96 | case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; | ||
97 | case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; | ||
98 | case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; | ||
99 | case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; | ||
100 | case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; | ||
101 | default: ret = -ENOSYS; | ||
102 | } | ||
103 | } | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | static inline int | ||
108 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | ||
109 | { | ||
110 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | ||
111 | return -EFAULT; | ||
112 | |||
113 | __asm__ __volatile__( | ||
114 | "1: " LOCK_PREFIX "cmpxchgl %3, %1 \n" | ||
115 | |||
116 | "2: .section .fixup, \"ax\" \n" | ||
117 | "3: mov %2, %0 \n" | ||
118 | " jmp 2b \n" | ||
119 | " .previous \n" | ||
120 | |||
121 | " .section __ex_table, \"a\" \n" | ||
122 | " .align 8 \n" | ||
123 | " .long 1b,3b \n" | ||
124 | " .previous \n" | ||
125 | |||
126 | : "=a" (oldval), "+m" (*uaddr) | ||
127 | : "i" (-EFAULT), "r" (newval), "0" (oldval) | ||
128 | : "memory" | ||
129 | ); | ||
130 | |||
131 | return oldval; | ||
132 | } | ||
133 | |||
134 | #endif | ||
135 | #endif | ||
diff --git a/include/asm-x86/futex_64.h b/include/asm-x86/futex_64.h new file mode 100644 index 000000000000..5cdfb08013c3 --- /dev/null +++ b/include/asm-x86/futex_64.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef _ASM_FUTEX_H | ||
2 | #define _ASM_FUTEX_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/futex.h> | ||
7 | #include <asm/errno.h> | ||
8 | #include <asm/system.h> | ||
9 | #include <asm/uaccess.h> | ||
10 | |||
11 | #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ | ||
12 | __asm__ __volatile ( \ | ||
13 | "1: " insn "\n" \ | ||
14 | "2: .section .fixup,\"ax\"\n\ | ||
15 | 3: mov %3, %1\n\ | ||
16 | jmp 2b\n\ | ||
17 | .previous\n\ | ||
18 | .section __ex_table,\"a\"\n\ | ||
19 | .align 8\n\ | ||
20 | .quad 1b,3b\n\ | ||
21 | .previous" \ | ||
22 | : "=r" (oldval), "=r" (ret), "=m" (*uaddr) \ | ||
23 | : "i" (-EFAULT), "m" (*uaddr), "0" (oparg), "1" (0)) | ||
24 | |||
25 | #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \ | ||
26 | __asm__ __volatile ( \ | ||
27 | "1: movl %2, %0\n\ | ||
28 | movl %0, %3\n" \ | ||
29 | insn "\n" \ | ||
30 | "2: " LOCK_PREFIX "cmpxchgl %3, %2\n\ | ||
31 | jnz 1b\n\ | ||
32 | 3: .section .fixup,\"ax\"\n\ | ||
33 | 4: mov %5, %1\n\ | ||
34 | jmp 3b\n\ | ||
35 | .previous\n\ | ||
36 | .section __ex_table,\"a\"\n\ | ||
37 | .align 8\n\ | ||
38 | .quad 1b,4b,2b,4b\n\ | ||
39 | .previous" \ | ||
40 | : "=&a" (oldval), "=&r" (ret), "=m" (*uaddr), \ | ||
41 | "=&r" (tem) \ | ||
42 | : "r" (oparg), "i" (-EFAULT), "m" (*uaddr), "1" (0)) | ||
43 | |||
44 | static inline int | ||
45 | futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | ||
46 | { | ||
47 | int op = (encoded_op >> 28) & 7; | ||
48 | int cmp = (encoded_op >> 24) & 15; | ||
49 | int oparg = (encoded_op << 8) >> 20; | ||
50 | int cmparg = (encoded_op << 20) >> 20; | ||
51 | int oldval = 0, ret, tem; | ||
52 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | ||
53 | oparg = 1 << oparg; | ||
54 | |||
55 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | ||
56 | return -EFAULT; | ||
57 | |||
58 | pagefault_disable(); | ||
59 | |||
60 | switch (op) { | ||
61 | case FUTEX_OP_SET: | ||
62 | __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg); | ||
63 | break; | ||
64 | case FUTEX_OP_ADD: | ||
65 | __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval, | ||
66 | uaddr, oparg); | ||
67 | break; | ||
68 | case FUTEX_OP_OR: | ||
69 | __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr, oparg); | ||
70 | break; | ||
71 | case FUTEX_OP_ANDN: | ||
72 | __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr, ~oparg); | ||
73 | break; | ||
74 | case FUTEX_OP_XOR: | ||
75 | __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr, oparg); | ||
76 | break; | ||
77 | default: | ||
78 | ret = -ENOSYS; | ||
79 | } | ||
80 | |||
81 | pagefault_enable(); | ||
82 | |||
83 | if (!ret) { | ||
84 | switch (cmp) { | ||
85 | case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; | ||
86 | case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; | ||
87 | case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; | ||
88 | case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; | ||
89 | case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; | ||
90 | case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; | ||
91 | default: ret = -ENOSYS; | ||
92 | } | ||
93 | } | ||
94 | return ret; | ||
95 | } | ||
96 | |||
97 | static inline int | ||
98 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | ||
99 | { | ||
100 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | ||
101 | return -EFAULT; | ||
102 | |||
103 | __asm__ __volatile__( | ||
104 | "1: " LOCK_PREFIX "cmpxchgl %3, %1 \n" | ||
105 | |||
106 | "2: .section .fixup, \"ax\" \n" | ||
107 | "3: mov %2, %0 \n" | ||
108 | " jmp 2b \n" | ||
109 | " .previous \n" | ||
110 | |||
111 | " .section __ex_table, \"a\" \n" | ||
112 | " .align 8 \n" | ||
113 | " .quad 1b,3b \n" | ||
114 | " .previous \n" | ||
115 | |||
116 | : "=a" (oldval), "=m" (*uaddr) | ||
117 | : "i" (-EFAULT), "r" (newval), "0" (oldval) | ||
118 | : "memory" | ||
119 | ); | ||
120 | |||
121 | return oldval; | ||
122 | } | ||
123 | |||
124 | #endif | ||
125 | #endif | ||
diff --git a/include/asm-x86/genapic.h b/include/asm-x86/genapic.h new file mode 100644 index 000000000000..d48bee663a6f --- /dev/null +++ b/include/asm-x86/genapic.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "genapic_32.h" | ||
3 | #else | ||
4 | # include "genapic_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/genapic_32.h b/include/asm-x86/genapic_32.h new file mode 100644 index 000000000000..33e3ffe1766c --- /dev/null +++ b/include/asm-x86/genapic_32.h | |||
@@ -0,0 +1,127 @@ | |||
1 | #ifndef _ASM_GENAPIC_H | ||
2 | #define _ASM_GENAPIC_H 1 | ||
3 | |||
4 | #include <asm/mpspec.h> | ||
5 | |||
6 | /* | ||
7 | * Generic APIC driver interface. | ||
8 | * | ||
9 | * An straight forward mapping of the APIC related parts of the | ||
10 | * x86 subarchitecture interface to a dynamic object. | ||
11 | * | ||
12 | * This is used by the "generic" x86 subarchitecture. | ||
13 | * | ||
14 | * Copyright 2003 Andi Kleen, SuSE Labs. | ||
15 | */ | ||
16 | |||
17 | struct mpc_config_translation; | ||
18 | struct mpc_config_bus; | ||
19 | struct mp_config_table; | ||
20 | struct mpc_config_processor; | ||
21 | |||
22 | struct genapic { | ||
23 | char *name; | ||
24 | int (*probe)(void); | ||
25 | |||
26 | int (*apic_id_registered)(void); | ||
27 | cpumask_t (*target_cpus)(void); | ||
28 | int int_delivery_mode; | ||
29 | int int_dest_mode; | ||
30 | int ESR_DISABLE; | ||
31 | int apic_destination_logical; | ||
32 | unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid); | ||
33 | unsigned long (*check_apicid_present)(int apicid); | ||
34 | int no_balance_irq; | ||
35 | int no_ioapic_check; | ||
36 | void (*init_apic_ldr)(void); | ||
37 | physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map); | ||
38 | |||
39 | void (*setup_apic_routing)(void); | ||
40 | int (*multi_timer_check)(int apic, int irq); | ||
41 | int (*apicid_to_node)(int logical_apicid); | ||
42 | int (*cpu_to_logical_apicid)(int cpu); | ||
43 | int (*cpu_present_to_apicid)(int mps_cpu); | ||
44 | physid_mask_t (*apicid_to_cpu_present)(int phys_apicid); | ||
45 | int (*mpc_apic_id)(struct mpc_config_processor *m, | ||
46 | struct mpc_config_translation *t); | ||
47 | void (*setup_portio_remap)(void); | ||
48 | int (*check_phys_apicid_present)(int boot_cpu_physical_apicid); | ||
49 | void (*enable_apic_mode)(void); | ||
50 | u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb); | ||
51 | |||
52 | /* mpparse */ | ||
53 | void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *, | ||
54 | struct mpc_config_translation *); | ||
55 | void (*mpc_oem_pci_bus)(struct mpc_config_bus *, | ||
56 | struct mpc_config_translation *); | ||
57 | |||
58 | /* When one of the next two hooks returns 1 the genapic | ||
59 | is switched to this. Essentially they are additional probe | ||
60 | functions. */ | ||
61 | int (*mps_oem_check)(struct mp_config_table *mpc, char *oem, | ||
62 | char *productid); | ||
63 | int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); | ||
64 | |||
65 | unsigned (*get_apic_id)(unsigned long x); | ||
66 | unsigned long apic_id_mask; | ||
67 | unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); | ||
68 | |||
69 | #ifdef CONFIG_SMP | ||
70 | /* ipi */ | ||
71 | void (*send_IPI_mask)(cpumask_t mask, int vector); | ||
72 | void (*send_IPI_allbutself)(int vector); | ||
73 | void (*send_IPI_all)(int vector); | ||
74 | #endif | ||
75 | }; | ||
76 | |||
77 | #define APICFUNC(x) .x = x, | ||
78 | |||
79 | /* More functions could be probably marked IPIFUNC and save some space | ||
80 | in UP GENERICARCH kernels, but I don't have the nerve right now | ||
81 | to untangle this mess. -AK */ | ||
82 | #ifdef CONFIG_SMP | ||
83 | #define IPIFUNC(x) APICFUNC(x) | ||
84 | #else | ||
85 | #define IPIFUNC(x) | ||
86 | #endif | ||
87 | |||
88 | #define APIC_INIT(aname, aprobe) { \ | ||
89 | .name = aname, \ | ||
90 | .probe = aprobe, \ | ||
91 | .int_delivery_mode = INT_DELIVERY_MODE, \ | ||
92 | .int_dest_mode = INT_DEST_MODE, \ | ||
93 | .no_balance_irq = NO_BALANCE_IRQ, \ | ||
94 | .ESR_DISABLE = esr_disable, \ | ||
95 | .apic_destination_logical = APIC_DEST_LOGICAL, \ | ||
96 | APICFUNC(apic_id_registered) \ | ||
97 | APICFUNC(target_cpus) \ | ||
98 | APICFUNC(check_apicid_used) \ | ||
99 | APICFUNC(check_apicid_present) \ | ||
100 | APICFUNC(init_apic_ldr) \ | ||
101 | APICFUNC(ioapic_phys_id_map) \ | ||
102 | APICFUNC(setup_apic_routing) \ | ||
103 | APICFUNC(multi_timer_check) \ | ||
104 | APICFUNC(apicid_to_node) \ | ||
105 | APICFUNC(cpu_to_logical_apicid) \ | ||
106 | APICFUNC(cpu_present_to_apicid) \ | ||
107 | APICFUNC(apicid_to_cpu_present) \ | ||
108 | APICFUNC(mpc_apic_id) \ | ||
109 | APICFUNC(setup_portio_remap) \ | ||
110 | APICFUNC(check_phys_apicid_present) \ | ||
111 | APICFUNC(mpc_oem_bus_info) \ | ||
112 | APICFUNC(mpc_oem_pci_bus) \ | ||
113 | APICFUNC(mps_oem_check) \ | ||
114 | APICFUNC(get_apic_id) \ | ||
115 | .apic_id_mask = APIC_ID_MASK, \ | ||
116 | APICFUNC(cpu_mask_to_apicid) \ | ||
117 | APICFUNC(acpi_madt_oem_check) \ | ||
118 | IPIFUNC(send_IPI_mask) \ | ||
119 | IPIFUNC(send_IPI_allbutself) \ | ||
120 | IPIFUNC(send_IPI_all) \ | ||
121 | APICFUNC(enable_apic_mode) \ | ||
122 | APICFUNC(phys_pkg_id) \ | ||
123 | } | ||
124 | |||
125 | extern struct genapic *genapic; | ||
126 | |||
127 | #endif | ||
diff --git a/include/asm-x86/genapic_64.h b/include/asm-x86/genapic_64.h new file mode 100644 index 000000000000..d7e516ccbaa4 --- /dev/null +++ b/include/asm-x86/genapic_64.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef _ASM_GENAPIC_H | ||
2 | #define _ASM_GENAPIC_H 1 | ||
3 | |||
4 | /* | ||
5 | * Copyright 2004 James Cleverdon, IBM. | ||
6 | * Subject to the GNU Public License, v.2 | ||
7 | * | ||
8 | * Generic APIC sub-arch data struct. | ||
9 | * | ||
10 | * Hacked for x86-64 by James Cleverdon from i386 architecture code by | ||
11 | * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and | ||
12 | * James Cleverdon. | ||
13 | */ | ||
14 | |||
15 | struct genapic { | ||
16 | char *name; | ||
17 | u32 int_delivery_mode; | ||
18 | u32 int_dest_mode; | ||
19 | int (*apic_id_registered)(void); | ||
20 | cpumask_t (*target_cpus)(void); | ||
21 | cpumask_t (*vector_allocation_domain)(int cpu); | ||
22 | void (*init_apic_ldr)(void); | ||
23 | /* ipi */ | ||
24 | void (*send_IPI_mask)(cpumask_t mask, int vector); | ||
25 | void (*send_IPI_allbutself)(int vector); | ||
26 | void (*send_IPI_all)(int vector); | ||
27 | /* */ | ||
28 | unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); | ||
29 | unsigned int (*phys_pkg_id)(int index_msb); | ||
30 | }; | ||
31 | |||
32 | extern struct genapic *genapic; | ||
33 | |||
34 | extern struct genapic apic_flat; | ||
35 | extern struct genapic apic_physflat; | ||
36 | |||
37 | #endif | ||
diff --git a/include/asm-x86/geode.h b/include/asm-x86/geode.h new file mode 100644 index 000000000000..6da4bbbea3dc --- /dev/null +++ b/include/asm-x86/geode.h | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * AMD Geode definitions | ||
3 | * Copyright (C) 2006, Advanced Micro Devices, Inc. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of version 2 of the GNU General Public License | ||
7 | * as published by the Free Software Foundation. | ||
8 | */ | ||
9 | |||
10 | #ifndef _ASM_GEODE_H_ | ||
11 | #define _ASM_GEODE_H_ | ||
12 | |||
13 | #include <asm/processor.h> | ||
14 | #include <linux/io.h> | ||
15 | |||
16 | /* Generic southbridge functions */ | ||
17 | |||
18 | #define GEODE_DEV_PMS 0 | ||
19 | #define GEODE_DEV_ACPI 1 | ||
20 | #define GEODE_DEV_GPIO 2 | ||
21 | #define GEODE_DEV_MFGPT 3 | ||
22 | |||
23 | extern int geode_get_dev_base(unsigned int dev); | ||
24 | |||
25 | /* Useful macros */ | ||
26 | #define geode_pms_base() geode_get_dev_base(GEODE_DEV_PMS) | ||
27 | #define geode_acpi_base() geode_get_dev_base(GEODE_DEV_ACPI) | ||
28 | #define geode_gpio_base() geode_get_dev_base(GEODE_DEV_GPIO) | ||
29 | #define geode_mfgpt_base() geode_get_dev_base(GEODE_DEV_MFGPT) | ||
30 | |||
31 | /* MSRS */ | ||
32 | |||
33 | #define GX_GLCP_SYS_RSTPLL 0x4C000014 | ||
34 | |||
35 | #define MSR_LBAR_SMB 0x5140000B | ||
36 | #define MSR_LBAR_GPIO 0x5140000C | ||
37 | #define MSR_LBAR_MFGPT 0x5140000D | ||
38 | #define MSR_LBAR_ACPI 0x5140000E | ||
39 | #define MSR_LBAR_PMS 0x5140000F | ||
40 | |||
41 | #define MSR_PIC_YSEL_LOW 0x51400020 | ||
42 | #define MSR_PIC_YSEL_HIGH 0x51400021 | ||
43 | #define MSR_PIC_ZSEL_LOW 0x51400022 | ||
44 | #define MSR_PIC_ZSEL_HIGH 0x51400023 | ||
45 | |||
46 | #define MFGPT_IRQ_MSR 0x51400028 | ||
47 | #define MFGPT_NR_MSR 0x51400029 | ||
48 | |||
49 | /* Resource Sizes */ | ||
50 | |||
51 | #define LBAR_GPIO_SIZE 0xFF | ||
52 | #define LBAR_MFGPT_SIZE 0x40 | ||
53 | #define LBAR_ACPI_SIZE 0x40 | ||
54 | #define LBAR_PMS_SIZE 0x80 | ||
55 | |||
56 | /* ACPI registers (PMS block) */ | ||
57 | |||
58 | /* | ||
59 | * PM1_EN is only valid when VSA is enabled for 16 bit reads. | ||
60 | * When VSA is not enabled, *always* read both PM1_STS and PM1_EN | ||
61 | * with a 32 bit read at offset 0x0 | ||
62 | */ | ||
63 | |||
64 | #define PM1_STS 0x00 | ||
65 | #define PM1_EN 0x02 | ||
66 | #define PM1_CNT 0x08 | ||
67 | #define PM2_CNT 0x0C | ||
68 | #define PM_TMR 0x10 | ||
69 | #define PM_GPE0_STS 0x18 | ||
70 | #define PM_GPE0_EN 0x1C | ||
71 | |||
72 | /* PMC registers (PMS block) */ | ||
73 | |||
74 | #define PM_SSD 0x00 | ||
75 | #define PM_SCXA 0x04 | ||
76 | #define PM_SCYA 0x08 | ||
77 | #define PM_OUT_SLPCTL 0x0C | ||
78 | #define PM_SCLK 0x10 | ||
79 | #define PM_SED 0x1 | ||
80 | #define PM_SCXD 0x18 | ||
81 | #define PM_SCYD 0x1C | ||
82 | #define PM_IN_SLPCTL 0x20 | ||
83 | #define PM_WKD 0x30 | ||
84 | #define PM_WKXD 0x34 | ||
85 | #define PM_RD 0x38 | ||
86 | #define PM_WKXA 0x3C | ||
87 | #define PM_FSD 0x40 | ||
88 | #define PM_TSD 0x44 | ||
89 | #define PM_PSD 0x48 | ||
90 | #define PM_NWKD 0x4C | ||
91 | #define PM_AWKD 0x50 | ||
92 | #define PM_SSC 0x54 | ||
93 | |||
94 | /* GPIO */ | ||
95 | |||
96 | #define GPIO_OUTPUT_VAL 0x00 | ||
97 | #define GPIO_OUTPUT_ENABLE 0x04 | ||
98 | #define GPIO_OUTPUT_OPEN_DRAIN 0x08 | ||
99 | #define GPIO_OUTPUT_INVERT 0x0C | ||
100 | #define GPIO_OUTPUT_AUX1 0x10 | ||
101 | #define GPIO_OUTPUT_AUX2 0x14 | ||
102 | #define GPIO_PULL_UP 0x18 | ||
103 | #define GPIO_PULL_DOWN 0x1C | ||
104 | #define GPIO_INPUT_ENABLE 0x20 | ||
105 | #define GPIO_INPUT_INVERT 0x24 | ||
106 | #define GPIO_INPUT_FILTER 0x28 | ||
107 | #define GPIO_INPUT_EVENT_COUNT 0x2C | ||
108 | #define GPIO_READ_BACK 0x30 | ||
109 | #define GPIO_INPUT_AUX1 0x34 | ||
110 | #define GPIO_EVENTS_ENABLE 0x38 | ||
111 | #define GPIO_LOCK_ENABLE 0x3C | ||
112 | #define GPIO_POSITIVE_EDGE_EN 0x40 | ||
113 | #define GPIO_NEGATIVE_EDGE_EN 0x44 | ||
114 | #define GPIO_POSITIVE_EDGE_STS 0x48 | ||
115 | #define GPIO_NEGATIVE_EDGE_STS 0x4C | ||
116 | |||
117 | #define GPIO_MAP_X 0xE0 | ||
118 | #define GPIO_MAP_Y 0xE4 | ||
119 | #define GPIO_MAP_Z 0xE8 | ||
120 | #define GPIO_MAP_W 0xEC | ||
121 | |||
122 | extern void geode_gpio_set(unsigned int, unsigned int); | ||
123 | extern void geode_gpio_clear(unsigned int, unsigned int); | ||
124 | extern int geode_gpio_isset(unsigned int, unsigned int); | ||
125 | extern void geode_gpio_setup_event(unsigned int, int, int); | ||
126 | extern void geode_gpio_set_irq(unsigned int, unsigned int); | ||
127 | |||
128 | static inline void geode_gpio_event_irq(unsigned int gpio, int pair) | ||
129 | { | ||
130 | geode_gpio_setup_event(gpio, pair, 0); | ||
131 | } | ||
132 | |||
133 | static inline void geode_gpio_event_pme(unsigned int gpio, int pair) | ||
134 | { | ||
135 | geode_gpio_setup_event(gpio, pair, 1); | ||
136 | } | ||
137 | |||
138 | /* Specific geode tests */ | ||
139 | |||
140 | static inline int is_geode_gx(void) | ||
141 | { | ||
142 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) && | ||
143 | (boot_cpu_data.x86 == 5) && | ||
144 | (boot_cpu_data.x86_model == 5)); | ||
145 | } | ||
146 | |||
147 | static inline int is_geode_lx(void) | ||
148 | { | ||
149 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && | ||
150 | (boot_cpu_data.x86 == 5) && | ||
151 | (boot_cpu_data.x86_model == 10)); | ||
152 | } | ||
153 | |||
154 | static inline int is_geode(void) | ||
155 | { | ||
156 | return (is_geode_gx() || is_geode_lx()); | ||
157 | } | ||
158 | |||
159 | #endif | ||
diff --git a/include/asm-x86/hardirq.h b/include/asm-x86/hardirq.h new file mode 100644 index 000000000000..314434d664e7 --- /dev/null +++ b/include/asm-x86/hardirq.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "hardirq_32.h" | ||
3 | #else | ||
4 | # include "hardirq_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/hardirq_32.h b/include/asm-x86/hardirq_32.h new file mode 100644 index 000000000000..0e358dc405f8 --- /dev/null +++ b/include/asm-x86/hardirq_32.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef __ASM_HARDIRQ_H | ||
2 | #define __ASM_HARDIRQ_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/irq.h> | ||
6 | |||
7 | typedef struct { | ||
8 | unsigned int __softirq_pending; | ||
9 | unsigned long idle_timestamp; | ||
10 | unsigned int __nmi_count; /* arch dependent */ | ||
11 | unsigned int apic_timer_irqs; /* arch dependent */ | ||
12 | } ____cacheline_aligned irq_cpustat_t; | ||
13 | |||
14 | DECLARE_PER_CPU(irq_cpustat_t, irq_stat); | ||
15 | extern irq_cpustat_t irq_stat[]; | ||
16 | |||
17 | #define __ARCH_IRQ_STAT | ||
18 | #define __IRQ_STAT(cpu, member) (per_cpu(irq_stat, cpu).member) | ||
19 | |||
20 | void ack_bad_irq(unsigned int irq); | ||
21 | #include <linux/irq_cpustat.h> | ||
22 | |||
23 | #endif /* __ASM_HARDIRQ_H */ | ||
diff --git a/include/asm-x86/hardirq_64.h b/include/asm-x86/hardirq_64.h new file mode 100644 index 000000000000..95d5e090ed89 --- /dev/null +++ b/include/asm-x86/hardirq_64.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef __ASM_HARDIRQ_H | ||
2 | #define __ASM_HARDIRQ_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/irq.h> | ||
6 | #include <asm/pda.h> | ||
7 | #include <asm/apic.h> | ||
8 | |||
9 | /* We can have at most NR_VECTORS irqs routed to a cpu at a time */ | ||
10 | #define MAX_HARDIRQS_PER_CPU NR_VECTORS | ||
11 | |||
12 | #define __ARCH_IRQ_STAT 1 | ||
13 | |||
14 | #define local_softirq_pending() read_pda(__softirq_pending) | ||
15 | |||
16 | #define __ARCH_SET_SOFTIRQ_PENDING 1 | ||
17 | |||
18 | #define set_softirq_pending(x) write_pda(__softirq_pending, (x)) | ||
19 | #define or_softirq_pending(x) or_pda(__softirq_pending, (x)) | ||
20 | |||
21 | extern void ack_bad_irq(unsigned int irq); | ||
22 | |||
23 | #endif /* __ASM_HARDIRQ_H */ | ||
diff --git a/include/asm-x86/highmem.h b/include/asm-x86/highmem.h new file mode 100644 index 000000000000..13cdcd66fff2 --- /dev/null +++ b/include/asm-x86/highmem.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * highmem.h: virtual kernel memory mappings for high memory | ||
3 | * | ||
4 | * Used in CONFIG_HIGHMEM systems for memory pages which | ||
5 | * are not addressable by direct kernel virtual addresses. | ||
6 | * | ||
7 | * Copyright (C) 1999 Gerhard Wichert, Siemens AG | ||
8 | * Gerhard.Wichert@pdb.siemens.de | ||
9 | * | ||
10 | * | ||
11 | * Redesigned the x86 32-bit VM architecture to deal with | ||
12 | * up to 16 Terabyte physical memory. With current x86 CPUs | ||
13 | * we now support up to 64 Gigabytes physical RAM. | ||
14 | * | ||
15 | * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> | ||
16 | */ | ||
17 | |||
18 | #ifndef _ASM_HIGHMEM_H | ||
19 | #define _ASM_HIGHMEM_H | ||
20 | |||
21 | #ifdef __KERNEL__ | ||
22 | |||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/threads.h> | ||
25 | #include <asm/kmap_types.h> | ||
26 | #include <asm/tlbflush.h> | ||
27 | #include <asm/paravirt.h> | ||
28 | |||
29 | /* declarations for highmem.c */ | ||
30 | extern unsigned long highstart_pfn, highend_pfn; | ||
31 | |||
32 | extern pte_t *kmap_pte; | ||
33 | extern pgprot_t kmap_prot; | ||
34 | extern pte_t *pkmap_page_table; | ||
35 | |||
36 | /* | ||
37 | * Right now we initialize only a single pte table. It can be extended | ||
38 | * easily, subsequent pte tables have to be allocated in one physical | ||
39 | * chunk of RAM. | ||
40 | */ | ||
41 | #ifdef CONFIG_X86_PAE | ||
42 | #define LAST_PKMAP 512 | ||
43 | #else | ||
44 | #define LAST_PKMAP 1024 | ||
45 | #endif | ||
46 | /* | ||
47 | * Ordering is: | ||
48 | * | ||
49 | * FIXADDR_TOP | ||
50 | * fixed_addresses | ||
51 | * FIXADDR_START | ||
52 | * temp fixed addresses | ||
53 | * FIXADDR_BOOT_START | ||
54 | * Persistent kmap area | ||
55 | * PKMAP_BASE | ||
56 | * VMALLOC_END | ||
57 | * Vmalloc area | ||
58 | * VMALLOC_START | ||
59 | * high_memory | ||
60 | */ | ||
61 | #define PKMAP_BASE ( (FIXADDR_BOOT_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK ) | ||
62 | #define LAST_PKMAP_MASK (LAST_PKMAP-1) | ||
63 | #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) | ||
64 | #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) | ||
65 | |||
66 | extern void * FASTCALL(kmap_high(struct page *page)); | ||
67 | extern void FASTCALL(kunmap_high(struct page *page)); | ||
68 | |||
69 | void *kmap(struct page *page); | ||
70 | void kunmap(struct page *page); | ||
71 | void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot); | ||
72 | void *kmap_atomic(struct page *page, enum km_type type); | ||
73 | void kunmap_atomic(void *kvaddr, enum km_type type); | ||
74 | void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); | ||
75 | struct page *kmap_atomic_to_page(void *ptr); | ||
76 | |||
77 | #ifndef CONFIG_PARAVIRT | ||
78 | #define kmap_atomic_pte(page, type) kmap_atomic(page, type) | ||
79 | #endif | ||
80 | |||
81 | #define flush_cache_kmaps() do { } while (0) | ||
82 | |||
83 | #endif /* __KERNEL__ */ | ||
84 | |||
85 | #endif /* _ASM_HIGHMEM_H */ | ||
diff --git a/include/asm-x86/hpet.h b/include/asm-x86/hpet.h new file mode 100644 index 000000000000..9eff48601254 --- /dev/null +++ b/include/asm-x86/hpet.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "hpet_32.h" | ||
3 | #else | ||
4 | # include "hpet_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/hpet_32.h b/include/asm-x86/hpet_32.h new file mode 100644 index 000000000000..c82dc7ed96b3 --- /dev/null +++ b/include/asm-x86/hpet_32.h | |||
@@ -0,0 +1,90 @@ | |||
1 | |||
2 | #ifndef _I386_HPET_H | ||
3 | #define _I386_HPET_H | ||
4 | |||
5 | #ifdef CONFIG_HPET_TIMER | ||
6 | |||
7 | /* | ||
8 | * Documentation on HPET can be found at: | ||
9 | * http://www.intel.com/ial/home/sp/pcmmspec.htm | ||
10 | * ftp://download.intel.com/ial/home/sp/mmts098.pdf | ||
11 | */ | ||
12 | |||
13 | #define HPET_MMAP_SIZE 1024 | ||
14 | |||
15 | #define HPET_ID 0x000 | ||
16 | #define HPET_PERIOD 0x004 | ||
17 | #define HPET_CFG 0x010 | ||
18 | #define HPET_STATUS 0x020 | ||
19 | #define HPET_COUNTER 0x0f0 | ||
20 | #define HPET_T0_CFG 0x100 | ||
21 | #define HPET_T0_CMP 0x108 | ||
22 | #define HPET_T0_ROUTE 0x110 | ||
23 | #define HPET_T1_CFG 0x120 | ||
24 | #define HPET_T1_CMP 0x128 | ||
25 | #define HPET_T1_ROUTE 0x130 | ||
26 | #define HPET_T2_CFG 0x140 | ||
27 | #define HPET_T2_CMP 0x148 | ||
28 | #define HPET_T2_ROUTE 0x150 | ||
29 | |||
30 | #define HPET_ID_REV 0x000000ff | ||
31 | #define HPET_ID_NUMBER 0x00001f00 | ||
32 | #define HPET_ID_64BIT 0x00002000 | ||
33 | #define HPET_ID_LEGSUP 0x00008000 | ||
34 | #define HPET_ID_VENDOR 0xffff0000 | ||
35 | #define HPET_ID_NUMBER_SHIFT 8 | ||
36 | #define HPET_ID_VENDOR_SHIFT 16 | ||
37 | |||
38 | #define HPET_ID_VENDOR_8086 0x8086 | ||
39 | |||
40 | #define HPET_CFG_ENABLE 0x001 | ||
41 | #define HPET_CFG_LEGACY 0x002 | ||
42 | #define HPET_LEGACY_8254 2 | ||
43 | #define HPET_LEGACY_RTC 8 | ||
44 | |||
45 | #define HPET_TN_LEVEL 0x0002 | ||
46 | #define HPET_TN_ENABLE 0x0004 | ||
47 | #define HPET_TN_PERIODIC 0x0008 | ||
48 | #define HPET_TN_PERIODIC_CAP 0x0010 | ||
49 | #define HPET_TN_64BIT_CAP 0x0020 | ||
50 | #define HPET_TN_SETVAL 0x0040 | ||
51 | #define HPET_TN_32BIT 0x0100 | ||
52 | #define HPET_TN_ROUTE 0x3e00 | ||
53 | #define HPET_TN_FSB 0x4000 | ||
54 | #define HPET_TN_FSB_CAP 0x8000 | ||
55 | #define HPET_TN_ROUTE_SHIFT 9 | ||
56 | |||
57 | /* Max HPET Period is 10^8 femto sec as in HPET spec */ | ||
58 | #define HPET_MAX_PERIOD 100000000UL | ||
59 | /* | ||
60 | * Min HPET period is 10^5 femto sec just for safety. If it is less than this, | ||
61 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. | ||
62 | */ | ||
63 | #define HPET_MIN_PERIOD 100000UL | ||
64 | |||
65 | /* hpet memory map physical address */ | ||
66 | extern unsigned long hpet_address; | ||
67 | extern int is_hpet_enabled(void); | ||
68 | extern int hpet_enable(void); | ||
69 | |||
70 | #ifdef CONFIG_HPET_EMULATE_RTC | ||
71 | |||
72 | #include <linux/interrupt.h> | ||
73 | |||
74 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); | ||
75 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); | ||
76 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, | ||
77 | unsigned char sec); | ||
78 | extern int hpet_set_periodic_freq(unsigned long freq); | ||
79 | extern int hpet_rtc_dropped_irq(void); | ||
80 | extern int hpet_rtc_timer_init(void); | ||
81 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | ||
82 | |||
83 | #endif /* CONFIG_HPET_EMULATE_RTC */ | ||
84 | |||
85 | #else | ||
86 | |||
87 | static inline int hpet_enable(void) { return 0; } | ||
88 | |||
89 | #endif /* CONFIG_HPET_TIMER */ | ||
90 | #endif /* _I386_HPET_H */ | ||
diff --git a/include/asm-x86/hpet_64.h b/include/asm-x86/hpet_64.h new file mode 100644 index 000000000000..fd4decac93a8 --- /dev/null +++ b/include/asm-x86/hpet_64.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _ASM_X8664_HPET_H | ||
2 | #define _ASM_X8664_HPET_H 1 | ||
3 | |||
4 | #include <asm/hpet_32.h> | ||
5 | |||
6 | #define HPET_TICK_RATE (HZ * 100000UL) | ||
7 | |||
8 | extern int hpet_rtc_timer_init(void); | ||
9 | extern int hpet_arch_init(void); | ||
10 | extern int hpet_timer_stop_set_go(unsigned long tick); | ||
11 | extern int hpet_reenable(void); | ||
12 | extern unsigned int hpet_calibrate_tsc(void); | ||
13 | |||
14 | extern int hpet_use_timer; | ||
15 | extern unsigned long hpet_period; | ||
16 | extern unsigned long hpet_tick; | ||
17 | |||
18 | #endif | ||
diff --git a/include/asm-x86/hw_irq.h b/include/asm-x86/hw_irq.h new file mode 100644 index 000000000000..bf025399d939 --- /dev/null +++ b/include/asm-x86/hw_irq.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "hw_irq_32.h" | ||
3 | #else | ||
4 | # include "hw_irq_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/hw_irq_32.h b/include/asm-x86/hw_irq_32.h new file mode 100644 index 000000000000..0bedbdf5e907 --- /dev/null +++ b/include/asm-x86/hw_irq_32.h | |||
@@ -0,0 +1,66 @@ | |||
1 | #ifndef _ASM_HW_IRQ_H | ||
2 | #define _ASM_HW_IRQ_H | ||
3 | |||
4 | /* | ||
5 | * linux/include/asm/hw_irq.h | ||
6 | * | ||
7 | * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar | ||
8 | * | ||
9 | * moved some of the old arch/i386/kernel/irq.h to here. VY | ||
10 | * | ||
11 | * IRQ/IPI changes taken from work by Thomas Radke | ||
12 | * <tomsoft@informatik.tu-chemnitz.de> | ||
13 | */ | ||
14 | |||
15 | #include <linux/profile.h> | ||
16 | #include <asm/atomic.h> | ||
17 | #include <asm/irq.h> | ||
18 | #include <asm/sections.h> | ||
19 | |||
20 | #define NMI_VECTOR 0x02 | ||
21 | |||
22 | /* | ||
23 | * Various low-level irq details needed by irq.c, process.c, | ||
24 | * time.c, io_apic.c and smp.c | ||
25 | * | ||
26 | * Interrupt entry/exit code at both C and assembly level | ||
27 | */ | ||
28 | |||
29 | extern void (*interrupt[NR_IRQS])(void); | ||
30 | |||
31 | #ifdef CONFIG_SMP | ||
32 | fastcall void reschedule_interrupt(void); | ||
33 | fastcall void invalidate_interrupt(void); | ||
34 | fastcall void call_function_interrupt(void); | ||
35 | #endif | ||
36 | |||
37 | #ifdef CONFIG_X86_LOCAL_APIC | ||
38 | fastcall void apic_timer_interrupt(void); | ||
39 | fastcall void error_interrupt(void); | ||
40 | fastcall void spurious_interrupt(void); | ||
41 | fastcall void thermal_interrupt(void); | ||
42 | #define platform_legacy_irq(irq) ((irq) < 16) | ||
43 | #endif | ||
44 | |||
45 | void disable_8259A_irq(unsigned int irq); | ||
46 | void enable_8259A_irq(unsigned int irq); | ||
47 | int i8259A_irq_pending(unsigned int irq); | ||
48 | void make_8259A_irq(unsigned int irq); | ||
49 | void init_8259A(int aeoi); | ||
50 | void FASTCALL(send_IPI_self(int vector)); | ||
51 | void init_VISWS_APIC_irqs(void); | ||
52 | void setup_IO_APIC(void); | ||
53 | void disable_IO_APIC(void); | ||
54 | void print_IO_APIC(void); | ||
55 | int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); | ||
56 | void send_IPI(int dest, int vector); | ||
57 | void setup_ioapic_dest(void); | ||
58 | |||
59 | extern unsigned long io_apic_irqs; | ||
60 | |||
61 | extern atomic_t irq_err_count; | ||
62 | extern atomic_t irq_mis_count; | ||
63 | |||
64 | #define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) | ||
65 | |||
66 | #endif /* _ASM_HW_IRQ_H */ | ||
diff --git a/include/asm-x86/hw_irq_64.h b/include/asm-x86/hw_irq_64.h new file mode 100644 index 000000000000..09dfc18a6dd0 --- /dev/null +++ b/include/asm-x86/hw_irq_64.h | |||
@@ -0,0 +1,175 @@ | |||
1 | #ifndef _ASM_HW_IRQ_H | ||
2 | #define _ASM_HW_IRQ_H | ||
3 | |||
4 | /* | ||
5 | * linux/include/asm/hw_irq.h | ||
6 | * | ||
7 | * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar | ||
8 | * | ||
9 | * moved some of the old arch/i386/kernel/irq.h to here. VY | ||
10 | * | ||
11 | * IRQ/IPI changes taken from work by Thomas Radke | ||
12 | * <tomsoft@informatik.tu-chemnitz.de> | ||
13 | * | ||
14 | * hacked by Andi Kleen for x86-64. | ||
15 | */ | ||
16 | |||
17 | #ifndef __ASSEMBLY__ | ||
18 | #include <asm/atomic.h> | ||
19 | #include <asm/irq.h> | ||
20 | #include <linux/profile.h> | ||
21 | #include <linux/smp.h> | ||
22 | #include <linux/percpu.h> | ||
23 | #endif | ||
24 | |||
25 | #define NMI_VECTOR 0x02 | ||
26 | /* | ||
27 | * IDT vectors usable for external interrupt sources start | ||
28 | * at 0x20: | ||
29 | */ | ||
30 | #define FIRST_EXTERNAL_VECTOR 0x20 | ||
31 | |||
32 | #define IA32_SYSCALL_VECTOR 0x80 | ||
33 | |||
34 | |||
35 | /* Reserve the lowest usable priority level 0x20 - 0x2f for triggering | ||
36 | * cleanup after irq migration. | ||
37 | */ | ||
38 | #define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR | ||
39 | |||
40 | /* | ||
41 | * Vectors 0x30-0x3f are used for ISA interrupts. | ||
42 | */ | ||
43 | #define IRQ0_VECTOR FIRST_EXTERNAL_VECTOR + 0x10 | ||
44 | #define IRQ1_VECTOR IRQ0_VECTOR + 1 | ||
45 | #define IRQ2_VECTOR IRQ0_VECTOR + 2 | ||
46 | #define IRQ3_VECTOR IRQ0_VECTOR + 3 | ||
47 | #define IRQ4_VECTOR IRQ0_VECTOR + 4 | ||
48 | #define IRQ5_VECTOR IRQ0_VECTOR + 5 | ||
49 | #define IRQ6_VECTOR IRQ0_VECTOR + 6 | ||
50 | #define IRQ7_VECTOR IRQ0_VECTOR + 7 | ||
51 | #define IRQ8_VECTOR IRQ0_VECTOR + 8 | ||
52 | #define IRQ9_VECTOR IRQ0_VECTOR + 9 | ||
53 | #define IRQ10_VECTOR IRQ0_VECTOR + 10 | ||
54 | #define IRQ11_VECTOR IRQ0_VECTOR + 11 | ||
55 | #define IRQ12_VECTOR IRQ0_VECTOR + 12 | ||
56 | #define IRQ13_VECTOR IRQ0_VECTOR + 13 | ||
57 | #define IRQ14_VECTOR IRQ0_VECTOR + 14 | ||
58 | #define IRQ15_VECTOR IRQ0_VECTOR + 15 | ||
59 | |||
60 | /* | ||
61 | * Special IRQ vectors used by the SMP architecture, 0xf0-0xff | ||
62 | * | ||
63 | * some of the following vectors are 'rare', they are merged | ||
64 | * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. | ||
65 | * TLB, reschedule and local APIC vectors are performance-critical. | ||
66 | */ | ||
67 | #define SPURIOUS_APIC_VECTOR 0xff | ||
68 | #define ERROR_APIC_VECTOR 0xfe | ||
69 | #define RESCHEDULE_VECTOR 0xfd | ||
70 | #define CALL_FUNCTION_VECTOR 0xfc | ||
71 | /* fb free - please don't readd KDB here because it's useless | ||
72 | (hint - think what a NMI bit does to a vector) */ | ||
73 | #define THERMAL_APIC_VECTOR 0xfa | ||
74 | #define THRESHOLD_APIC_VECTOR 0xf9 | ||
75 | /* f8 free */ | ||
76 | #define INVALIDATE_TLB_VECTOR_END 0xf7 | ||
77 | #define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */ | ||
78 | |||
79 | #define NUM_INVALIDATE_TLB_VECTORS 8 | ||
80 | |||
81 | /* | ||
82 | * Local APIC timer IRQ vector is on a different priority level, | ||
83 | * to work around the 'lost local interrupt if more than 2 IRQ | ||
84 | * sources per level' errata. | ||
85 | */ | ||
86 | #define LOCAL_TIMER_VECTOR 0xef | ||
87 | |||
88 | /* | ||
89 | * First APIC vector available to drivers: (vectors 0x30-0xee) | ||
90 | * we start at 0x41 to spread out vectors evenly between priority | ||
91 | * levels. (0x80 is the syscall vector) | ||
92 | */ | ||
93 | #define FIRST_DEVICE_VECTOR (IRQ15_VECTOR + 2) | ||
94 | #define FIRST_SYSTEM_VECTOR 0xef /* duplicated in irq.h */ | ||
95 | |||
96 | |||
97 | #ifndef __ASSEMBLY__ | ||
98 | |||
99 | /* Interrupt handlers registered during init_IRQ */ | ||
100 | void apic_timer_interrupt(void); | ||
101 | void spurious_interrupt(void); | ||
102 | void error_interrupt(void); | ||
103 | void reschedule_interrupt(void); | ||
104 | void call_function_interrupt(void); | ||
105 | void irq_move_cleanup_interrupt(void); | ||
106 | void invalidate_interrupt0(void); | ||
107 | void invalidate_interrupt1(void); | ||
108 | void invalidate_interrupt2(void); | ||
109 | void invalidate_interrupt3(void); | ||
110 | void invalidate_interrupt4(void); | ||
111 | void invalidate_interrupt5(void); | ||
112 | void invalidate_interrupt6(void); | ||
113 | void invalidate_interrupt7(void); | ||
114 | void thermal_interrupt(void); | ||
115 | void threshold_interrupt(void); | ||
116 | void i8254_timer_resume(void); | ||
117 | |||
118 | typedef int vector_irq_t[NR_VECTORS]; | ||
119 | DECLARE_PER_CPU(vector_irq_t, vector_irq); | ||
120 | extern void __setup_vector_irq(int cpu); | ||
121 | extern spinlock_t vector_lock; | ||
122 | |||
123 | /* | ||
124 | * Various low-level irq details needed by irq.c, process.c, | ||
125 | * time.c, io_apic.c and smp.c | ||
126 | * | ||
127 | * Interrupt entry/exit code at both C and assembly level | ||
128 | */ | ||
129 | |||
130 | extern void disable_8259A_irq(unsigned int irq); | ||
131 | extern void enable_8259A_irq(unsigned int irq); | ||
132 | extern int i8259A_irq_pending(unsigned int irq); | ||
133 | extern void make_8259A_irq(unsigned int irq); | ||
134 | extern void init_8259A(int aeoi); | ||
135 | extern void send_IPI_self(int vector); | ||
136 | extern void init_VISWS_APIC_irqs(void); | ||
137 | extern void setup_IO_APIC(void); | ||
138 | extern void disable_IO_APIC(void); | ||
139 | extern void print_IO_APIC(void); | ||
140 | extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); | ||
141 | extern void send_IPI(int dest, int vector); | ||
142 | extern void setup_ioapic_dest(void); | ||
143 | |||
144 | extern unsigned long io_apic_irqs; | ||
145 | |||
146 | extern atomic_t irq_err_count; | ||
147 | extern atomic_t irq_mis_count; | ||
148 | |||
149 | #define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) | ||
150 | |||
151 | #define __STR(x) #x | ||
152 | #define STR(x) __STR(x) | ||
153 | |||
154 | #include <asm/ptrace.h> | ||
155 | |||
156 | #define IRQ_NAME2(nr) nr##_interrupt(void) | ||
157 | #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr) | ||
158 | |||
159 | /* | ||
160 | * SMP has a few special interrupts for IPI messages | ||
161 | */ | ||
162 | |||
163 | #define BUILD_IRQ(nr) \ | ||
164 | asmlinkage void IRQ_NAME(nr); \ | ||
165 | __asm__( \ | ||
166 | "\n.p2align\n" \ | ||
167 | "IRQ" #nr "_interrupt:\n\t" \ | ||
168 | "push $~(" #nr ") ; " \ | ||
169 | "jmp common_interrupt"); | ||
170 | |||
171 | #define platform_legacy_irq(irq) ((irq) < 16) | ||
172 | |||
173 | #endif | ||
174 | |||
175 | #endif /* _ASM_HW_IRQ_H */ | ||
diff --git a/include/asm-x86/hypertransport.h b/include/asm-x86/hypertransport.h new file mode 100644 index 000000000000..c16c6ff4bdd7 --- /dev/null +++ b/include/asm-x86/hypertransport.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef ASM_HYPERTRANSPORT_H | ||
2 | #define ASM_HYPERTRANSPORT_H | ||
3 | |||
4 | /* | ||
5 | * Constants for x86 Hypertransport Interrupts. | ||
6 | */ | ||
7 | |||
8 | #define HT_IRQ_LOW_BASE 0xf8000000 | ||
9 | |||
10 | #define HT_IRQ_LOW_VECTOR_SHIFT 16 | ||
11 | #define HT_IRQ_LOW_VECTOR_MASK 0x00ff0000 | ||
12 | #define HT_IRQ_LOW_VECTOR(v) (((v) << HT_IRQ_LOW_VECTOR_SHIFT) & HT_IRQ_LOW_VECTOR_MASK) | ||
13 | |||
14 | #define HT_IRQ_LOW_DEST_ID_SHIFT 8 | ||
15 | #define HT_IRQ_LOW_DEST_ID_MASK 0x0000ff00 | ||
16 | #define HT_IRQ_LOW_DEST_ID(v) (((v) << HT_IRQ_LOW_DEST_ID_SHIFT) & HT_IRQ_LOW_DEST_ID_MASK) | ||
17 | |||
18 | #define HT_IRQ_LOW_DM_PHYSICAL 0x0000000 | ||
19 | #define HT_IRQ_LOW_DM_LOGICAL 0x0000040 | ||
20 | |||
21 | #define HT_IRQ_LOW_RQEOI_EDGE 0x0000000 | ||
22 | #define HT_IRQ_LOW_RQEOI_LEVEL 0x0000020 | ||
23 | |||
24 | |||
25 | #define HT_IRQ_LOW_MT_FIXED 0x0000000 | ||
26 | #define HT_IRQ_LOW_MT_ARBITRATED 0x0000004 | ||
27 | #define HT_IRQ_LOW_MT_SMI 0x0000008 | ||
28 | #define HT_IRQ_LOW_MT_NMI 0x000000c | ||
29 | #define HT_IRQ_LOW_MT_INIT 0x0000010 | ||
30 | #define HT_IRQ_LOW_MT_STARTUP 0x0000014 | ||
31 | #define HT_IRQ_LOW_MT_EXTINT 0x0000018 | ||
32 | #define HT_IRQ_LOW_MT_LINT1 0x000008c | ||
33 | #define HT_IRQ_LOW_MT_LINT0 0x0000098 | ||
34 | |||
35 | #define HT_IRQ_LOW_IRQ_MASKED 0x0000001 | ||
36 | |||
37 | |||
38 | #define HT_IRQ_HIGH_DEST_ID_SHIFT 0 | ||
39 | #define HT_IRQ_HIGH_DEST_ID_MASK 0x00ffffff | ||
40 | #define HT_IRQ_HIGH_DEST_ID(v) ((((v) >> 8) << HT_IRQ_HIGH_DEST_ID_SHIFT) & HT_IRQ_HIGH_DEST_ID_MASK) | ||
41 | |||
42 | #endif /* ASM_HYPERTRANSPORT_H */ | ||
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h new file mode 100644 index 000000000000..a8bbed349664 --- /dev/null +++ b/include/asm-x86/i387.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "i387_32.h" | ||
3 | #else | ||
4 | # include "i387_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/i387_32.h b/include/asm-x86/i387_32.h new file mode 100644 index 000000000000..cdd1e248e3b4 --- /dev/null +++ b/include/asm-x86/i387_32.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * include/asm-i386/i387.h | ||
3 | * | ||
4 | * Copyright (C) 1994 Linus Torvalds | ||
5 | * | ||
6 | * Pentium III FXSR, SSE support | ||
7 | * General FPU state handling cleanups | ||
8 | * Gareth Hughes <gareth@valinux.com>, May 2000 | ||
9 | */ | ||
10 | |||
11 | #ifndef __ASM_I386_I387_H | ||
12 | #define __ASM_I386_I387_H | ||
13 | |||
14 | #include <linux/sched.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/kernel_stat.h> | ||
17 | #include <asm/processor.h> | ||
18 | #include <asm/sigcontext.h> | ||
19 | #include <asm/user.h> | ||
20 | |||
21 | extern void mxcsr_feature_mask_init(void); | ||
22 | extern void init_fpu(struct task_struct *); | ||
23 | |||
24 | /* | ||
25 | * FPU lazy state save handling... | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | * The "nop" is needed to make the instructions the same | ||
30 | * length. | ||
31 | */ | ||
32 | #define restore_fpu(tsk) \ | ||
33 | alternative_input( \ | ||
34 | "nop ; frstor %1", \ | ||
35 | "fxrstor %1", \ | ||
36 | X86_FEATURE_FXSR, \ | ||
37 | "m" ((tsk)->thread.i387.fxsave)) | ||
38 | |||
39 | extern void kernel_fpu_begin(void); | ||
40 | #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) | ||
41 | |||
42 | /* We need a safe address that is cheap to find and that is already | ||
43 | in L1 during context switch. The best choices are unfortunately | ||
44 | different for UP and SMP */ | ||
45 | #ifdef CONFIG_SMP | ||
46 | #define safe_address (__per_cpu_offset[0]) | ||
47 | #else | ||
48 | #define safe_address (kstat_cpu(0).cpustat.user) | ||
49 | #endif | ||
50 | |||
51 | /* | ||
52 | * These must be called with preempt disabled | ||
53 | */ | ||
54 | static inline void __save_init_fpu( struct task_struct *tsk ) | ||
55 | { | ||
56 | /* Use more nops than strictly needed in case the compiler | ||
57 | varies code */ | ||
58 | alternative_input( | ||
59 | "fnsave %[fx] ;fwait;" GENERIC_NOP8 GENERIC_NOP4, | ||
60 | "fxsave %[fx]\n" | ||
61 | "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:", | ||
62 | X86_FEATURE_FXSR, | ||
63 | [fx] "m" (tsk->thread.i387.fxsave), | ||
64 | [fsw] "m" (tsk->thread.i387.fxsave.swd) : "memory"); | ||
65 | /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception | ||
66 | is pending. Clear the x87 state here by setting it to fixed | ||
67 | values. safe_address is a random variable that should be in L1 */ | ||
68 | alternative_input( | ||
69 | GENERIC_NOP8 GENERIC_NOP2, | ||
70 | "emms\n\t" /* clear stack tags */ | ||
71 | "fildl %[addr]", /* set F?P to defined value */ | ||
72 | X86_FEATURE_FXSAVE_LEAK, | ||
73 | [addr] "m" (safe_address)); | ||
74 | task_thread_info(tsk)->status &= ~TS_USEDFPU; | ||
75 | } | ||
76 | |||
77 | #define __unlazy_fpu( tsk ) do { \ | ||
78 | if (task_thread_info(tsk)->status & TS_USEDFPU) { \ | ||
79 | __save_init_fpu(tsk); \ | ||
80 | stts(); \ | ||
81 | } else \ | ||
82 | tsk->fpu_counter = 0; \ | ||
83 | } while (0) | ||
84 | |||
85 | #define __clear_fpu( tsk ) \ | ||
86 | do { \ | ||
87 | if (task_thread_info(tsk)->status & TS_USEDFPU) { \ | ||
88 | asm volatile("fnclex ; fwait"); \ | ||
89 | task_thread_info(tsk)->status &= ~TS_USEDFPU; \ | ||
90 | stts(); \ | ||
91 | } \ | ||
92 | } while (0) | ||
93 | |||
94 | |||
95 | /* | ||
96 | * These disable preemption on their own and are safe | ||
97 | */ | ||
98 | static inline void save_init_fpu( struct task_struct *tsk ) | ||
99 | { | ||
100 | preempt_disable(); | ||
101 | __save_init_fpu(tsk); | ||
102 | stts(); | ||
103 | preempt_enable(); | ||
104 | } | ||
105 | |||
106 | #define unlazy_fpu( tsk ) do { \ | ||
107 | preempt_disable(); \ | ||
108 | __unlazy_fpu(tsk); \ | ||
109 | preempt_enable(); \ | ||
110 | } while (0) | ||
111 | |||
112 | #define clear_fpu( tsk ) do { \ | ||
113 | preempt_disable(); \ | ||
114 | __clear_fpu( tsk ); \ | ||
115 | preempt_enable(); \ | ||
116 | } while (0) | ||
117 | |||
118 | /* | ||
119 | * FPU state interaction... | ||
120 | */ | ||
121 | extern unsigned short get_fpu_cwd( struct task_struct *tsk ); | ||
122 | extern unsigned short get_fpu_swd( struct task_struct *tsk ); | ||
123 | extern unsigned short get_fpu_mxcsr( struct task_struct *tsk ); | ||
124 | extern asmlinkage void math_state_restore(void); | ||
125 | |||
126 | /* | ||
127 | * Signal frame handlers... | ||
128 | */ | ||
129 | extern int save_i387( struct _fpstate __user *buf ); | ||
130 | extern int restore_i387( struct _fpstate __user *buf ); | ||
131 | |||
132 | /* | ||
133 | * ptrace request handers... | ||
134 | */ | ||
135 | extern int get_fpregs( struct user_i387_struct __user *buf, | ||
136 | struct task_struct *tsk ); | ||
137 | extern int set_fpregs( struct task_struct *tsk, | ||
138 | struct user_i387_struct __user *buf ); | ||
139 | |||
140 | extern int get_fpxregs( struct user_fxsr_struct __user *buf, | ||
141 | struct task_struct *tsk ); | ||
142 | extern int set_fpxregs( struct task_struct *tsk, | ||
143 | struct user_fxsr_struct __user *buf ); | ||
144 | |||
145 | /* | ||
146 | * FPU state for core dumps... | ||
147 | */ | ||
148 | extern int dump_fpu( struct pt_regs *regs, | ||
149 | struct user_i387_struct *fpu ); | ||
150 | |||
151 | #endif /* __ASM_I386_I387_H */ | ||
diff --git a/include/asm-x86/i387_64.h b/include/asm-x86/i387_64.h new file mode 100644 index 000000000000..0217b74cc9fc --- /dev/null +++ b/include/asm-x86/i387_64.h | |||
@@ -0,0 +1,209 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/i387.h | ||
3 | * | ||
4 | * Copyright (C) 1994 Linus Torvalds | ||
5 | * | ||
6 | * Pentium III FXSR, SSE support | ||
7 | * General FPU state handling cleanups | ||
8 | * Gareth Hughes <gareth@valinux.com>, May 2000 | ||
9 | * x86-64 work by Andi Kleen 2002 | ||
10 | */ | ||
11 | |||
12 | #ifndef __ASM_X86_64_I387_H | ||
13 | #define __ASM_X86_64_I387_H | ||
14 | |||
15 | #include <linux/sched.h> | ||
16 | #include <asm/processor.h> | ||
17 | #include <asm/sigcontext.h> | ||
18 | #include <asm/user.h> | ||
19 | #include <asm/thread_info.h> | ||
20 | #include <asm/uaccess.h> | ||
21 | |||
22 | extern void fpu_init(void); | ||
23 | extern unsigned int mxcsr_feature_mask; | ||
24 | extern void mxcsr_feature_mask_init(void); | ||
25 | extern void init_fpu(struct task_struct *child); | ||
26 | extern int save_i387(struct _fpstate __user *buf); | ||
27 | extern asmlinkage void math_state_restore(void); | ||
28 | |||
29 | /* | ||
30 | * FPU lazy state save handling... | ||
31 | */ | ||
32 | |||
33 | #define unlazy_fpu(tsk) do { \ | ||
34 | if (task_thread_info(tsk)->status & TS_USEDFPU) \ | ||
35 | save_init_fpu(tsk); \ | ||
36 | else \ | ||
37 | tsk->fpu_counter = 0; \ | ||
38 | } while (0) | ||
39 | |||
40 | /* Ignore delayed exceptions from user space */ | ||
41 | static inline void tolerant_fwait(void) | ||
42 | { | ||
43 | asm volatile("1: fwait\n" | ||
44 | "2:\n" | ||
45 | " .section __ex_table,\"a\"\n" | ||
46 | " .align 8\n" | ||
47 | " .quad 1b,2b\n" | ||
48 | " .previous\n"); | ||
49 | } | ||
50 | |||
51 | #define clear_fpu(tsk) do { \ | ||
52 | if (task_thread_info(tsk)->status & TS_USEDFPU) { \ | ||
53 | tolerant_fwait(); \ | ||
54 | task_thread_info(tsk)->status &= ~TS_USEDFPU; \ | ||
55 | stts(); \ | ||
56 | } \ | ||
57 | } while (0) | ||
58 | |||
59 | /* | ||
60 | * ptrace request handers... | ||
61 | */ | ||
62 | extern int get_fpregs(struct user_i387_struct __user *buf, | ||
63 | struct task_struct *tsk); | ||
64 | extern int set_fpregs(struct task_struct *tsk, | ||
65 | struct user_i387_struct __user *buf); | ||
66 | |||
67 | /* | ||
68 | * i387 state interaction | ||
69 | */ | ||
70 | #define get_fpu_mxcsr(t) ((t)->thread.i387.fxsave.mxcsr) | ||
71 | #define get_fpu_cwd(t) ((t)->thread.i387.fxsave.cwd) | ||
72 | #define get_fpu_fxsr_twd(t) ((t)->thread.i387.fxsave.twd) | ||
73 | #define get_fpu_swd(t) ((t)->thread.i387.fxsave.swd) | ||
74 | #define set_fpu_cwd(t,val) ((t)->thread.i387.fxsave.cwd = (val)) | ||
75 | #define set_fpu_swd(t,val) ((t)->thread.i387.fxsave.swd = (val)) | ||
76 | #define set_fpu_fxsr_twd(t,val) ((t)->thread.i387.fxsave.twd = (val)) | ||
77 | |||
78 | #define X87_FSW_ES (1 << 7) /* Exception Summary */ | ||
79 | |||
80 | /* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception | ||
81 | is pending. Clear the x87 state here by setting it to fixed | ||
82 | values. The kernel data segment can be sometimes 0 and sometimes | ||
83 | new user value. Both should be ok. | ||
84 | Use the PDA as safe address because it should be already in L1. */ | ||
85 | static inline void clear_fpu_state(struct i387_fxsave_struct *fx) | ||
86 | { | ||
87 | if (unlikely(fx->swd & X87_FSW_ES)) | ||
88 | asm volatile("fnclex"); | ||
89 | alternative_input(ASM_NOP8 ASM_NOP2, | ||
90 | " emms\n" /* clear stack tags */ | ||
91 | " fildl %%gs:0", /* load to clear state */ | ||
92 | X86_FEATURE_FXSAVE_LEAK); | ||
93 | } | ||
94 | |||
95 | static inline int restore_fpu_checking(struct i387_fxsave_struct *fx) | ||
96 | { | ||
97 | int err; | ||
98 | |||
99 | asm volatile("1: rex64/fxrstor (%[fx])\n\t" | ||
100 | "2:\n" | ||
101 | ".section .fixup,\"ax\"\n" | ||
102 | "3: movl $-1,%[err]\n" | ||
103 | " jmp 2b\n" | ||
104 | ".previous\n" | ||
105 | ".section __ex_table,\"a\"\n" | ||
106 | " .align 8\n" | ||
107 | " .quad 1b,3b\n" | ||
108 | ".previous" | ||
109 | : [err] "=r" (err) | ||
110 | #if 0 /* See comment in __fxsave_clear() below. */ | ||
111 | : [fx] "r" (fx), "m" (*fx), "0" (0)); | ||
112 | #else | ||
113 | : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0)); | ||
114 | #endif | ||
115 | if (unlikely(err)) | ||
116 | init_fpu(current); | ||
117 | return err; | ||
118 | } | ||
119 | |||
120 | static inline int save_i387_checking(struct i387_fxsave_struct __user *fx) | ||
121 | { | ||
122 | int err; | ||
123 | |||
124 | asm volatile("1: rex64/fxsave (%[fx])\n\t" | ||
125 | "2:\n" | ||
126 | ".section .fixup,\"ax\"\n" | ||
127 | "3: movl $-1,%[err]\n" | ||
128 | " jmp 2b\n" | ||
129 | ".previous\n" | ||
130 | ".section __ex_table,\"a\"\n" | ||
131 | " .align 8\n" | ||
132 | " .quad 1b,3b\n" | ||
133 | ".previous" | ||
134 | : [err] "=r" (err), "=m" (*fx) | ||
135 | #if 0 /* See comment in __fxsave_clear() below. */ | ||
136 | : [fx] "r" (fx), "0" (0)); | ||
137 | #else | ||
138 | : [fx] "cdaSDb" (fx), "0" (0)); | ||
139 | #endif | ||
140 | if (unlikely(err) && __clear_user(fx, sizeof(struct i387_fxsave_struct))) | ||
141 | err = -EFAULT; | ||
142 | /* No need to clear here because the caller clears USED_MATH */ | ||
143 | return err; | ||
144 | } | ||
145 | |||
146 | static inline void __fxsave_clear(struct task_struct *tsk) | ||
147 | { | ||
148 | /* Using "rex64; fxsave %0" is broken because, if the memory operand | ||
149 | uses any extended registers for addressing, a second REX prefix | ||
150 | will be generated (to the assembler, rex64 followed by semicolon | ||
151 | is a separate instruction), and hence the 64-bitness is lost. */ | ||
152 | #if 0 | ||
153 | /* Using "fxsaveq %0" would be the ideal choice, but is only supported | ||
154 | starting with gas 2.16. */ | ||
155 | __asm__ __volatile__("fxsaveq %0" | ||
156 | : "=m" (tsk->thread.i387.fxsave)); | ||
157 | #elif 0 | ||
158 | /* Using, as a workaround, the properly prefixed form below isn't | ||
159 | accepted by any binutils version so far released, complaining that | ||
160 | the same type of prefix is used twice if an extended register is | ||
161 | needed for addressing (fix submitted to mainline 2005-11-21). */ | ||
162 | __asm__ __volatile__("rex64/fxsave %0" | ||
163 | : "=m" (tsk->thread.i387.fxsave)); | ||
164 | #else | ||
165 | /* This, however, we can work around by forcing the compiler to select | ||
166 | an addressing mode that doesn't require extended registers. */ | ||
167 | __asm__ __volatile__("rex64/fxsave %P2(%1)" | ||
168 | : "=m" (tsk->thread.i387.fxsave) | ||
169 | : "cdaSDb" (tsk), | ||
170 | "i" (offsetof(__typeof__(*tsk), | ||
171 | thread.i387.fxsave))); | ||
172 | #endif | ||
173 | clear_fpu_state(&tsk->thread.i387.fxsave); | ||
174 | } | ||
175 | |||
176 | static inline void kernel_fpu_begin(void) | ||
177 | { | ||
178 | struct thread_info *me = current_thread_info(); | ||
179 | preempt_disable(); | ||
180 | if (me->status & TS_USEDFPU) { | ||
181 | __fxsave_clear(me->task); | ||
182 | me->status &= ~TS_USEDFPU; | ||
183 | return; | ||
184 | } | ||
185 | clts(); | ||
186 | } | ||
187 | |||
188 | static inline void kernel_fpu_end(void) | ||
189 | { | ||
190 | stts(); | ||
191 | preempt_enable(); | ||
192 | } | ||
193 | |||
194 | static inline void save_init_fpu(struct task_struct *tsk) | ||
195 | { | ||
196 | __fxsave_clear(tsk); | ||
197 | task_thread_info(tsk)->status &= ~TS_USEDFPU; | ||
198 | stts(); | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * This restores directly out of user space. Exceptions are handled. | ||
203 | */ | ||
204 | static inline int restore_i387(struct _fpstate __user *buf) | ||
205 | { | ||
206 | return restore_fpu_checking((__force struct i387_fxsave_struct *)buf); | ||
207 | } | ||
208 | |||
209 | #endif /* __ASM_X86_64_I387_H */ | ||
diff --git a/include/asm-x86/i8253.h b/include/asm-x86/i8253.h new file mode 100644 index 000000000000..b2a4f995a33f --- /dev/null +++ b/include/asm-x86/i8253.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "i8253_32.h" | ||
3 | #else | ||
4 | # include "i8253_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/i8253_32.h b/include/asm-x86/i8253_32.h new file mode 100644 index 000000000000..7577d058d86e --- /dev/null +++ b/include/asm-x86/i8253_32.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef __ASM_I8253_H__ | ||
2 | #define __ASM_I8253_H__ | ||
3 | |||
4 | #include <linux/clockchips.h> | ||
5 | |||
6 | /* i8253A PIT registers */ | ||
7 | #define PIT_MODE 0x43 | ||
8 | #define PIT_CH0 0x40 | ||
9 | #define PIT_CH2 0x42 | ||
10 | |||
11 | extern spinlock_t i8253_lock; | ||
12 | |||
13 | extern struct clock_event_device *global_clock_event; | ||
14 | |||
15 | extern void setup_pit_timer(void); | ||
16 | |||
17 | #endif /* __ASM_I8253_H__ */ | ||
diff --git a/include/asm-x86/i8253_64.h b/include/asm-x86/i8253_64.h new file mode 100644 index 000000000000..015d8df07690 --- /dev/null +++ b/include/asm-x86/i8253_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_I8253_H__ | ||
2 | #define __ASM_I8253_H__ | ||
3 | |||
4 | extern spinlock_t i8253_lock; | ||
5 | |||
6 | #endif /* __ASM_I8253_H__ */ | ||
diff --git a/include/asm-x86/i8259.h b/include/asm-x86/i8259.h new file mode 100644 index 000000000000..29d8f9a6b3fc --- /dev/null +++ b/include/asm-x86/i8259.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef __ASM_I8259_H__ | ||
2 | #define __ASM_I8259_H__ | ||
3 | |||
4 | extern unsigned int cached_irq_mask; | ||
5 | |||
6 | #define __byte(x,y) (((unsigned char *) &(y))[x]) | ||
7 | #define cached_master_mask (__byte(0, cached_irq_mask)) | ||
8 | #define cached_slave_mask (__byte(1, cached_irq_mask)) | ||
9 | |||
10 | extern spinlock_t i8259A_lock; | ||
11 | |||
12 | extern void init_8259A(int auto_eoi); | ||
13 | extern void enable_8259A_irq(unsigned int irq); | ||
14 | extern void disable_8259A_irq(unsigned int irq); | ||
15 | extern unsigned int startup_8259A_irq(unsigned int irq); | ||
16 | |||
17 | #endif /* __ASM_I8259_H__ */ | ||
diff --git a/include/asm-x86/ia32.h b/include/asm-x86/ia32.h new file mode 100644 index 000000000000..0190b7c4e319 --- /dev/null +++ b/include/asm-x86/ia32.h | |||
@@ -0,0 +1,178 @@ | |||
1 | #ifndef _ASM_X86_64_IA32_H | ||
2 | #define _ASM_X86_64_IA32_H | ||
3 | |||
4 | |||
5 | #ifdef CONFIG_IA32_EMULATION | ||
6 | |||
7 | #include <linux/compat.h> | ||
8 | |||
9 | /* | ||
10 | * 32 bit structures for IA32 support. | ||
11 | */ | ||
12 | |||
13 | #include <asm/sigcontext32.h> | ||
14 | |||
15 | /* signal.h */ | ||
16 | struct sigaction32 { | ||
17 | unsigned int sa_handler; /* Really a pointer, but need to deal | ||
18 | with 32 bits */ | ||
19 | unsigned int sa_flags; | ||
20 | unsigned int sa_restorer; /* Another 32 bit pointer */ | ||
21 | compat_sigset_t sa_mask; /* A 32 bit mask */ | ||
22 | }; | ||
23 | |||
24 | struct old_sigaction32 { | ||
25 | unsigned int sa_handler; /* Really a pointer, but need to deal | ||
26 | with 32 bits */ | ||
27 | compat_old_sigset_t sa_mask; /* A 32 bit mask */ | ||
28 | unsigned int sa_flags; | ||
29 | unsigned int sa_restorer; /* Another 32 bit pointer */ | ||
30 | }; | ||
31 | |||
32 | typedef struct sigaltstack_ia32 { | ||
33 | unsigned int ss_sp; | ||
34 | int ss_flags; | ||
35 | unsigned int ss_size; | ||
36 | } stack_ia32_t; | ||
37 | |||
38 | struct ucontext_ia32 { | ||
39 | unsigned int uc_flags; | ||
40 | unsigned int uc_link; | ||
41 | stack_ia32_t uc_stack; | ||
42 | struct sigcontext_ia32 uc_mcontext; | ||
43 | compat_sigset_t uc_sigmask; /* mask last for extensibility */ | ||
44 | }; | ||
45 | |||
46 | /* This matches struct stat64 in glibc2.2, hence the absolutely | ||
47 | * insane amounts of padding around dev_t's. | ||
48 | */ | ||
49 | struct stat64 { | ||
50 | unsigned long long st_dev; | ||
51 | unsigned char __pad0[4]; | ||
52 | |||
53 | #define STAT64_HAS_BROKEN_ST_INO 1 | ||
54 | unsigned int __st_ino; | ||
55 | |||
56 | unsigned int st_mode; | ||
57 | unsigned int st_nlink; | ||
58 | |||
59 | unsigned int st_uid; | ||
60 | unsigned int st_gid; | ||
61 | |||
62 | unsigned long long st_rdev; | ||
63 | unsigned char __pad3[4]; | ||
64 | |||
65 | long long st_size; | ||
66 | unsigned int st_blksize; | ||
67 | |||
68 | long long st_blocks;/* Number 512-byte blocks allocated. */ | ||
69 | |||
70 | unsigned st_atime; | ||
71 | unsigned st_atime_nsec; | ||
72 | unsigned st_mtime; | ||
73 | unsigned st_mtime_nsec; | ||
74 | unsigned st_ctime; | ||
75 | unsigned st_ctime_nsec; | ||
76 | |||
77 | unsigned long long st_ino; | ||
78 | } __attribute__((packed)); | ||
79 | |||
80 | typedef struct compat_siginfo{ | ||
81 | int si_signo; | ||
82 | int si_errno; | ||
83 | int si_code; | ||
84 | |||
85 | union { | ||
86 | int _pad[((128/sizeof(int)) - 3)]; | ||
87 | |||
88 | /* kill() */ | ||
89 | struct { | ||
90 | unsigned int _pid; /* sender's pid */ | ||
91 | unsigned int _uid; /* sender's uid */ | ||
92 | } _kill; | ||
93 | |||
94 | /* POSIX.1b timers */ | ||
95 | struct { | ||
96 | compat_timer_t _tid; /* timer id */ | ||
97 | int _overrun; /* overrun count */ | ||
98 | compat_sigval_t _sigval; /* same as below */ | ||
99 | int _sys_private; /* not to be passed to user */ | ||
100 | int _overrun_incr; /* amount to add to overrun */ | ||
101 | } _timer; | ||
102 | |||
103 | /* POSIX.1b signals */ | ||
104 | struct { | ||
105 | unsigned int _pid; /* sender's pid */ | ||
106 | unsigned int _uid; /* sender's uid */ | ||
107 | compat_sigval_t _sigval; | ||
108 | } _rt; | ||
109 | |||
110 | /* SIGCHLD */ | ||
111 | struct { | ||
112 | unsigned int _pid; /* which child */ | ||
113 | unsigned int _uid; /* sender's uid */ | ||
114 | int _status; /* exit code */ | ||
115 | compat_clock_t _utime; | ||
116 | compat_clock_t _stime; | ||
117 | } _sigchld; | ||
118 | |||
119 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ | ||
120 | struct { | ||
121 | unsigned int _addr; /* faulting insn/memory ref. */ | ||
122 | } _sigfault; | ||
123 | |||
124 | /* SIGPOLL */ | ||
125 | struct { | ||
126 | int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ | ||
127 | int _fd; | ||
128 | } _sigpoll; | ||
129 | } _sifields; | ||
130 | } compat_siginfo_t; | ||
131 | |||
132 | struct sigframe32 | ||
133 | { | ||
134 | u32 pretcode; | ||
135 | int sig; | ||
136 | struct sigcontext_ia32 sc; | ||
137 | struct _fpstate_ia32 fpstate; | ||
138 | unsigned int extramask[_COMPAT_NSIG_WORDS-1]; | ||
139 | }; | ||
140 | |||
141 | struct rt_sigframe32 | ||
142 | { | ||
143 | u32 pretcode; | ||
144 | int sig; | ||
145 | u32 pinfo; | ||
146 | u32 puc; | ||
147 | compat_siginfo_t info; | ||
148 | struct ucontext_ia32 uc; | ||
149 | struct _fpstate_ia32 fpstate; | ||
150 | }; | ||
151 | |||
152 | struct ustat32 { | ||
153 | __u32 f_tfree; | ||
154 | compat_ino_t f_tinode; | ||
155 | char f_fname[6]; | ||
156 | char f_fpack[6]; | ||
157 | }; | ||
158 | |||
159 | #define IA32_STACK_TOP IA32_PAGE_OFFSET | ||
160 | |||
161 | #ifdef __KERNEL__ | ||
162 | struct user_desc; | ||
163 | struct siginfo_t; | ||
164 | int do_get_thread_area(struct thread_struct *t, struct user_desc __user *info); | ||
165 | int do_set_thread_area(struct thread_struct *t, struct user_desc __user *info); | ||
166 | int ia32_child_tls(struct task_struct *p, struct pt_regs *childregs); | ||
167 | |||
168 | struct linux_binprm; | ||
169 | extern int ia32_setup_arg_pages(struct linux_binprm *bprm, | ||
170 | unsigned long stack_top, int exec_stack); | ||
171 | struct mm_struct; | ||
172 | extern void ia32_pick_mmap_layout(struct mm_struct *mm); | ||
173 | |||
174 | #endif | ||
175 | |||
176 | #endif /* !CONFIG_IA32_SUPPORT */ | ||
177 | |||
178 | #endif | ||
diff --git a/include/asm-x86/ia32_unistd.h b/include/asm-x86/ia32_unistd.h new file mode 100644 index 000000000000..5b52ce507338 --- /dev/null +++ b/include/asm-x86/ia32_unistd.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _ASM_X86_64_IA32_UNISTD_H_ | ||
2 | #define _ASM_X86_64_IA32_UNISTD_H_ | ||
3 | |||
4 | /* | ||
5 | * This file contains the system call numbers of the ia32 port, | ||
6 | * this is for the kernel only. | ||
7 | * Only add syscalls here where some part of the kernel needs to know | ||
8 | * the number. This should be otherwise in sync with asm-i386/unistd.h. -AK | ||
9 | */ | ||
10 | |||
11 | #define __NR_ia32_restart_syscall 0 | ||
12 | #define __NR_ia32_exit 1 | ||
13 | #define __NR_ia32_read 3 | ||
14 | #define __NR_ia32_write 4 | ||
15 | #define __NR_ia32_sigreturn 119 | ||
16 | #define __NR_ia32_rt_sigreturn 173 | ||
17 | |||
18 | #endif /* _ASM_X86_64_IA32_UNISTD_H_ */ | ||
diff --git a/include/asm-x86/ide.h b/include/asm-x86/ide.h new file mode 100644 index 000000000000..e7817a3d6578 --- /dev/null +++ b/include/asm-x86/ide.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/ide.h | ||
3 | * | ||
4 | * Copyright (C) 1994-1996 Linus Torvalds & authors | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * This file contains the i386 architecture specific IDE code. | ||
9 | */ | ||
10 | |||
11 | #ifndef __ASMi386_IDE_H | ||
12 | #define __ASMi386_IDE_H | ||
13 | |||
14 | #ifdef __KERNEL__ | ||
15 | |||
16 | |||
17 | #ifndef MAX_HWIFS | ||
18 | # ifdef CONFIG_BLK_DEV_IDEPCI | ||
19 | #define MAX_HWIFS 10 | ||
20 | # else | ||
21 | #define MAX_HWIFS 6 | ||
22 | # endif | ||
23 | #endif | ||
24 | |||
25 | #define IDE_ARCH_OBSOLETE_DEFAULTS | ||
26 | |||
27 | static __inline__ int ide_default_irq(unsigned long base) | ||
28 | { | ||
29 | switch (base) { | ||
30 | case 0x1f0: return 14; | ||
31 | case 0x170: return 15; | ||
32 | case 0x1e8: return 11; | ||
33 | case 0x168: return 10; | ||
34 | case 0x1e0: return 8; | ||
35 | case 0x160: return 12; | ||
36 | default: | ||
37 | return 0; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | static __inline__ unsigned long ide_default_io_base(int index) | ||
42 | { | ||
43 | /* | ||
44 | * If PCI is present then it is not safe to poke around | ||
45 | * the other legacy IDE ports. Only 0x1f0 and 0x170 are | ||
46 | * defined compatibility mode ports for PCI. A user can | ||
47 | * override this using ide= but we must default safe. | ||
48 | */ | ||
49 | if (no_pci_devices()) { | ||
50 | switch(index) { | ||
51 | case 2: return 0x1e8; | ||
52 | case 3: return 0x168; | ||
53 | case 4: return 0x1e0; | ||
54 | case 5: return 0x160; | ||
55 | } | ||
56 | } | ||
57 | switch (index) { | ||
58 | case 0: return 0x1f0; | ||
59 | case 1: return 0x170; | ||
60 | default: | ||
61 | return 0; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | #define IDE_ARCH_OBSOLETE_INIT | ||
66 | #define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */ | ||
67 | |||
68 | #ifdef CONFIG_BLK_DEV_IDEPCI | ||
69 | #define ide_init_default_irq(base) (0) | ||
70 | #else | ||
71 | #define ide_init_default_irq(base) ide_default_irq(base) | ||
72 | #endif | ||
73 | |||
74 | #include <asm-generic/ide_iops.h> | ||
75 | |||
76 | #endif /* __KERNEL__ */ | ||
77 | |||
78 | #endif /* __ASMi386_IDE_H */ | ||
diff --git a/include/asm-x86/idle.h b/include/asm-x86/idle.h new file mode 100644 index 000000000000..6bd47dcf2067 --- /dev/null +++ b/include/asm-x86/idle.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_X86_64_IDLE_H | ||
2 | #define _ASM_X86_64_IDLE_H 1 | ||
3 | |||
4 | #define IDLE_START 1 | ||
5 | #define IDLE_END 2 | ||
6 | |||
7 | struct notifier_block; | ||
8 | void idle_notifier_register(struct notifier_block *n); | ||
9 | void idle_notifier_unregister(struct notifier_block *n); | ||
10 | |||
11 | void enter_idle(void); | ||
12 | void exit_idle(void); | ||
13 | |||
14 | #endif | ||
diff --git a/include/asm-x86/intel_arch_perfmon.h b/include/asm-x86/intel_arch_perfmon.h new file mode 100644 index 000000000000..4f6d4e6bf57e --- /dev/null +++ b/include/asm-x86/intel_arch_perfmon.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "intel_arch_perfmon_32.h" | ||
3 | #else | ||
4 | # include "intel_arch_perfmon_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/intel_arch_perfmon_32.h b/include/asm-x86/intel_arch_perfmon_32.h new file mode 100644 index 000000000000..b52cd60a075b --- /dev/null +++ b/include/asm-x86/intel_arch_perfmon_32.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef X86_INTEL_ARCH_PERFMON_H | ||
2 | #define X86_INTEL_ARCH_PERFMON_H 1 | ||
3 | |||
4 | #define MSR_ARCH_PERFMON_PERFCTR0 0xc1 | ||
5 | #define MSR_ARCH_PERFMON_PERFCTR1 0xc2 | ||
6 | |||
7 | #define MSR_ARCH_PERFMON_EVENTSEL0 0x186 | ||
8 | #define MSR_ARCH_PERFMON_EVENTSEL1 0x187 | ||
9 | |||
10 | #define ARCH_PERFMON_EVENTSEL0_ENABLE (1 << 22) | ||
11 | #define ARCH_PERFMON_EVENTSEL_INT (1 << 20) | ||
12 | #define ARCH_PERFMON_EVENTSEL_OS (1 << 17) | ||
13 | #define ARCH_PERFMON_EVENTSEL_USR (1 << 16) | ||
14 | |||
15 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c) | ||
16 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) | ||
17 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX (0) | ||
18 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \ | ||
19 | (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX)) | ||
20 | |||
21 | union cpuid10_eax { | ||
22 | struct { | ||
23 | unsigned int version_id:8; | ||
24 | unsigned int num_counters:8; | ||
25 | unsigned int bit_width:8; | ||
26 | unsigned int mask_length:8; | ||
27 | } split; | ||
28 | unsigned int full; | ||
29 | }; | ||
30 | |||
31 | #endif /* X86_INTEL_ARCH_PERFMON_H */ | ||
diff --git a/include/asm-x86/intel_arch_perfmon_64.h b/include/asm-x86/intel_arch_perfmon_64.h new file mode 100644 index 000000000000..8633331420ec --- /dev/null +++ b/include/asm-x86/intel_arch_perfmon_64.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef X86_64_INTEL_ARCH_PERFMON_H | ||
2 | #define X86_64_INTEL_ARCH_PERFMON_H 1 | ||
3 | |||
4 | #define MSR_ARCH_PERFMON_PERFCTR0 0xc1 | ||
5 | #define MSR_ARCH_PERFMON_PERFCTR1 0xc2 | ||
6 | |||
7 | #define MSR_ARCH_PERFMON_EVENTSEL0 0x186 | ||
8 | #define MSR_ARCH_PERFMON_EVENTSEL1 0x187 | ||
9 | |||
10 | #define ARCH_PERFMON_EVENTSEL0_ENABLE (1 << 22) | ||
11 | #define ARCH_PERFMON_EVENTSEL_INT (1 << 20) | ||
12 | #define ARCH_PERFMON_EVENTSEL_OS (1 << 17) | ||
13 | #define ARCH_PERFMON_EVENTSEL_USR (1 << 16) | ||
14 | |||
15 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c) | ||
16 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) | ||
17 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX (0) | ||
18 | #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \ | ||
19 | (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX)) | ||
20 | |||
21 | union cpuid10_eax { | ||
22 | struct { | ||
23 | unsigned int version_id:8; | ||
24 | unsigned int num_counters:8; | ||
25 | unsigned int bit_width:8; | ||
26 | unsigned int mask_length:8; | ||
27 | } split; | ||
28 | unsigned int full; | ||
29 | }; | ||
30 | |||
31 | #endif /* X86_64_INTEL_ARCH_PERFMON_H */ | ||
diff --git a/include/asm-x86/io.h b/include/asm-x86/io.h new file mode 100644 index 000000000000..5a58b176dd61 --- /dev/null +++ b/include/asm-x86/io.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "io_32.h" | ||
3 | #else | ||
4 | # include "io_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h new file mode 100644 index 000000000000..e8e0bd641120 --- /dev/null +++ b/include/asm-x86/io_32.h | |||
@@ -0,0 +1,349 @@ | |||
1 | #ifndef _ASM_IO_H | ||
2 | #define _ASM_IO_H | ||
3 | |||
4 | #include <linux/string.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | /* | ||
8 | * This file contains the definitions for the x86 IO instructions | ||
9 | * inb/inw/inl/outb/outw/outl and the "string versions" of the same | ||
10 | * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing" | ||
11 | * versions of the single-IO instructions (inb_p/inw_p/..). | ||
12 | * | ||
13 | * This file is not meant to be obfuscating: it's just complicated | ||
14 | * to (a) handle it all in a way that makes gcc able to optimize it | ||
15 | * as well as possible and (b) trying to avoid writing the same thing | ||
16 | * over and over again with slight variations and possibly making a | ||
17 | * mistake somewhere. | ||
18 | */ | ||
19 | |||
20 | /* | ||
21 | * Thanks to James van Artsdalen for a better timing-fix than | ||
22 | * the two short jumps: using outb's to a nonexistent port seems | ||
23 | * to guarantee better timings even on fast machines. | ||
24 | * | ||
25 | * On the other hand, I'd like to be sure of a non-existent port: | ||
26 | * I feel a bit unsafe about using 0x80 (should be safe, though) | ||
27 | * | ||
28 | * Linus | ||
29 | */ | ||
30 | |||
31 | /* | ||
32 | * Bit simplified and optimized by Jan Hubicka | ||
33 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999. | ||
34 | * | ||
35 | * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added, | ||
36 | * isa_read[wl] and isa_write[wl] fixed | ||
37 | * - Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
38 | */ | ||
39 | |||
40 | #define IO_SPACE_LIMIT 0xffff | ||
41 | |||
42 | #define XQUAD_PORTIO_BASE 0xfe400000 | ||
43 | #define XQUAD_PORTIO_QUAD 0x40000 /* 256k per quad. */ | ||
44 | |||
45 | #ifdef __KERNEL__ | ||
46 | |||
47 | #include <asm-generic/iomap.h> | ||
48 | |||
49 | #include <linux/vmalloc.h> | ||
50 | |||
51 | /* | ||
52 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
53 | * access | ||
54 | */ | ||
55 | #define xlate_dev_mem_ptr(p) __va(p) | ||
56 | |||
57 | /* | ||
58 | * Convert a virtual cached pointer to an uncached pointer | ||
59 | */ | ||
60 | #define xlate_dev_kmem_ptr(p) p | ||
61 | |||
62 | /** | ||
63 | * virt_to_phys - map virtual addresses to physical | ||
64 | * @address: address to remap | ||
65 | * | ||
66 | * The returned physical address is the physical (CPU) mapping for | ||
67 | * the memory address given. It is only valid to use this function on | ||
68 | * addresses directly mapped or allocated via kmalloc. | ||
69 | * | ||
70 | * This function does not give bus mappings for DMA transfers. In | ||
71 | * almost all conceivable cases a device driver should not be using | ||
72 | * this function | ||
73 | */ | ||
74 | |||
75 | static inline unsigned long virt_to_phys(volatile void * address) | ||
76 | { | ||
77 | return __pa(address); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * phys_to_virt - map physical address to virtual | ||
82 | * @address: address to remap | ||
83 | * | ||
84 | * The returned virtual address is a current CPU mapping for | ||
85 | * the memory address given. It is only valid to use this function on | ||
86 | * addresses that have a kernel mapping | ||
87 | * | ||
88 | * This function does not handle bus mappings for DMA transfers. In | ||
89 | * almost all conceivable cases a device driver should not be using | ||
90 | * this function | ||
91 | */ | ||
92 | |||
93 | static inline void * phys_to_virt(unsigned long address) | ||
94 | { | ||
95 | return __va(address); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * Change "struct page" to physical address. | ||
100 | */ | ||
101 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
102 | |||
103 | extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags); | ||
104 | |||
105 | /** | ||
106 | * ioremap - map bus memory into CPU space | ||
107 | * @offset: bus address of the memory | ||
108 | * @size: size of the resource to map | ||
109 | * | ||
110 | * ioremap performs a platform specific sequence of operations to | ||
111 | * make bus memory CPU accessible via the readb/readw/readl/writeb/ | ||
112 | * writew/writel functions and the other mmio helpers. The returned | ||
113 | * address is not guaranteed to be usable directly as a virtual | ||
114 | * address. | ||
115 | * | ||
116 | * If the area you are trying to map is a PCI BAR you should have a | ||
117 | * look at pci_iomap(). | ||
118 | */ | ||
119 | |||
120 | static inline void __iomem * ioremap(unsigned long offset, unsigned long size) | ||
121 | { | ||
122 | return __ioremap(offset, size, 0); | ||
123 | } | ||
124 | |||
125 | extern void __iomem * ioremap_nocache(unsigned long offset, unsigned long size); | ||
126 | extern void iounmap(volatile void __iomem *addr); | ||
127 | |||
128 | /* | ||
129 | * bt_ioremap() and bt_iounmap() are for temporary early boot-time | ||
130 | * mappings, before the real ioremap() is functional. | ||
131 | * A boot-time mapping is currently limited to at most 16 pages. | ||
132 | */ | ||
133 | extern void *bt_ioremap(unsigned long offset, unsigned long size); | ||
134 | extern void bt_iounmap(void *addr, unsigned long size); | ||
135 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); | ||
136 | |||
137 | /* Use early IO mappings for DMI because it's initialized early */ | ||
138 | #define dmi_ioremap bt_ioremap | ||
139 | #define dmi_iounmap bt_iounmap | ||
140 | #define dmi_alloc alloc_bootmem | ||
141 | |||
142 | /* | ||
143 | * ISA I/O bus memory addresses are 1:1 with the physical address. | ||
144 | */ | ||
145 | #define isa_virt_to_bus virt_to_phys | ||
146 | #define isa_page_to_bus page_to_phys | ||
147 | #define isa_bus_to_virt phys_to_virt | ||
148 | |||
149 | /* | ||
150 | * However PCI ones are not necessarily 1:1 and therefore these interfaces | ||
151 | * are forbidden in portable PCI drivers. | ||
152 | * | ||
153 | * Allow them on x86 for legacy drivers, though. | ||
154 | */ | ||
155 | #define virt_to_bus virt_to_phys | ||
156 | #define bus_to_virt phys_to_virt | ||
157 | |||
158 | /* | ||
159 | * readX/writeX() are used to access memory mapped devices. On some | ||
160 | * architectures the memory mapped IO stuff needs to be accessed | ||
161 | * differently. On the x86 architecture, we just read/write the | ||
162 | * memory location directly. | ||
163 | */ | ||
164 | |||
165 | static inline unsigned char readb(const volatile void __iomem *addr) | ||
166 | { | ||
167 | return *(volatile unsigned char __force *) addr; | ||
168 | } | ||
169 | static inline unsigned short readw(const volatile void __iomem *addr) | ||
170 | { | ||
171 | return *(volatile unsigned short __force *) addr; | ||
172 | } | ||
173 | static inline unsigned int readl(const volatile void __iomem *addr) | ||
174 | { | ||
175 | return *(volatile unsigned int __force *) addr; | ||
176 | } | ||
177 | #define readb_relaxed(addr) readb(addr) | ||
178 | #define readw_relaxed(addr) readw(addr) | ||
179 | #define readl_relaxed(addr) readl(addr) | ||
180 | #define __raw_readb readb | ||
181 | #define __raw_readw readw | ||
182 | #define __raw_readl readl | ||
183 | |||
184 | static inline void writeb(unsigned char b, volatile void __iomem *addr) | ||
185 | { | ||
186 | *(volatile unsigned char __force *) addr = b; | ||
187 | } | ||
188 | static inline void writew(unsigned short b, volatile void __iomem *addr) | ||
189 | { | ||
190 | *(volatile unsigned short __force *) addr = b; | ||
191 | } | ||
192 | static inline void writel(unsigned int b, volatile void __iomem *addr) | ||
193 | { | ||
194 | *(volatile unsigned int __force *) addr = b; | ||
195 | } | ||
196 | #define __raw_writeb writeb | ||
197 | #define __raw_writew writew | ||
198 | #define __raw_writel writel | ||
199 | |||
200 | #define mmiowb() | ||
201 | |||
202 | static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count) | ||
203 | { | ||
204 | memset((void __force *) addr, val, count); | ||
205 | } | ||
206 | static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count) | ||
207 | { | ||
208 | __memcpy(dst, (void __force *) src, count); | ||
209 | } | ||
210 | static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count) | ||
211 | { | ||
212 | __memcpy((void __force *) dst, src, count); | ||
213 | } | ||
214 | |||
215 | /* | ||
216 | * ISA space is 'always mapped' on a typical x86 system, no need to | ||
217 | * explicitly ioremap() it. The fact that the ISA IO space is mapped | ||
218 | * to PAGE_OFFSET is pure coincidence - it does not mean ISA values | ||
219 | * are physical addresses. The following constant pointer can be | ||
220 | * used as the IO-area pointer (it can be iounmapped as well, so the | ||
221 | * analogy with PCI is quite large): | ||
222 | */ | ||
223 | #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) | ||
224 | |||
225 | /* | ||
226 | * Cache management | ||
227 | * | ||
228 | * This needed for two cases | ||
229 | * 1. Out of order aware processors | ||
230 | * 2. Accidentally out of order processors (PPro errata #51) | ||
231 | */ | ||
232 | |||
233 | #if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE) | ||
234 | |||
235 | static inline void flush_write_buffers(void) | ||
236 | { | ||
237 | __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory"); | ||
238 | } | ||
239 | |||
240 | #define dma_cache_inv(_start,_size) flush_write_buffers() | ||
241 | #define dma_cache_wback(_start,_size) flush_write_buffers() | ||
242 | #define dma_cache_wback_inv(_start,_size) flush_write_buffers() | ||
243 | |||
244 | #else | ||
245 | |||
246 | /* Nothing to do */ | ||
247 | |||
248 | #define dma_cache_inv(_start,_size) do { } while (0) | ||
249 | #define dma_cache_wback(_start,_size) do { } while (0) | ||
250 | #define dma_cache_wback_inv(_start,_size) do { } while (0) | ||
251 | #define flush_write_buffers() | ||
252 | |||
253 | #endif | ||
254 | |||
255 | #endif /* __KERNEL__ */ | ||
256 | |||
257 | static inline void native_io_delay(void) | ||
258 | { | ||
259 | asm volatile("outb %%al,$0x80" : : : "memory"); | ||
260 | } | ||
261 | |||
262 | #if defined(CONFIG_PARAVIRT) | ||
263 | #include <asm/paravirt.h> | ||
264 | #else | ||
265 | |||
266 | static inline void slow_down_io(void) { | ||
267 | native_io_delay(); | ||
268 | #ifdef REALLY_SLOW_IO | ||
269 | native_io_delay(); | ||
270 | native_io_delay(); | ||
271 | native_io_delay(); | ||
272 | #endif | ||
273 | } | ||
274 | |||
275 | #endif | ||
276 | |||
277 | #ifdef CONFIG_X86_NUMAQ | ||
278 | extern void *xquad_portio; /* Where the IO area was mapped */ | ||
279 | #define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port) | ||
280 | #define __BUILDIO(bwl,bw,type) \ | ||
281 | static inline void out##bwl##_quad(unsigned type value, int port, int quad) { \ | ||
282 | if (xquad_portio) \ | ||
283 | write##bwl(value, XQUAD_PORT_ADDR(port, quad)); \ | ||
284 | else \ | ||
285 | out##bwl##_local(value, port); \ | ||
286 | } \ | ||
287 | static inline void out##bwl(unsigned type value, int port) { \ | ||
288 | out##bwl##_quad(value, port, 0); \ | ||
289 | } \ | ||
290 | static inline unsigned type in##bwl##_quad(int port, int quad) { \ | ||
291 | if (xquad_portio) \ | ||
292 | return read##bwl(XQUAD_PORT_ADDR(port, quad)); \ | ||
293 | else \ | ||
294 | return in##bwl##_local(port); \ | ||
295 | } \ | ||
296 | static inline unsigned type in##bwl(int port) { \ | ||
297 | return in##bwl##_quad(port, 0); \ | ||
298 | } | ||
299 | #else | ||
300 | #define __BUILDIO(bwl,bw,type) \ | ||
301 | static inline void out##bwl(unsigned type value, int port) { \ | ||
302 | out##bwl##_local(value, port); \ | ||
303 | } \ | ||
304 | static inline unsigned type in##bwl(int port) { \ | ||
305 | return in##bwl##_local(port); \ | ||
306 | } | ||
307 | #endif | ||
308 | |||
309 | |||
310 | #define BUILDIO(bwl,bw,type) \ | ||
311 | static inline void out##bwl##_local(unsigned type value, int port) { \ | ||
312 | __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \ | ||
313 | } \ | ||
314 | static inline unsigned type in##bwl##_local(int port) { \ | ||
315 | unsigned type value; \ | ||
316 | __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \ | ||
317 | return value; \ | ||
318 | } \ | ||
319 | static inline void out##bwl##_local_p(unsigned type value, int port) { \ | ||
320 | out##bwl##_local(value, port); \ | ||
321 | slow_down_io(); \ | ||
322 | } \ | ||
323 | static inline unsigned type in##bwl##_local_p(int port) { \ | ||
324 | unsigned type value = in##bwl##_local(port); \ | ||
325 | slow_down_io(); \ | ||
326 | return value; \ | ||
327 | } \ | ||
328 | __BUILDIO(bwl,bw,type) \ | ||
329 | static inline void out##bwl##_p(unsigned type value, int port) { \ | ||
330 | out##bwl(value, port); \ | ||
331 | slow_down_io(); \ | ||
332 | } \ | ||
333 | static inline unsigned type in##bwl##_p(int port) { \ | ||
334 | unsigned type value = in##bwl(port); \ | ||
335 | slow_down_io(); \ | ||
336 | return value; \ | ||
337 | } \ | ||
338 | static inline void outs##bwl(int port, const void *addr, unsigned long count) { \ | ||
339 | __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \ | ||
340 | } \ | ||
341 | static inline void ins##bwl(int port, void *addr, unsigned long count) { \ | ||
342 | __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \ | ||
343 | } | ||
344 | |||
345 | BUILDIO(b,b,char) | ||
346 | BUILDIO(w,w,short) | ||
347 | BUILDIO(l,,int) | ||
348 | |||
349 | #endif | ||
diff --git a/include/asm-x86/io_64.h b/include/asm-x86/io_64.h new file mode 100644 index 000000000000..7475095c5061 --- /dev/null +++ b/include/asm-x86/io_64.h | |||
@@ -0,0 +1,276 @@ | |||
1 | #ifndef _ASM_IO_H | ||
2 | #define _ASM_IO_H | ||
3 | |||
4 | |||
5 | /* | ||
6 | * This file contains the definitions for the x86 IO instructions | ||
7 | * inb/inw/inl/outb/outw/outl and the "string versions" of the same | ||
8 | * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing" | ||
9 | * versions of the single-IO instructions (inb_p/inw_p/..). | ||
10 | * | ||
11 | * This file is not meant to be obfuscating: it's just complicated | ||
12 | * to (a) handle it all in a way that makes gcc able to optimize it | ||
13 | * as well as possible and (b) trying to avoid writing the same thing | ||
14 | * over and over again with slight variations and possibly making a | ||
15 | * mistake somewhere. | ||
16 | */ | ||
17 | |||
18 | /* | ||
19 | * Thanks to James van Artsdalen for a better timing-fix than | ||
20 | * the two short jumps: using outb's to a nonexistent port seems | ||
21 | * to guarantee better timings even on fast machines. | ||
22 | * | ||
23 | * On the other hand, I'd like to be sure of a non-existent port: | ||
24 | * I feel a bit unsafe about using 0x80 (should be safe, though) | ||
25 | * | ||
26 | * Linus | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Bit simplified and optimized by Jan Hubicka | ||
31 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999. | ||
32 | * | ||
33 | * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added, | ||
34 | * isa_read[wl] and isa_write[wl] fixed | ||
35 | * - Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
36 | */ | ||
37 | |||
38 | #define __SLOW_DOWN_IO "\noutb %%al,$0x80" | ||
39 | |||
40 | #ifdef REALLY_SLOW_IO | ||
41 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO | ||
42 | #else | ||
43 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO | ||
44 | #endif | ||
45 | |||
46 | /* | ||
47 | * Talk about misusing macros.. | ||
48 | */ | ||
49 | #define __OUT1(s,x) \ | ||
50 | static inline void out##s(unsigned x value, unsigned short port) { | ||
51 | |||
52 | #define __OUT2(s,s1,s2) \ | ||
53 | __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" | ||
54 | |||
55 | #define __OUT(s,s1,x) \ | ||
56 | __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \ | ||
57 | __OUT1(s##_p,x) __OUT2(s,s1,"w") __FULL_SLOW_DOWN_IO : : "a" (value), "Nd" (port));} \ | ||
58 | |||
59 | #define __IN1(s) \ | ||
60 | static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v; | ||
61 | |||
62 | #define __IN2(s,s1,s2) \ | ||
63 | __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" | ||
64 | |||
65 | #define __IN(s,s1,i...) \ | ||
66 | __IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \ | ||
67 | __IN1(s##_p) __IN2(s,s1,"w") __FULL_SLOW_DOWN_IO : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \ | ||
68 | |||
69 | #define __INS(s) \ | ||
70 | static inline void ins##s(unsigned short port, void * addr, unsigned long count) \ | ||
71 | { __asm__ __volatile__ ("rep ; ins" #s \ | ||
72 | : "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } | ||
73 | |||
74 | #define __OUTS(s) \ | ||
75 | static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ | ||
76 | { __asm__ __volatile__ ("rep ; outs" #s \ | ||
77 | : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } | ||
78 | |||
79 | #define RETURN_TYPE unsigned char | ||
80 | __IN(b,"") | ||
81 | #undef RETURN_TYPE | ||
82 | #define RETURN_TYPE unsigned short | ||
83 | __IN(w,"") | ||
84 | #undef RETURN_TYPE | ||
85 | #define RETURN_TYPE unsigned int | ||
86 | __IN(l,"") | ||
87 | #undef RETURN_TYPE | ||
88 | |||
89 | __OUT(b,"b",char) | ||
90 | __OUT(w,"w",short) | ||
91 | __OUT(l,,int) | ||
92 | |||
93 | __INS(b) | ||
94 | __INS(w) | ||
95 | __INS(l) | ||
96 | |||
97 | __OUTS(b) | ||
98 | __OUTS(w) | ||
99 | __OUTS(l) | ||
100 | |||
101 | #define IO_SPACE_LIMIT 0xffff | ||
102 | |||
103 | #if defined(__KERNEL__) && defined(__x86_64__) | ||
104 | |||
105 | #include <linux/vmalloc.h> | ||
106 | |||
107 | #ifndef __i386__ | ||
108 | /* | ||
109 | * Change virtual addresses to physical addresses and vv. | ||
110 | * These are pretty trivial | ||
111 | */ | ||
112 | static inline unsigned long virt_to_phys(volatile void * address) | ||
113 | { | ||
114 | return __pa(address); | ||
115 | } | ||
116 | |||
117 | static inline void * phys_to_virt(unsigned long address) | ||
118 | { | ||
119 | return __va(address); | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | /* | ||
124 | * Change "struct page" to physical address. | ||
125 | */ | ||
126 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
127 | |||
128 | #include <asm-generic/iomap.h> | ||
129 | |||
130 | extern void __iomem *__ioremap(unsigned long offset, unsigned long size, unsigned long flags); | ||
131 | |||
132 | static inline void __iomem * ioremap (unsigned long offset, unsigned long size) | ||
133 | { | ||
134 | return __ioremap(offset, size, 0); | ||
135 | } | ||
136 | |||
137 | extern void *early_ioremap(unsigned long addr, unsigned long size); | ||
138 | extern void early_iounmap(void *addr, unsigned long size); | ||
139 | |||
140 | /* | ||
141 | * This one maps high address device memory and turns off caching for that area. | ||
142 | * it's useful if some control registers are in such an area and write combining | ||
143 | * or read caching is not desirable: | ||
144 | */ | ||
145 | extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); | ||
146 | extern void iounmap(volatile void __iomem *addr); | ||
147 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); | ||
148 | |||
149 | /* | ||
150 | * ISA I/O bus memory addresses are 1:1 with the physical address. | ||
151 | */ | ||
152 | #define isa_virt_to_bus virt_to_phys | ||
153 | #define isa_page_to_bus page_to_phys | ||
154 | #define isa_bus_to_virt phys_to_virt | ||
155 | |||
156 | /* | ||
157 | * However PCI ones are not necessarily 1:1 and therefore these interfaces | ||
158 | * are forbidden in portable PCI drivers. | ||
159 | * | ||
160 | * Allow them on x86 for legacy drivers, though. | ||
161 | */ | ||
162 | #define virt_to_bus virt_to_phys | ||
163 | #define bus_to_virt phys_to_virt | ||
164 | |||
165 | /* | ||
166 | * readX/writeX() are used to access memory mapped devices. On some | ||
167 | * architectures the memory mapped IO stuff needs to be accessed | ||
168 | * differently. On the x86 architecture, we just read/write the | ||
169 | * memory location directly. | ||
170 | */ | ||
171 | |||
172 | static inline __u8 __readb(const volatile void __iomem *addr) | ||
173 | { | ||
174 | return *(__force volatile __u8 *)addr; | ||
175 | } | ||
176 | static inline __u16 __readw(const volatile void __iomem *addr) | ||
177 | { | ||
178 | return *(__force volatile __u16 *)addr; | ||
179 | } | ||
180 | static __always_inline __u32 __readl(const volatile void __iomem *addr) | ||
181 | { | ||
182 | return *(__force volatile __u32 *)addr; | ||
183 | } | ||
184 | static inline __u64 __readq(const volatile void __iomem *addr) | ||
185 | { | ||
186 | return *(__force volatile __u64 *)addr; | ||
187 | } | ||
188 | #define readb(x) __readb(x) | ||
189 | #define readw(x) __readw(x) | ||
190 | #define readl(x) __readl(x) | ||
191 | #define readq(x) __readq(x) | ||
192 | #define readb_relaxed(a) readb(a) | ||
193 | #define readw_relaxed(a) readw(a) | ||
194 | #define readl_relaxed(a) readl(a) | ||
195 | #define readq_relaxed(a) readq(a) | ||
196 | #define __raw_readb readb | ||
197 | #define __raw_readw readw | ||
198 | #define __raw_readl readl | ||
199 | #define __raw_readq readq | ||
200 | |||
201 | #define mmiowb() | ||
202 | |||
203 | static inline void __writel(__u32 b, volatile void __iomem *addr) | ||
204 | { | ||
205 | *(__force volatile __u32 *)addr = b; | ||
206 | } | ||
207 | static inline void __writeq(__u64 b, volatile void __iomem *addr) | ||
208 | { | ||
209 | *(__force volatile __u64 *)addr = b; | ||
210 | } | ||
211 | static inline void __writeb(__u8 b, volatile void __iomem *addr) | ||
212 | { | ||
213 | *(__force volatile __u8 *)addr = b; | ||
214 | } | ||
215 | static inline void __writew(__u16 b, volatile void __iomem *addr) | ||
216 | { | ||
217 | *(__force volatile __u16 *)addr = b; | ||
218 | } | ||
219 | #define writeq(val,addr) __writeq((val),(addr)) | ||
220 | #define writel(val,addr) __writel((val),(addr)) | ||
221 | #define writew(val,addr) __writew((val),(addr)) | ||
222 | #define writeb(val,addr) __writeb((val),(addr)) | ||
223 | #define __raw_writeb writeb | ||
224 | #define __raw_writew writew | ||
225 | #define __raw_writel writel | ||
226 | #define __raw_writeq writeq | ||
227 | |||
228 | void __memcpy_fromio(void*,unsigned long,unsigned); | ||
229 | void __memcpy_toio(unsigned long,const void*,unsigned); | ||
230 | |||
231 | static inline void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned len) | ||
232 | { | ||
233 | __memcpy_fromio(to,(unsigned long)from,len); | ||
234 | } | ||
235 | static inline void memcpy_toio(volatile void __iomem *to, const void *from, unsigned len) | ||
236 | { | ||
237 | __memcpy_toio((unsigned long)to,from,len); | ||
238 | } | ||
239 | |||
240 | void memset_io(volatile void __iomem *a, int b, size_t c); | ||
241 | |||
242 | /* | ||
243 | * ISA space is 'always mapped' on a typical x86 system, no need to | ||
244 | * explicitly ioremap() it. The fact that the ISA IO space is mapped | ||
245 | * to PAGE_OFFSET is pure coincidence - it does not mean ISA values | ||
246 | * are physical addresses. The following constant pointer can be | ||
247 | * used as the IO-area pointer (it can be iounmapped as well, so the | ||
248 | * analogy with PCI is quite large): | ||
249 | */ | ||
250 | #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) | ||
251 | |||
252 | /* Nothing to do */ | ||
253 | |||
254 | #define dma_cache_inv(_start,_size) do { } while (0) | ||
255 | #define dma_cache_wback(_start,_size) do { } while (0) | ||
256 | #define dma_cache_wback_inv(_start,_size) do { } while (0) | ||
257 | |||
258 | #define flush_write_buffers() | ||
259 | |||
260 | extern int iommu_bio_merge; | ||
261 | #define BIO_VMERGE_BOUNDARY iommu_bio_merge | ||
262 | |||
263 | /* | ||
264 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
265 | * access | ||
266 | */ | ||
267 | #define xlate_dev_mem_ptr(p) __va(p) | ||
268 | |||
269 | /* | ||
270 | * Convert a virtual cached pointer to an uncached pointer | ||
271 | */ | ||
272 | #define xlate_dev_kmem_ptr(p) p | ||
273 | |||
274 | #endif /* __KERNEL__ */ | ||
275 | |||
276 | #endif | ||
diff --git a/include/asm-x86/io_apic.h b/include/asm-x86/io_apic.h new file mode 100644 index 000000000000..88494966beeb --- /dev/null +++ b/include/asm-x86/io_apic.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "io_apic_32.h" | ||
3 | #else | ||
4 | # include "io_apic_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/io_apic_32.h b/include/asm-x86/io_apic_32.h new file mode 100644 index 000000000000..dbe734ddf2af --- /dev/null +++ b/include/asm-x86/io_apic_32.h | |||
@@ -0,0 +1,155 @@ | |||
1 | #ifndef __ASM_IO_APIC_H | ||
2 | #define __ASM_IO_APIC_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <asm/mpspec.h> | ||
6 | #include <asm/apicdef.h> | ||
7 | |||
8 | /* | ||
9 | * Intel IO-APIC support for SMP and UP systems. | ||
10 | * | ||
11 | * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_X86_IO_APIC | ||
15 | |||
16 | /* | ||
17 | * The structure of the IO-APIC: | ||
18 | */ | ||
19 | union IO_APIC_reg_00 { | ||
20 | u32 raw; | ||
21 | struct { | ||
22 | u32 __reserved_2 : 14, | ||
23 | LTS : 1, | ||
24 | delivery_type : 1, | ||
25 | __reserved_1 : 8, | ||
26 | ID : 8; | ||
27 | } __attribute__ ((packed)) bits; | ||
28 | }; | ||
29 | |||
30 | union IO_APIC_reg_01 { | ||
31 | u32 raw; | ||
32 | struct { | ||
33 | u32 version : 8, | ||
34 | __reserved_2 : 7, | ||
35 | PRQ : 1, | ||
36 | entries : 8, | ||
37 | __reserved_1 : 8; | ||
38 | } __attribute__ ((packed)) bits; | ||
39 | }; | ||
40 | |||
41 | union IO_APIC_reg_02 { | ||
42 | u32 raw; | ||
43 | struct { | ||
44 | u32 __reserved_2 : 24, | ||
45 | arbitration : 4, | ||
46 | __reserved_1 : 4; | ||
47 | } __attribute__ ((packed)) bits; | ||
48 | }; | ||
49 | |||
50 | union IO_APIC_reg_03 { | ||
51 | u32 raw; | ||
52 | struct { | ||
53 | u32 boot_DT : 1, | ||
54 | __reserved_1 : 31; | ||
55 | } __attribute__ ((packed)) bits; | ||
56 | }; | ||
57 | |||
58 | /* | ||
59 | * # of IO-APICs and # of IRQ routing registers | ||
60 | */ | ||
61 | extern int nr_ioapics; | ||
62 | extern int nr_ioapic_registers[MAX_IO_APICS]; | ||
63 | |||
64 | enum ioapic_irq_destination_types { | ||
65 | dest_Fixed = 0, | ||
66 | dest_LowestPrio = 1, | ||
67 | dest_SMI = 2, | ||
68 | dest__reserved_1 = 3, | ||
69 | dest_NMI = 4, | ||
70 | dest_INIT = 5, | ||
71 | dest__reserved_2 = 6, | ||
72 | dest_ExtINT = 7 | ||
73 | }; | ||
74 | |||
75 | struct IO_APIC_route_entry { | ||
76 | __u32 vector : 8, | ||
77 | delivery_mode : 3, /* 000: FIXED | ||
78 | * 001: lowest prio | ||
79 | * 111: ExtINT | ||
80 | */ | ||
81 | dest_mode : 1, /* 0: physical, 1: logical */ | ||
82 | delivery_status : 1, | ||
83 | polarity : 1, | ||
84 | irr : 1, | ||
85 | trigger : 1, /* 0: edge, 1: level */ | ||
86 | mask : 1, /* 0: enabled, 1: disabled */ | ||
87 | __reserved_2 : 15; | ||
88 | |||
89 | union { struct { __u32 | ||
90 | __reserved_1 : 24, | ||
91 | physical_dest : 4, | ||
92 | __reserved_2 : 4; | ||
93 | } physical; | ||
94 | |||
95 | struct { __u32 | ||
96 | __reserved_1 : 24, | ||
97 | logical_dest : 8; | ||
98 | } logical; | ||
99 | } dest; | ||
100 | |||
101 | } __attribute__ ((packed)); | ||
102 | |||
103 | /* | ||
104 | * MP-BIOS irq configuration table structures: | ||
105 | */ | ||
106 | |||
107 | /* I/O APIC entries */ | ||
108 | extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS]; | ||
109 | |||
110 | /* # of MP IRQ source entries */ | ||
111 | extern int mp_irq_entries; | ||
112 | |||
113 | /* MP IRQ source entries */ | ||
114 | extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES]; | ||
115 | |||
116 | /* non-0 if default (table-less) MP configuration */ | ||
117 | extern int mpc_default_type; | ||
118 | |||
119 | /* Older SiS APIC requires we rewrite the index register */ | ||
120 | extern int sis_apic_bug; | ||
121 | |||
122 | /* 1 if "noapic" boot option passed */ | ||
123 | extern int skip_ioapic_setup; | ||
124 | |||
125 | static inline void disable_ioapic_setup(void) | ||
126 | { | ||
127 | skip_ioapic_setup = 1; | ||
128 | } | ||
129 | |||
130 | static inline int ioapic_setup_disabled(void) | ||
131 | { | ||
132 | return skip_ioapic_setup; | ||
133 | } | ||
134 | |||
135 | /* | ||
136 | * If we use the IO-APIC for IRQ routing, disable automatic | ||
137 | * assignment of PCI IRQ's. | ||
138 | */ | ||
139 | #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) | ||
140 | |||
141 | #ifdef CONFIG_ACPI | ||
142 | extern int io_apic_get_unique_id (int ioapic, int apic_id); | ||
143 | extern int io_apic_get_version (int ioapic); | ||
144 | extern int io_apic_get_redir_entries (int ioapic); | ||
145 | extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low); | ||
146 | extern int timer_uses_ioapic_pin_0; | ||
147 | #endif /* CONFIG_ACPI */ | ||
148 | |||
149 | extern int (*ioapic_renumber_irq)(int ioapic, int irq); | ||
150 | |||
151 | #else /* !CONFIG_X86_IO_APIC */ | ||
152 | #define io_apic_assign_pci_irqs 0 | ||
153 | #endif | ||
154 | |||
155 | #endif | ||
diff --git a/include/asm-x86/io_apic_64.h b/include/asm-x86/io_apic_64.h new file mode 100644 index 000000000000..d9f2e54324d5 --- /dev/null +++ b/include/asm-x86/io_apic_64.h | |||
@@ -0,0 +1,136 @@ | |||
1 | #ifndef __ASM_IO_APIC_H | ||
2 | #define __ASM_IO_APIC_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <asm/mpspec.h> | ||
6 | #include <asm/apicdef.h> | ||
7 | |||
8 | /* | ||
9 | * Intel IO-APIC support for SMP and UP systems. | ||
10 | * | ||
11 | * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar | ||
12 | */ | ||
13 | |||
14 | #define APIC_MISMATCH_DEBUG | ||
15 | |||
16 | /* | ||
17 | * The structure of the IO-APIC: | ||
18 | */ | ||
19 | union IO_APIC_reg_00 { | ||
20 | u32 raw; | ||
21 | struct { | ||
22 | u32 __reserved_2 : 14, | ||
23 | LTS : 1, | ||
24 | delivery_type : 1, | ||
25 | __reserved_1 : 8, | ||
26 | ID : 8; | ||
27 | } __attribute__ ((packed)) bits; | ||
28 | }; | ||
29 | |||
30 | union IO_APIC_reg_01 { | ||
31 | u32 raw; | ||
32 | struct { | ||
33 | u32 version : 8, | ||
34 | __reserved_2 : 7, | ||
35 | PRQ : 1, | ||
36 | entries : 8, | ||
37 | __reserved_1 : 8; | ||
38 | } __attribute__ ((packed)) bits; | ||
39 | }; | ||
40 | |||
41 | union IO_APIC_reg_02 { | ||
42 | u32 raw; | ||
43 | struct { | ||
44 | u32 __reserved_2 : 24, | ||
45 | arbitration : 4, | ||
46 | __reserved_1 : 4; | ||
47 | } __attribute__ ((packed)) bits; | ||
48 | }; | ||
49 | |||
50 | union IO_APIC_reg_03 { | ||
51 | u32 raw; | ||
52 | struct { | ||
53 | u32 boot_DT : 1, | ||
54 | __reserved_1 : 31; | ||
55 | } __attribute__ ((packed)) bits; | ||
56 | }; | ||
57 | |||
58 | /* | ||
59 | * # of IO-APICs and # of IRQ routing registers | ||
60 | */ | ||
61 | extern int nr_ioapics; | ||
62 | extern int nr_ioapic_registers[MAX_IO_APICS]; | ||
63 | |||
64 | enum ioapic_irq_destination_types { | ||
65 | dest_Fixed = 0, | ||
66 | dest_LowestPrio = 1, | ||
67 | dest_SMI = 2, | ||
68 | dest__reserved_1 = 3, | ||
69 | dest_NMI = 4, | ||
70 | dest_INIT = 5, | ||
71 | dest__reserved_2 = 6, | ||
72 | dest_ExtINT = 7 | ||
73 | }; | ||
74 | |||
75 | struct IO_APIC_route_entry { | ||
76 | __u32 vector : 8, | ||
77 | delivery_mode : 3, /* 000: FIXED | ||
78 | * 001: lowest prio | ||
79 | * 111: ExtINT | ||
80 | */ | ||
81 | dest_mode : 1, /* 0: physical, 1: logical */ | ||
82 | delivery_status : 1, | ||
83 | polarity : 1, | ||
84 | irr : 1, | ||
85 | trigger : 1, /* 0: edge, 1: level */ | ||
86 | mask : 1, /* 0: enabled, 1: disabled */ | ||
87 | __reserved_2 : 15; | ||
88 | |||
89 | __u32 __reserved_3 : 24, | ||
90 | dest : 8; | ||
91 | } __attribute__ ((packed)); | ||
92 | |||
93 | /* | ||
94 | * MP-BIOS irq configuration table structures: | ||
95 | */ | ||
96 | |||
97 | /* I/O APIC entries */ | ||
98 | extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS]; | ||
99 | |||
100 | /* # of MP IRQ source entries */ | ||
101 | extern int mp_irq_entries; | ||
102 | |||
103 | /* MP IRQ source entries */ | ||
104 | extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES]; | ||
105 | |||
106 | /* non-0 if default (table-less) MP configuration */ | ||
107 | extern int mpc_default_type; | ||
108 | |||
109 | /* 1 if "noapic" boot option passed */ | ||
110 | extern int skip_ioapic_setup; | ||
111 | |||
112 | static inline void disable_ioapic_setup(void) | ||
113 | { | ||
114 | skip_ioapic_setup = 1; | ||
115 | } | ||
116 | |||
117 | |||
118 | /* | ||
119 | * If we use the IO-APIC for IRQ routing, disable automatic | ||
120 | * assignment of PCI IRQ's. | ||
121 | */ | ||
122 | #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) | ||
123 | |||
124 | #ifdef CONFIG_ACPI | ||
125 | extern int io_apic_get_version (int ioapic); | ||
126 | extern int io_apic_get_redir_entries (int ioapic); | ||
127 | extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int); | ||
128 | #endif | ||
129 | |||
130 | extern int sis_apic_bug; /* dummy */ | ||
131 | |||
132 | void enable_NMI_through_LVT0 (void * dummy); | ||
133 | |||
134 | extern spinlock_t i8259A_lock; | ||
135 | |||
136 | #endif | ||
diff --git a/include/asm-x86/ioctl.h b/include/asm-x86/ioctl.h new file mode 100644 index 000000000000..b279fe06dfe5 --- /dev/null +++ b/include/asm-x86/ioctl.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/ioctl.h> | |||
diff --git a/include/asm-x86/ioctls.h b/include/asm-x86/ioctls.h new file mode 100644 index 000000000000..1e0fd48f18bc --- /dev/null +++ b/include/asm-x86/ioctls.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ioctls_32.h" | ||
4 | # else | ||
5 | # include "ioctls_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ioctls_32.h" | ||
10 | # else | ||
11 | # include "ioctls_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ioctls_32.h b/include/asm-x86/ioctls_32.h new file mode 100644 index 000000000000..ef5878762dc9 --- /dev/null +++ b/include/asm-x86/ioctls_32.h | |||
@@ -0,0 +1,87 @@ | |||
1 | #ifndef __ARCH_I386_IOCTLS_H__ | ||
2 | #define __ARCH_I386_IOCTLS_H__ | ||
3 | |||
4 | #include <asm/ioctl.h> | ||
5 | |||
6 | /* 0x54 is just a magic number to make these relatively unique ('T') */ | ||
7 | |||
8 | #define TCGETS 0x5401 | ||
9 | #define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ | ||
10 | #define TCSETSW 0x5403 | ||
11 | #define TCSETSF 0x5404 | ||
12 | #define TCGETA 0x5405 | ||
13 | #define TCSETA 0x5406 | ||
14 | #define TCSETAW 0x5407 | ||
15 | #define TCSETAF 0x5408 | ||
16 | #define TCSBRK 0x5409 | ||
17 | #define TCXONC 0x540A | ||
18 | #define TCFLSH 0x540B | ||
19 | #define TIOCEXCL 0x540C | ||
20 | #define TIOCNXCL 0x540D | ||
21 | #define TIOCSCTTY 0x540E | ||
22 | #define TIOCGPGRP 0x540F | ||
23 | #define TIOCSPGRP 0x5410 | ||
24 | #define TIOCOUTQ 0x5411 | ||
25 | #define TIOCSTI 0x5412 | ||
26 | #define TIOCGWINSZ 0x5413 | ||
27 | #define TIOCSWINSZ 0x5414 | ||
28 | #define TIOCMGET 0x5415 | ||
29 | #define TIOCMBIS 0x5416 | ||
30 | #define TIOCMBIC 0x5417 | ||
31 | #define TIOCMSET 0x5418 | ||
32 | #define TIOCGSOFTCAR 0x5419 | ||
33 | #define TIOCSSOFTCAR 0x541A | ||
34 | #define FIONREAD 0x541B | ||
35 | #define TIOCINQ FIONREAD | ||
36 | #define TIOCLINUX 0x541C | ||
37 | #define TIOCCONS 0x541D | ||
38 | #define TIOCGSERIAL 0x541E | ||
39 | #define TIOCSSERIAL 0x541F | ||
40 | #define TIOCPKT 0x5420 | ||
41 | #define FIONBIO 0x5421 | ||
42 | #define TIOCNOTTY 0x5422 | ||
43 | #define TIOCSETD 0x5423 | ||
44 | #define TIOCGETD 0x5424 | ||
45 | #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ | ||
46 | /* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ | ||
47 | #define TIOCSBRK 0x5427 /* BSD compatibility */ | ||
48 | #define TIOCCBRK 0x5428 /* BSD compatibility */ | ||
49 | #define TIOCGSID 0x5429 /* Return the session ID of FD */ | ||
50 | #define TCGETS2 _IOR('T',0x2A, struct termios2) | ||
51 | #define TCSETS2 _IOW('T',0x2B, struct termios2) | ||
52 | #define TCSETSW2 _IOW('T',0x2C, struct termios2) | ||
53 | #define TCSETSF2 _IOW('T',0x2D, struct termios2) | ||
54 | #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ | ||
55 | #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ | ||
56 | |||
57 | #define FIONCLEX 0x5450 | ||
58 | #define FIOCLEX 0x5451 | ||
59 | #define FIOASYNC 0x5452 | ||
60 | #define TIOCSERCONFIG 0x5453 | ||
61 | #define TIOCSERGWILD 0x5454 | ||
62 | #define TIOCSERSWILD 0x5455 | ||
63 | #define TIOCGLCKTRMIOS 0x5456 | ||
64 | #define TIOCSLCKTRMIOS 0x5457 | ||
65 | #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ | ||
66 | #define TIOCSERGETLSR 0x5459 /* Get line status register */ | ||
67 | #define TIOCSERGETMULTI 0x545A /* Get multiport config */ | ||
68 | #define TIOCSERSETMULTI 0x545B /* Set multiport config */ | ||
69 | |||
70 | #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ | ||
71 | #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ | ||
72 | #define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ | ||
73 | #define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ | ||
74 | #define FIOQSIZE 0x5460 | ||
75 | |||
76 | /* Used for packet mode */ | ||
77 | #define TIOCPKT_DATA 0 | ||
78 | #define TIOCPKT_FLUSHREAD 1 | ||
79 | #define TIOCPKT_FLUSHWRITE 2 | ||
80 | #define TIOCPKT_STOP 4 | ||
81 | #define TIOCPKT_START 8 | ||
82 | #define TIOCPKT_NOSTOP 16 | ||
83 | #define TIOCPKT_DOSTOP 32 | ||
84 | |||
85 | #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ | ||
86 | |||
87 | #endif | ||
diff --git a/include/asm-x86/ioctls_64.h b/include/asm-x86/ioctls_64.h new file mode 100644 index 000000000000..3fc0b15a0d7e --- /dev/null +++ b/include/asm-x86/ioctls_64.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef __ARCH_X8664_IOCTLS_H__ | ||
2 | #define __ARCH_X8664_IOCTLS_H__ | ||
3 | |||
4 | #include <asm/ioctl.h> | ||
5 | |||
6 | /* 0x54 is just a magic number to make these relatively unique ('T') */ | ||
7 | |||
8 | #define TCGETS 0x5401 | ||
9 | #define TCSETS 0x5402 | ||
10 | #define TCSETSW 0x5403 | ||
11 | #define TCSETSF 0x5404 | ||
12 | #define TCGETA 0x5405 | ||
13 | #define TCSETA 0x5406 | ||
14 | #define TCSETAW 0x5407 | ||
15 | #define TCSETAF 0x5408 | ||
16 | #define TCSBRK 0x5409 | ||
17 | #define TCXONC 0x540A | ||
18 | #define TCFLSH 0x540B | ||
19 | #define TIOCEXCL 0x540C | ||
20 | #define TIOCNXCL 0x540D | ||
21 | #define TIOCSCTTY 0x540E | ||
22 | #define TIOCGPGRP 0x540F | ||
23 | #define TIOCSPGRP 0x5410 | ||
24 | #define TIOCOUTQ 0x5411 | ||
25 | #define TIOCSTI 0x5412 | ||
26 | #define TIOCGWINSZ 0x5413 | ||
27 | #define TIOCSWINSZ 0x5414 | ||
28 | #define TIOCMGET 0x5415 | ||
29 | #define TIOCMBIS 0x5416 | ||
30 | #define TIOCMBIC 0x5417 | ||
31 | #define TIOCMSET 0x5418 | ||
32 | #define TIOCGSOFTCAR 0x5419 | ||
33 | #define TIOCSSOFTCAR 0x541A | ||
34 | #define FIONREAD 0x541B | ||
35 | #define TIOCINQ FIONREAD | ||
36 | #define TIOCLINUX 0x541C | ||
37 | #define TIOCCONS 0x541D | ||
38 | #define TIOCGSERIAL 0x541E | ||
39 | #define TIOCSSERIAL 0x541F | ||
40 | #define TIOCPKT 0x5420 | ||
41 | #define FIONBIO 0x5421 | ||
42 | #define TIOCNOTTY 0x5422 | ||
43 | #define TIOCSETD 0x5423 | ||
44 | #define TIOCGETD 0x5424 | ||
45 | #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ | ||
46 | #define TIOCSBRK 0x5427 /* BSD compatibility */ | ||
47 | #define TIOCCBRK 0x5428 /* BSD compatibility */ | ||
48 | #define TIOCGSID 0x5429 /* Return the session ID of FD */ | ||
49 | #define TCGETS2 _IOR('T',0x2A, struct termios2) | ||
50 | #define TCSETS2 _IOW('T',0x2B, struct termios2) | ||
51 | #define TCSETSW2 _IOW('T',0x2C, struct termios2) | ||
52 | #define TCSETSF2 _IOW('T',0x2D, struct termios2) | ||
53 | #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ | ||
54 | #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ | ||
55 | |||
56 | #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ | ||
57 | #define FIOCLEX 0x5451 | ||
58 | #define FIOASYNC 0x5452 | ||
59 | #define TIOCSERCONFIG 0x5453 | ||
60 | #define TIOCSERGWILD 0x5454 | ||
61 | #define TIOCSERSWILD 0x5455 | ||
62 | #define TIOCGLCKTRMIOS 0x5456 | ||
63 | #define TIOCSLCKTRMIOS 0x5457 | ||
64 | #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ | ||
65 | #define TIOCSERGETLSR 0x5459 /* Get line status register */ | ||
66 | #define TIOCSERGETMULTI 0x545A /* Get multiport config */ | ||
67 | #define TIOCSERSETMULTI 0x545B /* Set multiport config */ | ||
68 | |||
69 | #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ | ||
70 | #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ | ||
71 | #define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ | ||
72 | #define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ | ||
73 | #define FIOQSIZE 0x5460 | ||
74 | |||
75 | /* Used for packet mode */ | ||
76 | #define TIOCPKT_DATA 0 | ||
77 | #define TIOCPKT_FLUSHREAD 1 | ||
78 | #define TIOCPKT_FLUSHWRITE 2 | ||
79 | #define TIOCPKT_STOP 4 | ||
80 | #define TIOCPKT_START 8 | ||
81 | #define TIOCPKT_NOSTOP 16 | ||
82 | #define TIOCPKT_DOSTOP 32 | ||
83 | |||
84 | #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ | ||
85 | |||
86 | #endif | ||
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h new file mode 100644 index 000000000000..5af471f228ee --- /dev/null +++ b/include/asm-x86/iommu.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef _ASM_X8664_IOMMU_H | ||
2 | #define _ASM_X8664_IOMMU_H 1 | ||
3 | |||
4 | extern void pci_iommu_shutdown(void); | ||
5 | extern void no_iommu_init(void); | ||
6 | extern int force_iommu, no_iommu; | ||
7 | extern int iommu_detected; | ||
8 | #ifdef CONFIG_IOMMU | ||
9 | extern void gart_iommu_init(void); | ||
10 | extern void gart_iommu_shutdown(void); | ||
11 | extern void __init gart_parse_options(char *); | ||
12 | extern void iommu_hole_init(void); | ||
13 | extern int fallback_aper_order; | ||
14 | extern int fallback_aper_force; | ||
15 | extern int iommu_aperture; | ||
16 | extern int iommu_aperture_allowed; | ||
17 | extern int iommu_aperture_disabled; | ||
18 | extern int fix_aperture; | ||
19 | #else | ||
20 | #define iommu_aperture 0 | ||
21 | #define iommu_aperture_allowed 0 | ||
22 | |||
23 | static inline void gart_iommu_shutdown(void) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | #endif | ||
28 | |||
29 | #endif | ||
diff --git a/include/asm-x86/ipc.h b/include/asm-x86/ipc.h new file mode 100644 index 000000000000..a46e3d9c2a3f --- /dev/null +++ b/include/asm-x86/ipc.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/ipc.h> | |||
diff --git a/include/asm-x86/ipcbuf.h b/include/asm-x86/ipcbuf.h new file mode 100644 index 000000000000..eb2e448c6e28 --- /dev/null +++ b/include/asm-x86/ipcbuf.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ipcbuf_32.h" | ||
4 | # else | ||
5 | # include "ipcbuf_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ipcbuf_32.h" | ||
10 | # else | ||
11 | # include "ipcbuf_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ipcbuf_32.h b/include/asm-x86/ipcbuf_32.h new file mode 100644 index 000000000000..0dcad4f84c2a --- /dev/null +++ b/include/asm-x86/ipcbuf_32.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __i386_IPCBUF_H__ | ||
2 | #define __i386_IPCBUF_H__ | ||
3 | |||
4 | /* | ||
5 | * The ipc64_perm structure for i386 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 32-bit mode_t and seq | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct ipc64_perm | ||
15 | { | ||
16 | __kernel_key_t key; | ||
17 | __kernel_uid32_t uid; | ||
18 | __kernel_gid32_t gid; | ||
19 | __kernel_uid32_t cuid; | ||
20 | __kernel_gid32_t cgid; | ||
21 | __kernel_mode_t mode; | ||
22 | unsigned short __pad1; | ||
23 | unsigned short seq; | ||
24 | unsigned short __pad2; | ||
25 | unsigned long __unused1; | ||
26 | unsigned long __unused2; | ||
27 | }; | ||
28 | |||
29 | #endif /* __i386_IPCBUF_H__ */ | ||
diff --git a/include/asm-x86/ipcbuf_64.h b/include/asm-x86/ipcbuf_64.h new file mode 100644 index 000000000000..470cf85e3ba8 --- /dev/null +++ b/include/asm-x86/ipcbuf_64.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __x86_64_IPCBUF_H__ | ||
2 | #define __x86_64_IPCBUF_H__ | ||
3 | |||
4 | /* | ||
5 | * The ipc64_perm structure for x86_64 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 32-bit mode_t and seq | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct ipc64_perm | ||
15 | { | ||
16 | __kernel_key_t key; | ||
17 | __kernel_uid32_t uid; | ||
18 | __kernel_gid32_t gid; | ||
19 | __kernel_uid32_t cuid; | ||
20 | __kernel_gid32_t cgid; | ||
21 | __kernel_mode_t mode; | ||
22 | unsigned short __pad1; | ||
23 | unsigned short seq; | ||
24 | unsigned short __pad2; | ||
25 | unsigned long __unused1; | ||
26 | unsigned long __unused2; | ||
27 | }; | ||
28 | |||
29 | #endif /* __x86_64_IPCBUF_H__ */ | ||
diff --git a/include/asm-x86/ipi.h b/include/asm-x86/ipi.h new file mode 100644 index 000000000000..a7c75ea408a8 --- /dev/null +++ b/include/asm-x86/ipi.h | |||
@@ -0,0 +1,128 @@ | |||
1 | #ifndef __ASM_IPI_H | ||
2 | #define __ASM_IPI_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 2004 James Cleverdon, IBM. | ||
6 | * Subject to the GNU Public License, v.2 | ||
7 | * | ||
8 | * Generic APIC InterProcessor Interrupt code. | ||
9 | * | ||
10 | * Moved to include file by James Cleverdon from | ||
11 | * arch/x86-64/kernel/smp.c | ||
12 | * | ||
13 | * Copyrights from kernel/smp.c: | ||
14 | * | ||
15 | * (c) 1995 Alan Cox, Building #3 <alan@redhat.com> | ||
16 | * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com> | ||
17 | * (c) 2002,2003 Andi Kleen, SuSE Labs. | ||
18 | * Subject to the GNU Public License, v.2 | ||
19 | */ | ||
20 | |||
21 | #include <asm/hw_irq.h> | ||
22 | #include <asm/apic.h> | ||
23 | |||
24 | /* | ||
25 | * the following functions deal with sending IPIs between CPUs. | ||
26 | * | ||
27 | * We use 'broadcast', CPU->CPU IPIs and self-IPIs too. | ||
28 | */ | ||
29 | |||
30 | static inline unsigned int __prepare_ICR (unsigned int shortcut, int vector, unsigned int dest) | ||
31 | { | ||
32 | unsigned int icr = shortcut | dest; | ||
33 | |||
34 | switch (vector) { | ||
35 | default: | ||
36 | icr |= APIC_DM_FIXED | vector; | ||
37 | break; | ||
38 | case NMI_VECTOR: | ||
39 | icr |= APIC_DM_NMI; | ||
40 | break; | ||
41 | } | ||
42 | return icr; | ||
43 | } | ||
44 | |||
45 | static inline int __prepare_ICR2 (unsigned int mask) | ||
46 | { | ||
47 | return SET_APIC_DEST_FIELD(mask); | ||
48 | } | ||
49 | |||
50 | static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest) | ||
51 | { | ||
52 | /* | ||
53 | * Subtle. In the case of the 'never do double writes' workaround | ||
54 | * we have to lock out interrupts to be safe. As we don't care | ||
55 | * of the value read we use an atomic rmw access to avoid costly | ||
56 | * cli/sti. Otherwise we use an even cheaper single atomic write | ||
57 | * to the APIC. | ||
58 | */ | ||
59 | unsigned int cfg; | ||
60 | |||
61 | /* | ||
62 | * Wait for idle. | ||
63 | */ | ||
64 | apic_wait_icr_idle(); | ||
65 | |||
66 | /* | ||
67 | * No need to touch the target chip field | ||
68 | */ | ||
69 | cfg = __prepare_ICR(shortcut, vector, dest); | ||
70 | |||
71 | /* | ||
72 | * Send the IPI. The write to APIC_ICR fires this off. | ||
73 | */ | ||
74 | apic_write(APIC_ICR, cfg); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * This is used to send an IPI with no shorthand notation (the destination is | ||
79 | * specified in bits 56 to 63 of the ICR). | ||
80 | */ | ||
81 | static inline void __send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest) | ||
82 | { | ||
83 | unsigned long cfg; | ||
84 | |||
85 | /* | ||
86 | * Wait for idle. | ||
87 | */ | ||
88 | if (unlikely(vector == NMI_VECTOR)) | ||
89 | safe_apic_wait_icr_idle(); | ||
90 | else | ||
91 | apic_wait_icr_idle(); | ||
92 | |||
93 | /* | ||
94 | * prepare target chip field | ||
95 | */ | ||
96 | cfg = __prepare_ICR2(mask); | ||
97 | apic_write(APIC_ICR2, cfg); | ||
98 | |||
99 | /* | ||
100 | * program the ICR | ||
101 | */ | ||
102 | cfg = __prepare_ICR(0, vector, dest); | ||
103 | |||
104 | /* | ||
105 | * Send the IPI. The write to APIC_ICR fires this off. | ||
106 | */ | ||
107 | apic_write(APIC_ICR, cfg); | ||
108 | } | ||
109 | |||
110 | static inline void send_IPI_mask_sequence(cpumask_t mask, int vector) | ||
111 | { | ||
112 | unsigned long flags; | ||
113 | unsigned long query_cpu; | ||
114 | |||
115 | /* | ||
116 | * Hack. The clustered APIC addressing mode doesn't allow us to send | ||
117 | * to an arbitrary mask, so I do a unicast to each CPU instead. | ||
118 | * - mbligh | ||
119 | */ | ||
120 | local_irq_save(flags); | ||
121 | for_each_cpu_mask(query_cpu, mask) { | ||
122 | __send_IPI_dest_field(x86_cpu_to_apicid[query_cpu], | ||
123 | vector, APIC_DEST_PHYSICAL); | ||
124 | } | ||
125 | local_irq_restore(flags); | ||
126 | } | ||
127 | |||
128 | #endif /* __ASM_IPI_H */ | ||
diff --git a/include/asm-x86/irq.h b/include/asm-x86/irq.h new file mode 100644 index 000000000000..7ba905465a53 --- /dev/null +++ b/include/asm-x86/irq.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "irq_32.h" | ||
3 | #else | ||
4 | # include "irq_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/irq_32.h b/include/asm-x86/irq_32.h new file mode 100644 index 000000000000..36f310632c49 --- /dev/null +++ b/include/asm-x86/irq_32.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef _ASM_IRQ_H | ||
2 | #define _ASM_IRQ_H | ||
3 | |||
4 | /* | ||
5 | * linux/include/asm/irq.h | ||
6 | * | ||
7 | * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar | ||
8 | * | ||
9 | * IRQ/IPI changes taken from work by Thomas Radke | ||
10 | * <tomsoft@informatik.tu-chemnitz.de> | ||
11 | */ | ||
12 | |||
13 | #include <linux/sched.h> | ||
14 | /* include comes from machine specific directory */ | ||
15 | #include "irq_vectors.h" | ||
16 | #include <asm/thread_info.h> | ||
17 | |||
18 | static __inline__ int irq_canonicalize(int irq) | ||
19 | { | ||
20 | return ((irq == 2) ? 9 : irq); | ||
21 | } | ||
22 | |||
23 | #ifdef CONFIG_X86_LOCAL_APIC | ||
24 | # define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ | ||
25 | #endif | ||
26 | |||
27 | #ifdef CONFIG_4KSTACKS | ||
28 | extern void irq_ctx_init(int cpu); | ||
29 | extern void irq_ctx_exit(int cpu); | ||
30 | # define __ARCH_HAS_DO_SOFTIRQ | ||
31 | #else | ||
32 | # define irq_ctx_init(cpu) do { } while (0) | ||
33 | # define irq_ctx_exit(cpu) do { } while (0) | ||
34 | #endif | ||
35 | |||
36 | #ifdef CONFIG_IRQBALANCE | ||
37 | extern int irqbalance_disable(char *str); | ||
38 | #endif | ||
39 | |||
40 | #ifdef CONFIG_HOTPLUG_CPU | ||
41 | extern void fixup_irqs(cpumask_t map); | ||
42 | #endif | ||
43 | |||
44 | unsigned int do_IRQ(struct pt_regs *regs); | ||
45 | void init_IRQ(void); | ||
46 | void __init native_init_IRQ(void); | ||
47 | |||
48 | #endif /* _ASM_IRQ_H */ | ||
diff --git a/include/asm-x86/irq_64.h b/include/asm-x86/irq_64.h new file mode 100644 index 000000000000..5006c6e75656 --- /dev/null +++ b/include/asm-x86/irq_64.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _ASM_IRQ_H | ||
2 | #define _ASM_IRQ_H | ||
3 | |||
4 | /* | ||
5 | * linux/include/asm/irq.h | ||
6 | * | ||
7 | * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar | ||
8 | * | ||
9 | * IRQ/IPI changes taken from work by Thomas Radke | ||
10 | * <tomsoft@informatik.tu-chemnitz.de> | ||
11 | */ | ||
12 | |||
13 | #define TIMER_IRQ 0 | ||
14 | |||
15 | /* | ||
16 | * 16 8259A IRQ's, 208 potential APIC interrupt sources. | ||
17 | * Right now the APIC is mostly only used for SMP. | ||
18 | * 256 vectors is an architectural limit. (we can have | ||
19 | * more than 256 devices theoretically, but they will | ||
20 | * have to use shared interrupts) | ||
21 | * Since vectors 0x00-0x1f are used/reserved for the CPU, | ||
22 | * the usable vector space is 0x20-0xff (224 vectors) | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | * The maximum number of vectors supported by x86_64 processors | ||
27 | * is limited to 256. For processors other than x86_64, NR_VECTORS | ||
28 | * should be changed accordingly. | ||
29 | */ | ||
30 | #define NR_VECTORS 256 | ||
31 | |||
32 | #define FIRST_SYSTEM_VECTOR 0xef /* duplicated in hw_irq.h */ | ||
33 | |||
34 | #define NR_IRQS (NR_VECTORS + (32 *NR_CPUS)) | ||
35 | #define NR_IRQ_VECTORS NR_IRQS | ||
36 | |||
37 | static __inline__ int irq_canonicalize(int irq) | ||
38 | { | ||
39 | return ((irq == 2) ? 9 : irq); | ||
40 | } | ||
41 | |||
42 | #define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ | ||
43 | |||
44 | #ifdef CONFIG_HOTPLUG_CPU | ||
45 | #include <linux/cpumask.h> | ||
46 | extern void fixup_irqs(cpumask_t map); | ||
47 | #endif | ||
48 | |||
49 | #define __ARCH_HAS_DO_SOFTIRQ 1 | ||
50 | |||
51 | #endif /* _ASM_IRQ_H */ | ||
diff --git a/include/asm-x86/irq_regs.h b/include/asm-x86/irq_regs.h new file mode 100644 index 000000000000..89c898ab298b --- /dev/null +++ b/include/asm-x86/irq_regs.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "irq_regs_32.h" | ||
3 | #else | ||
4 | # include "irq_regs_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/irq_regs_32.h b/include/asm-x86/irq_regs_32.h new file mode 100644 index 000000000000..3368b20c0b48 --- /dev/null +++ b/include/asm-x86/irq_regs_32.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Per-cpu current frame pointer - the location of the last exception frame on | ||
3 | * the stack, stored in the per-cpu area. | ||
4 | * | ||
5 | * Jeremy Fitzhardinge <jeremy@goop.org> | ||
6 | */ | ||
7 | #ifndef _ASM_I386_IRQ_REGS_H | ||
8 | #define _ASM_I386_IRQ_REGS_H | ||
9 | |||
10 | #include <asm/percpu.h> | ||
11 | |||
12 | DECLARE_PER_CPU(struct pt_regs *, irq_regs); | ||
13 | |||
14 | static inline struct pt_regs *get_irq_regs(void) | ||
15 | { | ||
16 | return x86_read_percpu(irq_regs); | ||
17 | } | ||
18 | |||
19 | static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs) | ||
20 | { | ||
21 | struct pt_regs *old_regs; | ||
22 | |||
23 | old_regs = get_irq_regs(); | ||
24 | x86_write_percpu(irq_regs, new_regs); | ||
25 | |||
26 | return old_regs; | ||
27 | } | ||
28 | |||
29 | #endif /* _ASM_I386_IRQ_REGS_H */ | ||
diff --git a/include/asm-x86/irq_regs_64.h b/include/asm-x86/irq_regs_64.h new file mode 100644 index 000000000000..3dd9c0b70270 --- /dev/null +++ b/include/asm-x86/irq_regs_64.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/irq_regs.h> | |||
diff --git a/include/asm-x86/irqflags.h b/include/asm-x86/irqflags.h new file mode 100644 index 000000000000..1b695ff52687 --- /dev/null +++ b/include/asm-x86/irqflags.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "irqflags_32.h" | ||
3 | #else | ||
4 | # include "irqflags_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/irqflags_32.h b/include/asm-x86/irqflags_32.h new file mode 100644 index 000000000000..eff8585cb741 --- /dev/null +++ b/include/asm-x86/irqflags_32.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * include/asm-i386/irqflags.h | ||
3 | * | ||
4 | * IRQ flags handling | ||
5 | * | ||
6 | * This file gets included from lowlevel asm headers too, to provide | ||
7 | * wrapped versions of the local_irq_*() APIs, based on the | ||
8 | * raw_local_irq_*() functions from the lowlevel headers. | ||
9 | */ | ||
10 | #ifndef _ASM_IRQFLAGS_H | ||
11 | #define _ASM_IRQFLAGS_H | ||
12 | #include <asm/processor-flags.h> | ||
13 | |||
14 | #ifndef __ASSEMBLY__ | ||
15 | static inline unsigned long native_save_fl(void) | ||
16 | { | ||
17 | unsigned long f; | ||
18 | asm volatile("pushfl ; popl %0":"=g" (f): /* no input */); | ||
19 | return f; | ||
20 | } | ||
21 | |||
22 | static inline void native_restore_fl(unsigned long f) | ||
23 | { | ||
24 | asm volatile("pushl %0 ; popfl": /* no output */ | ||
25 | :"g" (f) | ||
26 | :"memory", "cc"); | ||
27 | } | ||
28 | |||
29 | static inline void native_irq_disable(void) | ||
30 | { | ||
31 | asm volatile("cli": : :"memory"); | ||
32 | } | ||
33 | |||
34 | static inline void native_irq_enable(void) | ||
35 | { | ||
36 | asm volatile("sti": : :"memory"); | ||
37 | } | ||
38 | |||
39 | static inline void native_safe_halt(void) | ||
40 | { | ||
41 | asm volatile("sti; hlt": : :"memory"); | ||
42 | } | ||
43 | |||
44 | static inline void native_halt(void) | ||
45 | { | ||
46 | asm volatile("hlt": : :"memory"); | ||
47 | } | ||
48 | #endif /* __ASSEMBLY__ */ | ||
49 | |||
50 | #ifdef CONFIG_PARAVIRT | ||
51 | #include <asm/paravirt.h> | ||
52 | #else | ||
53 | #ifndef __ASSEMBLY__ | ||
54 | |||
55 | static inline unsigned long __raw_local_save_flags(void) | ||
56 | { | ||
57 | return native_save_fl(); | ||
58 | } | ||
59 | |||
60 | static inline void raw_local_irq_restore(unsigned long flags) | ||
61 | { | ||
62 | native_restore_fl(flags); | ||
63 | } | ||
64 | |||
65 | static inline void raw_local_irq_disable(void) | ||
66 | { | ||
67 | native_irq_disable(); | ||
68 | } | ||
69 | |||
70 | static inline void raw_local_irq_enable(void) | ||
71 | { | ||
72 | native_irq_enable(); | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * Used in the idle loop; sti takes one instruction cycle | ||
77 | * to complete: | ||
78 | */ | ||
79 | static inline void raw_safe_halt(void) | ||
80 | { | ||
81 | native_safe_halt(); | ||
82 | } | ||
83 | |||
84 | /* | ||
85 | * Used when interrupts are already enabled or to | ||
86 | * shutdown the processor: | ||
87 | */ | ||
88 | static inline void halt(void) | ||
89 | { | ||
90 | native_halt(); | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * For spinlocks, etc: | ||
95 | */ | ||
96 | static inline unsigned long __raw_local_irq_save(void) | ||
97 | { | ||
98 | unsigned long flags = __raw_local_save_flags(); | ||
99 | |||
100 | raw_local_irq_disable(); | ||
101 | |||
102 | return flags; | ||
103 | } | ||
104 | |||
105 | #else | ||
106 | #define DISABLE_INTERRUPTS(clobbers) cli | ||
107 | #define ENABLE_INTERRUPTS(clobbers) sti | ||
108 | #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit | ||
109 | #define INTERRUPT_RETURN iret | ||
110 | #define GET_CR0_INTO_EAX movl %cr0, %eax | ||
111 | #endif /* __ASSEMBLY__ */ | ||
112 | #endif /* CONFIG_PARAVIRT */ | ||
113 | |||
114 | #ifndef __ASSEMBLY__ | ||
115 | #define raw_local_save_flags(flags) \ | ||
116 | do { (flags) = __raw_local_save_flags(); } while (0) | ||
117 | |||
118 | #define raw_local_irq_save(flags) \ | ||
119 | do { (flags) = __raw_local_irq_save(); } while (0) | ||
120 | |||
121 | static inline int raw_irqs_disabled_flags(unsigned long flags) | ||
122 | { | ||
123 | return !(flags & X86_EFLAGS_IF); | ||
124 | } | ||
125 | |||
126 | static inline int raw_irqs_disabled(void) | ||
127 | { | ||
128 | unsigned long flags = __raw_local_save_flags(); | ||
129 | |||
130 | return raw_irqs_disabled_flags(flags); | ||
131 | } | ||
132 | #endif /* __ASSEMBLY__ */ | ||
133 | |||
134 | /* | ||
135 | * Do the CPU's IRQ-state tracing from assembly code. We call a | ||
136 | * C function, so save all the C-clobbered registers: | ||
137 | */ | ||
138 | #ifdef CONFIG_TRACE_IRQFLAGS | ||
139 | |||
140 | # define TRACE_IRQS_ON \ | ||
141 | pushl %eax; \ | ||
142 | pushl %ecx; \ | ||
143 | pushl %edx; \ | ||
144 | call trace_hardirqs_on; \ | ||
145 | popl %edx; \ | ||
146 | popl %ecx; \ | ||
147 | popl %eax; | ||
148 | |||
149 | # define TRACE_IRQS_OFF \ | ||
150 | pushl %eax; \ | ||
151 | pushl %ecx; \ | ||
152 | pushl %edx; \ | ||
153 | call trace_hardirqs_off; \ | ||
154 | popl %edx; \ | ||
155 | popl %ecx; \ | ||
156 | popl %eax; | ||
157 | |||
158 | #else | ||
159 | # define TRACE_IRQS_ON | ||
160 | # define TRACE_IRQS_OFF | ||
161 | #endif | ||
162 | |||
163 | #endif | ||
diff --git a/include/asm-x86/irqflags_64.h b/include/asm-x86/irqflags_64.h new file mode 100644 index 000000000000..86e70fe23659 --- /dev/null +++ b/include/asm-x86/irqflags_64.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/irqflags.h | ||
3 | * | ||
4 | * IRQ flags handling | ||
5 | * | ||
6 | * This file gets included from lowlevel asm headers too, to provide | ||
7 | * wrapped versions of the local_irq_*() APIs, based on the | ||
8 | * raw_local_irq_*() functions from the lowlevel headers. | ||
9 | */ | ||
10 | #ifndef _ASM_IRQFLAGS_H | ||
11 | #define _ASM_IRQFLAGS_H | ||
12 | #include <asm/processor-flags.h> | ||
13 | |||
14 | #ifndef __ASSEMBLY__ | ||
15 | /* | ||
16 | * Interrupt control: | ||
17 | */ | ||
18 | |||
19 | static inline unsigned long __raw_local_save_flags(void) | ||
20 | { | ||
21 | unsigned long flags; | ||
22 | |||
23 | __asm__ __volatile__( | ||
24 | "# __raw_save_flags\n\t" | ||
25 | "pushfq ; popq %q0" | ||
26 | : "=g" (flags) | ||
27 | : /* no input */ | ||
28 | : "memory" | ||
29 | ); | ||
30 | |||
31 | return flags; | ||
32 | } | ||
33 | |||
34 | #define raw_local_save_flags(flags) \ | ||
35 | do { (flags) = __raw_local_save_flags(); } while (0) | ||
36 | |||
37 | static inline void raw_local_irq_restore(unsigned long flags) | ||
38 | { | ||
39 | __asm__ __volatile__( | ||
40 | "pushq %0 ; popfq" | ||
41 | : /* no output */ | ||
42 | :"g" (flags) | ||
43 | :"memory", "cc" | ||
44 | ); | ||
45 | } | ||
46 | |||
47 | #ifdef CONFIG_X86_VSMP | ||
48 | |||
49 | /* | ||
50 | * Interrupt control for the VSMP architecture: | ||
51 | */ | ||
52 | |||
53 | static inline void raw_local_irq_disable(void) | ||
54 | { | ||
55 | unsigned long flags = __raw_local_save_flags(); | ||
56 | |||
57 | raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC); | ||
58 | } | ||
59 | |||
60 | static inline void raw_local_irq_enable(void) | ||
61 | { | ||
62 | unsigned long flags = __raw_local_save_flags(); | ||
63 | |||
64 | raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC)); | ||
65 | } | ||
66 | |||
67 | static inline int raw_irqs_disabled_flags(unsigned long flags) | ||
68 | { | ||
69 | return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC); | ||
70 | } | ||
71 | |||
72 | #else /* CONFIG_X86_VSMP */ | ||
73 | |||
74 | static inline void raw_local_irq_disable(void) | ||
75 | { | ||
76 | __asm__ __volatile__("cli" : : : "memory"); | ||
77 | } | ||
78 | |||
79 | static inline void raw_local_irq_enable(void) | ||
80 | { | ||
81 | __asm__ __volatile__("sti" : : : "memory"); | ||
82 | } | ||
83 | |||
84 | static inline int raw_irqs_disabled_flags(unsigned long flags) | ||
85 | { | ||
86 | return !(flags & X86_EFLAGS_IF); | ||
87 | } | ||
88 | |||
89 | #endif | ||
90 | |||
91 | /* | ||
92 | * For spinlocks, etc.: | ||
93 | */ | ||
94 | |||
95 | static inline unsigned long __raw_local_irq_save(void) | ||
96 | { | ||
97 | unsigned long flags = __raw_local_save_flags(); | ||
98 | |||
99 | raw_local_irq_disable(); | ||
100 | |||
101 | return flags; | ||
102 | } | ||
103 | |||
104 | #define raw_local_irq_save(flags) \ | ||
105 | do { (flags) = __raw_local_irq_save(); } while (0) | ||
106 | |||
107 | static inline int raw_irqs_disabled(void) | ||
108 | { | ||
109 | unsigned long flags = __raw_local_save_flags(); | ||
110 | |||
111 | return raw_irqs_disabled_flags(flags); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Used in the idle loop; sti takes one instruction cycle | ||
116 | * to complete: | ||
117 | */ | ||
118 | static inline void raw_safe_halt(void) | ||
119 | { | ||
120 | __asm__ __volatile__("sti; hlt" : : : "memory"); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * Used when interrupts are already enabled or to | ||
125 | * shutdown the processor: | ||
126 | */ | ||
127 | static inline void halt(void) | ||
128 | { | ||
129 | __asm__ __volatile__("hlt": : :"memory"); | ||
130 | } | ||
131 | |||
132 | #else /* __ASSEMBLY__: */ | ||
133 | # ifdef CONFIG_TRACE_IRQFLAGS | ||
134 | # define TRACE_IRQS_ON call trace_hardirqs_on_thunk | ||
135 | # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk | ||
136 | # else | ||
137 | # define TRACE_IRQS_ON | ||
138 | # define TRACE_IRQS_OFF | ||
139 | # endif | ||
140 | #endif | ||
141 | |||
142 | #endif | ||
diff --git a/include/asm-x86/ist.h b/include/asm-x86/ist.h new file mode 100644 index 000000000000..ef2003ebc6f9 --- /dev/null +++ b/include/asm-x86/ist.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _ASM_IST_H | ||
2 | #define _ASM_IST_H | ||
3 | |||
4 | /* | ||
5 | * Include file for the interface to IST BIOS | ||
6 | * Copyright 2002 Andy Grover <andrew.grover@intel.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2, or (at your option) any | ||
11 | * later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | */ | ||
18 | |||
19 | |||
20 | #ifdef __KERNEL__ | ||
21 | |||
22 | #include <linux/types.h> | ||
23 | |||
24 | struct ist_info { | ||
25 | u32 signature; | ||
26 | u32 command; | ||
27 | u32 event; | ||
28 | u32 perf_level; | ||
29 | }; | ||
30 | |||
31 | extern struct ist_info ist_info; | ||
32 | |||
33 | #endif /* __KERNEL__ */ | ||
34 | #endif /* _ASM_IST_H */ | ||
diff --git a/include/asm-x86/k8.h b/include/asm-x86/k8.h new file mode 100644 index 000000000000..699dd6961eda --- /dev/null +++ b/include/asm-x86/k8.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_K8_H | ||
2 | #define _ASM_K8_H 1 | ||
3 | |||
4 | #include <linux/pci.h> | ||
5 | |||
6 | extern struct pci_device_id k8_nb_ids[]; | ||
7 | |||
8 | extern int early_is_k8_nb(u32 value); | ||
9 | extern struct pci_dev **k8_northbridges; | ||
10 | extern int num_k8_northbridges; | ||
11 | extern int cache_k8_northbridges(void); | ||
12 | extern void k8_flush_garts(void); | ||
13 | |||
14 | #endif | ||
diff --git a/include/asm-x86/kdebug.h b/include/asm-x86/kdebug.h new file mode 100644 index 000000000000..38479106c259 --- /dev/null +++ b/include/asm-x86/kdebug.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "kdebug_32.h" | ||
3 | #else | ||
4 | # include "kdebug_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/kdebug_32.h b/include/asm-x86/kdebug_32.h new file mode 100644 index 000000000000..a185b5f73e7f --- /dev/null +++ b/include/asm-x86/kdebug_32.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _I386_KDEBUG_H | ||
2 | #define _I386_KDEBUG_H 1 | ||
3 | |||
4 | /* | ||
5 | * Aug-05 2004 Ported by Prasanna S Panchamukhi <prasanna@in.ibm.com> | ||
6 | * from x86_64 architecture. | ||
7 | */ | ||
8 | #include <linux/notifier.h> | ||
9 | |||
10 | struct pt_regs; | ||
11 | |||
12 | extern int register_page_fault_notifier(struct notifier_block *); | ||
13 | extern int unregister_page_fault_notifier(struct notifier_block *); | ||
14 | |||
15 | |||
16 | /* Grossly misnamed. */ | ||
17 | enum die_val { | ||
18 | DIE_OOPS = 1, | ||
19 | DIE_INT3, | ||
20 | DIE_DEBUG, | ||
21 | DIE_PANIC, | ||
22 | DIE_NMI, | ||
23 | DIE_DIE, | ||
24 | DIE_NMIWATCHDOG, | ||
25 | DIE_KERNELDEBUG, | ||
26 | DIE_TRAP, | ||
27 | DIE_GPF, | ||
28 | DIE_CALL, | ||
29 | DIE_NMI_IPI, | ||
30 | DIE_PAGE_FAULT, | ||
31 | }; | ||
32 | |||
33 | #endif | ||
diff --git a/include/asm-x86/kdebug_64.h b/include/asm-x86/kdebug_64.h new file mode 100644 index 000000000000..d7e2bcf49e4f --- /dev/null +++ b/include/asm-x86/kdebug_64.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _X86_64_KDEBUG_H | ||
2 | #define _X86_64_KDEBUG_H 1 | ||
3 | |||
4 | #include <linux/notifier.h> | ||
5 | |||
6 | struct pt_regs; | ||
7 | |||
8 | extern int register_page_fault_notifier(struct notifier_block *); | ||
9 | extern int unregister_page_fault_notifier(struct notifier_block *); | ||
10 | |||
11 | /* Grossly misnamed. */ | ||
12 | enum die_val { | ||
13 | DIE_OOPS = 1, | ||
14 | DIE_INT3, | ||
15 | DIE_DEBUG, | ||
16 | DIE_PANIC, | ||
17 | DIE_NMI, | ||
18 | DIE_DIE, | ||
19 | DIE_NMIWATCHDOG, | ||
20 | DIE_KERNELDEBUG, | ||
21 | DIE_TRAP, | ||
22 | DIE_GPF, | ||
23 | DIE_CALL, | ||
24 | DIE_NMI_IPI, | ||
25 | DIE_PAGE_FAULT, | ||
26 | }; | ||
27 | |||
28 | extern void printk_address(unsigned long address); | ||
29 | extern void die(const char *,struct pt_regs *,long); | ||
30 | extern void __die(const char *,struct pt_regs *,long); | ||
31 | extern void show_registers(struct pt_regs *regs); | ||
32 | extern void dump_pagetable(unsigned long); | ||
33 | extern unsigned long oops_begin(void); | ||
34 | extern void oops_end(unsigned long); | ||
35 | |||
36 | #endif | ||
diff --git a/include/asm-x86/kexec.h b/include/asm-x86/kexec.h new file mode 100644 index 000000000000..718ddbfb9516 --- /dev/null +++ b/include/asm-x86/kexec.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "kexec_32.h" | ||
3 | #else | ||
4 | # include "kexec_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/kexec_32.h b/include/asm-x86/kexec_32.h new file mode 100644 index 000000000000..4b9dc9e6b701 --- /dev/null +++ b/include/asm-x86/kexec_32.h | |||
@@ -0,0 +1,99 @@ | |||
1 | #ifndef _I386_KEXEC_H | ||
2 | #define _I386_KEXEC_H | ||
3 | |||
4 | #define PA_CONTROL_PAGE 0 | ||
5 | #define VA_CONTROL_PAGE 1 | ||
6 | #define PA_PGD 2 | ||
7 | #define VA_PGD 3 | ||
8 | #define PA_PTE_0 4 | ||
9 | #define VA_PTE_0 5 | ||
10 | #define PA_PTE_1 6 | ||
11 | #define VA_PTE_1 7 | ||
12 | #ifdef CONFIG_X86_PAE | ||
13 | #define PA_PMD_0 8 | ||
14 | #define VA_PMD_0 9 | ||
15 | #define PA_PMD_1 10 | ||
16 | #define VA_PMD_1 11 | ||
17 | #define PAGES_NR 12 | ||
18 | #else | ||
19 | #define PAGES_NR 8 | ||
20 | #endif | ||
21 | |||
22 | #ifndef __ASSEMBLY__ | ||
23 | |||
24 | #include <asm/ptrace.h> | ||
25 | #include <asm/string.h> | ||
26 | |||
27 | /* | ||
28 | * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return. | ||
29 | * I.e. Maximum page that is mapped directly into kernel memory, | ||
30 | * and kmap is not required. | ||
31 | */ | ||
32 | |||
33 | /* Maximum physical address we can use pages from */ | ||
34 | #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) | ||
35 | /* Maximum address we can reach in physical address mode */ | ||
36 | #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) | ||
37 | /* Maximum address we can use for the control code buffer */ | ||
38 | #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE | ||
39 | |||
40 | #define KEXEC_CONTROL_CODE_SIZE 4096 | ||
41 | |||
42 | /* The native architecture */ | ||
43 | #define KEXEC_ARCH KEXEC_ARCH_386 | ||
44 | |||
45 | /* We can also handle crash dumps from 64 bit kernel. */ | ||
46 | #define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64) | ||
47 | |||
48 | /* CPU does not save ss and esp on stack if execution is already | ||
49 | * running in kernel mode at the time of NMI occurrence. This code | ||
50 | * fixes it. | ||
51 | */ | ||
52 | static inline void crash_fixup_ss_esp(struct pt_regs *newregs, | ||
53 | struct pt_regs *oldregs) | ||
54 | { | ||
55 | memcpy(newregs, oldregs, sizeof(*newregs)); | ||
56 | newregs->esp = (unsigned long)&(oldregs->esp); | ||
57 | __asm__ __volatile__( | ||
58 | "xorl %%eax, %%eax\n\t" | ||
59 | "movw %%ss, %%ax\n\t" | ||
60 | :"=a"(newregs->xss)); | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | * This function is responsible for capturing register states if coming | ||
65 | * via panic otherwise just fix up the ss and esp if coming via kernel | ||
66 | * mode exception. | ||
67 | */ | ||
68 | static inline void crash_setup_regs(struct pt_regs *newregs, | ||
69 | struct pt_regs *oldregs) | ||
70 | { | ||
71 | if (oldregs) | ||
72 | crash_fixup_ss_esp(newregs, oldregs); | ||
73 | else { | ||
74 | __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx)); | ||
75 | __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx)); | ||
76 | __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx)); | ||
77 | __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi)); | ||
78 | __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi)); | ||
79 | __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp)); | ||
80 | __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax)); | ||
81 | __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp)); | ||
82 | __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss)); | ||
83 | __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs)); | ||
84 | __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds)); | ||
85 | __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes)); | ||
86 | __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags)); | ||
87 | |||
88 | newregs->eip = (unsigned long)current_text_addr(); | ||
89 | } | ||
90 | } | ||
91 | asmlinkage NORET_TYPE void | ||
92 | relocate_kernel(unsigned long indirection_page, | ||
93 | unsigned long control_page, | ||
94 | unsigned long start_address, | ||
95 | unsigned int has_pae) ATTRIB_NORET; | ||
96 | |||
97 | #endif /* __ASSEMBLY__ */ | ||
98 | |||
99 | #endif /* _I386_KEXEC_H */ | ||
diff --git a/include/asm-x86/kexec_64.h b/include/asm-x86/kexec_64.h new file mode 100644 index 000000000000..738e581b67f8 --- /dev/null +++ b/include/asm-x86/kexec_64.h | |||
@@ -0,0 +1,94 @@ | |||
1 | #ifndef _X86_64_KEXEC_H | ||
2 | #define _X86_64_KEXEC_H | ||
3 | |||
4 | #define PA_CONTROL_PAGE 0 | ||
5 | #define VA_CONTROL_PAGE 1 | ||
6 | #define PA_PGD 2 | ||
7 | #define VA_PGD 3 | ||
8 | #define PA_PUD_0 4 | ||
9 | #define VA_PUD_0 5 | ||
10 | #define PA_PMD_0 6 | ||
11 | #define VA_PMD_0 7 | ||
12 | #define PA_PTE_0 8 | ||
13 | #define VA_PTE_0 9 | ||
14 | #define PA_PUD_1 10 | ||
15 | #define VA_PUD_1 11 | ||
16 | #define PA_PMD_1 12 | ||
17 | #define VA_PMD_1 13 | ||
18 | #define PA_PTE_1 14 | ||
19 | #define VA_PTE_1 15 | ||
20 | #define PA_TABLE_PAGE 16 | ||
21 | #define PAGES_NR 17 | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | ||
24 | |||
25 | #include <linux/string.h> | ||
26 | |||
27 | #include <asm/page.h> | ||
28 | #include <asm/ptrace.h> | ||
29 | |||
30 | /* | ||
31 | * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return. | ||
32 | * I.e. Maximum page that is mapped directly into kernel memory, | ||
33 | * and kmap is not required. | ||
34 | * | ||
35 | * So far x86_64 is limited to 40 physical address bits. | ||
36 | */ | ||
37 | |||
38 | /* Maximum physical address we can use pages from */ | ||
39 | #define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL) | ||
40 | /* Maximum address we can reach in physical address mode */ | ||
41 | #define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL) | ||
42 | /* Maximum address we can use for the control pages */ | ||
43 | #define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL) | ||
44 | |||
45 | /* Allocate one page for the pdp and the second for the code */ | ||
46 | #define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL) | ||
47 | |||
48 | /* The native architecture */ | ||
49 | #define KEXEC_ARCH KEXEC_ARCH_X86_64 | ||
50 | |||
51 | /* | ||
52 | * Saving the registers of the cpu on which panic occured in | ||
53 | * crash_kexec to save a valid sp. The registers of other cpus | ||
54 | * will be saved in machine_crash_shutdown while shooting down them. | ||
55 | */ | ||
56 | |||
57 | static inline void crash_setup_regs(struct pt_regs *newregs, | ||
58 | struct pt_regs *oldregs) | ||
59 | { | ||
60 | if (oldregs) | ||
61 | memcpy(newregs, oldregs, sizeof(*newregs)); | ||
62 | else { | ||
63 | __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->rbx)); | ||
64 | __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->rcx)); | ||
65 | __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->rdx)); | ||
66 | __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->rsi)); | ||
67 | __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->rdi)); | ||
68 | __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->rbp)); | ||
69 | __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->rax)); | ||
70 | __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->rsp)); | ||
71 | __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8)); | ||
72 | __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9)); | ||
73 | __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10)); | ||
74 | __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11)); | ||
75 | __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12)); | ||
76 | __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13)); | ||
77 | __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14)); | ||
78 | __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15)); | ||
79 | __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss)); | ||
80 | __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs)); | ||
81 | __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->eflags)); | ||
82 | |||
83 | newregs->rip = (unsigned long)current_text_addr(); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | NORET_TYPE void | ||
88 | relocate_kernel(unsigned long indirection_page, | ||
89 | unsigned long page_list, | ||
90 | unsigned long start_address) ATTRIB_NORET; | ||
91 | |||
92 | #endif /* __ASSEMBLY__ */ | ||
93 | |||
94 | #endif /* _X86_64_KEXEC_H */ | ||
diff --git a/include/asm-x86/kmap_types.h b/include/asm-x86/kmap_types.h new file mode 100644 index 000000000000..e4ec724b298e --- /dev/null +++ b/include/asm-x86/kmap_types.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "kmap_types_32.h" | ||
3 | #else | ||
4 | # include "kmap_types_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/kmap_types_32.h b/include/asm-x86/kmap_types_32.h new file mode 100644 index 000000000000..806aae3c5338 --- /dev/null +++ b/include/asm-x86/kmap_types_32.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef _ASM_KMAP_TYPES_H | ||
2 | #define _ASM_KMAP_TYPES_H | ||
3 | |||
4 | |||
5 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
6 | # define D(n) __KM_FENCE_##n , | ||
7 | #else | ||
8 | # define D(n) | ||
9 | #endif | ||
10 | |||
11 | enum km_type { | ||
12 | D(0) KM_BOUNCE_READ, | ||
13 | D(1) KM_SKB_SUNRPC_DATA, | ||
14 | D(2) KM_SKB_DATA_SOFTIRQ, | ||
15 | D(3) KM_USER0, | ||
16 | D(4) KM_USER1, | ||
17 | D(5) KM_BIO_SRC_IRQ, | ||
18 | D(6) KM_BIO_DST_IRQ, | ||
19 | D(7) KM_PTE0, | ||
20 | D(8) KM_PTE1, | ||
21 | D(9) KM_IRQ0, | ||
22 | D(10) KM_IRQ1, | ||
23 | D(11) KM_SOFTIRQ0, | ||
24 | D(12) KM_SOFTIRQ1, | ||
25 | D(13) KM_TYPE_NR | ||
26 | }; | ||
27 | |||
28 | #undef D | ||
29 | |||
30 | #endif | ||
diff --git a/include/asm-x86/kmap_types_64.h b/include/asm-x86/kmap_types_64.h new file mode 100644 index 000000000000..7486338c6cea --- /dev/null +++ b/include/asm-x86/kmap_types_64.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _ASM_KMAP_TYPES_H | ||
2 | #define _ASM_KMAP_TYPES_H | ||
3 | |||
4 | enum km_type { | ||
5 | KM_BOUNCE_READ, | ||
6 | KM_SKB_SUNRPC_DATA, | ||
7 | KM_SKB_DATA_SOFTIRQ, | ||
8 | KM_USER0, | ||
9 | KM_USER1, | ||
10 | KM_BIO_SRC_IRQ, | ||
11 | KM_BIO_DST_IRQ, | ||
12 | KM_IRQ0, | ||
13 | KM_IRQ1, | ||
14 | KM_SOFTIRQ0, | ||
15 | KM_SOFTIRQ1, | ||
16 | KM_TYPE_NR | ||
17 | }; | ||
18 | |||
19 | #endif | ||
diff --git a/include/asm-x86/kprobes.h b/include/asm-x86/kprobes.h new file mode 100644 index 000000000000..b7bbd25ba2a6 --- /dev/null +++ b/include/asm-x86/kprobes.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "kprobes_32.h" | ||
3 | #else | ||
4 | # include "kprobes_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/kprobes_32.h b/include/asm-x86/kprobes_32.h new file mode 100644 index 000000000000..06f7303c30ca --- /dev/null +++ b/include/asm-x86/kprobes_32.h | |||
@@ -0,0 +1,92 @@ | |||
1 | #ifndef _ASM_KPROBES_H | ||
2 | #define _ASM_KPROBES_H | ||
3 | /* | ||
4 | * Kernel Probes (KProbes) | ||
5 | * include/asm-i386/kprobes.h | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | * | ||
21 | * Copyright (C) IBM Corporation, 2002, 2004 | ||
22 | * | ||
23 | * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel | ||
24 | * Probes initial implementation ( includes suggestions from | ||
25 | * Rusty Russell). | ||
26 | */ | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/ptrace.h> | ||
29 | |||
30 | #define __ARCH_WANT_KPROBES_INSN_SLOT | ||
31 | |||
32 | struct kprobe; | ||
33 | struct pt_regs; | ||
34 | |||
35 | typedef u8 kprobe_opcode_t; | ||
36 | #define BREAKPOINT_INSTRUCTION 0xcc | ||
37 | #define RELATIVEJUMP_INSTRUCTION 0xe9 | ||
38 | #define MAX_INSN_SIZE 16 | ||
39 | #define MAX_STACK_SIZE 64 | ||
40 | #define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \ | ||
41 | (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \ | ||
42 | ? (MAX_STACK_SIZE) \ | ||
43 | : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) | ||
44 | |||
45 | #define ARCH_SUPPORTS_KRETPROBES | ||
46 | #define ARCH_INACTIVE_KPROBE_COUNT 0 | ||
47 | #define flush_insn_slot(p) do { } while (0) | ||
48 | |||
49 | void arch_remove_kprobe(struct kprobe *p); | ||
50 | void kretprobe_trampoline(void); | ||
51 | |||
52 | /* Architecture specific copy of original instruction*/ | ||
53 | struct arch_specific_insn { | ||
54 | /* copy of the original instruction */ | ||
55 | kprobe_opcode_t *insn; | ||
56 | /* | ||
57 | * If this flag is not 0, this kprobe can be boost when its | ||
58 | * post_handler and break_handler is not set. | ||
59 | */ | ||
60 | int boostable; | ||
61 | }; | ||
62 | |||
63 | struct prev_kprobe { | ||
64 | struct kprobe *kp; | ||
65 | unsigned long status; | ||
66 | unsigned long old_eflags; | ||
67 | unsigned long saved_eflags; | ||
68 | }; | ||
69 | |||
70 | /* per-cpu kprobe control block */ | ||
71 | struct kprobe_ctlblk { | ||
72 | unsigned long kprobe_status; | ||
73 | unsigned long kprobe_old_eflags; | ||
74 | unsigned long kprobe_saved_eflags; | ||
75 | long *jprobe_saved_esp; | ||
76 | struct pt_regs jprobe_saved_regs; | ||
77 | kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE]; | ||
78 | struct prev_kprobe prev_kprobe; | ||
79 | }; | ||
80 | |||
81 | /* trap3/1 are intr gates for kprobes. So, restore the status of IF, | ||
82 | * if necessary, before executing the original int3/1 (trap) handler. | ||
83 | */ | ||
84 | static inline void restore_interrupts(struct pt_regs *regs) | ||
85 | { | ||
86 | if (regs->eflags & IF_MASK) | ||
87 | local_irq_enable(); | ||
88 | } | ||
89 | |||
90 | extern int kprobe_exceptions_notify(struct notifier_block *self, | ||
91 | unsigned long val, void *data); | ||
92 | #endif /* _ASM_KPROBES_H */ | ||
diff --git a/include/asm-x86/kprobes_64.h b/include/asm-x86/kprobes_64.h new file mode 100644 index 000000000000..7db825403e01 --- /dev/null +++ b/include/asm-x86/kprobes_64.h | |||
@@ -0,0 +1,90 @@ | |||
1 | #ifndef _ASM_KPROBES_H | ||
2 | #define _ASM_KPROBES_H | ||
3 | /* | ||
4 | * Kernel Probes (KProbes) | ||
5 | * include/asm-x86_64/kprobes.h | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | * | ||
21 | * Copyright (C) IBM Corporation, 2002, 2004 | ||
22 | * | ||
23 | * 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston | ||
24 | * kenistoj@us.ibm.com adopted from i386. | ||
25 | */ | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/ptrace.h> | ||
28 | #include <linux/percpu.h> | ||
29 | |||
30 | #define __ARCH_WANT_KPROBES_INSN_SLOT | ||
31 | |||
32 | struct pt_regs; | ||
33 | struct kprobe; | ||
34 | |||
35 | typedef u8 kprobe_opcode_t; | ||
36 | #define BREAKPOINT_INSTRUCTION 0xcc | ||
37 | #define MAX_INSN_SIZE 15 | ||
38 | #define MAX_STACK_SIZE 64 | ||
39 | #define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \ | ||
40 | (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \ | ||
41 | ? (MAX_STACK_SIZE) \ | ||
42 | : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) | ||
43 | |||
44 | #define ARCH_SUPPORTS_KRETPROBES | ||
45 | #define ARCH_INACTIVE_KPROBE_COUNT 1 | ||
46 | |||
47 | void kretprobe_trampoline(void); | ||
48 | extern void arch_remove_kprobe(struct kprobe *p); | ||
49 | #define flush_insn_slot(p) do { } while (0) | ||
50 | |||
51 | /* Architecture specific copy of original instruction*/ | ||
52 | struct arch_specific_insn { | ||
53 | /* copy of the original instruction */ | ||
54 | kprobe_opcode_t *insn; | ||
55 | }; | ||
56 | |||
57 | struct prev_kprobe { | ||
58 | struct kprobe *kp; | ||
59 | unsigned long status; | ||
60 | unsigned long old_rflags; | ||
61 | unsigned long saved_rflags; | ||
62 | }; | ||
63 | |||
64 | /* per-cpu kprobe control block */ | ||
65 | struct kprobe_ctlblk { | ||
66 | unsigned long kprobe_status; | ||
67 | unsigned long kprobe_old_rflags; | ||
68 | unsigned long kprobe_saved_rflags; | ||
69 | long *jprobe_saved_rsp; | ||
70 | struct pt_regs jprobe_saved_regs; | ||
71 | kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE]; | ||
72 | struct prev_kprobe prev_kprobe; | ||
73 | }; | ||
74 | |||
75 | /* trap3/1 are intr gates for kprobes. So, restore the status of IF, | ||
76 | * if necessary, before executing the original int3/1 (trap) handler. | ||
77 | */ | ||
78 | static inline void restore_interrupts(struct pt_regs *regs) | ||
79 | { | ||
80 | if (regs->eflags & IF_MASK) | ||
81 | local_irq_enable(); | ||
82 | } | ||
83 | |||
84 | extern int post_kprobe_handler(struct pt_regs *regs); | ||
85 | extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr); | ||
86 | extern int kprobe_handler(struct pt_regs *regs); | ||
87 | |||
88 | extern int kprobe_exceptions_notify(struct notifier_block *self, | ||
89 | unsigned long val, void *data); | ||
90 | #endif /* _ASM_KPROBES_H */ | ||
diff --git a/include/asm-x86/ldt.h b/include/asm-x86/ldt.h new file mode 100644 index 000000000000..3d9cc20d2ba4 --- /dev/null +++ b/include/asm-x86/ldt.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ldt_32.h" | ||
4 | # else | ||
5 | # include "ldt_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ldt_32.h" | ||
10 | # else | ||
11 | # include "ldt_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ldt_32.h b/include/asm-x86/ldt_32.h new file mode 100644 index 000000000000..e9d3de1dee6c --- /dev/null +++ b/include/asm-x86/ldt_32.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * ldt.h | ||
3 | * | ||
4 | * Definitions of structures used with the modify_ldt system call. | ||
5 | */ | ||
6 | #ifndef _LINUX_LDT_H | ||
7 | #define _LINUX_LDT_H | ||
8 | |||
9 | /* Maximum number of LDT entries supported. */ | ||
10 | #define LDT_ENTRIES 8192 | ||
11 | /* The size of each LDT entry. */ | ||
12 | #define LDT_ENTRY_SIZE 8 | ||
13 | |||
14 | #ifndef __ASSEMBLY__ | ||
15 | struct user_desc { | ||
16 | unsigned int entry_number; | ||
17 | unsigned long base_addr; | ||
18 | unsigned int limit; | ||
19 | unsigned int seg_32bit:1; | ||
20 | unsigned int contents:2; | ||
21 | unsigned int read_exec_only:1; | ||
22 | unsigned int limit_in_pages:1; | ||
23 | unsigned int seg_not_present:1; | ||
24 | unsigned int useable:1; | ||
25 | }; | ||
26 | |||
27 | #define MODIFY_LDT_CONTENTS_DATA 0 | ||
28 | #define MODIFY_LDT_CONTENTS_STACK 1 | ||
29 | #define MODIFY_LDT_CONTENTS_CODE 2 | ||
30 | |||
31 | #endif /* !__ASSEMBLY__ */ | ||
32 | #endif | ||
diff --git a/include/asm-x86/ldt_64.h b/include/asm-x86/ldt_64.h new file mode 100644 index 000000000000..9ef647b890d2 --- /dev/null +++ b/include/asm-x86/ldt_64.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * ldt.h | ||
3 | * | ||
4 | * Definitions of structures used with the modify_ldt system call. | ||
5 | */ | ||
6 | #ifndef _LINUX_LDT_H | ||
7 | #define _LINUX_LDT_H | ||
8 | |||
9 | /* Maximum number of LDT entries supported. */ | ||
10 | #define LDT_ENTRIES 8192 | ||
11 | /* The size of each LDT entry. */ | ||
12 | #define LDT_ENTRY_SIZE 8 | ||
13 | |||
14 | #ifndef __ASSEMBLY__ | ||
15 | /* Note on 64bit base and limit is ignored and you cannot set | ||
16 | DS/ES/CS not to the default values if you still want to do syscalls. This | ||
17 | call is more for 32bit mode therefore. */ | ||
18 | struct user_desc { | ||
19 | unsigned int entry_number; | ||
20 | unsigned int base_addr; | ||
21 | unsigned int limit; | ||
22 | unsigned int seg_32bit:1; | ||
23 | unsigned int contents:2; | ||
24 | unsigned int read_exec_only:1; | ||
25 | unsigned int limit_in_pages:1; | ||
26 | unsigned int seg_not_present:1; | ||
27 | unsigned int useable:1; | ||
28 | unsigned int lm:1; | ||
29 | }; | ||
30 | |||
31 | #define MODIFY_LDT_CONTENTS_DATA 0 | ||
32 | #define MODIFY_LDT_CONTENTS_STACK 1 | ||
33 | #define MODIFY_LDT_CONTENTS_CODE 2 | ||
34 | |||
35 | #endif /* !__ASSEMBLY__ */ | ||
36 | #endif | ||
diff --git a/include/asm-x86/linkage.h b/include/asm-x86/linkage.h new file mode 100644 index 000000000000..94b257fa8701 --- /dev/null +++ b/include/asm-x86/linkage.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "linkage_32.h" | ||
3 | #else | ||
4 | # include "linkage_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/linkage_32.h b/include/asm-x86/linkage_32.h new file mode 100644 index 000000000000..f4a6ebac0247 --- /dev/null +++ b/include/asm-x86/linkage_32.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef __ASM_LINKAGE_H | ||
2 | #define __ASM_LINKAGE_H | ||
3 | |||
4 | #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) | ||
5 | #define FASTCALL(x) x __attribute__((regparm(3))) | ||
6 | #define fastcall __attribute__((regparm(3))) | ||
7 | |||
8 | #define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret)) | ||
9 | |||
10 | #ifdef CONFIG_X86_ALIGNMENT_16 | ||
11 | #define __ALIGN .align 16,0x90 | ||
12 | #define __ALIGN_STR ".align 16,0x90" | ||
13 | #endif | ||
14 | |||
15 | #endif | ||
diff --git a/include/asm-x86/linkage_64.h b/include/asm-x86/linkage_64.h new file mode 100644 index 000000000000..b5f39d0189ce --- /dev/null +++ b/include/asm-x86/linkage_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_LINKAGE_H | ||
2 | #define __ASM_LINKAGE_H | ||
3 | |||
4 | #define __ALIGN .p2align 4,,15 | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/local.h b/include/asm-x86/local.h new file mode 100644 index 000000000000..c7a1b1c66c96 --- /dev/null +++ b/include/asm-x86/local.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "local_32.h" | ||
3 | #else | ||
4 | # include "local_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/local_32.h b/include/asm-x86/local_32.h new file mode 100644 index 000000000000..6e85975b9ed2 --- /dev/null +++ b/include/asm-x86/local_32.h | |||
@@ -0,0 +1,233 @@ | |||
1 | #ifndef _ARCH_I386_LOCAL_H | ||
2 | #define _ARCH_I386_LOCAL_H | ||
3 | |||
4 | #include <linux/percpu.h> | ||
5 | #include <asm/system.h> | ||
6 | #include <asm/atomic.h> | ||
7 | |||
8 | typedef struct | ||
9 | { | ||
10 | atomic_long_t a; | ||
11 | } local_t; | ||
12 | |||
13 | #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) } | ||
14 | |||
15 | #define local_read(l) atomic_long_read(&(l)->a) | ||
16 | #define local_set(l,i) atomic_long_set(&(l)->a, (i)) | ||
17 | |||
18 | static __inline__ void local_inc(local_t *l) | ||
19 | { | ||
20 | __asm__ __volatile__( | ||
21 | "incl %0" | ||
22 | :"+m" (l->a.counter)); | ||
23 | } | ||
24 | |||
25 | static __inline__ void local_dec(local_t *l) | ||
26 | { | ||
27 | __asm__ __volatile__( | ||
28 | "decl %0" | ||
29 | :"+m" (l->a.counter)); | ||
30 | } | ||
31 | |||
32 | static __inline__ void local_add(long i, local_t *l) | ||
33 | { | ||
34 | __asm__ __volatile__( | ||
35 | "addl %1,%0" | ||
36 | :"+m" (l->a.counter) | ||
37 | :"ir" (i)); | ||
38 | } | ||
39 | |||
40 | static __inline__ void local_sub(long i, local_t *l) | ||
41 | { | ||
42 | __asm__ __volatile__( | ||
43 | "subl %1,%0" | ||
44 | :"+m" (l->a.counter) | ||
45 | :"ir" (i)); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * local_sub_and_test - subtract value from variable and test result | ||
50 | * @i: integer value to subtract | ||
51 | * @l: pointer of type local_t | ||
52 | * | ||
53 | * Atomically subtracts @i from @l and returns | ||
54 | * true if the result is zero, or false for all | ||
55 | * other cases. | ||
56 | */ | ||
57 | static __inline__ int local_sub_and_test(long i, local_t *l) | ||
58 | { | ||
59 | unsigned char c; | ||
60 | |||
61 | __asm__ __volatile__( | ||
62 | "subl %2,%0; sete %1" | ||
63 | :"+m" (l->a.counter), "=qm" (c) | ||
64 | :"ir" (i) : "memory"); | ||
65 | return c; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * local_dec_and_test - decrement and test | ||
70 | * @l: pointer of type local_t | ||
71 | * | ||
72 | * Atomically decrements @l by 1 and | ||
73 | * returns true if the result is 0, or false for all other | ||
74 | * cases. | ||
75 | */ | ||
76 | static __inline__ int local_dec_and_test(local_t *l) | ||
77 | { | ||
78 | unsigned char c; | ||
79 | |||
80 | __asm__ __volatile__( | ||
81 | "decl %0; sete %1" | ||
82 | :"+m" (l->a.counter), "=qm" (c) | ||
83 | : : "memory"); | ||
84 | return c != 0; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * local_inc_and_test - increment and test | ||
89 | * @l: pointer of type local_t | ||
90 | * | ||
91 | * Atomically increments @l by 1 | ||
92 | * and returns true if the result is zero, or false for all | ||
93 | * other cases. | ||
94 | */ | ||
95 | static __inline__ int local_inc_and_test(local_t *l) | ||
96 | { | ||
97 | unsigned char c; | ||
98 | |||
99 | __asm__ __volatile__( | ||
100 | "incl %0; sete %1" | ||
101 | :"+m" (l->a.counter), "=qm" (c) | ||
102 | : : "memory"); | ||
103 | return c != 0; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * local_add_negative - add and test if negative | ||
108 | * @l: pointer of type local_t | ||
109 | * @i: integer value to add | ||
110 | * | ||
111 | * Atomically adds @i to @l and returns true | ||
112 | * if the result is negative, or false when | ||
113 | * result is greater than or equal to zero. | ||
114 | */ | ||
115 | static __inline__ int local_add_negative(long i, local_t *l) | ||
116 | { | ||
117 | unsigned char c; | ||
118 | |||
119 | __asm__ __volatile__( | ||
120 | "addl %2,%0; sets %1" | ||
121 | :"+m" (l->a.counter), "=qm" (c) | ||
122 | :"ir" (i) : "memory"); | ||
123 | return c; | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * local_add_return - add and return | ||
128 | * @l: pointer of type local_t | ||
129 | * @i: integer value to add | ||
130 | * | ||
131 | * Atomically adds @i to @l and returns @i + @l | ||
132 | */ | ||
133 | static __inline__ long local_add_return(long i, local_t *l) | ||
134 | { | ||
135 | long __i; | ||
136 | #ifdef CONFIG_M386 | ||
137 | unsigned long flags; | ||
138 | if(unlikely(boot_cpu_data.x86 <= 3)) | ||
139 | goto no_xadd; | ||
140 | #endif | ||
141 | /* Modern 486+ processor */ | ||
142 | __i = i; | ||
143 | __asm__ __volatile__( | ||
144 | "xaddl %0, %1;" | ||
145 | :"+r" (i), "+m" (l->a.counter) | ||
146 | : : "memory"); | ||
147 | return i + __i; | ||
148 | |||
149 | #ifdef CONFIG_M386 | ||
150 | no_xadd: /* Legacy 386 processor */ | ||
151 | local_irq_save(flags); | ||
152 | __i = local_read(l); | ||
153 | local_set(l, i + __i); | ||
154 | local_irq_restore(flags); | ||
155 | return i + __i; | ||
156 | #endif | ||
157 | } | ||
158 | |||
159 | static __inline__ long local_sub_return(long i, local_t *l) | ||
160 | { | ||
161 | return local_add_return(-i,l); | ||
162 | } | ||
163 | |||
164 | #define local_inc_return(l) (local_add_return(1,l)) | ||
165 | #define local_dec_return(l) (local_sub_return(1,l)) | ||
166 | |||
167 | #define local_cmpxchg(l, o, n) \ | ||
168 | (cmpxchg_local(&((l)->a.counter), (o), (n))) | ||
169 | /* Always has a lock prefix */ | ||
170 | #define local_xchg(l, n) (xchg(&((l)->a.counter), (n))) | ||
171 | |||
172 | /** | ||
173 | * local_add_unless - add unless the number is a given value | ||
174 | * @l: pointer of type local_t | ||
175 | * @a: the amount to add to l... | ||
176 | * @u: ...unless l is equal to u. | ||
177 | * | ||
178 | * Atomically adds @a to @l, so long as it was not @u. | ||
179 | * Returns non-zero if @l was not @u, and zero otherwise. | ||
180 | */ | ||
181 | #define local_add_unless(l, a, u) \ | ||
182 | ({ \ | ||
183 | long c, old; \ | ||
184 | c = local_read(l); \ | ||
185 | for (;;) { \ | ||
186 | if (unlikely(c == (u))) \ | ||
187 | break; \ | ||
188 | old = local_cmpxchg((l), c, c + (a)); \ | ||
189 | if (likely(old == c)) \ | ||
190 | break; \ | ||
191 | c = old; \ | ||
192 | } \ | ||
193 | c != (u); \ | ||
194 | }) | ||
195 | #define local_inc_not_zero(l) local_add_unless((l), 1, 0) | ||
196 | |||
197 | /* On x86, these are no better than the atomic variants. */ | ||
198 | #define __local_inc(l) local_inc(l) | ||
199 | #define __local_dec(l) local_dec(l) | ||
200 | #define __local_add(i,l) local_add((i),(l)) | ||
201 | #define __local_sub(i,l) local_sub((i),(l)) | ||
202 | |||
203 | /* Use these for per-cpu local_t variables: on some archs they are | ||
204 | * much more efficient than these naive implementations. Note they take | ||
205 | * a variable, not an address. | ||
206 | */ | ||
207 | |||
208 | /* Need to disable preemption for the cpu local counters otherwise we could | ||
209 | still access a variable of a previous CPU in a non atomic way. */ | ||
210 | #define cpu_local_wrap_v(l) \ | ||
211 | ({ local_t res__; \ | ||
212 | preempt_disable(); \ | ||
213 | res__ = (l); \ | ||
214 | preempt_enable(); \ | ||
215 | res__; }) | ||
216 | #define cpu_local_wrap(l) \ | ||
217 | ({ preempt_disable(); \ | ||
218 | l; \ | ||
219 | preempt_enable(); }) \ | ||
220 | |||
221 | #define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l))) | ||
222 | #define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i))) | ||
223 | #define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l))) | ||
224 | #define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l))) | ||
225 | #define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l))) | ||
226 | #define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l))) | ||
227 | |||
228 | #define __cpu_local_inc(l) cpu_local_inc(l) | ||
229 | #define __cpu_local_dec(l) cpu_local_dec(l) | ||
230 | #define __cpu_local_add(i, l) cpu_local_add((i), (l)) | ||
231 | #define __cpu_local_sub(i, l) cpu_local_sub((i), (l)) | ||
232 | |||
233 | #endif /* _ARCH_I386_LOCAL_H */ | ||
diff --git a/include/asm-x86/local_64.h b/include/asm-x86/local_64.h new file mode 100644 index 000000000000..e87492bb0693 --- /dev/null +++ b/include/asm-x86/local_64.h | |||
@@ -0,0 +1,222 @@ | |||
1 | #ifndef _ARCH_X8664_LOCAL_H | ||
2 | #define _ARCH_X8664_LOCAL_H | ||
3 | |||
4 | #include <linux/percpu.h> | ||
5 | #include <asm/atomic.h> | ||
6 | |||
7 | typedef struct | ||
8 | { | ||
9 | atomic_long_t a; | ||
10 | } local_t; | ||
11 | |||
12 | #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) } | ||
13 | |||
14 | #define local_read(l) atomic_long_read(&(l)->a) | ||
15 | #define local_set(l,i) atomic_long_set(&(l)->a, (i)) | ||
16 | |||
17 | static inline void local_inc(local_t *l) | ||
18 | { | ||
19 | __asm__ __volatile__( | ||
20 | "incq %0" | ||
21 | :"=m" (l->a.counter) | ||
22 | :"m" (l->a.counter)); | ||
23 | } | ||
24 | |||
25 | static inline void local_dec(local_t *l) | ||
26 | { | ||
27 | __asm__ __volatile__( | ||
28 | "decq %0" | ||
29 | :"=m" (l->a.counter) | ||
30 | :"m" (l->a.counter)); | ||
31 | } | ||
32 | |||
33 | static inline void local_add(long i, local_t *l) | ||
34 | { | ||
35 | __asm__ __volatile__( | ||
36 | "addq %1,%0" | ||
37 | :"=m" (l->a.counter) | ||
38 | :"ir" (i), "m" (l->a.counter)); | ||
39 | } | ||
40 | |||
41 | static inline void local_sub(long i, local_t *l) | ||
42 | { | ||
43 | __asm__ __volatile__( | ||
44 | "subq %1,%0" | ||
45 | :"=m" (l->a.counter) | ||
46 | :"ir" (i), "m" (l->a.counter)); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * local_sub_and_test - subtract value from variable and test result | ||
51 | * @i: integer value to subtract | ||
52 | * @l: pointer to type local_t | ||
53 | * | ||
54 | * Atomically subtracts @i from @l and returns | ||
55 | * true if the result is zero, or false for all | ||
56 | * other cases. | ||
57 | */ | ||
58 | static __inline__ int local_sub_and_test(long i, local_t *l) | ||
59 | { | ||
60 | unsigned char c; | ||
61 | |||
62 | __asm__ __volatile__( | ||
63 | "subq %2,%0; sete %1" | ||
64 | :"=m" (l->a.counter), "=qm" (c) | ||
65 | :"ir" (i), "m" (l->a.counter) : "memory"); | ||
66 | return c; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * local_dec_and_test - decrement and test | ||
71 | * @l: pointer to type local_t | ||
72 | * | ||
73 | * Atomically decrements @l by 1 and | ||
74 | * returns true if the result is 0, or false for all other | ||
75 | * cases. | ||
76 | */ | ||
77 | static __inline__ int local_dec_and_test(local_t *l) | ||
78 | { | ||
79 | unsigned char c; | ||
80 | |||
81 | __asm__ __volatile__( | ||
82 | "decq %0; sete %1" | ||
83 | :"=m" (l->a.counter), "=qm" (c) | ||
84 | :"m" (l->a.counter) : "memory"); | ||
85 | return c != 0; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * local_inc_and_test - increment and test | ||
90 | * @l: pointer to type local_t | ||
91 | * | ||
92 | * Atomically increments @l by 1 | ||
93 | * and returns true if the result is zero, or false for all | ||
94 | * other cases. | ||
95 | */ | ||
96 | static __inline__ int local_inc_and_test(local_t *l) | ||
97 | { | ||
98 | unsigned char c; | ||
99 | |||
100 | __asm__ __volatile__( | ||
101 | "incq %0; sete %1" | ||
102 | :"=m" (l->a.counter), "=qm" (c) | ||
103 | :"m" (l->a.counter) : "memory"); | ||
104 | return c != 0; | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * local_add_negative - add and test if negative | ||
109 | * @i: integer value to add | ||
110 | * @l: pointer to type local_t | ||
111 | * | ||
112 | * Atomically adds @i to @l and returns true | ||
113 | * if the result is negative, or false when | ||
114 | * result is greater than or equal to zero. | ||
115 | */ | ||
116 | static __inline__ int local_add_negative(long i, local_t *l) | ||
117 | { | ||
118 | unsigned char c; | ||
119 | |||
120 | __asm__ __volatile__( | ||
121 | "addq %2,%0; sets %1" | ||
122 | :"=m" (l->a.counter), "=qm" (c) | ||
123 | :"ir" (i), "m" (l->a.counter) : "memory"); | ||
124 | return c; | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * local_add_return - add and return | ||
129 | * @i: integer value to add | ||
130 | * @l: pointer to type local_t | ||
131 | * | ||
132 | * Atomically adds @i to @l and returns @i + @l | ||
133 | */ | ||
134 | static __inline__ long local_add_return(long i, local_t *l) | ||
135 | { | ||
136 | long __i = i; | ||
137 | __asm__ __volatile__( | ||
138 | "xaddq %0, %1;" | ||
139 | :"+r" (i), "+m" (l->a.counter) | ||
140 | : : "memory"); | ||
141 | return i + __i; | ||
142 | } | ||
143 | |||
144 | static __inline__ long local_sub_return(long i, local_t *l) | ||
145 | { | ||
146 | return local_add_return(-i,l); | ||
147 | } | ||
148 | |||
149 | #define local_inc_return(l) (local_add_return(1,l)) | ||
150 | #define local_dec_return(l) (local_sub_return(1,l)) | ||
151 | |||
152 | #define local_cmpxchg(l, o, n) \ | ||
153 | (cmpxchg_local(&((l)->a.counter), (o), (n))) | ||
154 | /* Always has a lock prefix */ | ||
155 | #define local_xchg(l, n) (xchg(&((l)->a.counter), (n))) | ||
156 | |||
157 | /** | ||
158 | * atomic_up_add_unless - add unless the number is a given value | ||
159 | * @l: pointer of type local_t | ||
160 | * @a: the amount to add to l... | ||
161 | * @u: ...unless l is equal to u. | ||
162 | * | ||
163 | * Atomically adds @a to @l, so long as it was not @u. | ||
164 | * Returns non-zero if @l was not @u, and zero otherwise. | ||
165 | */ | ||
166 | #define local_add_unless(l, a, u) \ | ||
167 | ({ \ | ||
168 | long c, old; \ | ||
169 | c = local_read(l); \ | ||
170 | for (;;) { \ | ||
171 | if (unlikely(c == (u))) \ | ||
172 | break; \ | ||
173 | old = local_cmpxchg((l), c, c + (a)); \ | ||
174 | if (likely(old == c)) \ | ||
175 | break; \ | ||
176 | c = old; \ | ||
177 | } \ | ||
178 | c != (u); \ | ||
179 | }) | ||
180 | #define local_inc_not_zero(l) local_add_unless((l), 1, 0) | ||
181 | |||
182 | /* On x86-64 these are better than the atomic variants on SMP kernels | ||
183 | because they dont use a lock prefix. */ | ||
184 | #define __local_inc(l) local_inc(l) | ||
185 | #define __local_dec(l) local_dec(l) | ||
186 | #define __local_add(i,l) local_add((i),(l)) | ||
187 | #define __local_sub(i,l) local_sub((i),(l)) | ||
188 | |||
189 | /* Use these for per-cpu local_t variables: on some archs they are | ||
190 | * much more efficient than these naive implementations. Note they take | ||
191 | * a variable, not an address. | ||
192 | * | ||
193 | * This could be done better if we moved the per cpu data directly | ||
194 | * after GS. | ||
195 | */ | ||
196 | |||
197 | /* Need to disable preemption for the cpu local counters otherwise we could | ||
198 | still access a variable of a previous CPU in a non atomic way. */ | ||
199 | #define cpu_local_wrap_v(l) \ | ||
200 | ({ local_t res__; \ | ||
201 | preempt_disable(); \ | ||
202 | res__ = (l); \ | ||
203 | preempt_enable(); \ | ||
204 | res__; }) | ||
205 | #define cpu_local_wrap(l) \ | ||
206 | ({ preempt_disable(); \ | ||
207 | l; \ | ||
208 | preempt_enable(); }) \ | ||
209 | |||
210 | #define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l))) | ||
211 | #define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i))) | ||
212 | #define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l))) | ||
213 | #define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l))) | ||
214 | #define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l))) | ||
215 | #define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l))) | ||
216 | |||
217 | #define __cpu_local_inc(l) cpu_local_inc(l) | ||
218 | #define __cpu_local_dec(l) cpu_local_dec(l) | ||
219 | #define __cpu_local_add(i, l) cpu_local_add((i), (l)) | ||
220 | #define __cpu_local_sub(i, l) cpu_local_sub((i), (l)) | ||
221 | |||
222 | #endif /* _ARCH_X8664_LOCAL_H */ | ||
diff --git a/include/asm-x86/mach-bigsmp/mach_apic.h b/include/asm-x86/mach-bigsmp/mach_apic.h new file mode 100644 index 000000000000..ebd319f838ab --- /dev/null +++ b/include/asm-x86/mach-bigsmp/mach_apic.h | |||
@@ -0,0 +1,158 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | |||
5 | extern u8 bios_cpu_apicid[]; | ||
6 | |||
7 | #define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu]) | ||
8 | #define esr_disable (1) | ||
9 | |||
10 | static inline int apic_id_registered(void) | ||
11 | { | ||
12 | return (1); | ||
13 | } | ||
14 | |||
15 | /* Round robin the irqs amoung the online cpus */ | ||
16 | static inline cpumask_t target_cpus(void) | ||
17 | { | ||
18 | static unsigned long cpu = NR_CPUS; | ||
19 | do { | ||
20 | if (cpu >= NR_CPUS) | ||
21 | cpu = first_cpu(cpu_online_map); | ||
22 | else | ||
23 | cpu = next_cpu(cpu, cpu_online_map); | ||
24 | } while (cpu >= NR_CPUS); | ||
25 | return cpumask_of_cpu(cpu); | ||
26 | } | ||
27 | |||
28 | #undef APIC_DEST_LOGICAL | ||
29 | #define APIC_DEST_LOGICAL 0 | ||
30 | #define TARGET_CPUS (target_cpus()) | ||
31 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
32 | #define INT_DELIVERY_MODE (dest_Fixed) | ||
33 | #define INT_DEST_MODE (0) /* phys delivery to target proc */ | ||
34 | #define NO_BALANCE_IRQ (0) | ||
35 | #define WAKE_SECONDARY_VIA_INIT | ||
36 | |||
37 | |||
38 | static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) | ||
39 | { | ||
40 | return (0); | ||
41 | } | ||
42 | |||
43 | static inline unsigned long check_apicid_present(int bit) | ||
44 | { | ||
45 | return (1); | ||
46 | } | ||
47 | |||
48 | static inline unsigned long calculate_ldr(int cpu) | ||
49 | { | ||
50 | unsigned long val, id; | ||
51 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; | ||
52 | id = xapic_phys_to_log_apicid(cpu); | ||
53 | val |= SET_APIC_LOGICAL_ID(id); | ||
54 | return val; | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * Set up the logical destination ID. | ||
59 | * | ||
60 | * Intel recommends to set DFR, LDR and TPR before enabling | ||
61 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
62 | * document number 292116). So here it goes... | ||
63 | */ | ||
64 | static inline void init_apic_ldr(void) | ||
65 | { | ||
66 | unsigned long val; | ||
67 | int cpu = smp_processor_id(); | ||
68 | |||
69 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); | ||
70 | val = calculate_ldr(cpu); | ||
71 | apic_write_around(APIC_LDR, val); | ||
72 | } | ||
73 | |||
74 | static inline void setup_apic_routing(void) | ||
75 | { | ||
76 | printk("Enabling APIC mode: %s. Using %d I/O APICs\n", | ||
77 | "Physflat", nr_ioapics); | ||
78 | } | ||
79 | |||
80 | static inline int multi_timer_check(int apic, int irq) | ||
81 | { | ||
82 | return (0); | ||
83 | } | ||
84 | |||
85 | static inline int apicid_to_node(int logical_apicid) | ||
86 | { | ||
87 | return (0); | ||
88 | } | ||
89 | |||
90 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
91 | { | ||
92 | if (mps_cpu < NR_CPUS) | ||
93 | return (int) bios_cpu_apicid[mps_cpu]; | ||
94 | |||
95 | return BAD_APICID; | ||
96 | } | ||
97 | |||
98 | static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) | ||
99 | { | ||
100 | return physid_mask_of_physid(phys_apicid); | ||
101 | } | ||
102 | |||
103 | extern u8 cpu_2_logical_apicid[]; | ||
104 | /* Mapping from cpu number to logical apicid */ | ||
105 | static inline int cpu_to_logical_apicid(int cpu) | ||
106 | { | ||
107 | if (cpu >= NR_CPUS) | ||
108 | return BAD_APICID; | ||
109 | return cpu_physical_id(cpu); | ||
110 | } | ||
111 | |||
112 | static inline int mpc_apic_id(struct mpc_config_processor *m, | ||
113 | struct mpc_config_translation *translation_record) | ||
114 | { | ||
115 | printk("Processor #%d %ld:%ld APIC version %d\n", | ||
116 | m->mpc_apicid, | ||
117 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
118 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
119 | m->mpc_apicver); | ||
120 | return m->mpc_apicid; | ||
121 | } | ||
122 | |||
123 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) | ||
124 | { | ||
125 | /* For clustered we don't have a good way to do this yet - hack */ | ||
126 | return physids_promote(0xFFL); | ||
127 | } | ||
128 | |||
129 | static inline void setup_portio_remap(void) | ||
130 | { | ||
131 | } | ||
132 | |||
133 | static inline void enable_apic_mode(void) | ||
134 | { | ||
135 | } | ||
136 | |||
137 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) | ||
138 | { | ||
139 | return (1); | ||
140 | } | ||
141 | |||
142 | /* As we are using single CPU as destination, pick only one CPU here */ | ||
143 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
144 | { | ||
145 | int cpu; | ||
146 | int apicid; | ||
147 | |||
148 | cpu = first_cpu(cpumask); | ||
149 | apicid = cpu_to_logical_apicid(cpu); | ||
150 | return apicid; | ||
151 | } | ||
152 | |||
153 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
154 | { | ||
155 | return cpuid_apic >> index_msb; | ||
156 | } | ||
157 | |||
158 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-bigsmp/mach_apicdef.h b/include/asm-x86/mach-bigsmp/mach_apicdef.h new file mode 100644 index 000000000000..a58ab5a75c8c --- /dev/null +++ b/include/asm-x86/mach-bigsmp/mach_apicdef.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | #define APIC_ID_MASK (0xFF<<24) | ||
5 | |||
6 | static inline unsigned get_apic_id(unsigned long x) | ||
7 | { | ||
8 | return (((x)>>24)&0xFF); | ||
9 | } | ||
10 | |||
11 | #define GET_APIC_ID(x) get_apic_id(x) | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/mach-bigsmp/mach_ipi.h b/include/asm-x86/mach-bigsmp/mach_ipi.h new file mode 100644 index 000000000000..9404c535b7ec --- /dev/null +++ b/include/asm-x86/mach-bigsmp/mach_ipi.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | ||
2 | #define __ASM_MACH_IPI_H | ||
3 | |||
4 | void send_IPI_mask_sequence(cpumask_t mask, int vector); | ||
5 | |||
6 | static inline void send_IPI_mask(cpumask_t mask, int vector) | ||
7 | { | ||
8 | send_IPI_mask_sequence(mask, vector); | ||
9 | } | ||
10 | |||
11 | static inline void send_IPI_allbutself(int vector) | ||
12 | { | ||
13 | cpumask_t mask = cpu_online_map; | ||
14 | cpu_clear(smp_processor_id(), mask); | ||
15 | |||
16 | if (!cpus_empty(mask)) | ||
17 | send_IPI_mask(mask, vector); | ||
18 | } | ||
19 | |||
20 | static inline void send_IPI_all(int vector) | ||
21 | { | ||
22 | send_IPI_mask(cpu_online_map, vector); | ||
23 | } | ||
24 | |||
25 | #endif /* __ASM_MACH_IPI_H */ | ||
diff --git a/include/asm-x86/mach-bigsmp/mach_mpspec.h b/include/asm-x86/mach-bigsmp/mach_mpspec.h new file mode 100644 index 000000000000..6b5dadcf1d0e --- /dev/null +++ b/include/asm-x86/mach-bigsmp/mach_mpspec.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 256 | ||
5 | |||
6 | #define MAX_MP_BUSSES 32 | ||
7 | |||
8 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-default/apm.h b/include/asm-x86/mach-default/apm.h new file mode 100644 index 000000000000..1f730b8bd1fd --- /dev/null +++ b/include/asm-x86/mach-default/apm.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * include/asm-i386/mach-default/apm.h | ||
3 | * | ||
4 | * Machine specific APM BIOS functions for generic. | ||
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 | #ifdef APM_ZERO_SEGS | ||
12 | # define APM_DO_ZERO_SEGS \ | ||
13 | "pushl %%ds\n\t" \ | ||
14 | "pushl %%es\n\t" \ | ||
15 | "xorl %%edx, %%edx\n\t" \ | ||
16 | "mov %%dx, %%ds\n\t" \ | ||
17 | "mov %%dx, %%es\n\t" \ | ||
18 | "mov %%dx, %%fs\n\t" \ | ||
19 | "mov %%dx, %%gs\n\t" | ||
20 | # define APM_DO_POP_SEGS \ | ||
21 | "popl %%es\n\t" \ | ||
22 | "popl %%ds\n\t" | ||
23 | #else | ||
24 | # define APM_DO_ZERO_SEGS | ||
25 | # define APM_DO_POP_SEGS | ||
26 | #endif | ||
27 | |||
28 | static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in, | ||
29 | u32 *eax, u32 *ebx, u32 *ecx, | ||
30 | u32 *edx, u32 *esi) | ||
31 | { | ||
32 | /* | ||
33 | * N.B. We do NOT need a cld after the BIOS call | ||
34 | * because we always save and restore the flags. | ||
35 | */ | ||
36 | __asm__ __volatile__(APM_DO_ZERO_SEGS | ||
37 | "pushl %%edi\n\t" | ||
38 | "pushl %%ebp\n\t" | ||
39 | "lcall *%%cs:apm_bios_entry\n\t" | ||
40 | "setc %%al\n\t" | ||
41 | "popl %%ebp\n\t" | ||
42 | "popl %%edi\n\t" | ||
43 | APM_DO_POP_SEGS | ||
44 | : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx), | ||
45 | "=S" (*esi) | ||
46 | : "a" (func), "b" (ebx_in), "c" (ecx_in) | ||
47 | : "memory", "cc"); | ||
48 | } | ||
49 | |||
50 | static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in, | ||
51 | u32 ecx_in, u32 *eax) | ||
52 | { | ||
53 | int cx, dx, si; | ||
54 | u8 error; | ||
55 | |||
56 | /* | ||
57 | * N.B. We do NOT need a cld after the BIOS call | ||
58 | * because we always save and restore the flags. | ||
59 | */ | ||
60 | __asm__ __volatile__(APM_DO_ZERO_SEGS | ||
61 | "pushl %%edi\n\t" | ||
62 | "pushl %%ebp\n\t" | ||
63 | "lcall *%%cs:apm_bios_entry\n\t" | ||
64 | "setc %%bl\n\t" | ||
65 | "popl %%ebp\n\t" | ||
66 | "popl %%edi\n\t" | ||
67 | APM_DO_POP_SEGS | ||
68 | : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx), | ||
69 | "=S" (si) | ||
70 | : "a" (func), "b" (ebx_in), "c" (ecx_in) | ||
71 | : "memory", "cc"); | ||
72 | return error; | ||
73 | } | ||
74 | |||
75 | #endif /* _ASM_APM_H */ | ||
diff --git a/include/asm-x86/mach-default/bios_ebda.h b/include/asm-x86/mach-default/bios_ebda.h new file mode 100644 index 000000000000..9cbd9a668af8 --- /dev/null +++ b/include/asm-x86/mach-default/bios_ebda.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef _MACH_BIOS_EBDA_H | ||
2 | #define _MACH_BIOS_EBDA_H | ||
3 | |||
4 | /* | ||
5 | * there is a real-mode segmented pointer pointing to the | ||
6 | * 4K EBDA area at 0x40E. | ||
7 | */ | ||
8 | static inline unsigned int get_bios_ebda(void) | ||
9 | { | ||
10 | unsigned int address = *(unsigned short *)phys_to_virt(0x40E); | ||
11 | address <<= 4; | ||
12 | return address; /* 0 means none */ | ||
13 | } | ||
14 | |||
15 | #endif /* _MACH_BIOS_EBDA_H */ | ||
diff --git a/include/asm-x86/mach-default/do_timer.h b/include/asm-x86/mach-default/do_timer.h new file mode 100644 index 000000000000..23ecda0b28a0 --- /dev/null +++ b/include/asm-x86/mach-default/do_timer.h | |||
@@ -0,0 +1,16 @@ | |||
1 | /* defines for inline arch setup functions */ | ||
2 | #include <linux/clockchips.h> | ||
3 | |||
4 | #include <asm/i8259.h> | ||
5 | #include <asm/i8253.h> | ||
6 | |||
7 | /** | ||
8 | * do_timer_interrupt_hook - hook into timer tick | ||
9 | * | ||
10 | * Call the pit clock event handler. see asm/i8253.h | ||
11 | **/ | ||
12 | |||
13 | static inline void do_timer_interrupt_hook(void) | ||
14 | { | ||
15 | global_clock_event->event_handler(global_clock_event); | ||
16 | } | ||
diff --git a/include/asm-x86/mach-default/entry_arch.h b/include/asm-x86/mach-default/entry_arch.h new file mode 100644 index 000000000000..bc861469bdba --- /dev/null +++ b/include/asm-x86/mach-default/entry_arch.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * This file is designed to contain the BUILD_INTERRUPT specifications for | ||
3 | * all of the extra named interrupt vectors used by the architecture. | ||
4 | * Usually this is the Inter Process Interrupts (IPIs) | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * The following vectors are part of the Linux architecture, there | ||
9 | * is no hardware IRQ pin equivalent for them, they are triggered | ||
10 | * through the ICC by us (IPIs) | ||
11 | */ | ||
12 | #ifdef CONFIG_X86_SMP | ||
13 | BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) | ||
14 | BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR) | ||
15 | BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) | ||
16 | #endif | ||
17 | |||
18 | /* | ||
19 | * every pentium local APIC has two 'local interrupts', with a | ||
20 | * soft-definable vector attached to both interrupts, one of | ||
21 | * which is a timer interrupt, the other one is error counter | ||
22 | * overflow. Linux uses the local APIC timer interrupt to get | ||
23 | * a much simpler SMP time architecture: | ||
24 | */ | ||
25 | #ifdef CONFIG_X86_LOCAL_APIC | ||
26 | BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR) | ||
27 | BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR) | ||
28 | BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR) | ||
29 | |||
30 | #ifdef CONFIG_X86_MCE_P4THERMAL | ||
31 | BUILD_INTERRUPT(thermal_interrupt,THERMAL_APIC_VECTOR) | ||
32 | #endif | ||
33 | |||
34 | #endif | ||
diff --git a/include/asm-x86/mach-default/io_ports.h b/include/asm-x86/mach-default/io_ports.h new file mode 100644 index 000000000000..48540ba97166 --- /dev/null +++ b/include/asm-x86/mach-default/io_ports.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * arch/i386/mach-generic/io_ports.h | ||
3 | * | ||
4 | * Machine specific IO port address definition for generic. | ||
5 | * Written by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | #ifndef _MACH_IO_PORTS_H | ||
8 | #define _MACH_IO_PORTS_H | ||
9 | |||
10 | /* i8259A PIC registers */ | ||
11 | #define PIC_MASTER_CMD 0x20 | ||
12 | #define PIC_MASTER_IMR 0x21 | ||
13 | #define PIC_MASTER_ISR PIC_MASTER_CMD | ||
14 | #define PIC_MASTER_POLL PIC_MASTER_ISR | ||
15 | #define PIC_MASTER_OCW3 PIC_MASTER_ISR | ||
16 | #define PIC_SLAVE_CMD 0xa0 | ||
17 | #define PIC_SLAVE_IMR 0xa1 | ||
18 | |||
19 | /* i8259A PIC related value */ | ||
20 | #define PIC_CASCADE_IR 2 | ||
21 | #define MASTER_ICW4_DEFAULT 0x01 | ||
22 | #define SLAVE_ICW4_DEFAULT 0x01 | ||
23 | #define PIC_ICW4_AEOI 2 | ||
24 | |||
25 | #endif /* !_MACH_IO_PORTS_H */ | ||
diff --git a/include/asm-x86/mach-default/irq_vectors.h b/include/asm-x86/mach-default/irq_vectors.h new file mode 100644 index 000000000000..881c63ca61ad --- /dev/null +++ b/include/asm-x86/mach-default/irq_vectors.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * This file should contain #defines for all of the interrupt vector | ||
3 | * numbers used by this architecture. | ||
4 | * | ||
5 | * In addition, there are some standard defines: | ||
6 | * | ||
7 | * FIRST_EXTERNAL_VECTOR: | ||
8 | * The first free place for external interrupts | ||
9 | * | ||
10 | * SYSCALL_VECTOR: | ||
11 | * The IRQ vector a syscall makes the user to kernel transition | ||
12 | * under. | ||
13 | * | ||
14 | * TIMER_IRQ: | ||
15 | * The IRQ number the timer interrupt comes in at. | ||
16 | * | ||
17 | * NR_IRQS: | ||
18 | * The total number of interrupt vectors (including all the | ||
19 | * architecture specific interrupts) needed. | ||
20 | * | ||
21 | */ | ||
22 | #ifndef _ASM_IRQ_VECTORS_H | ||
23 | #define _ASM_IRQ_VECTORS_H | ||
24 | |||
25 | /* | ||
26 | * IDT vectors usable for external interrupt sources start | ||
27 | * at 0x20: | ||
28 | */ | ||
29 | #define FIRST_EXTERNAL_VECTOR 0x20 | ||
30 | |||
31 | #define SYSCALL_VECTOR 0x80 | ||
32 | |||
33 | /* | ||
34 | * Vectors 0x20-0x2f are used for ISA interrupts. | ||
35 | */ | ||
36 | |||
37 | /* | ||
38 | * Special IRQ vectors used by the SMP architecture, 0xf0-0xff | ||
39 | * | ||
40 | * some of the following vectors are 'rare', they are merged | ||
41 | * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. | ||
42 | * TLB, reschedule and local APIC vectors are performance-critical. | ||
43 | * | ||
44 | * Vectors 0xf0-0xfa are free (reserved for future Linux use). | ||
45 | */ | ||
46 | #define SPURIOUS_APIC_VECTOR 0xff | ||
47 | #define ERROR_APIC_VECTOR 0xfe | ||
48 | #define INVALIDATE_TLB_VECTOR 0xfd | ||
49 | #define RESCHEDULE_VECTOR 0xfc | ||
50 | #define CALL_FUNCTION_VECTOR 0xfb | ||
51 | |||
52 | #define THERMAL_APIC_VECTOR 0xf0 | ||
53 | /* | ||
54 | * Local APIC timer IRQ vector is on a different priority level, | ||
55 | * to work around the 'lost local interrupt if more than 2 IRQ | ||
56 | * sources per level' errata. | ||
57 | */ | ||
58 | #define LOCAL_TIMER_VECTOR 0xef | ||
59 | |||
60 | /* | ||
61 | * First APIC vector available to drivers: (vectors 0x30-0xee) | ||
62 | * we start at 0x31 to spread out vectors evenly between priority | ||
63 | * levels. (0x80 is the syscall vector) | ||
64 | */ | ||
65 | #define FIRST_DEVICE_VECTOR 0x31 | ||
66 | #define FIRST_SYSTEM_VECTOR 0xef | ||
67 | |||
68 | #define TIMER_IRQ 0 | ||
69 | |||
70 | /* | ||
71 | * 16 8259A IRQ's, 208 potential APIC interrupt sources. | ||
72 | * Right now the APIC is mostly only used for SMP. | ||
73 | * 256 vectors is an architectural limit. (we can have | ||
74 | * more than 256 devices theoretically, but they will | ||
75 | * have to use shared interrupts) | ||
76 | * Since vectors 0x00-0x1f are used/reserved for the CPU, | ||
77 | * the usable vector space is 0x20-0xff (224 vectors) | ||
78 | */ | ||
79 | |||
80 | /* | ||
81 | * The maximum number of vectors supported by i386 processors | ||
82 | * is limited to 256. For processors other than i386, NR_VECTORS | ||
83 | * should be changed accordingly. | ||
84 | */ | ||
85 | #define NR_VECTORS 256 | ||
86 | |||
87 | #include "irq_vectors_limits.h" | ||
88 | |||
89 | #define FPU_IRQ 13 | ||
90 | |||
91 | #define FIRST_VM86_IRQ 3 | ||
92 | #define LAST_VM86_IRQ 15 | ||
93 | #define invalid_vm86_irq(irq) ((irq) < 3 || (irq) > 15) | ||
94 | |||
95 | |||
96 | #endif /* _ASM_IRQ_VECTORS_H */ | ||
diff --git a/include/asm-x86/mach-default/irq_vectors_limits.h b/include/asm-x86/mach-default/irq_vectors_limits.h new file mode 100644 index 000000000000..a90c7a60109f --- /dev/null +++ b/include/asm-x86/mach-default/irq_vectors_limits.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _ASM_IRQ_VECTORS_LIMITS_H | ||
2 | #define _ASM_IRQ_VECTORS_LIMITS_H | ||
3 | |||
4 | #if defined(CONFIG_X86_IO_APIC) || defined(CONFIG_PARAVIRT) | ||
5 | #define NR_IRQS 224 | ||
6 | # if (224 >= 32 * NR_CPUS) | ||
7 | # define NR_IRQ_VECTORS NR_IRQS | ||
8 | # else | ||
9 | # define NR_IRQ_VECTORS (32 * NR_CPUS) | ||
10 | # endif | ||
11 | #else | ||
12 | #define NR_IRQS 16 | ||
13 | #define NR_IRQ_VECTORS NR_IRQS | ||
14 | #endif | ||
15 | |||
16 | #endif /* _ASM_IRQ_VECTORS_LIMITS_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_apic.h b/include/asm-x86/mach-default/mach_apic.h new file mode 100644 index 000000000000..6db1c3babe9a --- /dev/null +++ b/include/asm-x86/mach-default/mach_apic.h | |||
@@ -0,0 +1,131 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | #include <mach_apicdef.h> | ||
5 | #include <asm/smp.h> | ||
6 | |||
7 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
8 | |||
9 | static inline cpumask_t target_cpus(void) | ||
10 | { | ||
11 | #ifdef CONFIG_SMP | ||
12 | return cpu_online_map; | ||
13 | #else | ||
14 | return cpumask_of_cpu(0); | ||
15 | #endif | ||
16 | } | ||
17 | #define TARGET_CPUS (target_cpus()) | ||
18 | |||
19 | #define NO_BALANCE_IRQ (0) | ||
20 | #define esr_disable (0) | ||
21 | |||
22 | #define INT_DELIVERY_MODE dest_LowestPrio | ||
23 | #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ | ||
24 | |||
25 | static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) | ||
26 | { | ||
27 | return physid_isset(apicid, bitmap); | ||
28 | } | ||
29 | |||
30 | static inline unsigned long check_apicid_present(int bit) | ||
31 | { | ||
32 | return physid_isset(bit, phys_cpu_present_map); | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * Set up the logical destination ID. | ||
37 | * | ||
38 | * Intel recommends to set DFR, LDR and TPR before enabling | ||
39 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
40 | * document number 292116). So here it goes... | ||
41 | */ | ||
42 | static inline void init_apic_ldr(void) | ||
43 | { | ||
44 | unsigned long val; | ||
45 | |||
46 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); | ||
47 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; | ||
48 | val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id()); | ||
49 | apic_write_around(APIC_LDR, val); | ||
50 | } | ||
51 | |||
52 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) | ||
53 | { | ||
54 | return phys_map; | ||
55 | } | ||
56 | |||
57 | static inline void setup_apic_routing(void) | ||
58 | { | ||
59 | printk("Enabling APIC mode: %s. Using %d I/O APICs\n", | ||
60 | "Flat", nr_ioapics); | ||
61 | } | ||
62 | |||
63 | static inline int multi_timer_check(int apic, int irq) | ||
64 | { | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static inline int apicid_to_node(int logical_apicid) | ||
69 | { | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | /* Mapping from cpu number to logical apicid */ | ||
74 | static inline int cpu_to_logical_apicid(int cpu) | ||
75 | { | ||
76 | return 1 << cpu; | ||
77 | } | ||
78 | |||
79 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
80 | { | ||
81 | if (mps_cpu < get_physical_broadcast()) | ||
82 | return mps_cpu; | ||
83 | else | ||
84 | return BAD_APICID; | ||
85 | } | ||
86 | |||
87 | static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) | ||
88 | { | ||
89 | return physid_mask_of_physid(phys_apicid); | ||
90 | } | ||
91 | |||
92 | static inline int mpc_apic_id(struct mpc_config_processor *m, | ||
93 | struct mpc_config_translation *translation_record) | ||
94 | { | ||
95 | printk("Processor #%d %ld:%ld APIC version %d\n", | ||
96 | m->mpc_apicid, | ||
97 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
98 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
99 | m->mpc_apicver); | ||
100 | return (m->mpc_apicid); | ||
101 | } | ||
102 | |||
103 | static inline void setup_portio_remap(void) | ||
104 | { | ||
105 | } | ||
106 | |||
107 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) | ||
108 | { | ||
109 | return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map); | ||
110 | } | ||
111 | |||
112 | static inline int apic_id_registered(void) | ||
113 | { | ||
114 | return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map); | ||
115 | } | ||
116 | |||
117 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
118 | { | ||
119 | return cpus_addr(cpumask)[0]; | ||
120 | } | ||
121 | |||
122 | static inline void enable_apic_mode(void) | ||
123 | { | ||
124 | } | ||
125 | |||
126 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
127 | { | ||
128 | return cpuid_apic >> index_msb; | ||
129 | } | ||
130 | |||
131 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_apicdef.h b/include/asm-x86/mach-default/mach_apicdef.h new file mode 100644 index 000000000000..7bcb350c3ee8 --- /dev/null +++ b/include/asm-x86/mach-default/mach_apicdef.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | #define APIC_ID_MASK (0xF<<24) | ||
5 | |||
6 | static inline unsigned get_apic_id(unsigned long x) | ||
7 | { | ||
8 | return (((x)>>24)&0xF); | ||
9 | } | ||
10 | |||
11 | #define GET_APIC_ID(x) get_apic_id(x) | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/mach-default/mach_ipi.h b/include/asm-x86/mach-default/mach_ipi.h new file mode 100644 index 000000000000..0dba244c86db --- /dev/null +++ b/include/asm-x86/mach-default/mach_ipi.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | ||
2 | #define __ASM_MACH_IPI_H | ||
3 | |||
4 | /* Avoid include hell */ | ||
5 | #define NMI_VECTOR 0x02 | ||
6 | |||
7 | void send_IPI_mask_bitmask(cpumask_t mask, int vector); | ||
8 | void __send_IPI_shortcut(unsigned int shortcut, int vector); | ||
9 | |||
10 | extern int no_broadcast; | ||
11 | |||
12 | static inline void send_IPI_mask(cpumask_t mask, int vector) | ||
13 | { | ||
14 | send_IPI_mask_bitmask(mask, vector); | ||
15 | } | ||
16 | |||
17 | static inline void __local_send_IPI_allbutself(int vector) | ||
18 | { | ||
19 | if (no_broadcast || vector == NMI_VECTOR) { | ||
20 | cpumask_t mask = cpu_online_map; | ||
21 | |||
22 | cpu_clear(smp_processor_id(), mask); | ||
23 | send_IPI_mask(mask, vector); | ||
24 | } else | ||
25 | __send_IPI_shortcut(APIC_DEST_ALLBUT, vector); | ||
26 | } | ||
27 | |||
28 | static inline void __local_send_IPI_all(int vector) | ||
29 | { | ||
30 | if (no_broadcast || vector == NMI_VECTOR) | ||
31 | send_IPI_mask(cpu_online_map, vector); | ||
32 | else | ||
33 | __send_IPI_shortcut(APIC_DEST_ALLINC, vector); | ||
34 | } | ||
35 | |||
36 | static inline void send_IPI_allbutself(int vector) | ||
37 | { | ||
38 | /* | ||
39 | * if there are no other CPUs in the system then we get an APIC send | ||
40 | * error if we try to broadcast, thus avoid sending IPIs in this case. | ||
41 | */ | ||
42 | if (!(num_online_cpus() > 1)) | ||
43 | return; | ||
44 | |||
45 | __local_send_IPI_allbutself(vector); | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | static inline void send_IPI_all(int vector) | ||
50 | { | ||
51 | __local_send_IPI_all(vector); | ||
52 | } | ||
53 | |||
54 | #endif /* __ASM_MACH_IPI_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_mpparse.h b/include/asm-x86/mach-default/mach_mpparse.h new file mode 100644 index 000000000000..1d3832482580 --- /dev/null +++ b/include/asm-x86/mach-default/mach_mpparse.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __ASM_MACH_MPPARSE_H | ||
2 | #define __ASM_MACH_MPPARSE_H | ||
3 | |||
4 | static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, | ||
5 | struct mpc_config_translation *translation) | ||
6 | { | ||
7 | // Dprintk("Bus #%d is %s\n", m->mpc_busid, name); | ||
8 | } | ||
9 | |||
10 | static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, | ||
11 | struct mpc_config_translation *translation) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, | ||
16 | char *productid) | ||
17 | { | ||
18 | return 0; | ||
19 | } | ||
20 | |||
21 | /* Hook from generic ACPI tables.c */ | ||
22 | static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
23 | { | ||
24 | return 0; | ||
25 | } | ||
26 | |||
27 | |||
28 | #endif /* __ASM_MACH_MPPARSE_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_mpspec.h b/include/asm-x86/mach-default/mach_mpspec.h new file mode 100644 index 000000000000..51c9a9775932 --- /dev/null +++ b/include/asm-x86/mach-default/mach_mpspec.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 256 | ||
5 | |||
6 | #if CONFIG_BASE_SMALL == 0 | ||
7 | #define MAX_MP_BUSSES 256 | ||
8 | #else | ||
9 | #define MAX_MP_BUSSES 32 | ||
10 | #endif | ||
11 | |||
12 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_reboot.h b/include/asm-x86/mach-default/mach_reboot.h new file mode 100644 index 000000000000..e23fd9fbebb3 --- /dev/null +++ b/include/asm-x86/mach-default/mach_reboot.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * arch/i386/mach-generic/mach_reboot.h | ||
3 | * | ||
4 | * Machine specific reboot functions for generic. | ||
5 | * Split out from reboot.c by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | #ifndef _MACH_REBOOT_H | ||
8 | #define _MACH_REBOOT_H | ||
9 | |||
10 | static inline void kb_wait(void) | ||
11 | { | ||
12 | int i; | ||
13 | |||
14 | for (i = 0; i < 0x10000; i++) | ||
15 | if ((inb_p(0x64) & 0x02) == 0) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | static inline void mach_reboot(void) | ||
20 | { | ||
21 | int i; | ||
22 | |||
23 | /* old method, works on most machines */ | ||
24 | for (i = 0; i < 10; i++) { | ||
25 | kb_wait(); | ||
26 | udelay(50); | ||
27 | outb(0xfe, 0x64); /* pulse reset low */ | ||
28 | udelay(50); | ||
29 | } | ||
30 | |||
31 | /* New method: sets the "System flag" which, when set, indicates | ||
32 | * successful completion of the keyboard controller self-test (Basic | ||
33 | * Assurance Test, BAT). This is needed for some machines with no | ||
34 | * keyboard plugged in. This read-modify-write sequence sets only the | ||
35 | * system flag | ||
36 | */ | ||
37 | for (i = 0; i < 10; i++) { | ||
38 | int cmd; | ||
39 | |||
40 | outb(0x20, 0x64); /* read Controller Command Byte */ | ||
41 | udelay(50); | ||
42 | kb_wait(); | ||
43 | udelay(50); | ||
44 | cmd = inb(0x60); | ||
45 | udelay(50); | ||
46 | kb_wait(); | ||
47 | udelay(50); | ||
48 | outb(0x60, 0x64); /* write Controller Command Byte */ | ||
49 | udelay(50); | ||
50 | kb_wait(); | ||
51 | udelay(50); | ||
52 | outb(cmd | 0x04, 0x60); /* set "System flag" */ | ||
53 | udelay(50); | ||
54 | kb_wait(); | ||
55 | udelay(50); | ||
56 | outb(0xfe, 0x64); /* pulse reset low */ | ||
57 | udelay(50); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | #endif /* !_MACH_REBOOT_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_time.h b/include/asm-x86/mach-default/mach_time.h new file mode 100644 index 000000000000..31eb5de6f3dc --- /dev/null +++ b/include/asm-x86/mach-default/mach_time.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * include/asm-i386/mach-default/mach_time.h | ||
3 | * | ||
4 | * Machine specific set RTC function for generic. | ||
5 | * Split out from time.c by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | #ifndef _MACH_TIME_H | ||
8 | #define _MACH_TIME_H | ||
9 | |||
10 | #include <linux/mc146818rtc.h> | ||
11 | |||
12 | /* for check timing call set_rtc_mmss() 500ms */ | ||
13 | /* used in arch/i386/time.c::do_timer_interrupt() */ | ||
14 | #define USEC_AFTER 500000 | ||
15 | #define USEC_BEFORE 500000 | ||
16 | |||
17 | /* | ||
18 | * In order to set the CMOS clock precisely, set_rtc_mmss has to be | ||
19 | * called 500 ms after the second nowtime has started, because when | ||
20 | * nowtime is written into the registers of the CMOS clock, it will | ||
21 | * jump to the next second precisely 500 ms later. Check the Motorola | ||
22 | * MC146818A or Dallas DS12887 data sheet for details. | ||
23 | * | ||
24 | * BUG: This routine does not handle hour overflow properly; it just | ||
25 | * sets the minutes. Usually you'll only notice that after reboot! | ||
26 | */ | ||
27 | static inline int mach_set_rtc_mmss(unsigned long nowtime) | ||
28 | { | ||
29 | int retval = 0; | ||
30 | int real_seconds, real_minutes, cmos_minutes; | ||
31 | unsigned char save_control, save_freq_select; | ||
32 | |||
33 | save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */ | ||
34 | CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); | ||
35 | |||
36 | save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */ | ||
37 | CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); | ||
38 | |||
39 | cmos_minutes = CMOS_READ(RTC_MINUTES); | ||
40 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
41 | BCD_TO_BIN(cmos_minutes); | ||
42 | |||
43 | /* | ||
44 | * since we're only adjusting minutes and seconds, | ||
45 | * don't interfere with hour overflow. This avoids | ||
46 | * messing with unknown time zones but requires your | ||
47 | * RTC not to be off by more than 15 minutes | ||
48 | */ | ||
49 | real_seconds = nowtime % 60; | ||
50 | real_minutes = nowtime / 60; | ||
51 | if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) | ||
52 | real_minutes += 30; /* correct for half hour time zone */ | ||
53 | real_minutes %= 60; | ||
54 | |||
55 | if (abs(real_minutes - cmos_minutes) < 30) { | ||
56 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
57 | BIN_TO_BCD(real_seconds); | ||
58 | BIN_TO_BCD(real_minutes); | ||
59 | } | ||
60 | CMOS_WRITE(real_seconds,RTC_SECONDS); | ||
61 | CMOS_WRITE(real_minutes,RTC_MINUTES); | ||
62 | } else { | ||
63 | printk(KERN_WARNING | ||
64 | "set_rtc_mmss: can't update from %d to %d\n", | ||
65 | cmos_minutes, real_minutes); | ||
66 | retval = -1; | ||
67 | } | ||
68 | |||
69 | /* The following flags have to be released exactly in this order, | ||
70 | * otherwise the DS12887 (popular MC146818A clone with integrated | ||
71 | * battery and quartz) will not reset the oscillator and will not | ||
72 | * update precisely 500 ms later. You won't find this mentioned in | ||
73 | * the Dallas Semiconductor data sheets, but who believes data | ||
74 | * sheets anyway ... -- Markus Kuhn | ||
75 | */ | ||
76 | CMOS_WRITE(save_control, RTC_CONTROL); | ||
77 | CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); | ||
78 | |||
79 | return retval; | ||
80 | } | ||
81 | |||
82 | static inline unsigned long mach_get_cmos_time(void) | ||
83 | { | ||
84 | unsigned int year, mon, day, hour, min, sec; | ||
85 | |||
86 | do { | ||
87 | sec = CMOS_READ(RTC_SECONDS); | ||
88 | min = CMOS_READ(RTC_MINUTES); | ||
89 | hour = CMOS_READ(RTC_HOURS); | ||
90 | day = CMOS_READ(RTC_DAY_OF_MONTH); | ||
91 | mon = CMOS_READ(RTC_MONTH); | ||
92 | year = CMOS_READ(RTC_YEAR); | ||
93 | } while (sec != CMOS_READ(RTC_SECONDS)); | ||
94 | |||
95 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
96 | BCD_TO_BIN(sec); | ||
97 | BCD_TO_BIN(min); | ||
98 | BCD_TO_BIN(hour); | ||
99 | BCD_TO_BIN(day); | ||
100 | BCD_TO_BIN(mon); | ||
101 | BCD_TO_BIN(year); | ||
102 | } | ||
103 | |||
104 | year += 1900; | ||
105 | if (year < 1970) | ||
106 | year += 100; | ||
107 | |||
108 | return mktime(year, mon, day, hour, min, sec); | ||
109 | } | ||
110 | |||
111 | #endif /* !_MACH_TIME_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_timer.h b/include/asm-x86/mach-default/mach_timer.h new file mode 100644 index 000000000000..807992fd4171 --- /dev/null +++ b/include/asm-x86/mach-default/mach_timer.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * include/asm-i386/mach-default/mach_timer.h | ||
3 | * | ||
4 | * Machine specific calibrate_tsc() for generic. | ||
5 | * Split out from timer_tsc.c by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | /* ------ Calibrate the TSC ------- | ||
8 | * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset(). | ||
9 | * Too much 64-bit arithmetic here to do this cleanly in C, and for | ||
10 | * accuracy's sake we want to keep the overhead on the CTC speaker (channel 2) | ||
11 | * output busy loop as low as possible. We avoid reading the CTC registers | ||
12 | * directly because of the awkward 8-bit access mechanism of the 82C54 | ||
13 | * device. | ||
14 | */ | ||
15 | #ifndef _MACH_TIMER_H | ||
16 | #define _MACH_TIMER_H | ||
17 | |||
18 | #define CALIBRATE_TIME_MSEC 30 /* 30 msecs */ | ||
19 | #define CALIBRATE_LATCH \ | ||
20 | ((CLOCK_TICK_RATE * CALIBRATE_TIME_MSEC + 1000/2)/1000) | ||
21 | |||
22 | static inline void mach_prepare_counter(void) | ||
23 | { | ||
24 | /* Set the Gate high, disable speaker */ | ||
25 | outb((inb(0x61) & ~0x02) | 0x01, 0x61); | ||
26 | |||
27 | /* | ||
28 | * Now let's take care of CTC channel 2 | ||
29 | * | ||
30 | * Set the Gate high, program CTC channel 2 for mode 0, | ||
31 | * (interrupt on terminal count mode), binary count, | ||
32 | * load 5 * LATCH count, (LSB and MSB) to begin countdown. | ||
33 | * | ||
34 | * Some devices need a delay here. | ||
35 | */ | ||
36 | outb(0xb0, 0x43); /* binary, mode 0, LSB/MSB, Ch 2 */ | ||
37 | outb_p(CALIBRATE_LATCH & 0xff, 0x42); /* LSB of count */ | ||
38 | outb_p(CALIBRATE_LATCH >> 8, 0x42); /* MSB of count */ | ||
39 | } | ||
40 | |||
41 | static inline void mach_countup(unsigned long *count_p) | ||
42 | { | ||
43 | unsigned long count = 0; | ||
44 | do { | ||
45 | count++; | ||
46 | } while ((inb_p(0x61) & 0x20) == 0); | ||
47 | *count_p = count; | ||
48 | } | ||
49 | |||
50 | #endif /* !_MACH_TIMER_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_traps.h b/include/asm-x86/mach-default/mach_traps.h new file mode 100644 index 000000000000..625438b8a6eb --- /dev/null +++ b/include/asm-x86/mach-default/mach_traps.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * include/asm-i386/mach-default/mach_traps.h | ||
3 | * | ||
4 | * Machine specific NMI handling for generic. | ||
5 | * Split out from traps.c by Osamu Tomita <tomita@cinet.co.jp> | ||
6 | */ | ||
7 | #ifndef _MACH_TRAPS_H | ||
8 | #define _MACH_TRAPS_H | ||
9 | |||
10 | #include <asm/mc146818rtc.h> | ||
11 | |||
12 | static inline void clear_mem_error(unsigned char reason) | ||
13 | { | ||
14 | reason = (reason & 0xf) | 4; | ||
15 | outb(reason, 0x61); | ||
16 | } | ||
17 | |||
18 | static inline unsigned char get_nmi_reason(void) | ||
19 | { | ||
20 | return inb(0x61); | ||
21 | } | ||
22 | |||
23 | static inline void reassert_nmi(void) | ||
24 | { | ||
25 | int old_reg = -1; | ||
26 | |||
27 | if (do_i_have_lock_cmos()) | ||
28 | old_reg = current_lock_cmos_reg(); | ||
29 | else | ||
30 | lock_cmos(0); /* register doesn't matter here */ | ||
31 | outb(0x8f, 0x70); | ||
32 | inb(0x71); /* dummy */ | ||
33 | outb(0x0f, 0x70); | ||
34 | inb(0x71); /* dummy */ | ||
35 | if (old_reg >= 0) | ||
36 | outb(old_reg, 0x70); | ||
37 | else | ||
38 | unlock_cmos(); | ||
39 | } | ||
40 | |||
41 | #endif /* !_MACH_TRAPS_H */ | ||
diff --git a/include/asm-x86/mach-default/mach_wakecpu.h b/include/asm-x86/mach-default/mach_wakecpu.h new file mode 100644 index 000000000000..3ebb17893aa5 --- /dev/null +++ b/include/asm-x86/mach-default/mach_wakecpu.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef __ASM_MACH_WAKECPU_H | ||
2 | #define __ASM_MACH_WAKECPU_H | ||
3 | |||
4 | /* | ||
5 | * This file copes with machines that wakeup secondary CPUs by the | ||
6 | * INIT, INIT, STARTUP sequence. | ||
7 | */ | ||
8 | |||
9 | #define WAKE_SECONDARY_VIA_INIT | ||
10 | |||
11 | #define TRAMPOLINE_LOW phys_to_virt(0x467) | ||
12 | #define TRAMPOLINE_HIGH phys_to_virt(0x469) | ||
13 | |||
14 | #define boot_cpu_apicid boot_cpu_physical_apicid | ||
15 | |||
16 | static inline void wait_for_init_deassert(atomic_t *deassert) | ||
17 | { | ||
18 | while (!atomic_read(deassert)) | ||
19 | cpu_relax(); | ||
20 | return; | ||
21 | } | ||
22 | |||
23 | /* Nothing to do for most platforms, since cleared by the INIT cycle */ | ||
24 | static inline void smp_callin_clear_local_apic(void) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | static inline void store_NMI_vector(unsigned short *high, unsigned short *low) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | static inline void restore_NMI_vector(unsigned short *high, unsigned short *low) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | #if APIC_DEBUG | ||
37 | #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid) | ||
38 | #else | ||
39 | #define inquire_remote_apic(apicid) {} | ||
40 | #endif | ||
41 | |||
42 | #endif /* __ASM_MACH_WAKECPU_H */ | ||
diff --git a/include/asm-x86/mach-default/pci-functions.h b/include/asm-x86/mach-default/pci-functions.h new file mode 100644 index 000000000000..ed0bab427354 --- /dev/null +++ b/include/asm-x86/mach-default/pci-functions.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * PCI BIOS function numbering for conventional PCI BIOS | ||
3 | * systems | ||
4 | */ | ||
5 | |||
6 | #define PCIBIOS_PCI_FUNCTION_ID 0xb1XX | ||
7 | #define PCIBIOS_PCI_BIOS_PRESENT 0xb101 | ||
8 | #define PCIBIOS_FIND_PCI_DEVICE 0xb102 | ||
9 | #define PCIBIOS_FIND_PCI_CLASS_CODE 0xb103 | ||
10 | #define PCIBIOS_GENERATE_SPECIAL_CYCLE 0xb106 | ||
11 | #define PCIBIOS_READ_CONFIG_BYTE 0xb108 | ||
12 | #define PCIBIOS_READ_CONFIG_WORD 0xb109 | ||
13 | #define PCIBIOS_READ_CONFIG_DWORD 0xb10a | ||
14 | #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b | ||
15 | #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c | ||
16 | #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d | ||
17 | #define PCIBIOS_GET_ROUTING_OPTIONS 0xb10e | ||
18 | #define PCIBIOS_SET_PCI_HW_INT 0xb10f | ||
19 | |||
diff --git a/include/asm-x86/mach-default/setup_arch.h b/include/asm-x86/mach-default/setup_arch.h new file mode 100644 index 000000000000..605e3ccb991b --- /dev/null +++ b/include/asm-x86/mach-default/setup_arch.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* Hook to call BIOS initialisation function */ | ||
2 | |||
3 | /* no action for generic */ | ||
4 | |||
5 | #ifndef ARCH_SETUP | ||
6 | #define ARCH_SETUP | ||
7 | #endif | ||
diff --git a/include/asm-x86/mach-default/smpboot_hooks.h b/include/asm-x86/mach-default/smpboot_hooks.h new file mode 100644 index 000000000000..7f45f6311059 --- /dev/null +++ b/include/asm-x86/mach-default/smpboot_hooks.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* two abstractions specific to kernel/smpboot.c, mainly to cater to visws | ||
2 | * which needs to alter them. */ | ||
3 | |||
4 | static inline void smpboot_clear_io_apic_irqs(void) | ||
5 | { | ||
6 | io_apic_irqs = 0; | ||
7 | } | ||
8 | |||
9 | static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip) | ||
10 | { | ||
11 | CMOS_WRITE(0xa, 0xf); | ||
12 | local_flush_tlb(); | ||
13 | Dprintk("1.\n"); | ||
14 | *((volatile unsigned short *) TRAMPOLINE_HIGH) = start_eip >> 4; | ||
15 | Dprintk("2.\n"); | ||
16 | *((volatile unsigned short *) TRAMPOLINE_LOW) = start_eip & 0xf; | ||
17 | Dprintk("3.\n"); | ||
18 | } | ||
19 | |||
20 | static inline void smpboot_restore_warm_reset_vector(void) | ||
21 | { | ||
22 | /* | ||
23 | * Install writable page 0 entry to set BIOS data area. | ||
24 | */ | ||
25 | local_flush_tlb(); | ||
26 | |||
27 | /* | ||
28 | * Paranoid: Set warm reset code and vector here back | ||
29 | * to default values. | ||
30 | */ | ||
31 | CMOS_WRITE(0, 0xf); | ||
32 | |||
33 | *((volatile long *) phys_to_virt(0x467)) = 0; | ||
34 | } | ||
35 | |||
36 | static inline void smpboot_setup_io_apic(void) | ||
37 | { | ||
38 | /* | ||
39 | * Here we can be sure that there is an IO-APIC in the system. Let's | ||
40 | * go and set it up: | ||
41 | */ | ||
42 | if (!skip_ioapic_setup && nr_ioapics) | ||
43 | setup_IO_APIC(); | ||
44 | } | ||
diff --git a/include/asm-x86/mach-es7000/mach_apic.h b/include/asm-x86/mach-es7000/mach_apic.h new file mode 100644 index 000000000000..caec64be516d --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_apic.h | |||
@@ -0,0 +1,206 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | extern u8 bios_cpu_apicid[]; | ||
5 | |||
6 | #define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu]) | ||
7 | #define esr_disable (1) | ||
8 | |||
9 | static inline int apic_id_registered(void) | ||
10 | { | ||
11 | return (1); | ||
12 | } | ||
13 | |||
14 | static inline cpumask_t target_cpus(void) | ||
15 | { | ||
16 | #if defined CONFIG_ES7000_CLUSTERED_APIC | ||
17 | return CPU_MASK_ALL; | ||
18 | #else | ||
19 | return cpumask_of_cpu(smp_processor_id()); | ||
20 | #endif | ||
21 | } | ||
22 | #define TARGET_CPUS (target_cpus()) | ||
23 | |||
24 | #if defined CONFIG_ES7000_CLUSTERED_APIC | ||
25 | #define APIC_DFR_VALUE (APIC_DFR_CLUSTER) | ||
26 | #define INT_DELIVERY_MODE (dest_LowestPrio) | ||
27 | #define INT_DEST_MODE (1) /* logical delivery broadcast to all procs */ | ||
28 | #define NO_BALANCE_IRQ (1) | ||
29 | #undef WAKE_SECONDARY_VIA_INIT | ||
30 | #define WAKE_SECONDARY_VIA_MIP | ||
31 | #else | ||
32 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
33 | #define INT_DELIVERY_MODE (dest_Fixed) | ||
34 | #define INT_DEST_MODE (0) /* phys delivery to target procs */ | ||
35 | #define NO_BALANCE_IRQ (0) | ||
36 | #undef APIC_DEST_LOGICAL | ||
37 | #define APIC_DEST_LOGICAL 0x0 | ||
38 | #define WAKE_SECONDARY_VIA_INIT | ||
39 | #endif | ||
40 | |||
41 | static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) | ||
42 | { | ||
43 | return 0; | ||
44 | } | ||
45 | static inline unsigned long check_apicid_present(int bit) | ||
46 | { | ||
47 | return physid_isset(bit, phys_cpu_present_map); | ||
48 | } | ||
49 | |||
50 | #define apicid_cluster(apicid) (apicid & 0xF0) | ||
51 | |||
52 | static inline unsigned long calculate_ldr(int cpu) | ||
53 | { | ||
54 | unsigned long id; | ||
55 | id = xapic_phys_to_log_apicid(cpu); | ||
56 | return (SET_APIC_LOGICAL_ID(id)); | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | * Set up the logical destination ID. | ||
61 | * | ||
62 | * Intel recommends to set DFR, LdR and TPR before enabling | ||
63 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
64 | * document number 292116). So here it goes... | ||
65 | */ | ||
66 | static inline void init_apic_ldr(void) | ||
67 | { | ||
68 | unsigned long val; | ||
69 | int cpu = smp_processor_id(); | ||
70 | |||
71 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); | ||
72 | val = calculate_ldr(cpu); | ||
73 | apic_write_around(APIC_LDR, val); | ||
74 | } | ||
75 | |||
76 | #ifndef CONFIG_X86_GENERICARCH | ||
77 | extern void enable_apic_mode(void); | ||
78 | #endif | ||
79 | |||
80 | extern int apic_version [MAX_APICS]; | ||
81 | static inline void setup_apic_routing(void) | ||
82 | { | ||
83 | int apic = bios_cpu_apicid[smp_processor_id()]; | ||
84 | printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", | ||
85 | (apic_version[apic] == 0x14) ? | ||
86 | "Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(TARGET_CPUS)[0]); | ||
87 | } | ||
88 | |||
89 | static inline int multi_timer_check(int apic, int irq) | ||
90 | { | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static inline int apicid_to_node(int logical_apicid) | ||
95 | { | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | |||
100 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
101 | { | ||
102 | if (!mps_cpu) | ||
103 | return boot_cpu_physical_apicid; | ||
104 | else if (mps_cpu < NR_CPUS) | ||
105 | return (int) bios_cpu_apicid[mps_cpu]; | ||
106 | else | ||
107 | return BAD_APICID; | ||
108 | } | ||
109 | |||
110 | static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) | ||
111 | { | ||
112 | static int id = 0; | ||
113 | physid_mask_t mask; | ||
114 | mask = physid_mask_of_physid(id); | ||
115 | ++id; | ||
116 | return mask; | ||
117 | } | ||
118 | |||
119 | extern u8 cpu_2_logical_apicid[]; | ||
120 | /* Mapping from cpu number to logical apicid */ | ||
121 | static inline int cpu_to_logical_apicid(int cpu) | ||
122 | { | ||
123 | #ifdef CONFIG_SMP | ||
124 | if (cpu >= NR_CPUS) | ||
125 | return BAD_APICID; | ||
126 | return (int)cpu_2_logical_apicid[cpu]; | ||
127 | #else | ||
128 | return logical_smp_processor_id(); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused) | ||
133 | { | ||
134 | printk("Processor #%d %ld:%ld APIC version %d\n", | ||
135 | m->mpc_apicid, | ||
136 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
137 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
138 | m->mpc_apicver); | ||
139 | return (m->mpc_apicid); | ||
140 | } | ||
141 | |||
142 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) | ||
143 | { | ||
144 | /* For clustered we don't have a good way to do this yet - hack */ | ||
145 | return physids_promote(0xff); | ||
146 | } | ||
147 | |||
148 | |||
149 | static inline void setup_portio_remap(void) | ||
150 | { | ||
151 | } | ||
152 | |||
153 | extern unsigned int boot_cpu_physical_apicid; | ||
154 | static inline int check_phys_apicid_present(int cpu_physical_apicid) | ||
155 | { | ||
156 | boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); | ||
157 | return (1); | ||
158 | } | ||
159 | |||
160 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
161 | { | ||
162 | int num_bits_set; | ||
163 | int cpus_found = 0; | ||
164 | int cpu; | ||
165 | int apicid; | ||
166 | |||
167 | num_bits_set = cpus_weight(cpumask); | ||
168 | /* Return id to all */ | ||
169 | if (num_bits_set == NR_CPUS) | ||
170 | #if defined CONFIG_ES7000_CLUSTERED_APIC | ||
171 | return 0xFF; | ||
172 | #else | ||
173 | return cpu_to_logical_apicid(0); | ||
174 | #endif | ||
175 | /* | ||
176 | * The cpus in the mask must all be on the apic cluster. If are not | ||
177 | * on the same apicid cluster return default value of TARGET_CPUS. | ||
178 | */ | ||
179 | cpu = first_cpu(cpumask); | ||
180 | apicid = cpu_to_logical_apicid(cpu); | ||
181 | while (cpus_found < num_bits_set) { | ||
182 | if (cpu_isset(cpu, cpumask)) { | ||
183 | int new_apicid = cpu_to_logical_apicid(cpu); | ||
184 | if (apicid_cluster(apicid) != | ||
185 | apicid_cluster(new_apicid)){ | ||
186 | printk ("%s: Not a valid mask!\n",__FUNCTION__); | ||
187 | #if defined CONFIG_ES7000_CLUSTERED_APIC | ||
188 | return 0xFF; | ||
189 | #else | ||
190 | return cpu_to_logical_apicid(0); | ||
191 | #endif | ||
192 | } | ||
193 | apicid = new_apicid; | ||
194 | cpus_found++; | ||
195 | } | ||
196 | cpu++; | ||
197 | } | ||
198 | return apicid; | ||
199 | } | ||
200 | |||
201 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
202 | { | ||
203 | return cpuid_apic >> index_msb; | ||
204 | } | ||
205 | |||
206 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-es7000/mach_apicdef.h b/include/asm-x86/mach-es7000/mach_apicdef.h new file mode 100644 index 000000000000..a58ab5a75c8c --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_apicdef.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | #define APIC_ID_MASK (0xFF<<24) | ||
5 | |||
6 | static inline unsigned get_apic_id(unsigned long x) | ||
7 | { | ||
8 | return (((x)>>24)&0xFF); | ||
9 | } | ||
10 | |||
11 | #define GET_APIC_ID(x) get_apic_id(x) | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/mach-es7000/mach_ipi.h b/include/asm-x86/mach-es7000/mach_ipi.h new file mode 100644 index 000000000000..5e61bd220b06 --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_ipi.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | ||
2 | #define __ASM_MACH_IPI_H | ||
3 | |||
4 | void send_IPI_mask_sequence(cpumask_t mask, int vector); | ||
5 | |||
6 | static inline void send_IPI_mask(cpumask_t mask, int vector) | ||
7 | { | ||
8 | send_IPI_mask_sequence(mask, vector); | ||
9 | } | ||
10 | |||
11 | static inline void send_IPI_allbutself(int vector) | ||
12 | { | ||
13 | cpumask_t mask = cpu_online_map; | ||
14 | cpu_clear(smp_processor_id(), mask); | ||
15 | if (!cpus_empty(mask)) | ||
16 | send_IPI_mask(mask, vector); | ||
17 | } | ||
18 | |||
19 | static inline void send_IPI_all(int vector) | ||
20 | { | ||
21 | send_IPI_mask(cpu_online_map, vector); | ||
22 | } | ||
23 | |||
24 | #endif /* __ASM_MACH_IPI_H */ | ||
diff --git a/include/asm-x86/mach-es7000/mach_mpparse.h b/include/asm-x86/mach-es7000/mach_mpparse.h new file mode 100644 index 000000000000..8aa10547b4b1 --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_mpparse.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef __ASM_MACH_MPPARSE_H | ||
2 | #define __ASM_MACH_MPPARSE_H | ||
3 | |||
4 | #include <linux/acpi.h> | ||
5 | |||
6 | static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, | ||
7 | struct mpc_config_translation *translation) | ||
8 | { | ||
9 | Dprintk("Bus #%d is %s\n", m->mpc_busid, name); | ||
10 | } | ||
11 | |||
12 | static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, | ||
13 | struct mpc_config_translation *translation) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | extern int parse_unisys_oem (char *oemptr); | ||
18 | extern int find_unisys_acpi_oem_table(unsigned long *oem_addr); | ||
19 | extern void setup_unisys(void); | ||
20 | |||
21 | #ifndef CONFIG_X86_GENERICARCH | ||
22 | extern int acpi_madt_oem_check(char *oem_id, char *oem_table_id); | ||
23 | extern int mps_oem_check(struct mp_config_table *mpc, char *oem, | ||
24 | char *productid); | ||
25 | #endif | ||
26 | |||
27 | #ifdef CONFIG_ACPI | ||
28 | |||
29 | static inline int es7000_check_dsdt(void) | ||
30 | { | ||
31 | struct acpi_table_header header; | ||
32 | memcpy(&header, 0, sizeof(struct acpi_table_header)); | ||
33 | acpi_get_table_header(ACPI_SIG_DSDT, 0, &header); | ||
34 | if (!strncmp(header.oem_id, "UNISYS", 6)) | ||
35 | return 1; | ||
36 | return 0; | ||
37 | } | ||
38 | #endif | ||
39 | |||
40 | #endif /* __ASM_MACH_MPPARSE_H */ | ||
diff --git a/include/asm-x86/mach-es7000/mach_mpspec.h b/include/asm-x86/mach-es7000/mach_mpspec.h new file mode 100644 index 000000000000..b1f5039d4506 --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_mpspec.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 256 | ||
5 | |||
6 | #define MAX_MP_BUSSES 256 | ||
7 | |||
8 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-es7000/mach_wakecpu.h b/include/asm-x86/mach-es7000/mach_wakecpu.h new file mode 100644 index 000000000000..84ff58314501 --- /dev/null +++ b/include/asm-x86/mach-es7000/mach_wakecpu.h | |||
@@ -0,0 +1,59 @@ | |||
1 | #ifndef __ASM_MACH_WAKECPU_H | ||
2 | #define __ASM_MACH_WAKECPU_H | ||
3 | |||
4 | /* | ||
5 | * This file copes with machines that wakeup secondary CPUs by the | ||
6 | * INIT, INIT, STARTUP sequence. | ||
7 | */ | ||
8 | |||
9 | #ifdef CONFIG_ES7000_CLUSTERED_APIC | ||
10 | #define WAKE_SECONDARY_VIA_MIP | ||
11 | #else | ||
12 | #define WAKE_SECONDARY_VIA_INIT | ||
13 | #endif | ||
14 | |||
15 | #ifdef WAKE_SECONDARY_VIA_MIP | ||
16 | extern int es7000_start_cpu(int cpu, unsigned long eip); | ||
17 | static inline int | ||
18 | wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) | ||
19 | { | ||
20 | int boot_error = 0; | ||
21 | boot_error = es7000_start_cpu(phys_apicid, start_eip); | ||
22 | return boot_error; | ||
23 | } | ||
24 | #endif | ||
25 | |||
26 | #define TRAMPOLINE_LOW phys_to_virt(0x467) | ||
27 | #define TRAMPOLINE_HIGH phys_to_virt(0x469) | ||
28 | |||
29 | #define boot_cpu_apicid boot_cpu_physical_apicid | ||
30 | |||
31 | static inline void wait_for_init_deassert(atomic_t *deassert) | ||
32 | { | ||
33 | #ifdef WAKE_SECONDARY_VIA_INIT | ||
34 | while (!atomic_read(deassert)) | ||
35 | cpu_relax(); | ||
36 | #endif | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | /* Nothing to do for most platforms, since cleared by the INIT cycle */ | ||
41 | static inline void smp_callin_clear_local_apic(void) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | static inline void store_NMI_vector(unsigned short *high, unsigned short *low) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | static inline void restore_NMI_vector(unsigned short *high, unsigned short *low) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | #if APIC_DEBUG | ||
54 | #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid) | ||
55 | #else | ||
56 | #define inquire_remote_apic(apicid) {} | ||
57 | #endif | ||
58 | |||
59 | #endif /* __ASM_MACH_WAKECPU_H */ | ||
diff --git a/include/asm-x86/mach-generic/irq_vectors_limits.h b/include/asm-x86/mach-generic/irq_vectors_limits.h new file mode 100644 index 000000000000..890ce3f5e09a --- /dev/null +++ b/include/asm-x86/mach-generic/irq_vectors_limits.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_IRQ_VECTORS_LIMITS_H | ||
2 | #define _ASM_IRQ_VECTORS_LIMITS_H | ||
3 | |||
4 | /* | ||
5 | * For Summit or generic (i.e. installer) kernels, we have lots of I/O APICs, | ||
6 | * even with uni-proc kernels, so use a big array. | ||
7 | * | ||
8 | * This value should be the same in both the generic and summit subarches. | ||
9 | * Change one, change 'em both. | ||
10 | */ | ||
11 | #define NR_IRQS 224 | ||
12 | #define NR_IRQ_VECTORS 1024 | ||
13 | |||
14 | #endif /* _ASM_IRQ_VECTORS_LIMITS_H */ | ||
diff --git a/include/asm-x86/mach-generic/mach_apic.h b/include/asm-x86/mach-generic/mach_apic.h new file mode 100644 index 000000000000..a236e7021528 --- /dev/null +++ b/include/asm-x86/mach-generic/mach_apic.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | #include <asm/genapic.h> | ||
5 | |||
6 | #define esr_disable (genapic->ESR_DISABLE) | ||
7 | #define NO_BALANCE_IRQ (genapic->no_balance_irq) | ||
8 | #define INT_DELIVERY_MODE (genapic->int_delivery_mode) | ||
9 | #define INT_DEST_MODE (genapic->int_dest_mode) | ||
10 | #undef APIC_DEST_LOGICAL | ||
11 | #define APIC_DEST_LOGICAL (genapic->apic_destination_logical) | ||
12 | #define TARGET_CPUS (genapic->target_cpus()) | ||
13 | #define apic_id_registered (genapic->apic_id_registered) | ||
14 | #define init_apic_ldr (genapic->init_apic_ldr) | ||
15 | #define ioapic_phys_id_map (genapic->ioapic_phys_id_map) | ||
16 | #define setup_apic_routing (genapic->setup_apic_routing) | ||
17 | #define multi_timer_check (genapic->multi_timer_check) | ||
18 | #define apicid_to_node (genapic->apicid_to_node) | ||
19 | #define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid) | ||
20 | #define cpu_present_to_apicid (genapic->cpu_present_to_apicid) | ||
21 | #define apicid_to_cpu_present (genapic->apicid_to_cpu_present) | ||
22 | #define mpc_apic_id (genapic->mpc_apic_id) | ||
23 | #define setup_portio_remap (genapic->setup_portio_remap) | ||
24 | #define check_apicid_present (genapic->check_apicid_present) | ||
25 | #define check_phys_apicid_present (genapic->check_phys_apicid_present) | ||
26 | #define check_apicid_used (genapic->check_apicid_used) | ||
27 | #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) | ||
28 | #define enable_apic_mode (genapic->enable_apic_mode) | ||
29 | #define phys_pkg_id (genapic->phys_pkg_id) | ||
30 | |||
31 | extern void generic_bigsmp_probe(void); | ||
32 | |||
33 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-generic/mach_apicdef.h b/include/asm-x86/mach-generic/mach_apicdef.h new file mode 100644 index 000000000000..28ed98972ca8 --- /dev/null +++ b/include/asm-x86/mach-generic/mach_apicdef.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _GENAPIC_MACH_APICDEF_H | ||
2 | #define _GENAPIC_MACH_APICDEF_H 1 | ||
3 | |||
4 | #ifndef APIC_DEFINITION | ||
5 | #include <asm/genapic.h> | ||
6 | |||
7 | #define GET_APIC_ID (genapic->get_apic_id) | ||
8 | #define APIC_ID_MASK (genapic->apic_id_mask) | ||
9 | #endif | ||
10 | |||
11 | #endif | ||
diff --git a/include/asm-x86/mach-generic/mach_ipi.h b/include/asm-x86/mach-generic/mach_ipi.h new file mode 100644 index 000000000000..441b0fe3ed1d --- /dev/null +++ b/include/asm-x86/mach-generic/mach_ipi.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _MACH_IPI_H | ||
2 | #define _MACH_IPI_H 1 | ||
3 | |||
4 | #include <asm/genapic.h> | ||
5 | |||
6 | #define send_IPI_mask (genapic->send_IPI_mask) | ||
7 | #define send_IPI_allbutself (genapic->send_IPI_allbutself) | ||
8 | #define send_IPI_all (genapic->send_IPI_all) | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/mach-generic/mach_mpparse.h b/include/asm-x86/mach-generic/mach_mpparse.h new file mode 100644 index 000000000000..dbd9fce54f4d --- /dev/null +++ b/include/asm-x86/mach-generic/mach_mpparse.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _MACH_MPPARSE_H | ||
2 | #define _MACH_MPPARSE_H 1 | ||
3 | |||
4 | #include <asm/genapic.h> | ||
5 | |||
6 | #define mpc_oem_bus_info (genapic->mpc_oem_bus_info) | ||
7 | #define mpc_oem_pci_bus (genapic->mpc_oem_pci_bus) | ||
8 | |||
9 | int mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid); | ||
10 | int acpi_madt_oem_check(char *oem_id, char *oem_table_id); | ||
11 | |||
12 | #endif | ||
diff --git a/include/asm-x86/mach-generic/mach_mpspec.h b/include/asm-x86/mach-generic/mach_mpspec.h new file mode 100644 index 000000000000..9ef0b941bb22 --- /dev/null +++ b/include/asm-x86/mach-generic/mach_mpspec.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 256 | ||
5 | |||
6 | /* Summit or generic (i.e. installer) kernels need lots of bus entries. */ | ||
7 | /* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */ | ||
8 | #define MAX_MP_BUSSES 260 | ||
9 | |||
10 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-numaq/mach_apic.h b/include/asm-x86/mach-numaq/mach_apic.h new file mode 100644 index 000000000000..5e5e7dd2692e --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_apic.h | |||
@@ -0,0 +1,149 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | #include <asm/io.h> | ||
5 | #include <linux/mmzone.h> | ||
6 | #include <linux/nodemask.h> | ||
7 | |||
8 | #define APIC_DFR_VALUE (APIC_DFR_CLUSTER) | ||
9 | |||
10 | static inline cpumask_t target_cpus(void) | ||
11 | { | ||
12 | return CPU_MASK_ALL; | ||
13 | } | ||
14 | |||
15 | #define TARGET_CPUS (target_cpus()) | ||
16 | |||
17 | #define NO_BALANCE_IRQ (1) | ||
18 | #define esr_disable (1) | ||
19 | |||
20 | #define INT_DELIVERY_MODE dest_LowestPrio | ||
21 | #define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */ | ||
22 | |||
23 | #define check_apicid_used(bitmap, apicid) physid_isset(apicid, bitmap) | ||
24 | #define check_apicid_present(bit) physid_isset(bit, phys_cpu_present_map) | ||
25 | #define apicid_cluster(apicid) (apicid & 0xF0) | ||
26 | |||
27 | static inline int apic_id_registered(void) | ||
28 | { | ||
29 | return 1; | ||
30 | } | ||
31 | |||
32 | static inline void init_apic_ldr(void) | ||
33 | { | ||
34 | /* Already done in NUMA-Q firmware */ | ||
35 | } | ||
36 | |||
37 | static inline void setup_apic_routing(void) | ||
38 | { | ||
39 | printk("Enabling APIC mode: %s. Using %d I/O APICs\n", | ||
40 | "NUMA-Q", nr_ioapics); | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * Skip adding the timer int on secondary nodes, which causes | ||
45 | * a small but painful rift in the time-space continuum. | ||
46 | */ | ||
47 | static inline int multi_timer_check(int apic, int irq) | ||
48 | { | ||
49 | return apic != 0 && irq == 0; | ||
50 | } | ||
51 | |||
52 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) | ||
53 | { | ||
54 | /* We don't have a good way to do this yet - hack */ | ||
55 | return physids_promote(0xFUL); | ||
56 | } | ||
57 | |||
58 | /* Mapping from cpu number to logical apicid */ | ||
59 | extern u8 cpu_2_logical_apicid[]; | ||
60 | static inline int cpu_to_logical_apicid(int cpu) | ||
61 | { | ||
62 | if (cpu >= NR_CPUS) | ||
63 | return BAD_APICID; | ||
64 | return (int)cpu_2_logical_apicid[cpu]; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Supporting over 60 cpus on NUMA-Q requires a locality-dependent | ||
69 | * cpu to APIC ID relation to properly interact with the intelligent | ||
70 | * mode of the cluster controller. | ||
71 | */ | ||
72 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
73 | { | ||
74 | if (mps_cpu < 60) | ||
75 | return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3)); | ||
76 | else | ||
77 | return BAD_APICID; | ||
78 | } | ||
79 | |||
80 | static inline int generate_logical_apicid(int quad, int phys_apicid) | ||
81 | { | ||
82 | return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1); | ||
83 | } | ||
84 | |||
85 | static inline int apicid_to_node(int logical_apicid) | ||
86 | { | ||
87 | return logical_apicid >> 4; | ||
88 | } | ||
89 | |||
90 | static inline physid_mask_t apicid_to_cpu_present(int logical_apicid) | ||
91 | { | ||
92 | int node = apicid_to_node(logical_apicid); | ||
93 | int cpu = __ffs(logical_apicid & 0xf); | ||
94 | |||
95 | return physid_mask_of_physid(cpu + 4*node); | ||
96 | } | ||
97 | |||
98 | static inline int mpc_apic_id(struct mpc_config_processor *m, | ||
99 | struct mpc_config_translation *translation_record) | ||
100 | { | ||
101 | int quad = translation_record->trans_quad; | ||
102 | int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid); | ||
103 | |||
104 | printk("Processor #%d %ld:%ld APIC version %d (quad %d, apic %d)\n", | ||
105 | m->mpc_apicid, | ||
106 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
107 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
108 | m->mpc_apicver, quad, logical_apicid); | ||
109 | return logical_apicid; | ||
110 | } | ||
111 | |||
112 | static inline void setup_portio_remap(void) | ||
113 | { | ||
114 | int num_quads = num_online_nodes(); | ||
115 | |||
116 | if (num_quads <= 1) | ||
117 | return; | ||
118 | |||
119 | printk("Remapping cross-quad port I/O for %d quads\n", num_quads); | ||
120 | xquad_portio = ioremap(XQUAD_PORTIO_BASE, num_quads*XQUAD_PORTIO_QUAD); | ||
121 | printk("xquad_portio vaddr 0x%08lx, len %08lx\n", | ||
122 | (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD); | ||
123 | } | ||
124 | |||
125 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) | ||
126 | { | ||
127 | return (1); | ||
128 | } | ||
129 | |||
130 | static inline void enable_apic_mode(void) | ||
131 | { | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * We use physical apicids here, not logical, so just return the default | ||
136 | * physical broadcast to stop people from breaking us | ||
137 | */ | ||
138 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
139 | { | ||
140 | return (int) 0xF; | ||
141 | } | ||
142 | |||
143 | /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ | ||
144 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
145 | { | ||
146 | return cpuid_apic >> index_msb; | ||
147 | } | ||
148 | |||
149 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-numaq/mach_apicdef.h b/include/asm-x86/mach-numaq/mach_apicdef.h new file mode 100644 index 000000000000..bf439d0690f5 --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_apicdef.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | |||
5 | #define APIC_ID_MASK (0xF<<24) | ||
6 | |||
7 | static inline unsigned get_apic_id(unsigned long x) | ||
8 | { | ||
9 | return (((x)>>24)&0x0F); | ||
10 | } | ||
11 | |||
12 | #define GET_APIC_ID(x) get_apic_id(x) | ||
13 | |||
14 | #endif | ||
diff --git a/include/asm-x86/mach-numaq/mach_ipi.h b/include/asm-x86/mach-numaq/mach_ipi.h new file mode 100644 index 000000000000..c6044488e9e6 --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_ipi.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | ||
2 | #define __ASM_MACH_IPI_H | ||
3 | |||
4 | void send_IPI_mask_sequence(cpumask_t, int vector); | ||
5 | |||
6 | static inline void send_IPI_mask(cpumask_t mask, int vector) | ||
7 | { | ||
8 | send_IPI_mask_sequence(mask, vector); | ||
9 | } | ||
10 | |||
11 | static inline void send_IPI_allbutself(int vector) | ||
12 | { | ||
13 | cpumask_t mask = cpu_online_map; | ||
14 | cpu_clear(smp_processor_id(), mask); | ||
15 | |||
16 | if (!cpus_empty(mask)) | ||
17 | send_IPI_mask(mask, vector); | ||
18 | } | ||
19 | |||
20 | static inline void send_IPI_all(int vector) | ||
21 | { | ||
22 | send_IPI_mask(cpu_online_map, vector); | ||
23 | } | ||
24 | |||
25 | #endif /* __ASM_MACH_IPI_H */ | ||
diff --git a/include/asm-x86/mach-numaq/mach_mpparse.h b/include/asm-x86/mach-numaq/mach_mpparse.h new file mode 100644 index 000000000000..51bbac8fc0c2 --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_mpparse.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __ASM_MACH_MPPARSE_H | ||
2 | #define __ASM_MACH_MPPARSE_H | ||
3 | |||
4 | static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, | ||
5 | struct mpc_config_translation *translation) | ||
6 | { | ||
7 | int quad = translation->trans_quad; | ||
8 | int local = translation->trans_local; | ||
9 | |||
10 | mp_bus_id_to_node[m->mpc_busid] = quad; | ||
11 | mp_bus_id_to_local[m->mpc_busid] = local; | ||
12 | printk("Bus #%d is %s (node %d)\n", m->mpc_busid, name, quad); | ||
13 | } | ||
14 | |||
15 | static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, | ||
16 | struct mpc_config_translation *translation) | ||
17 | { | ||
18 | int quad = translation->trans_quad; | ||
19 | int local = translation->trans_local; | ||
20 | |||
21 | quad_local_to_mp_bus_id[quad][local] = m->mpc_busid; | ||
22 | } | ||
23 | |||
24 | /* Hook from generic ACPI tables.c */ | ||
25 | static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | #endif /* __ASM_MACH_MPPARSE_H */ | ||
diff --git a/include/asm-x86/mach-numaq/mach_mpspec.h b/include/asm-x86/mach-numaq/mach_mpspec.h new file mode 100644 index 000000000000..dffb09856f8f --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_mpspec.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 512 | ||
5 | |||
6 | #define MAX_MP_BUSSES 32 | ||
7 | |||
8 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-numaq/mach_wakecpu.h b/include/asm-x86/mach-numaq/mach_wakecpu.h new file mode 100644 index 000000000000..00530041a991 --- /dev/null +++ b/include/asm-x86/mach-numaq/mach_wakecpu.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef __ASM_MACH_WAKECPU_H | ||
2 | #define __ASM_MACH_WAKECPU_H | ||
3 | |||
4 | /* This file copes with machines that wakeup secondary CPUs by NMIs */ | ||
5 | |||
6 | #define WAKE_SECONDARY_VIA_NMI | ||
7 | |||
8 | #define TRAMPOLINE_LOW phys_to_virt(0x8) | ||
9 | #define TRAMPOLINE_HIGH phys_to_virt(0xa) | ||
10 | |||
11 | #define boot_cpu_apicid boot_cpu_logical_apicid | ||
12 | |||
13 | /* We don't do anything here because we use NMI's to boot instead */ | ||
14 | static inline void wait_for_init_deassert(atomic_t *deassert) | ||
15 | { | ||
16 | } | ||
17 | |||
18 | /* | ||
19 | * Because we use NMIs rather than the INIT-STARTUP sequence to | ||
20 | * bootstrap the CPUs, the APIC may be in a weird state. Kick it. | ||
21 | */ | ||
22 | static inline void smp_callin_clear_local_apic(void) | ||
23 | { | ||
24 | clear_local_APIC(); | ||
25 | } | ||
26 | |||
27 | static inline void store_NMI_vector(unsigned short *high, unsigned short *low) | ||
28 | { | ||
29 | printk("Storing NMI vector\n"); | ||
30 | *high = *((volatile unsigned short *) TRAMPOLINE_HIGH); | ||
31 | *low = *((volatile unsigned short *) TRAMPOLINE_LOW); | ||
32 | } | ||
33 | |||
34 | static inline void restore_NMI_vector(unsigned short *high, unsigned short *low) | ||
35 | { | ||
36 | printk("Restoring NMI vector\n"); | ||
37 | *((volatile unsigned short *) TRAMPOLINE_HIGH) = *high; | ||
38 | *((volatile unsigned short *) TRAMPOLINE_LOW) = *low; | ||
39 | } | ||
40 | |||
41 | #define inquire_remote_apic(apicid) {} | ||
42 | |||
43 | #endif /* __ASM_MACH_WAKECPU_H */ | ||
diff --git a/include/asm-x86/mach-summit/irq_vectors_limits.h b/include/asm-x86/mach-summit/irq_vectors_limits.h new file mode 100644 index 000000000000..890ce3f5e09a --- /dev/null +++ b/include/asm-x86/mach-summit/irq_vectors_limits.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_IRQ_VECTORS_LIMITS_H | ||
2 | #define _ASM_IRQ_VECTORS_LIMITS_H | ||
3 | |||
4 | /* | ||
5 | * For Summit or generic (i.e. installer) kernels, we have lots of I/O APICs, | ||
6 | * even with uni-proc kernels, so use a big array. | ||
7 | * | ||
8 | * This value should be the same in both the generic and summit subarches. | ||
9 | * Change one, change 'em both. | ||
10 | */ | ||
11 | #define NR_IRQS 224 | ||
12 | #define NR_IRQ_VECTORS 1024 | ||
13 | |||
14 | #endif /* _ASM_IRQ_VECTORS_LIMITS_H */ | ||
diff --git a/include/asm-x86/mach-summit/mach_apic.h b/include/asm-x86/mach-summit/mach_apic.h new file mode 100644 index 000000000000..732f776aab8e --- /dev/null +++ b/include/asm-x86/mach-summit/mach_apic.h | |||
@@ -0,0 +1,197 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | #include <asm/smp.h> | ||
5 | |||
6 | #define esr_disable (1) | ||
7 | #define NO_BALANCE_IRQ (0) | ||
8 | |||
9 | /* In clustered mode, the high nibble of APIC ID is a cluster number. | ||
10 | * The low nibble is a 4-bit bitmap. */ | ||
11 | #define XAPIC_DEST_CPUS_SHIFT 4 | ||
12 | #define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1) | ||
13 | #define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT) | ||
14 | |||
15 | #define APIC_DFR_VALUE (APIC_DFR_CLUSTER) | ||
16 | |||
17 | static inline cpumask_t target_cpus(void) | ||
18 | { | ||
19 | /* CPU_MASK_ALL (0xff) has undefined behaviour with | ||
20 | * dest_LowestPrio mode logical clustered apic interrupt routing | ||
21 | * Just start on cpu 0. IRQ balancing will spread load | ||
22 | */ | ||
23 | return cpumask_of_cpu(0); | ||
24 | } | ||
25 | #define TARGET_CPUS (target_cpus()) | ||
26 | |||
27 | #define INT_DELIVERY_MODE (dest_LowestPrio) | ||
28 | #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ | ||
29 | |||
30 | static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) | ||
31 | { | ||
32 | return 0; | ||
33 | } | ||
34 | |||
35 | /* we don't use the phys_cpu_present_map to indicate apicid presence */ | ||
36 | static inline unsigned long check_apicid_present(int bit) | ||
37 | { | ||
38 | return 1; | ||
39 | } | ||
40 | |||
41 | #define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK) | ||
42 | |||
43 | extern u8 bios_cpu_apicid[]; | ||
44 | extern u8 cpu_2_logical_apicid[]; | ||
45 | |||
46 | static inline void init_apic_ldr(void) | ||
47 | { | ||
48 | unsigned long val, id; | ||
49 | int count = 0; | ||
50 | u8 my_id = (u8)hard_smp_processor_id(); | ||
51 | u8 my_cluster = (u8)apicid_cluster(my_id); | ||
52 | #ifdef CONFIG_SMP | ||
53 | u8 lid; | ||
54 | int i; | ||
55 | |||
56 | /* Create logical APIC IDs by counting CPUs already in cluster. */ | ||
57 | for (count = 0, i = NR_CPUS; --i >= 0; ) { | ||
58 | lid = cpu_2_logical_apicid[i]; | ||
59 | if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster) | ||
60 | ++count; | ||
61 | } | ||
62 | #endif | ||
63 | /* We only have a 4 wide bitmap in cluster mode. If a deranged | ||
64 | * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */ | ||
65 | BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT); | ||
66 | id = my_cluster | (1UL << count); | ||
67 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); | ||
68 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; | ||
69 | val |= SET_APIC_LOGICAL_ID(id); | ||
70 | apic_write_around(APIC_LDR, val); | ||
71 | } | ||
72 | |||
73 | static inline int multi_timer_check(int apic, int irq) | ||
74 | { | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static inline int apic_id_registered(void) | ||
79 | { | ||
80 | return 1; | ||
81 | } | ||
82 | |||
83 | static inline void setup_apic_routing(void) | ||
84 | { | ||
85 | printk("Enabling APIC mode: Summit. Using %d I/O APICs\n", | ||
86 | nr_ioapics); | ||
87 | } | ||
88 | |||
89 | static inline int apicid_to_node(int logical_apicid) | ||
90 | { | ||
91 | #ifdef CONFIG_SMP | ||
92 | return apicid_2_node[hard_smp_processor_id()]; | ||
93 | #else | ||
94 | return 0; | ||
95 | #endif | ||
96 | } | ||
97 | |||
98 | /* Mapping from cpu number to logical apicid */ | ||
99 | static inline int cpu_to_logical_apicid(int cpu) | ||
100 | { | ||
101 | #ifdef CONFIG_SMP | ||
102 | if (cpu >= NR_CPUS) | ||
103 | return BAD_APICID; | ||
104 | return (int)cpu_2_logical_apicid[cpu]; | ||
105 | #else | ||
106 | return logical_smp_processor_id(); | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
111 | { | ||
112 | if (mps_cpu < NR_CPUS) | ||
113 | return (int)bios_cpu_apicid[mps_cpu]; | ||
114 | else | ||
115 | return BAD_APICID; | ||
116 | } | ||
117 | |||
118 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_id_map) | ||
119 | { | ||
120 | /* For clustered we don't have a good way to do this yet - hack */ | ||
121 | return physids_promote(0x0F); | ||
122 | } | ||
123 | |||
124 | static inline physid_mask_t apicid_to_cpu_present(int apicid) | ||
125 | { | ||
126 | return physid_mask_of_physid(0); | ||
127 | } | ||
128 | |||
129 | static inline int mpc_apic_id(struct mpc_config_processor *m, | ||
130 | struct mpc_config_translation *translation_record) | ||
131 | { | ||
132 | printk("Processor #%d %ld:%ld APIC version %d\n", | ||
133 | m->mpc_apicid, | ||
134 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
135 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
136 | m->mpc_apicver); | ||
137 | return (m->mpc_apicid); | ||
138 | } | ||
139 | |||
140 | static inline void setup_portio_remap(void) | ||
141 | { | ||
142 | } | ||
143 | |||
144 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) | ||
145 | { | ||
146 | return 1; | ||
147 | } | ||
148 | |||
149 | static inline void enable_apic_mode(void) | ||
150 | { | ||
151 | } | ||
152 | |||
153 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
154 | { | ||
155 | int num_bits_set; | ||
156 | int cpus_found = 0; | ||
157 | int cpu; | ||
158 | int apicid; | ||
159 | |||
160 | num_bits_set = cpus_weight(cpumask); | ||
161 | /* Return id to all */ | ||
162 | if (num_bits_set == NR_CPUS) | ||
163 | return (int) 0xFF; | ||
164 | /* | ||
165 | * The cpus in the mask must all be on the apic cluster. If are not | ||
166 | * on the same apicid cluster return default value of TARGET_CPUS. | ||
167 | */ | ||
168 | cpu = first_cpu(cpumask); | ||
169 | apicid = cpu_to_logical_apicid(cpu); | ||
170 | while (cpus_found < num_bits_set) { | ||
171 | if (cpu_isset(cpu, cpumask)) { | ||
172 | int new_apicid = cpu_to_logical_apicid(cpu); | ||
173 | if (apicid_cluster(apicid) != | ||
174 | apicid_cluster(new_apicid)){ | ||
175 | printk ("%s: Not a valid mask!\n",__FUNCTION__); | ||
176 | return 0xFF; | ||
177 | } | ||
178 | apicid = apicid | new_apicid; | ||
179 | cpus_found++; | ||
180 | } | ||
181 | cpu++; | ||
182 | } | ||
183 | return apicid; | ||
184 | } | ||
185 | |||
186 | /* cpuid returns the value latched in the HW at reset, not the APIC ID | ||
187 | * register's value. For any box whose BIOS changes APIC IDs, like | ||
188 | * clustered APIC systems, we must use hard_smp_processor_id. | ||
189 | * | ||
190 | * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. | ||
191 | */ | ||
192 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
193 | { | ||
194 | return hard_smp_processor_id() >> index_msb; | ||
195 | } | ||
196 | |||
197 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-summit/mach_apicdef.h b/include/asm-x86/mach-summit/mach_apicdef.h new file mode 100644 index 000000000000..a58ab5a75c8c --- /dev/null +++ b/include/asm-x86/mach-summit/mach_apicdef.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | #define APIC_ID_MASK (0xFF<<24) | ||
5 | |||
6 | static inline unsigned get_apic_id(unsigned long x) | ||
7 | { | ||
8 | return (((x)>>24)&0xFF); | ||
9 | } | ||
10 | |||
11 | #define GET_APIC_ID(x) get_apic_id(x) | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/mach-summit/mach_ipi.h b/include/asm-x86/mach-summit/mach_ipi.h new file mode 100644 index 000000000000..9404c535b7ec --- /dev/null +++ b/include/asm-x86/mach-summit/mach_ipi.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | ||
2 | #define __ASM_MACH_IPI_H | ||
3 | |||
4 | void send_IPI_mask_sequence(cpumask_t mask, int vector); | ||
5 | |||
6 | static inline void send_IPI_mask(cpumask_t mask, int vector) | ||
7 | { | ||
8 | send_IPI_mask_sequence(mask, vector); | ||
9 | } | ||
10 | |||
11 | static inline void send_IPI_allbutself(int vector) | ||
12 | { | ||
13 | cpumask_t mask = cpu_online_map; | ||
14 | cpu_clear(smp_processor_id(), mask); | ||
15 | |||
16 | if (!cpus_empty(mask)) | ||
17 | send_IPI_mask(mask, vector); | ||
18 | } | ||
19 | |||
20 | static inline void send_IPI_all(int vector) | ||
21 | { | ||
22 | send_IPI_mask(cpu_online_map, vector); | ||
23 | } | ||
24 | |||
25 | #endif /* __ASM_MACH_IPI_H */ | ||
diff --git a/include/asm-x86/mach-summit/mach_mpparse.h b/include/asm-x86/mach-summit/mach_mpparse.h new file mode 100644 index 000000000000..c2520539d934 --- /dev/null +++ b/include/asm-x86/mach-summit/mach_mpparse.h | |||
@@ -0,0 +1,121 @@ | |||
1 | #ifndef __ASM_MACH_MPPARSE_H | ||
2 | #define __ASM_MACH_MPPARSE_H | ||
3 | |||
4 | #include <mach_apic.h> | ||
5 | #include <asm/tsc.h> | ||
6 | |||
7 | extern int use_cyclone; | ||
8 | |||
9 | #ifdef CONFIG_X86_SUMMIT_NUMA | ||
10 | extern void setup_summit(void); | ||
11 | #else | ||
12 | #define setup_summit() {} | ||
13 | #endif | ||
14 | |||
15 | static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, | ||
16 | struct mpc_config_translation *translation) | ||
17 | { | ||
18 | Dprintk("Bus #%d is %s\n", m->mpc_busid, name); | ||
19 | } | ||
20 | |||
21 | static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, | ||
22 | struct mpc_config_translation *translation) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, | ||
27 | char *productid) | ||
28 | { | ||
29 | if (!strncmp(oem, "IBM ENSW", 8) && | ||
30 | (!strncmp(productid, "VIGIL SMP", 9) | ||
31 | || !strncmp(productid, "EXA", 3) | ||
32 | || !strncmp(productid, "RUTHLESS SMP", 12))){ | ||
33 | mark_tsc_unstable("Summit based system"); | ||
34 | use_cyclone = 1; /*enable cyclone-timer*/ | ||
35 | setup_summit(); | ||
36 | return 1; | ||
37 | } | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | /* Hook from generic ACPI tables.c */ | ||
42 | static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
43 | { | ||
44 | if (!strncmp(oem_id, "IBM", 3) && | ||
45 | (!strncmp(oem_table_id, "SERVIGIL", 8) | ||
46 | || !strncmp(oem_table_id, "EXA", 3))){ | ||
47 | mark_tsc_unstable("Summit based system"); | ||
48 | use_cyclone = 1; /*enable cyclone-timer*/ | ||
49 | setup_summit(); | ||
50 | return 1; | ||
51 | } | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | struct rio_table_hdr { | ||
56 | unsigned char version; /* Version number of this data structure */ | ||
57 | /* Version 3 adds chassis_num & WP_index */ | ||
58 | unsigned char num_scal_dev; /* # of Scalability devices (Twisters for Vigil) */ | ||
59 | unsigned char num_rio_dev; /* # of RIO I/O devices (Cyclones and Winnipegs) */ | ||
60 | } __attribute__((packed)); | ||
61 | |||
62 | struct scal_detail { | ||
63 | unsigned char node_id; /* Scalability Node ID */ | ||
64 | unsigned long CBAR; /* Address of 1MB register space */ | ||
65 | unsigned char port0node; /* Node ID port connected to: 0xFF=None */ | ||
66 | unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */ | ||
67 | unsigned char port1node; /* Node ID port connected to: 0xFF = None */ | ||
68 | unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */ | ||
69 | unsigned char port2node; /* Node ID port connected to: 0xFF = None */ | ||
70 | unsigned char port2port; /* Port num port connected to: 0,1,2, or 0xFF=None */ | ||
71 | unsigned char chassis_num; /* 1 based Chassis number (1 = boot node) */ | ||
72 | } __attribute__((packed)); | ||
73 | |||
74 | struct rio_detail { | ||
75 | unsigned char node_id; /* RIO Node ID */ | ||
76 | unsigned long BBAR; /* Address of 1MB register space */ | ||
77 | unsigned char type; /* Type of device */ | ||
78 | unsigned char owner_id; /* For WPEG: Node ID of Cyclone that owns this WPEG*/ | ||
79 | /* For CYC: Node ID of Twister that owns this CYC */ | ||
80 | unsigned char port0node; /* Node ID port connected to: 0xFF=None */ | ||
81 | unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */ | ||
82 | unsigned char port1node; /* Node ID port connected to: 0xFF=None */ | ||
83 | unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */ | ||
84 | unsigned char first_slot; /* For WPEG: Lowest slot number below this WPEG */ | ||
85 | /* For CYC: 0 */ | ||
86 | unsigned char status; /* For WPEG: Bit 0 = 1 : the XAPIC is used */ | ||
87 | /* = 0 : the XAPIC is not used, ie:*/ | ||
88 | /* ints fwded to another XAPIC */ | ||
89 | /* Bits1:7 Reserved */ | ||
90 | /* For CYC: Bits0:7 Reserved */ | ||
91 | unsigned char WP_index; /* For WPEG: WPEG instance index - lower ones have */ | ||
92 | /* lower slot numbers/PCI bus numbers */ | ||
93 | /* For CYC: No meaning */ | ||
94 | unsigned char chassis_num; /* 1 based Chassis number */ | ||
95 | /* For LookOut WPEGs this field indicates the */ | ||
96 | /* Expansion Chassis #, enumerated from Boot */ | ||
97 | /* Node WPEG external port, then Boot Node CYC */ | ||
98 | /* external port, then Next Vigil chassis WPEG */ | ||
99 | /* external port, etc. */ | ||
100 | /* Shared Lookouts have only 1 chassis number (the */ | ||
101 | /* first one assigned) */ | ||
102 | } __attribute__((packed)); | ||
103 | |||
104 | |||
105 | typedef enum { | ||
106 | CompatTwister = 0, /* Compatibility Twister */ | ||
107 | AltTwister = 1, /* Alternate Twister of internal 8-way */ | ||
108 | CompatCyclone = 2, /* Compatibility Cyclone */ | ||
109 | AltCyclone = 3, /* Alternate Cyclone of internal 8-way */ | ||
110 | CompatWPEG = 4, /* Compatibility WPEG */ | ||
111 | AltWPEG = 5, /* Second Planar WPEG */ | ||
112 | LookOutAWPEG = 6, /* LookOut WPEG */ | ||
113 | LookOutBWPEG = 7, /* LookOut WPEG */ | ||
114 | } node_type; | ||
115 | |||
116 | static inline int is_WPEG(struct rio_detail *rio){ | ||
117 | return (rio->type == CompatWPEG || rio->type == AltWPEG || | ||
118 | rio->type == LookOutAWPEG || rio->type == LookOutBWPEG); | ||
119 | } | ||
120 | |||
121 | #endif /* __ASM_MACH_MPPARSE_H */ | ||
diff --git a/include/asm-x86/mach-summit/mach_mpspec.h b/include/asm-x86/mach-summit/mach_mpspec.h new file mode 100644 index 000000000000..bd765523511a --- /dev/null +++ b/include/asm-x86/mach-summit/mach_mpspec.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __ASM_MACH_MPSPEC_H | ||
2 | #define __ASM_MACH_MPSPEC_H | ||
3 | |||
4 | #define MAX_IRQ_SOURCES 256 | ||
5 | |||
6 | /* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */ | ||
7 | #define MAX_MP_BUSSES 260 | ||
8 | |||
9 | #endif /* __ASM_MACH_MPSPEC_H */ | ||
diff --git a/include/asm-x86/mach-visws/cobalt.h b/include/asm-x86/mach-visws/cobalt.h new file mode 100644 index 000000000000..33c36225a042 --- /dev/null +++ b/include/asm-x86/mach-visws/cobalt.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef __I386_SGI_COBALT_H | ||
2 | #define __I386_SGI_COBALT_H | ||
3 | |||
4 | #include <asm/fixmap.h> | ||
5 | |||
6 | /* | ||
7 | * Cobalt SGI Visual Workstation system ASIC | ||
8 | */ | ||
9 | |||
10 | #define CO_CPU_NUM_PHYS 0x1e00 | ||
11 | #define CO_CPU_TAB_PHYS (CO_CPU_NUM_PHYS + 2) | ||
12 | |||
13 | #define CO_CPU_MAX 4 | ||
14 | |||
15 | #define CO_CPU_PHYS 0xc2000000 | ||
16 | #define CO_APIC_PHYS 0xc4000000 | ||
17 | |||
18 | /* see set_fixmap() and asm/fixmap.h */ | ||
19 | #define CO_CPU_VADDR (fix_to_virt(FIX_CO_CPU)) | ||
20 | #define CO_APIC_VADDR (fix_to_virt(FIX_CO_APIC)) | ||
21 | |||
22 | /* Cobalt CPU registers -- relative to CO_CPU_VADDR, use co_cpu_*() */ | ||
23 | #define CO_CPU_REV 0x08 | ||
24 | #define CO_CPU_CTRL 0x10 | ||
25 | #define CO_CPU_STAT 0x20 | ||
26 | #define CO_CPU_TIMEVAL 0x30 | ||
27 | |||
28 | /* CO_CPU_CTRL bits */ | ||
29 | #define CO_CTRL_TIMERUN 0x04 /* 0 == disabled */ | ||
30 | #define CO_CTRL_TIMEMASK 0x08 /* 0 == unmasked */ | ||
31 | |||
32 | /* CO_CPU_STATUS bits */ | ||
33 | #define CO_STAT_TIMEINTR 0x02 /* (r) 1 == int pend, (w) 0 == clear */ | ||
34 | |||
35 | /* CO_CPU_TIMEVAL value */ | ||
36 | #define CO_TIME_HZ 100000000 /* Cobalt core rate */ | ||
37 | |||
38 | /* Cobalt APIC registers -- relative to CO_APIC_VADDR, use co_apic_*() */ | ||
39 | #define CO_APIC_HI(n) (((n) * 0x10) + 4) | ||
40 | #define CO_APIC_LO(n) ((n) * 0x10) | ||
41 | #define CO_APIC_ID 0x0ffc | ||
42 | |||
43 | /* CO_APIC_ID bits */ | ||
44 | #define CO_APIC_ENABLE 0x00000100 | ||
45 | |||
46 | /* CO_APIC_LO bits */ | ||
47 | #define CO_APIC_MASK 0x00010000 /* 0 = enabled */ | ||
48 | #define CO_APIC_LEVEL 0x00008000 /* 0 = edge */ | ||
49 | |||
50 | /* | ||
51 | * Where things are physically wired to Cobalt | ||
52 | * #defines with no board _<type>_<rev>_ are common to all (thus far) | ||
53 | */ | ||
54 | #define CO_APIC_IDE0 4 | ||
55 | #define CO_APIC_IDE1 2 /* Only on 320 */ | ||
56 | |||
57 | #define CO_APIC_8259 12 /* serial, floppy, par-l-l */ | ||
58 | |||
59 | /* Lithium PCI Bridge A -- "the one with 82557 Ethernet" */ | ||
60 | #define CO_APIC_PCIA_BASE0 0 /* and 1 */ /* slot 0, line 0 */ | ||
61 | #define CO_APIC_PCIA_BASE123 5 /* and 6 */ /* slot 0, line 1 */ | ||
62 | |||
63 | #define CO_APIC_PIIX4_USB 7 /* this one is weird */ | ||
64 | |||
65 | /* Lithium PCI Bridge B -- "the one with PIIX4" */ | ||
66 | #define CO_APIC_PCIB_BASE0 8 /* and 9-12 *//* slot 0, line 0 */ | ||
67 | #define CO_APIC_PCIB_BASE123 13 /* 14.15 */ /* slot 0, line 1 */ | ||
68 | |||
69 | #define CO_APIC_VIDOUT0 16 | ||
70 | #define CO_APIC_VIDOUT1 17 | ||
71 | #define CO_APIC_VIDIN0 18 | ||
72 | #define CO_APIC_VIDIN1 19 | ||
73 | |||
74 | #define CO_APIC_LI_AUDIO 22 | ||
75 | |||
76 | #define CO_APIC_AS 24 | ||
77 | #define CO_APIC_RE 25 | ||
78 | |||
79 | #define CO_APIC_CPU 28 /* Timer and Cache interrupt */ | ||
80 | #define CO_APIC_NMI 29 | ||
81 | #define CO_APIC_LAST CO_APIC_NMI | ||
82 | |||
83 | /* | ||
84 | * This is how irqs are assigned on the Visual Workstation. | ||
85 | * Legacy devices get irq's 1-15 (system clock is 0 and is CO_APIC_CPU). | ||
86 | * All other devices (including PCI) go to Cobalt and are irq's 16 on up. | ||
87 | */ | ||
88 | #define CO_IRQ_APIC0 16 /* irq of apic entry 0 */ | ||
89 | #define IS_CO_APIC(irq) ((irq) >= CO_IRQ_APIC0) | ||
90 | #define CO_IRQ(apic) (CO_IRQ_APIC0 + (apic)) /* apic ent to irq */ | ||
91 | #define CO_APIC(irq) ((irq) - CO_IRQ_APIC0) /* irq to apic ent */ | ||
92 | #define CO_IRQ_IDE0 14 /* knowledge of... */ | ||
93 | #define CO_IRQ_IDE1 15 /* ... ide driver defaults! */ | ||
94 | #define CO_IRQ_8259 CO_IRQ(CO_APIC_8259) | ||
95 | |||
96 | #ifdef CONFIG_X86_VISWS_APIC | ||
97 | extern __inline void co_cpu_write(unsigned long reg, unsigned long v) | ||
98 | { | ||
99 | *((volatile unsigned long *)(CO_CPU_VADDR+reg))=v; | ||
100 | } | ||
101 | |||
102 | extern __inline unsigned long co_cpu_read(unsigned long reg) | ||
103 | { | ||
104 | return *((volatile unsigned long *)(CO_CPU_VADDR+reg)); | ||
105 | } | ||
106 | |||
107 | extern __inline void co_apic_write(unsigned long reg, unsigned long v) | ||
108 | { | ||
109 | *((volatile unsigned long *)(CO_APIC_VADDR+reg))=v; | ||
110 | } | ||
111 | |||
112 | extern __inline unsigned long co_apic_read(unsigned long reg) | ||
113 | { | ||
114 | return *((volatile unsigned long *)(CO_APIC_VADDR+reg)); | ||
115 | } | ||
116 | #endif | ||
117 | |||
118 | extern char visws_board_type; | ||
119 | |||
120 | #define VISWS_320 0 | ||
121 | #define VISWS_540 1 | ||
122 | |||
123 | extern char visws_board_rev; | ||
124 | |||
125 | #endif /* __I386_SGI_COBALT_H */ | ||
diff --git a/include/asm-x86/mach-visws/entry_arch.h b/include/asm-x86/mach-visws/entry_arch.h new file mode 100644 index 000000000000..b183fa6d83d9 --- /dev/null +++ b/include/asm-x86/mach-visws/entry_arch.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * The following vectors are part of the Linux architecture, there | ||
3 | * is no hardware IRQ pin equivalent for them, they are triggered | ||
4 | * through the ICC by us (IPIs) | ||
5 | */ | ||
6 | #ifdef CONFIG_X86_SMP | ||
7 | BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) | ||
8 | BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR) | ||
9 | BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) | ||
10 | #endif | ||
11 | |||
12 | /* | ||
13 | * every pentium local APIC has two 'local interrupts', with a | ||
14 | * soft-definable vector attached to both interrupts, one of | ||
15 | * which is a timer interrupt, the other one is error counter | ||
16 | * overflow. Linux uses the local APIC timer interrupt to get | ||
17 | * a much simpler SMP time architecture: | ||
18 | */ | ||
19 | #ifdef CONFIG_X86_LOCAL_APIC | ||
20 | BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR) | ||
21 | BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR) | ||
22 | BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR) | ||
23 | #endif | ||
diff --git a/include/asm-x86/mach-visws/irq_vectors.h b/include/asm-x86/mach-visws/irq_vectors.h new file mode 100644 index 000000000000..cb572d8db505 --- /dev/null +++ b/include/asm-x86/mach-visws/irq_vectors.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef _ASM_IRQ_VECTORS_H | ||
2 | #define _ASM_IRQ_VECTORS_H | ||
3 | |||
4 | /* | ||
5 | * IDT vectors usable for external interrupt sources start | ||
6 | * at 0x20: | ||
7 | */ | ||
8 | #define FIRST_EXTERNAL_VECTOR 0x20 | ||
9 | |||
10 | #define SYSCALL_VECTOR 0x80 | ||
11 | |||
12 | /* | ||
13 | * Vectors 0x20-0x2f are used for ISA interrupts. | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | * Special IRQ vectors used by the SMP architecture, 0xf0-0xff | ||
18 | * | ||
19 | * some of the following vectors are 'rare', they are merged | ||
20 | * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. | ||
21 | * TLB, reschedule and local APIC vectors are performance-critical. | ||
22 | * | ||
23 | * Vectors 0xf0-0xfa are free (reserved for future Linux use). | ||
24 | */ | ||
25 | #define SPURIOUS_APIC_VECTOR 0xff | ||
26 | #define ERROR_APIC_VECTOR 0xfe | ||
27 | #define INVALIDATE_TLB_VECTOR 0xfd | ||
28 | #define RESCHEDULE_VECTOR 0xfc | ||
29 | #define CALL_FUNCTION_VECTOR 0xfb | ||
30 | |||
31 | #define THERMAL_APIC_VECTOR 0xf0 | ||
32 | /* | ||
33 | * Local APIC timer IRQ vector is on a different priority level, | ||
34 | * to work around the 'lost local interrupt if more than 2 IRQ | ||
35 | * sources per level' errata. | ||
36 | */ | ||
37 | #define LOCAL_TIMER_VECTOR 0xef | ||
38 | |||
39 | /* | ||
40 | * First APIC vector available to drivers: (vectors 0x30-0xee) | ||
41 | * we start at 0x31 to spread out vectors evenly between priority | ||
42 | * levels. (0x80 is the syscall vector) | ||
43 | */ | ||
44 | #define FIRST_DEVICE_VECTOR 0x31 | ||
45 | #define FIRST_SYSTEM_VECTOR 0xef | ||
46 | |||
47 | #define TIMER_IRQ 0 | ||
48 | |||
49 | /* | ||
50 | * IRQ definitions | ||
51 | */ | ||
52 | #define NR_VECTORS 256 | ||
53 | #define NR_IRQS 224 | ||
54 | #define NR_IRQ_VECTORS NR_IRQS | ||
55 | |||
56 | #define FPU_IRQ 13 | ||
57 | |||
58 | #define FIRST_VM86_IRQ 3 | ||
59 | #define LAST_VM86_IRQ 15 | ||
60 | #define invalid_vm86_irq(irq) ((irq) < 3 || (irq) > 15) | ||
61 | |||
62 | #endif /* _ASM_IRQ_VECTORS_H */ | ||
diff --git a/include/asm-x86/mach-visws/lithium.h b/include/asm-x86/mach-visws/lithium.h new file mode 100644 index 000000000000..d443e68d0066 --- /dev/null +++ b/include/asm-x86/mach-visws/lithium.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef __I386_SGI_LITHIUM_H | ||
2 | #define __I386_SGI_LITHIUM_H | ||
3 | |||
4 | #include <asm/fixmap.h> | ||
5 | |||
6 | /* | ||
7 | * Lithium is the SGI Visual Workstation I/O ASIC | ||
8 | */ | ||
9 | |||
10 | #define LI_PCI_A_PHYS 0xfc000000 /* Enet is dev 3 */ | ||
11 | #define LI_PCI_B_PHYS 0xfd000000 /* PIIX4 is here */ | ||
12 | |||
13 | /* see set_fixmap() and asm/fixmap.h */ | ||
14 | #define LI_PCIA_VADDR (fix_to_virt(FIX_LI_PCIA)) | ||
15 | #define LI_PCIB_VADDR (fix_to_virt(FIX_LI_PCIB)) | ||
16 | |||
17 | /* Not a standard PCI? (not in linux/pci.h) */ | ||
18 | #define LI_PCI_BUSNUM 0x44 /* lo8: primary, hi8: sub */ | ||
19 | #define LI_PCI_INTEN 0x46 | ||
20 | |||
21 | /* LI_PCI_INTENT bits */ | ||
22 | #define LI_INTA_0 0x0001 | ||
23 | #define LI_INTA_1 0x0002 | ||
24 | #define LI_INTA_2 0x0004 | ||
25 | #define LI_INTA_3 0x0008 | ||
26 | #define LI_INTA_4 0x0010 | ||
27 | #define LI_INTB 0x0020 | ||
28 | #define LI_INTC 0x0040 | ||
29 | #define LI_INTD 0x0080 | ||
30 | |||
31 | /* More special purpose macros... */ | ||
32 | extern __inline void li_pcia_write16(unsigned long reg, unsigned short v) | ||
33 | { | ||
34 | *((volatile unsigned short *)(LI_PCIA_VADDR+reg))=v; | ||
35 | } | ||
36 | |||
37 | extern __inline unsigned short li_pcia_read16(unsigned long reg) | ||
38 | { | ||
39 | return *((volatile unsigned short *)(LI_PCIA_VADDR+reg)); | ||
40 | } | ||
41 | |||
42 | extern __inline void li_pcib_write16(unsigned long reg, unsigned short v) | ||
43 | { | ||
44 | *((volatile unsigned short *)(LI_PCIB_VADDR+reg))=v; | ||
45 | } | ||
46 | |||
47 | extern __inline unsigned short li_pcib_read16(unsigned long reg) | ||
48 | { | ||
49 | return *((volatile unsigned short *)(LI_PCIB_VADDR+reg)); | ||
50 | } | ||
51 | |||
52 | #endif | ||
53 | |||
diff --git a/include/asm-x86/mach-visws/mach_apic.h b/include/asm-x86/mach-visws/mach_apic.h new file mode 100644 index 000000000000..efac6f0d139f --- /dev/null +++ b/include/asm-x86/mach-visws/mach_apic.h | |||
@@ -0,0 +1,103 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | #include <mach_apicdef.h> | ||
5 | #include <asm/smp.h> | ||
6 | |||
7 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
8 | |||
9 | #define no_balance_irq (0) | ||
10 | #define esr_disable (0) | ||
11 | |||
12 | #define INT_DELIVERY_MODE dest_LowestPrio | ||
13 | #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ | ||
14 | |||
15 | #ifdef CONFIG_SMP | ||
16 | #define TARGET_CPUS cpu_online_map | ||
17 | #else | ||
18 | #define TARGET_CPUS cpumask_of_cpu(0) | ||
19 | #endif | ||
20 | |||
21 | #define check_apicid_used(bitmap, apicid) physid_isset(apicid, bitmap) | ||
22 | #define check_apicid_present(bit) physid_isset(bit, phys_cpu_present_map) | ||
23 | |||
24 | static inline int apic_id_registered(void) | ||
25 | { | ||
26 | return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map); | ||
27 | } | ||
28 | |||
29 | /* | ||
30 | * Set up the logical destination ID. | ||
31 | * | ||
32 | * Intel recommends to set DFR, LDR and TPR before enabling | ||
33 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
34 | * document number 292116). So here it goes... | ||
35 | */ | ||
36 | static inline void init_apic_ldr(void) | ||
37 | { | ||
38 | unsigned long val; | ||
39 | |||
40 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); | ||
41 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; | ||
42 | val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id()); | ||
43 | apic_write_around(APIC_LDR, val); | ||
44 | } | ||
45 | |||
46 | static inline void summit_check(char *oem, char *productid) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | static inline void setup_apic_routing(void) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | static inline int apicid_to_node(int logical_apicid) | ||
55 | { | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | /* Mapping from cpu number to logical apicid */ | ||
60 | static inline int cpu_to_logical_apicid(int cpu) | ||
61 | { | ||
62 | return 1 << cpu; | ||
63 | } | ||
64 | |||
65 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
66 | { | ||
67 | if (mps_cpu < get_physical_broadcast()) | ||
68 | return mps_cpu; | ||
69 | else | ||
70 | return BAD_APICID; | ||
71 | } | ||
72 | |||
73 | static inline physid_mask_t apicid_to_cpu_present(int apicid) | ||
74 | { | ||
75 | return physid_mask_of_physid(apicid); | ||
76 | } | ||
77 | |||
78 | #define WAKE_SECONDARY_VIA_INIT | ||
79 | |||
80 | static inline void setup_portio_remap(void) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | static inline void enable_apic_mode(void) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) | ||
89 | { | ||
90 | return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map); | ||
91 | } | ||
92 | |||
93 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) | ||
94 | { | ||
95 | return cpus_addr(cpumask)[0]; | ||
96 | } | ||
97 | |||
98 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) | ||
99 | { | ||
100 | return cpuid_apic >> index_msb; | ||
101 | } | ||
102 | |||
103 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/mach-visws/mach_apicdef.h b/include/asm-x86/mach-visws/mach_apicdef.h new file mode 100644 index 000000000000..826cfa97d778 --- /dev/null +++ b/include/asm-x86/mach-visws/mach_apicdef.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __ASM_MACH_APICDEF_H | ||
2 | #define __ASM_MACH_APICDEF_H | ||
3 | |||
4 | #define APIC_ID_MASK (0xF<<24) | ||
5 | |||
6 | static inline unsigned get_apic_id(unsigned long x) | ||
7 | { | ||
8 | return (((x)>>24)&0xF); | ||
9 | } | ||
10 | #define GET_APIC_ID(x) get_apic_id(x) | ||
11 | |||
12 | #endif | ||
diff --git a/include/asm-x86/mach-visws/piix4.h b/include/asm-x86/mach-visws/piix4.h new file mode 100644 index 000000000000..83ea4f46e419 --- /dev/null +++ b/include/asm-x86/mach-visws/piix4.h | |||
@@ -0,0 +1,107 @@ | |||
1 | #ifndef __I386_SGI_PIIX_H | ||
2 | #define __I386_SGI_PIIX_H | ||
3 | |||
4 | /* | ||
5 | * PIIX4 as used on SGI Visual Workstations | ||
6 | */ | ||
7 | |||
8 | #define PIIX_PM_START 0x0F80 | ||
9 | |||
10 | #define SIO_GPIO_START 0x0FC0 | ||
11 | |||
12 | #define SIO_PM_START 0x0FC8 | ||
13 | |||
14 | #define PMBASE PIIX_PM_START | ||
15 | #define GPIREG0 (PMBASE+0x30) | ||
16 | #define GPIREG(x) (GPIREG0+((x)/8)) | ||
17 | #define GPIBIT(x) (1 << ((x)%8)) | ||
18 | |||
19 | #define PIIX_GPI_BD_ID1 18 | ||
20 | #define PIIX_GPI_BD_ID2 19 | ||
21 | #define PIIX_GPI_BD_ID3 20 | ||
22 | #define PIIX_GPI_BD_ID4 21 | ||
23 | #define PIIX_GPI_BD_REG GPIREG(PIIX_GPI_BD_ID1) | ||
24 | #define PIIX_GPI_BD_MASK (GPIBIT(PIIX_GPI_BD_ID1) | \ | ||
25 | GPIBIT(PIIX_GPI_BD_ID2) | \ | ||
26 | GPIBIT(PIIX_GPI_BD_ID3) | \ | ||
27 | GPIBIT(PIIX_GPI_BD_ID4) ) | ||
28 | |||
29 | #define PIIX_GPI_BD_SHIFT (PIIX_GPI_BD_ID1 % 8) | ||
30 | |||
31 | #define SIO_INDEX 0x2e | ||
32 | #define SIO_DATA 0x2f | ||
33 | |||
34 | #define SIO_DEV_SEL 0x7 | ||
35 | #define SIO_DEV_ENB 0x30 | ||
36 | #define SIO_DEV_MSB 0x60 | ||
37 | #define SIO_DEV_LSB 0x61 | ||
38 | |||
39 | #define SIO_GP_DEV 0x7 | ||
40 | |||
41 | #define SIO_GP_BASE SIO_GPIO_START | ||
42 | #define SIO_GP_MSB (SIO_GP_BASE>>8) | ||
43 | #define SIO_GP_LSB (SIO_GP_BASE&0xff) | ||
44 | |||
45 | #define SIO_GP_DATA1 (SIO_GP_BASE+0) | ||
46 | |||
47 | #define SIO_PM_DEV 0x8 | ||
48 | |||
49 | #define SIO_PM_BASE SIO_PM_START | ||
50 | #define SIO_PM_MSB (SIO_PM_BASE>>8) | ||
51 | #define SIO_PM_LSB (SIO_PM_BASE&0xff) | ||
52 | #define SIO_PM_INDEX (SIO_PM_BASE+0) | ||
53 | #define SIO_PM_DATA (SIO_PM_BASE+1) | ||
54 | |||
55 | #define SIO_PM_FER2 0x1 | ||
56 | |||
57 | #define SIO_PM_GP_EN 0x80 | ||
58 | |||
59 | |||
60 | |||
61 | /* | ||
62 | * This is the dev/reg where generating a config cycle will | ||
63 | * result in a PCI special cycle. | ||
64 | */ | ||
65 | #define SPECIAL_DEV 0xff | ||
66 | #define SPECIAL_REG 0x00 | ||
67 | |||
68 | /* | ||
69 | * PIIX4 needs to see a special cycle with the following data | ||
70 | * to be convinced the processor has gone into the stop grant | ||
71 | * state. PIIX4 insists on seeing this before it will power | ||
72 | * down a system. | ||
73 | */ | ||
74 | #define PIIX_SPECIAL_STOP 0x00120002 | ||
75 | |||
76 | #define PIIX4_RESET_PORT 0xcf9 | ||
77 | #define PIIX4_RESET_VAL 0x6 | ||
78 | |||
79 | #define PMSTS_PORT 0xf80 // 2 bytes PM Status | ||
80 | #define PMEN_PORT 0xf82 // 2 bytes PM Enable | ||
81 | #define PMCNTRL_PORT 0xf84 // 2 bytes PM Control | ||
82 | |||
83 | #define PM_SUSPEND_ENABLE 0x2000 // start sequence to suspend state | ||
84 | |||
85 | /* | ||
86 | * PMSTS and PMEN I/O bit definitions. | ||
87 | * (Bits are the same in both registers) | ||
88 | */ | ||
89 | #define PM_STS_RSM (1<<15) // Resume Status | ||
90 | #define PM_STS_PWRBTNOR (1<<11) // Power Button Override | ||
91 | #define PM_STS_RTC (1<<10) // RTC status | ||
92 | #define PM_STS_PWRBTN (1<<8) // Power Button Pressed? | ||
93 | #define PM_STS_GBL (1<<5) // Global Status | ||
94 | #define PM_STS_BM (1<<4) // Bus Master Status | ||
95 | #define PM_STS_TMROF (1<<0) // Timer Overflow Status. | ||
96 | |||
97 | /* | ||
98 | * Stop clock GPI register | ||
99 | */ | ||
100 | #define PIIX_GPIREG0 (0xf80 + 0x30) | ||
101 | |||
102 | /* | ||
103 | * Stop clock GPI bit in GPIREG0 | ||
104 | */ | ||
105 | #define PIIX_GPI_STPCLK 0x4 // STPCLK signal routed back in | ||
106 | |||
107 | #endif | ||
diff --git a/include/asm-x86/mach-visws/setup_arch.h b/include/asm-x86/mach-visws/setup_arch.h new file mode 100644 index 000000000000..33f700ef6831 --- /dev/null +++ b/include/asm-x86/mach-visws/setup_arch.h | |||
@@ -0,0 +1,8 @@ | |||
1 | /* Hook to call BIOS initialisation function */ | ||
2 | |||
3 | extern unsigned long sgivwfb_mem_phys; | ||
4 | extern unsigned long sgivwfb_mem_size; | ||
5 | |||
6 | /* no action for visws */ | ||
7 | |||
8 | #define ARCH_SETUP | ||
diff --git a/include/asm-x86/mach-visws/smpboot_hooks.h b/include/asm-x86/mach-visws/smpboot_hooks.h new file mode 100644 index 000000000000..d926471fa359 --- /dev/null +++ b/include/asm-x86/mach-visws/smpboot_hooks.h | |||
@@ -0,0 +1,24 @@ | |||
1 | static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip) | ||
2 | { | ||
3 | CMOS_WRITE(0xa, 0xf); | ||
4 | local_flush_tlb(); | ||
5 | Dprintk("1.\n"); | ||
6 | *((volatile unsigned short *) TRAMPOLINE_HIGH) = start_eip >> 4; | ||
7 | Dprintk("2.\n"); | ||
8 | *((volatile unsigned short *) TRAMPOLINE_LOW) = start_eip & 0xf; | ||
9 | Dprintk("3.\n"); | ||
10 | } | ||
11 | |||
12 | /* for visws do nothing for any of these */ | ||
13 | |||
14 | static inline void smpboot_clear_io_apic_irqs(void) | ||
15 | { | ||
16 | } | ||
17 | |||
18 | static inline void smpboot_restore_warm_reset_vector(void) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | static inline void smpboot_setup_io_apic(void) | ||
23 | { | ||
24 | } | ||
diff --git a/include/asm-x86/mach-voyager/do_timer.h b/include/asm-x86/mach-voyager/do_timer.h new file mode 100644 index 000000000000..bc2b58926308 --- /dev/null +++ b/include/asm-x86/mach-voyager/do_timer.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* defines for inline arch setup functions */ | ||
2 | #include <linux/clockchips.h> | ||
3 | |||
4 | #include <asm/voyager.h> | ||
5 | #include <asm/i8253.h> | ||
6 | |||
7 | /** | ||
8 | * do_timer_interrupt_hook - hook into timer tick | ||
9 | * @regs: standard registers from interrupt | ||
10 | * | ||
11 | * Call the pit clock event handler. see asm/i8253.h | ||
12 | **/ | ||
13 | static inline void do_timer_interrupt_hook(void) | ||
14 | { | ||
15 | global_clock_event->event_handler(global_clock_event); | ||
16 | voyager_timer_interrupt(); | ||
17 | } | ||
18 | |||
diff --git a/include/asm-x86/mach-voyager/entry_arch.h b/include/asm-x86/mach-voyager/entry_arch.h new file mode 100644 index 000000000000..4a1e1e8c10b6 --- /dev/null +++ b/include/asm-x86/mach-voyager/entry_arch.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8 -*- */ | ||
2 | |||
3 | /* Copyright (C) 2002 | ||
4 | * | ||
5 | * Author: James.Bottomley@HansenPartnership.com | ||
6 | * | ||
7 | * linux/arch/i386/voyager/entry_arch.h | ||
8 | * | ||
9 | * This file builds the VIC and QIC CPI gates | ||
10 | */ | ||
11 | |||
12 | /* initialise the voyager interrupt gates | ||
13 | * | ||
14 | * This uses the macros in irq.h to set up assembly jump gates. The | ||
15 | * calls are then redirected to the same routine with smp_ prefixed */ | ||
16 | BUILD_INTERRUPT(vic_sys_interrupt, VIC_SYS_INT) | ||
17 | BUILD_INTERRUPT(vic_cmn_interrupt, VIC_CMN_INT) | ||
18 | BUILD_INTERRUPT(vic_cpi_interrupt, VIC_CPI_LEVEL0); | ||
19 | |||
20 | /* do all the QIC interrupts */ | ||
21 | BUILD_INTERRUPT(qic_timer_interrupt, QIC_TIMER_CPI); | ||
22 | BUILD_INTERRUPT(qic_invalidate_interrupt, QIC_INVALIDATE_CPI); | ||
23 | BUILD_INTERRUPT(qic_reschedule_interrupt, QIC_RESCHEDULE_CPI); | ||
24 | BUILD_INTERRUPT(qic_enable_irq_interrupt, QIC_ENABLE_IRQ_CPI); | ||
25 | BUILD_INTERRUPT(qic_call_function_interrupt, QIC_CALL_FUNCTION_CPI); | ||
26 | |||
diff --git a/include/asm-x86/mach-voyager/irq_vectors.h b/include/asm-x86/mach-voyager/irq_vectors.h new file mode 100644 index 000000000000..165421f5821c --- /dev/null +++ b/include/asm-x86/mach-voyager/irq_vectors.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8 -*- */ | ||
2 | |||
3 | /* Copyright (C) 2002 | ||
4 | * | ||
5 | * Author: James.Bottomley@HansenPartnership.com | ||
6 | * | ||
7 | * linux/arch/i386/voyager/irq_vectors.h | ||
8 | * | ||
9 | * This file provides definitions for the VIC and QIC CPIs | ||
10 | */ | ||
11 | |||
12 | #ifndef _ASM_IRQ_VECTORS_H | ||
13 | #define _ASM_IRQ_VECTORS_H | ||
14 | |||
15 | /* | ||
16 | * IDT vectors usable for external interrupt sources start | ||
17 | * at 0x20: | ||
18 | */ | ||
19 | #define FIRST_EXTERNAL_VECTOR 0x20 | ||
20 | |||
21 | #define SYSCALL_VECTOR 0x80 | ||
22 | |||
23 | /* | ||
24 | * Vectors 0x20-0x2f are used for ISA interrupts. | ||
25 | */ | ||
26 | |||
27 | /* These define the CPIs we use in linux */ | ||
28 | #define VIC_CPI_LEVEL0 0 | ||
29 | #define VIC_CPI_LEVEL1 1 | ||
30 | /* now the fake CPIs */ | ||
31 | #define VIC_TIMER_CPI 2 | ||
32 | #define VIC_INVALIDATE_CPI 3 | ||
33 | #define VIC_RESCHEDULE_CPI 4 | ||
34 | #define VIC_ENABLE_IRQ_CPI 5 | ||
35 | #define VIC_CALL_FUNCTION_CPI 6 | ||
36 | |||
37 | /* Now the QIC CPIs: Since we don't need the two initial levels, | ||
38 | * these are 2 less than the VIC CPIs */ | ||
39 | #define QIC_CPI_OFFSET 1 | ||
40 | #define QIC_TIMER_CPI (VIC_TIMER_CPI - QIC_CPI_OFFSET) | ||
41 | #define QIC_INVALIDATE_CPI (VIC_INVALIDATE_CPI - QIC_CPI_OFFSET) | ||
42 | #define QIC_RESCHEDULE_CPI (VIC_RESCHEDULE_CPI - QIC_CPI_OFFSET) | ||
43 | #define QIC_ENABLE_IRQ_CPI (VIC_ENABLE_IRQ_CPI - QIC_CPI_OFFSET) | ||
44 | #define QIC_CALL_FUNCTION_CPI (VIC_CALL_FUNCTION_CPI - QIC_CPI_OFFSET) | ||
45 | |||
46 | #define VIC_START_FAKE_CPI VIC_TIMER_CPI | ||
47 | #define VIC_END_FAKE_CPI VIC_CALL_FUNCTION_CPI | ||
48 | |||
49 | /* this is the SYS_INT CPI. */ | ||
50 | #define VIC_SYS_INT 8 | ||
51 | #define VIC_CMN_INT 15 | ||
52 | |||
53 | /* This is the boot CPI for alternate processors. It gets overwritten | ||
54 | * by the above once the system has activated all available processors */ | ||
55 | #define VIC_CPU_BOOT_CPI VIC_CPI_LEVEL0 | ||
56 | #define VIC_CPU_BOOT_ERRATA_CPI (VIC_CPI_LEVEL0 + 8) | ||
57 | |||
58 | #define NR_VECTORS 256 | ||
59 | #define NR_IRQS 224 | ||
60 | #define NR_IRQ_VECTORS NR_IRQS | ||
61 | |||
62 | #define FPU_IRQ 13 | ||
63 | |||
64 | #define FIRST_VM86_IRQ 3 | ||
65 | #define LAST_VM86_IRQ 15 | ||
66 | #define invalid_vm86_irq(irq) ((irq) < 3 || (irq) > 15) | ||
67 | |||
68 | #ifndef __ASSEMBLY__ | ||
69 | extern asmlinkage void vic_cpi_interrupt(void); | ||
70 | extern asmlinkage void vic_sys_interrupt(void); | ||
71 | extern asmlinkage void vic_cmn_interrupt(void); | ||
72 | extern asmlinkage void qic_timer_interrupt(void); | ||
73 | extern asmlinkage void qic_invalidate_interrupt(void); | ||
74 | extern asmlinkage void qic_reschedule_interrupt(void); | ||
75 | extern asmlinkage void qic_enable_irq_interrupt(void); | ||
76 | extern asmlinkage void qic_call_function_interrupt(void); | ||
77 | #endif /* !__ASSEMBLY__ */ | ||
78 | |||
79 | #endif /* _ASM_IRQ_VECTORS_H */ | ||
diff --git a/include/asm-x86/mach-voyager/setup_arch.h b/include/asm-x86/mach-voyager/setup_arch.h new file mode 100644 index 000000000000..84d01ad33459 --- /dev/null +++ b/include/asm-x86/mach-voyager/setup_arch.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #include <asm/voyager.h> | ||
2 | #define VOYAGER_BIOS_INFO ((struct voyager_bios_info *)(PARAM+0x40)) | ||
3 | |||
4 | /* Hook to call BIOS initialisation function */ | ||
5 | |||
6 | /* for voyager, pass the voyager BIOS/SUS info area to the detection | ||
7 | * routines */ | ||
8 | |||
9 | #define ARCH_SETUP voyager_detect(VOYAGER_BIOS_INFO); | ||
10 | |||
diff --git a/include/asm-x86/mach_apic.h b/include/asm-x86/mach_apic.h new file mode 100644 index 000000000000..7b7115a0c1c9 --- /dev/null +++ b/include/asm-x86/mach_apic.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __ASM_MACH_APIC_H | ||
2 | #define __ASM_MACH_APIC_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 2004 James Cleverdon, IBM. | ||
6 | * Subject to the GNU Public License, v.2 | ||
7 | * | ||
8 | * Generic APIC sub-arch defines. | ||
9 | * | ||
10 | * Hacked for x86-64 by James Cleverdon from i386 architecture code by | ||
11 | * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and | ||
12 | * James Cleverdon. | ||
13 | */ | ||
14 | |||
15 | #include <asm/genapic.h> | ||
16 | |||
17 | #define INT_DELIVERY_MODE (genapic->int_delivery_mode) | ||
18 | #define INT_DEST_MODE (genapic->int_dest_mode) | ||
19 | #define TARGET_CPUS (genapic->target_cpus()) | ||
20 | #define vector_allocation_domain (genapic->vector_allocation_domain) | ||
21 | #define apic_id_registered (genapic->apic_id_registered) | ||
22 | #define init_apic_ldr (genapic->init_apic_ldr) | ||
23 | #define send_IPI_mask (genapic->send_IPI_mask) | ||
24 | #define send_IPI_allbutself (genapic->send_IPI_allbutself) | ||
25 | #define send_IPI_all (genapic->send_IPI_all) | ||
26 | #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) | ||
27 | #define phys_pkg_id (genapic->phys_pkg_id) | ||
28 | |||
29 | #endif /* __ASM_MACH_APIC_H */ | ||
diff --git a/include/asm-x86/math_emu.h b/include/asm-x86/math_emu.h new file mode 100644 index 000000000000..a4b0aa3320e6 --- /dev/null +++ b/include/asm-x86/math_emu.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _I386_MATH_EMU_H | ||
2 | #define _I386_MATH_EMU_H | ||
3 | |||
4 | #include <asm/sigcontext.h> | ||
5 | |||
6 | int restore_i387_soft(void *s387, struct _fpstate __user *buf); | ||
7 | int save_i387_soft(void *s387, struct _fpstate __user *buf); | ||
8 | |||
9 | /* This structure matches the layout of the data saved to the stack | ||
10 | following a device-not-present interrupt, part of it saved | ||
11 | automatically by the 80386/80486. | ||
12 | */ | ||
13 | struct info { | ||
14 | long ___orig_eip; | ||
15 | long ___ebx; | ||
16 | long ___ecx; | ||
17 | long ___edx; | ||
18 | long ___esi; | ||
19 | long ___edi; | ||
20 | long ___ebp; | ||
21 | long ___eax; | ||
22 | long ___ds; | ||
23 | long ___es; | ||
24 | long ___fs; | ||
25 | long ___orig_eax; | ||
26 | long ___eip; | ||
27 | long ___cs; | ||
28 | long ___eflags; | ||
29 | long ___esp; | ||
30 | long ___ss; | ||
31 | long ___vm86_es; /* This and the following only in vm86 mode */ | ||
32 | long ___vm86_ds; | ||
33 | long ___vm86_fs; | ||
34 | long ___vm86_gs; | ||
35 | }; | ||
36 | #endif | ||
diff --git a/include/asm-x86/mc146818rtc.h b/include/asm-x86/mc146818rtc.h new file mode 100644 index 000000000000..5c2bb66caf17 --- /dev/null +++ b/include/asm-x86/mc146818rtc.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mc146818rtc_32.h" | ||
3 | #else | ||
4 | # include "mc146818rtc_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mc146818rtc_32.h b/include/asm-x86/mc146818rtc_32.h new file mode 100644 index 000000000000..1613b42eaf58 --- /dev/null +++ b/include/asm-x86/mc146818rtc_32.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Machine dependent access functions for RTC registers. | ||
3 | */ | ||
4 | #ifndef _ASM_MC146818RTC_H | ||
5 | #define _ASM_MC146818RTC_H | ||
6 | |||
7 | #include <asm/io.h> | ||
8 | #include <asm/system.h> | ||
9 | #include <asm/processor.h> | ||
10 | #include <linux/mc146818rtc.h> | ||
11 | |||
12 | #ifndef RTC_PORT | ||
13 | #define RTC_PORT(x) (0x70 + (x)) | ||
14 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ | ||
15 | #endif | ||
16 | |||
17 | #ifdef __HAVE_ARCH_CMPXCHG | ||
18 | /* | ||
19 | * This lock provides nmi access to the CMOS/RTC registers. It has some | ||
20 | * special properties. It is owned by a CPU and stores the index register | ||
21 | * currently being accessed (if owned). The idea here is that it works | ||
22 | * like a normal lock (normally). However, in an NMI, the NMI code will | ||
23 | * first check to see if its CPU owns the lock, meaning that the NMI | ||
24 | * interrupted during the read/write of the device. If it does, it goes ahead | ||
25 | * and performs the access and then restores the index register. If it does | ||
26 | * not, it locks normally. | ||
27 | * | ||
28 | * Note that since we are working with NMIs, we need this lock even in | ||
29 | * a non-SMP machine just to mark that the lock is owned. | ||
30 | * | ||
31 | * This only works with compare-and-swap. There is no other way to | ||
32 | * atomically claim the lock and set the owner. | ||
33 | */ | ||
34 | #include <linux/smp.h> | ||
35 | extern volatile unsigned long cmos_lock; | ||
36 | |||
37 | /* | ||
38 | * All of these below must be called with interrupts off, preempt | ||
39 | * disabled, etc. | ||
40 | */ | ||
41 | |||
42 | static inline void lock_cmos(unsigned char reg) | ||
43 | { | ||
44 | unsigned long new; | ||
45 | new = ((smp_processor_id()+1) << 8) | reg; | ||
46 | for (;;) { | ||
47 | if (cmos_lock) { | ||
48 | cpu_relax(); | ||
49 | continue; | ||
50 | } | ||
51 | if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0) | ||
52 | return; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | static inline void unlock_cmos(void) | ||
57 | { | ||
58 | cmos_lock = 0; | ||
59 | } | ||
60 | static inline int do_i_have_lock_cmos(void) | ||
61 | { | ||
62 | return (cmos_lock >> 8) == (smp_processor_id()+1); | ||
63 | } | ||
64 | static inline unsigned char current_lock_cmos_reg(void) | ||
65 | { | ||
66 | return cmos_lock & 0xff; | ||
67 | } | ||
68 | #define lock_cmos_prefix(reg) \ | ||
69 | do { \ | ||
70 | unsigned long cmos_flags; \ | ||
71 | local_irq_save(cmos_flags); \ | ||
72 | lock_cmos(reg) | ||
73 | #define lock_cmos_suffix(reg) \ | ||
74 | unlock_cmos(); \ | ||
75 | local_irq_restore(cmos_flags); \ | ||
76 | } while (0) | ||
77 | #else | ||
78 | #define lock_cmos_prefix(reg) do {} while (0) | ||
79 | #define lock_cmos_suffix(reg) do {} while (0) | ||
80 | #define lock_cmos(reg) | ||
81 | #define unlock_cmos() | ||
82 | #define do_i_have_lock_cmos() 0 | ||
83 | #define current_lock_cmos_reg() 0 | ||
84 | #endif | ||
85 | |||
86 | /* | ||
87 | * The yet supported machines all access the RTC index register via | ||
88 | * an ISA port access but the way to access the date register differs ... | ||
89 | */ | ||
90 | #define CMOS_READ(addr) rtc_cmos_read(addr) | ||
91 | #define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr) | ||
92 | unsigned char rtc_cmos_read(unsigned char addr); | ||
93 | void rtc_cmos_write(unsigned char val, unsigned char addr); | ||
94 | |||
95 | #define RTC_IRQ 8 | ||
96 | |||
97 | #endif /* _ASM_MC146818RTC_H */ | ||
diff --git a/include/asm-x86/mc146818rtc_64.h b/include/asm-x86/mc146818rtc_64.h new file mode 100644 index 000000000000..d6e3009430c1 --- /dev/null +++ b/include/asm-x86/mc146818rtc_64.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Machine dependent access functions for RTC registers. | ||
3 | */ | ||
4 | #ifndef _ASM_MC146818RTC_H | ||
5 | #define _ASM_MC146818RTC_H | ||
6 | |||
7 | #include <asm/io.h> | ||
8 | |||
9 | #ifndef RTC_PORT | ||
10 | #define RTC_PORT(x) (0x70 + (x)) | ||
11 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ | ||
12 | #endif | ||
13 | |||
14 | /* | ||
15 | * The yet supported machines all access the RTC index register via | ||
16 | * an ISA port access but the way to access the date register differs ... | ||
17 | */ | ||
18 | #define CMOS_READ(addr) ({ \ | ||
19 | outb_p((addr),RTC_PORT(0)); \ | ||
20 | inb_p(RTC_PORT(1)); \ | ||
21 | }) | ||
22 | #define CMOS_WRITE(val, addr) ({ \ | ||
23 | outb_p((addr),RTC_PORT(0)); \ | ||
24 | outb_p((val),RTC_PORT(1)); \ | ||
25 | }) | ||
26 | |||
27 | #define RTC_IRQ 8 | ||
28 | |||
29 | #endif /* _ASM_MC146818RTC_H */ | ||
diff --git a/include/asm-x86/mca.h b/include/asm-x86/mca.h new file mode 100644 index 000000000000..09adf2eac4dc --- /dev/null +++ b/include/asm-x86/mca.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8 -*- */ | ||
2 | |||
3 | /* Platform specific MCA defines */ | ||
4 | #ifndef _ASM_MCA_H | ||
5 | #define _ASM_MCA_H | ||
6 | |||
7 | /* Maximal number of MCA slots - actually, some machines have less, but | ||
8 | * they all have sufficient number of POS registers to cover 8. | ||
9 | */ | ||
10 | #define MCA_MAX_SLOT_NR 8 | ||
11 | |||
12 | /* Most machines have only one MCA bus. The only multiple bus machines | ||
13 | * I know have at most two */ | ||
14 | #define MAX_MCA_BUSSES 2 | ||
15 | |||
16 | #define MCA_PRIMARY_BUS 0 | ||
17 | #define MCA_SECONDARY_BUS 1 | ||
18 | |||
19 | /* Dummy slot numbers on primary MCA for integrated functions */ | ||
20 | #define MCA_INTEGSCSI (MCA_MAX_SLOT_NR) | ||
21 | #define MCA_INTEGVIDEO (MCA_MAX_SLOT_NR+1) | ||
22 | #define MCA_MOTHERBOARD (MCA_MAX_SLOT_NR+2) | ||
23 | |||
24 | /* Dummy POS values for integrated functions */ | ||
25 | #define MCA_DUMMY_POS_START 0x10000 | ||
26 | #define MCA_INTEGSCSI_POS (MCA_DUMMY_POS_START+1) | ||
27 | #define MCA_INTEGVIDEO_POS (MCA_DUMMY_POS_START+2) | ||
28 | #define MCA_MOTHERBOARD_POS (MCA_DUMMY_POS_START+3) | ||
29 | |||
30 | /* MCA registers */ | ||
31 | |||
32 | #define MCA_MOTHERBOARD_SETUP_REG 0x94 | ||
33 | #define MCA_ADAPTER_SETUP_REG 0x96 | ||
34 | #define MCA_POS_REG(n) (0x100+(n)) | ||
35 | |||
36 | #define MCA_ENABLED 0x01 /* POS 2, set if adapter enabled */ | ||
37 | |||
38 | /* Max number of adapters, including both slots and various integrated | ||
39 | * things. | ||
40 | */ | ||
41 | #define MCA_NUMADAPTERS (MCA_MAX_SLOT_NR+3) | ||
42 | |||
43 | #endif | ||
diff --git a/include/asm-x86/mca_dma.h b/include/asm-x86/mca_dma.h new file mode 100644 index 000000000000..fbb1f3b71279 --- /dev/null +++ b/include/asm-x86/mca_dma.h | |||
@@ -0,0 +1,201 @@ | |||
1 | #ifndef MCA_DMA_H | ||
2 | #define MCA_DMA_H | ||
3 | |||
4 | #include <asm/io.h> | ||
5 | #include <linux/ioport.h> | ||
6 | |||
7 | /* | ||
8 | * Microchannel specific DMA stuff. DMA on an MCA machine is fairly similar to | ||
9 | * standard PC dma, but it certainly has its quirks. DMA register addresses | ||
10 | * are in a different place and there are some added functions. Most of this | ||
11 | * should be pretty obvious on inspection. Note that the user must divide | ||
12 | * count by 2 when using 16-bit dma; that is not handled by these functions. | ||
13 | * | ||
14 | * Ramen Noodles are yummy. | ||
15 | * | ||
16 | * 1998 Tymm Twillman <tymm@computer.org> | ||
17 | */ | ||
18 | |||
19 | /* | ||
20 | * Registers that are used by the DMA controller; FN is the function register | ||
21 | * (tell the controller what to do) and EXE is the execution register (how | ||
22 | * to do it) | ||
23 | */ | ||
24 | |||
25 | #define MCA_DMA_REG_FN 0x18 | ||
26 | #define MCA_DMA_REG_EXE 0x1A | ||
27 | |||
28 | /* | ||
29 | * Functions that the DMA controller can do | ||
30 | */ | ||
31 | |||
32 | #define MCA_DMA_FN_SET_IO 0x00 | ||
33 | #define MCA_DMA_FN_SET_ADDR 0x20 | ||
34 | #define MCA_DMA_FN_GET_ADDR 0x30 | ||
35 | #define MCA_DMA_FN_SET_COUNT 0x40 | ||
36 | #define MCA_DMA_FN_GET_COUNT 0x50 | ||
37 | #define MCA_DMA_FN_GET_STATUS 0x60 | ||
38 | #define MCA_DMA_FN_SET_MODE 0x70 | ||
39 | #define MCA_DMA_FN_SET_ARBUS 0x80 | ||
40 | #define MCA_DMA_FN_MASK 0x90 | ||
41 | #define MCA_DMA_FN_RESET_MASK 0xA0 | ||
42 | #define MCA_DMA_FN_MASTER_CLEAR 0xD0 | ||
43 | |||
44 | /* | ||
45 | * Modes (used by setting MCA_DMA_FN_MODE in the function register) | ||
46 | * | ||
47 | * Note that the MODE_READ is read from memory (write to device), and | ||
48 | * MODE_WRITE is vice-versa. | ||
49 | */ | ||
50 | |||
51 | #define MCA_DMA_MODE_XFER 0x04 /* read by default */ | ||
52 | #define MCA_DMA_MODE_READ 0x04 /* same as XFER */ | ||
53 | #define MCA_DMA_MODE_WRITE 0x08 /* OR with MODE_XFER to use */ | ||
54 | #define MCA_DMA_MODE_IO 0x01 /* DMA from IO register */ | ||
55 | #define MCA_DMA_MODE_16 0x40 /* 16 bit xfers */ | ||
56 | |||
57 | |||
58 | /** | ||
59 | * mca_enable_dma - channel to enable DMA on | ||
60 | * @dmanr: DMA channel | ||
61 | * | ||
62 | * Enable the MCA bus DMA on a channel. This can be called from | ||
63 | * IRQ context. | ||
64 | */ | ||
65 | |||
66 | static __inline__ void mca_enable_dma(unsigned int dmanr) | ||
67 | { | ||
68 | outb(MCA_DMA_FN_RESET_MASK | dmanr, MCA_DMA_REG_FN); | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * mca_disble_dma - channel to disable DMA on | ||
73 | * @dmanr: DMA channel | ||
74 | * | ||
75 | * Enable the MCA bus DMA on a channel. This can be called from | ||
76 | * IRQ context. | ||
77 | */ | ||
78 | |||
79 | static __inline__ void mca_disable_dma(unsigned int dmanr) | ||
80 | { | ||
81 | outb(MCA_DMA_FN_MASK | dmanr, MCA_DMA_REG_FN); | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * mca_set_dma_addr - load a 24bit DMA address | ||
86 | * @dmanr: DMA channel | ||
87 | * @a: 24bit bus address | ||
88 | * | ||
89 | * Load the address register in the DMA controller. This has a 24bit | ||
90 | * limitation (16Mb). | ||
91 | */ | ||
92 | |||
93 | static __inline__ void mca_set_dma_addr(unsigned int dmanr, unsigned int a) | ||
94 | { | ||
95 | outb(MCA_DMA_FN_SET_ADDR | dmanr, MCA_DMA_REG_FN); | ||
96 | outb(a & 0xff, MCA_DMA_REG_EXE); | ||
97 | outb((a >> 8) & 0xff, MCA_DMA_REG_EXE); | ||
98 | outb((a >> 16) & 0xff, MCA_DMA_REG_EXE); | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * mca_get_dma_addr - load a 24bit DMA address | ||
103 | * @dmanr: DMA channel | ||
104 | * | ||
105 | * Read the address register in the DMA controller. This has a 24bit | ||
106 | * limitation (16Mb). The return is a bus address. | ||
107 | */ | ||
108 | |||
109 | static __inline__ unsigned int mca_get_dma_addr(unsigned int dmanr) | ||
110 | { | ||
111 | unsigned int addr; | ||
112 | |||
113 | outb(MCA_DMA_FN_GET_ADDR | dmanr, MCA_DMA_REG_FN); | ||
114 | addr = inb(MCA_DMA_REG_EXE); | ||
115 | addr |= inb(MCA_DMA_REG_EXE) << 8; | ||
116 | addr |= inb(MCA_DMA_REG_EXE) << 16; | ||
117 | |||
118 | return addr; | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * mca_set_dma_count - load a 16bit transfer count | ||
123 | * @dmanr: DMA channel | ||
124 | * @count: count | ||
125 | * | ||
126 | * Set the DMA count for this channel. This can be up to 64Kbytes. | ||
127 | * Setting a count of zero will not do what you expect. | ||
128 | */ | ||
129 | |||
130 | static __inline__ void mca_set_dma_count(unsigned int dmanr, unsigned int count) | ||
131 | { | ||
132 | count--; /* transfers one more than count -- correct for this */ | ||
133 | |||
134 | outb(MCA_DMA_FN_SET_COUNT | dmanr, MCA_DMA_REG_FN); | ||
135 | outb(count & 0xff, MCA_DMA_REG_EXE); | ||
136 | outb((count >> 8) & 0xff, MCA_DMA_REG_EXE); | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * mca_get_dma_residue - get the remaining bytes to transfer | ||
141 | * @dmanr: DMA channel | ||
142 | * | ||
143 | * This function returns the number of bytes left to transfer | ||
144 | * on this DMA channel. | ||
145 | */ | ||
146 | |||
147 | static __inline__ unsigned int mca_get_dma_residue(unsigned int dmanr) | ||
148 | { | ||
149 | unsigned short count; | ||
150 | |||
151 | outb(MCA_DMA_FN_GET_COUNT | dmanr, MCA_DMA_REG_FN); | ||
152 | count = 1 + inb(MCA_DMA_REG_EXE); | ||
153 | count += inb(MCA_DMA_REG_EXE) << 8; | ||
154 | |||
155 | return count; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * mca_set_dma_io - set the port for an I/O transfer | ||
160 | * @dmanr: DMA channel | ||
161 | * @io_addr: an I/O port number | ||
162 | * | ||
163 | * Unlike the ISA bus DMA controllers the DMA on MCA bus can transfer | ||
164 | * with an I/O port target. | ||
165 | */ | ||
166 | |||
167 | static __inline__ void mca_set_dma_io(unsigned int dmanr, unsigned int io_addr) | ||
168 | { | ||
169 | /* | ||
170 | * DMA from a port address -- set the io address | ||
171 | */ | ||
172 | |||
173 | outb(MCA_DMA_FN_SET_IO | dmanr, MCA_DMA_REG_FN); | ||
174 | outb(io_addr & 0xff, MCA_DMA_REG_EXE); | ||
175 | outb((io_addr >> 8) & 0xff, MCA_DMA_REG_EXE); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * mca_set_dma_mode - set the DMA mode | ||
180 | * @dmanr: DMA channel | ||
181 | * @mode: mode to set | ||
182 | * | ||
183 | * The DMA controller supports several modes. The mode values you can | ||
184 | * set are- | ||
185 | * | ||
186 | * %MCA_DMA_MODE_READ when reading from the DMA device. | ||
187 | * | ||
188 | * %MCA_DMA_MODE_WRITE to writing to the DMA device. | ||
189 | * | ||
190 | * %MCA_DMA_MODE_IO to do DMA to or from an I/O port. | ||
191 | * | ||
192 | * %MCA_DMA_MODE_16 to do 16bit transfers. | ||
193 | */ | ||
194 | |||
195 | static __inline__ void mca_set_dma_mode(unsigned int dmanr, unsigned int mode) | ||
196 | { | ||
197 | outb(MCA_DMA_FN_SET_MODE | dmanr, MCA_DMA_REG_FN); | ||
198 | outb(mode, MCA_DMA_REG_EXE); | ||
199 | } | ||
200 | |||
201 | #endif /* MCA_DMA_H */ | ||
diff --git a/include/asm-x86/mce.h b/include/asm-x86/mce.h new file mode 100644 index 000000000000..cc8ca389912e --- /dev/null +++ b/include/asm-x86/mce.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mce_32.h" | ||
3 | #else | ||
4 | # include "mce_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mce_32.h b/include/asm-x86/mce_32.h new file mode 100644 index 000000000000..d56d89742e8f --- /dev/null +++ b/include/asm-x86/mce_32.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifdef CONFIG_X86_MCE | ||
2 | extern void mcheck_init(struct cpuinfo_x86 *c); | ||
3 | #else | ||
4 | #define mcheck_init(c) do {} while(0) | ||
5 | #endif | ||
6 | |||
7 | extern int mce_disabled; | ||
8 | |||
9 | extern void stop_mce(void); | ||
10 | extern void restart_mce(void); | ||
11 | |||
diff --git a/include/asm-x86/mce_64.h b/include/asm-x86/mce_64.h new file mode 100644 index 000000000000..7bc030a1996d --- /dev/null +++ b/include/asm-x86/mce_64.h | |||
@@ -0,0 +1,115 @@ | |||
1 | #ifndef _ASM_MCE_H | ||
2 | #define _ASM_MCE_H 1 | ||
3 | |||
4 | #include <asm/ioctls.h> | ||
5 | #include <asm/types.h> | ||
6 | |||
7 | /* | ||
8 | * Machine Check support for x86 | ||
9 | */ | ||
10 | |||
11 | #define MCG_CTL_P (1UL<<8) /* MCG_CAP register available */ | ||
12 | |||
13 | #define MCG_STATUS_RIPV (1UL<<0) /* restart ip valid */ | ||
14 | #define MCG_STATUS_EIPV (1UL<<1) /* eip points to correct instruction */ | ||
15 | #define MCG_STATUS_MCIP (1UL<<2) /* machine check in progress */ | ||
16 | |||
17 | #define MCI_STATUS_VAL (1UL<<63) /* valid error */ | ||
18 | #define MCI_STATUS_OVER (1UL<<62) /* previous errors lost */ | ||
19 | #define MCI_STATUS_UC (1UL<<61) /* uncorrected error */ | ||
20 | #define MCI_STATUS_EN (1UL<<60) /* error enabled */ | ||
21 | #define MCI_STATUS_MISCV (1UL<<59) /* misc error reg. valid */ | ||
22 | #define MCI_STATUS_ADDRV (1UL<<58) /* addr reg. valid */ | ||
23 | #define MCI_STATUS_PCC (1UL<<57) /* processor context corrupt */ | ||
24 | |||
25 | /* Fields are zero when not available */ | ||
26 | struct mce { | ||
27 | __u64 status; | ||
28 | __u64 misc; | ||
29 | __u64 addr; | ||
30 | __u64 mcgstatus; | ||
31 | __u64 rip; | ||
32 | __u64 tsc; /* cpu time stamp counter */ | ||
33 | __u64 res1; /* for future extension */ | ||
34 | __u64 res2; /* dito. */ | ||
35 | __u8 cs; /* code segment */ | ||
36 | __u8 bank; /* machine check bank */ | ||
37 | __u8 cpu; /* cpu that raised the error */ | ||
38 | __u8 finished; /* entry is valid */ | ||
39 | __u32 pad; | ||
40 | }; | ||
41 | |||
42 | /* | ||
43 | * This structure contains all data related to the MCE log. | ||
44 | * Also carries a signature to make it easier to find from external debugging tools. | ||
45 | * Each entry is only valid when its finished flag is set. | ||
46 | */ | ||
47 | |||
48 | #define MCE_LOG_LEN 32 | ||
49 | |||
50 | struct mce_log { | ||
51 | char signature[12]; /* "MACHINECHECK" */ | ||
52 | unsigned len; /* = MCE_LOG_LEN */ | ||
53 | unsigned next; | ||
54 | unsigned flags; | ||
55 | unsigned pad0; | ||
56 | struct mce entry[MCE_LOG_LEN]; | ||
57 | }; | ||
58 | |||
59 | #define MCE_OVERFLOW 0 /* bit 0 in flags means overflow */ | ||
60 | |||
61 | #define MCE_LOG_SIGNATURE "MACHINECHECK" | ||
62 | |||
63 | #define MCE_GET_RECORD_LEN _IOR('M', 1, int) | ||
64 | #define MCE_GET_LOG_LEN _IOR('M', 2, int) | ||
65 | #define MCE_GETCLEAR_FLAGS _IOR('M', 3, int) | ||
66 | |||
67 | /* Software defined banks */ | ||
68 | #define MCE_EXTENDED_BANK 128 | ||
69 | #define MCE_THERMAL_BANK MCE_EXTENDED_BANK + 0 | ||
70 | |||
71 | #define K8_MCE_THRESHOLD_BASE (MCE_EXTENDED_BANK + 1) /* MCE_AMD */ | ||
72 | #define K8_MCE_THRESHOLD_BANK_0 (MCE_THRESHOLD_BASE + 0 * 9) | ||
73 | #define K8_MCE_THRESHOLD_BANK_1 (MCE_THRESHOLD_BASE + 1 * 9) | ||
74 | #define K8_MCE_THRESHOLD_BANK_2 (MCE_THRESHOLD_BASE + 2 * 9) | ||
75 | #define K8_MCE_THRESHOLD_BANK_3 (MCE_THRESHOLD_BASE + 3 * 9) | ||
76 | #define K8_MCE_THRESHOLD_BANK_4 (MCE_THRESHOLD_BASE + 4 * 9) | ||
77 | #define K8_MCE_THRESHOLD_BANK_5 (MCE_THRESHOLD_BASE + 5 * 9) | ||
78 | #define K8_MCE_THRESHOLD_DRAM_ECC (MCE_THRESHOLD_BANK_4 + 0) | ||
79 | |||
80 | #ifdef __KERNEL__ | ||
81 | #include <asm/atomic.h> | ||
82 | |||
83 | void mce_log(struct mce *m); | ||
84 | DECLARE_PER_CPU(struct sys_device, device_mce); | ||
85 | |||
86 | #ifdef CONFIG_X86_MCE_INTEL | ||
87 | void mce_intel_feature_init(struct cpuinfo_x86 *c); | ||
88 | #else | ||
89 | static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) | ||
90 | { | ||
91 | } | ||
92 | #endif | ||
93 | |||
94 | #ifdef CONFIG_X86_MCE_AMD | ||
95 | void mce_amd_feature_init(struct cpuinfo_x86 *c); | ||
96 | #else | ||
97 | static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) | ||
98 | { | ||
99 | } | ||
100 | #endif | ||
101 | |||
102 | void mce_log_therm_throt_event(unsigned int cpu, __u64 status); | ||
103 | |||
104 | extern atomic_t mce_entry; | ||
105 | |||
106 | extern void do_machine_check(struct pt_regs *, long); | ||
107 | |||
108 | extern int mce_notify_user(void); | ||
109 | |||
110 | extern void stop_mce(void); | ||
111 | extern void restart_mce(void); | ||
112 | |||
113 | #endif | ||
114 | |||
115 | #endif | ||
diff --git a/include/asm-x86/mman.h b/include/asm-x86/mman.h new file mode 100644 index 000000000000..322db07e82c3 --- /dev/null +++ b/include/asm-x86/mman.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "mman_32.h" | ||
4 | # else | ||
5 | # include "mman_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "mman_32.h" | ||
10 | # else | ||
11 | # include "mman_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/mman_32.h b/include/asm-x86/mman_32.h new file mode 100644 index 000000000000..8fd9d7ab7faf --- /dev/null +++ b/include/asm-x86/mman_32.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef __I386_MMAN_H__ | ||
2 | #define __I386_MMAN_H__ | ||
3 | |||
4 | #include <asm-generic/mman.h> | ||
5 | |||
6 | #define MAP_GROWSDOWN 0x0100 /* stack-like segment */ | ||
7 | #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ | ||
8 | #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ | ||
9 | #define MAP_LOCKED 0x2000 /* pages are locked */ | ||
10 | #define MAP_NORESERVE 0x4000 /* don't check for reservations */ | ||
11 | #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ | ||
12 | #define MAP_NONBLOCK 0x10000 /* do not block on IO */ | ||
13 | |||
14 | #define MCL_CURRENT 1 /* lock all current mappings */ | ||
15 | #define MCL_FUTURE 2 /* lock all future mappings */ | ||
16 | |||
17 | #endif /* __I386_MMAN_H__ */ | ||
diff --git a/include/asm-x86/mman_64.h b/include/asm-x86/mman_64.h new file mode 100644 index 000000000000..dd5cb0534d37 --- /dev/null +++ b/include/asm-x86/mman_64.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef __X8664_MMAN_H__ | ||
2 | #define __X8664_MMAN_H__ | ||
3 | |||
4 | #include <asm-generic/mman.h> | ||
5 | |||
6 | #define MAP_32BIT 0x40 /* only give out 32bit addresses */ | ||
7 | |||
8 | #define MAP_GROWSDOWN 0x0100 /* stack-like segment */ | ||
9 | #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ | ||
10 | #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ | ||
11 | #define MAP_LOCKED 0x2000 /* pages are locked */ | ||
12 | #define MAP_NORESERVE 0x4000 /* don't check for reservations */ | ||
13 | #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ | ||
14 | #define MAP_NONBLOCK 0x10000 /* do not block on IO */ | ||
15 | |||
16 | #define MCL_CURRENT 1 /* lock all current mappings */ | ||
17 | #define MCL_FUTURE 2 /* lock all future mappings */ | ||
18 | |||
19 | #endif | ||
diff --git a/include/asm-x86/mmsegment.h b/include/asm-x86/mmsegment.h new file mode 100644 index 000000000000..d3f80c996330 --- /dev/null +++ b/include/asm-x86/mmsegment.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _ASM_MMSEGMENT_H | ||
2 | #define _ASM_MMSEGMENT_H 1 | ||
3 | |||
4 | typedef struct { | ||
5 | unsigned long seg; | ||
6 | } mm_segment_t; | ||
7 | |||
8 | #endif | ||
diff --git a/include/asm-x86/mmu.h b/include/asm-x86/mmu.h new file mode 100644 index 000000000000..9c628cd70e23 --- /dev/null +++ b/include/asm-x86/mmu.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mmu_32.h" | ||
3 | #else | ||
4 | # include "mmu_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mmu_32.h b/include/asm-x86/mmu_32.h new file mode 100644 index 000000000000..8358dd3df7aa --- /dev/null +++ b/include/asm-x86/mmu_32.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef __i386_MMU_H | ||
2 | #define __i386_MMU_H | ||
3 | |||
4 | #include <asm/semaphore.h> | ||
5 | /* | ||
6 | * The i386 doesn't have a mmu context, but | ||
7 | * we put the segment information here. | ||
8 | * | ||
9 | * cpu_vm_mask is used to optimize ldt flushing. | ||
10 | */ | ||
11 | typedef struct { | ||
12 | int size; | ||
13 | struct semaphore sem; | ||
14 | void *ldt; | ||
15 | void *vdso; | ||
16 | } mm_context_t; | ||
17 | |||
18 | #endif | ||
diff --git a/include/asm-x86/mmu_64.h b/include/asm-x86/mmu_64.h new file mode 100644 index 000000000000..d2cd4a9d984d --- /dev/null +++ b/include/asm-x86/mmu_64.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef __x86_64_MMU_H | ||
2 | #define __x86_64_MMU_H | ||
3 | |||
4 | #include <linux/spinlock.h> | ||
5 | #include <asm/semaphore.h> | ||
6 | |||
7 | /* | ||
8 | * The x86_64 doesn't have a mmu context, but | ||
9 | * we put the segment information here. | ||
10 | * | ||
11 | * cpu_vm_mask is used to optimize ldt flushing. | ||
12 | */ | ||
13 | typedef struct { | ||
14 | void *ldt; | ||
15 | rwlock_t ldtlock; | ||
16 | int size; | ||
17 | struct semaphore sem; | ||
18 | void *vdso; | ||
19 | } mm_context_t; | ||
20 | |||
21 | #endif | ||
diff --git a/include/asm-x86/mmu_context.h b/include/asm-x86/mmu_context.h new file mode 100644 index 000000000000..6598450da6c6 --- /dev/null +++ b/include/asm-x86/mmu_context.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mmu_context_32.h" | ||
3 | #else | ||
4 | # include "mmu_context_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mmu_context_32.h b/include/asm-x86/mmu_context_32.h new file mode 100644 index 000000000000..7eb0b0b1fb3c --- /dev/null +++ b/include/asm-x86/mmu_context_32.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef __I386_SCHED_H | ||
2 | #define __I386_SCHED_H | ||
3 | |||
4 | #include <asm/desc.h> | ||
5 | #include <asm/atomic.h> | ||
6 | #include <asm/pgalloc.h> | ||
7 | #include <asm/tlbflush.h> | ||
8 | #include <asm/paravirt.h> | ||
9 | #ifndef CONFIG_PARAVIRT | ||
10 | #include <asm-generic/mm_hooks.h> | ||
11 | |||
12 | static inline void paravirt_activate_mm(struct mm_struct *prev, | ||
13 | struct mm_struct *next) | ||
14 | { | ||
15 | } | ||
16 | #endif /* !CONFIG_PARAVIRT */ | ||
17 | |||
18 | |||
19 | /* | ||
20 | * Used for LDT copy/destruction. | ||
21 | */ | ||
22 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm); | ||
23 | void destroy_context(struct mm_struct *mm); | ||
24 | |||
25 | |||
26 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
27 | { | ||
28 | #ifdef CONFIG_SMP | ||
29 | unsigned cpu = smp_processor_id(); | ||
30 | if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK) | ||
31 | per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_LAZY; | ||
32 | #endif | ||
33 | } | ||
34 | |||
35 | void leave_mm(unsigned long cpu); | ||
36 | |||
37 | static inline void switch_mm(struct mm_struct *prev, | ||
38 | struct mm_struct *next, | ||
39 | struct task_struct *tsk) | ||
40 | { | ||
41 | int cpu = smp_processor_id(); | ||
42 | |||
43 | if (likely(prev != next)) { | ||
44 | /* stop flush ipis for the previous mm */ | ||
45 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
46 | #ifdef CONFIG_SMP | ||
47 | per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_OK; | ||
48 | per_cpu(cpu_tlbstate, cpu).active_mm = next; | ||
49 | #endif | ||
50 | cpu_set(cpu, next->cpu_vm_mask); | ||
51 | |||
52 | /* Re-load page tables */ | ||
53 | load_cr3(next->pgd); | ||
54 | |||
55 | /* | ||
56 | * load the LDT, if the LDT is different: | ||
57 | */ | ||
58 | if (unlikely(prev->context.ldt != next->context.ldt)) | ||
59 | load_LDT_nolock(&next->context); | ||
60 | } | ||
61 | #ifdef CONFIG_SMP | ||
62 | else { | ||
63 | per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_OK; | ||
64 | BUG_ON(per_cpu(cpu_tlbstate, cpu).active_mm != next); | ||
65 | |||
66 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { | ||
67 | /* We were in lazy tlb mode and leave_mm disabled | ||
68 | * tlb flush IPI delivery. We must reload %cr3. | ||
69 | */ | ||
70 | load_cr3(next->pgd); | ||
71 | load_LDT_nolock(&next->context); | ||
72 | } | ||
73 | } | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | #define deactivate_mm(tsk, mm) \ | ||
78 | asm("movl %0,%%gs": :"r" (0)); | ||
79 | |||
80 | #define activate_mm(prev, next) \ | ||
81 | do { \ | ||
82 | paravirt_activate_mm(prev, next); \ | ||
83 | switch_mm((prev),(next),NULL); \ | ||
84 | } while(0); | ||
85 | |||
86 | #endif | ||
diff --git a/include/asm-x86/mmu_context_64.h b/include/asm-x86/mmu_context_64.h new file mode 100644 index 000000000000..0cce83a78378 --- /dev/null +++ b/include/asm-x86/mmu_context_64.h | |||
@@ -0,0 +1,74 @@ | |||
1 | #ifndef __X86_64_MMU_CONTEXT_H | ||
2 | #define __X86_64_MMU_CONTEXT_H | ||
3 | |||
4 | #include <asm/desc.h> | ||
5 | #include <asm/atomic.h> | ||
6 | #include <asm/pgalloc.h> | ||
7 | #include <asm/pda.h> | ||
8 | #include <asm/pgtable.h> | ||
9 | #include <asm/tlbflush.h> | ||
10 | #include <asm-generic/mm_hooks.h> | ||
11 | |||
12 | /* | ||
13 | * possibly do the LDT unload here? | ||
14 | */ | ||
15 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm); | ||
16 | void destroy_context(struct mm_struct *mm); | ||
17 | |||
18 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
19 | { | ||
20 | #ifdef CONFIG_SMP | ||
21 | if (read_pda(mmu_state) == TLBSTATE_OK) | ||
22 | write_pda(mmu_state, TLBSTATE_LAZY); | ||
23 | #endif | ||
24 | } | ||
25 | |||
26 | static inline void load_cr3(pgd_t *pgd) | ||
27 | { | ||
28 | asm volatile("movq %0,%%cr3" :: "r" (__pa(pgd)) : "memory"); | ||
29 | } | ||
30 | |||
31 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
32 | struct task_struct *tsk) | ||
33 | { | ||
34 | unsigned cpu = smp_processor_id(); | ||
35 | if (likely(prev != next)) { | ||
36 | /* stop flush ipis for the previous mm */ | ||
37 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
38 | #ifdef CONFIG_SMP | ||
39 | write_pda(mmu_state, TLBSTATE_OK); | ||
40 | write_pda(active_mm, next); | ||
41 | #endif | ||
42 | cpu_set(cpu, next->cpu_vm_mask); | ||
43 | load_cr3(next->pgd); | ||
44 | |||
45 | if (unlikely(next->context.ldt != prev->context.ldt)) | ||
46 | load_LDT_nolock(&next->context, cpu); | ||
47 | } | ||
48 | #ifdef CONFIG_SMP | ||
49 | else { | ||
50 | write_pda(mmu_state, TLBSTATE_OK); | ||
51 | if (read_pda(active_mm) != next) | ||
52 | out_of_line_bug(); | ||
53 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { | ||
54 | /* We were in lazy tlb mode and leave_mm disabled | ||
55 | * tlb flush IPI delivery. We must reload CR3 | ||
56 | * to make sure to use no freed page tables. | ||
57 | */ | ||
58 | load_cr3(next->pgd); | ||
59 | load_LDT_nolock(&next->context, cpu); | ||
60 | } | ||
61 | } | ||
62 | #endif | ||
63 | } | ||
64 | |||
65 | #define deactivate_mm(tsk,mm) do { \ | ||
66 | load_gs_index(0); \ | ||
67 | asm volatile("movl %0,%%fs"::"r"(0)); \ | ||
68 | } while(0) | ||
69 | |||
70 | #define activate_mm(prev, next) \ | ||
71 | switch_mm((prev),(next),NULL) | ||
72 | |||
73 | |||
74 | #endif | ||
diff --git a/include/asm-x86/mmx.h b/include/asm-x86/mmx.h new file mode 100644 index 000000000000..46b71da99869 --- /dev/null +++ b/include/asm-x86/mmx.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_MMX_H | ||
2 | #define _ASM_MMX_H | ||
3 | |||
4 | /* | ||
5 | * MMX 3Dnow! helper operations | ||
6 | */ | ||
7 | |||
8 | #include <linux/types.h> | ||
9 | |||
10 | extern void *_mmx_memcpy(void *to, const void *from, size_t size); | ||
11 | extern void mmx_clear_page(void *page); | ||
12 | extern void mmx_copy_page(void *to, void *from); | ||
13 | |||
14 | #endif | ||
diff --git a/include/asm-x86/mmzone.h b/include/asm-x86/mmzone.h new file mode 100644 index 000000000000..64217ea16a36 --- /dev/null +++ b/include/asm-x86/mmzone.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mmzone_32.h" | ||
3 | #else | ||
4 | # include "mmzone_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mmzone_32.h b/include/asm-x86/mmzone_32.h new file mode 100644 index 000000000000..118e9812778f --- /dev/null +++ b/include/asm-x86/mmzone_32.h | |||
@@ -0,0 +1,145 @@ | |||
1 | /* | ||
2 | * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002 | ||
3 | * | ||
4 | */ | ||
5 | |||
6 | #ifndef _ASM_MMZONE_H_ | ||
7 | #define _ASM_MMZONE_H_ | ||
8 | |||
9 | #include <asm/smp.h> | ||
10 | |||
11 | #ifdef CONFIG_NUMA | ||
12 | extern struct pglist_data *node_data[]; | ||
13 | #define NODE_DATA(nid) (node_data[nid]) | ||
14 | |||
15 | #ifdef CONFIG_X86_NUMAQ | ||
16 | #include <asm/numaq.h> | ||
17 | #elif defined(CONFIG_ACPI_SRAT)/* summit or generic arch */ | ||
18 | #include <asm/srat.h> | ||
19 | #endif | ||
20 | |||
21 | extern int get_memcfg_numa_flat(void ); | ||
22 | /* | ||
23 | * This allows any one NUMA architecture to be compiled | ||
24 | * for, and still fall back to the flat function if it | ||
25 | * fails. | ||
26 | */ | ||
27 | static inline void get_memcfg_numa(void) | ||
28 | { | ||
29 | #ifdef CONFIG_X86_NUMAQ | ||
30 | if (get_memcfg_numaq()) | ||
31 | return; | ||
32 | #elif defined(CONFIG_ACPI_SRAT) | ||
33 | if (get_memcfg_from_srat()) | ||
34 | return; | ||
35 | #endif | ||
36 | |||
37 | get_memcfg_numa_flat(); | ||
38 | } | ||
39 | |||
40 | extern int early_pfn_to_nid(unsigned long pfn); | ||
41 | extern void numa_kva_reserve(void); | ||
42 | |||
43 | #else /* !CONFIG_NUMA */ | ||
44 | |||
45 | #define get_memcfg_numa get_memcfg_numa_flat | ||
46 | #define get_zholes_size(n) (0) | ||
47 | |||
48 | static inline void numa_kva_reserve(void) | ||
49 | { | ||
50 | } | ||
51 | #endif /* CONFIG_NUMA */ | ||
52 | |||
53 | #ifdef CONFIG_DISCONTIGMEM | ||
54 | |||
55 | /* | ||
56 | * generic node memory support, the following assumptions apply: | ||
57 | * | ||
58 | * 1) memory comes in 256Mb contigious chunks which are either present or not | ||
59 | * 2) we will not have more than 64Gb in total | ||
60 | * | ||
61 | * for now assume that 64Gb is max amount of RAM for whole system | ||
62 | * 64Gb / 4096bytes/page = 16777216 pages | ||
63 | */ | ||
64 | #define MAX_NR_PAGES 16777216 | ||
65 | #define MAX_ELEMENTS 256 | ||
66 | #define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS) | ||
67 | |||
68 | extern s8 physnode_map[]; | ||
69 | |||
70 | static inline int pfn_to_nid(unsigned long pfn) | ||
71 | { | ||
72 | #ifdef CONFIG_NUMA | ||
73 | return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]); | ||
74 | #else | ||
75 | return 0; | ||
76 | #endif | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Following are macros that each numa implmentation must define. | ||
81 | */ | ||
82 | |||
83 | #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) | ||
84 | #define node_end_pfn(nid) \ | ||
85 | ({ \ | ||
86 | pg_data_t *__pgdat = NODE_DATA(nid); \ | ||
87 | __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ | ||
88 | }) | ||
89 | |||
90 | /* XXX: FIXME -- wli */ | ||
91 | #define kern_addr_valid(kaddr) (0) | ||
92 | |||
93 | #ifdef CONFIG_X86_NUMAQ /* we have contiguous memory on NUMA-Q */ | ||
94 | #define pfn_valid(pfn) ((pfn) < num_physpages) | ||
95 | #else | ||
96 | static inline int pfn_valid(int pfn) | ||
97 | { | ||
98 | int nid = pfn_to_nid(pfn); | ||
99 | |||
100 | if (nid >= 0) | ||
101 | return (pfn < node_end_pfn(nid)); | ||
102 | return 0; | ||
103 | } | ||
104 | #endif /* CONFIG_X86_NUMAQ */ | ||
105 | |||
106 | #endif /* CONFIG_DISCONTIGMEM */ | ||
107 | |||
108 | #ifdef CONFIG_NEED_MULTIPLE_NODES | ||
109 | |||
110 | /* | ||
111 | * Following are macros that are specific to this numa platform. | ||
112 | */ | ||
113 | #define reserve_bootmem(addr, size) \ | ||
114 | reserve_bootmem_node(NODE_DATA(0), (addr), (size)) | ||
115 | #define alloc_bootmem(x) \ | ||
116 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | ||
117 | #define alloc_bootmem_low(x) \ | ||
118 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0) | ||
119 | #define alloc_bootmem_pages(x) \ | ||
120 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | ||
121 | #define alloc_bootmem_low_pages(x) \ | ||
122 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) | ||
123 | #define alloc_bootmem_node(pgdat, x) \ | ||
124 | ({ \ | ||
125 | struct pglist_data __maybe_unused \ | ||
126 | *__alloc_bootmem_node__pgdat = (pgdat); \ | ||
127 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \ | ||
128 | __pa(MAX_DMA_ADDRESS)); \ | ||
129 | }) | ||
130 | #define alloc_bootmem_pages_node(pgdat, x) \ | ||
131 | ({ \ | ||
132 | struct pglist_data __maybe_unused \ | ||
133 | *__alloc_bootmem_node__pgdat = (pgdat); \ | ||
134 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \ | ||
135 | __pa(MAX_DMA_ADDRESS)) \ | ||
136 | }) | ||
137 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | ||
138 | ({ \ | ||
139 | struct pglist_data __maybe_unused \ | ||
140 | *__alloc_bootmem_node__pgdat = (pgdat); \ | ||
141 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \ | ||
142 | }) | ||
143 | #endif /* CONFIG_NEED_MULTIPLE_NODES */ | ||
144 | |||
145 | #endif /* _ASM_MMZONE_H_ */ | ||
diff --git a/include/asm-x86/mmzone_64.h b/include/asm-x86/mmzone_64.h new file mode 100644 index 000000000000..19a89377b123 --- /dev/null +++ b/include/asm-x86/mmzone_64.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* K8 NUMA support */ | ||
2 | /* Copyright 2002,2003 by Andi Kleen, SuSE Labs */ | ||
3 | /* 2.5 Version loosely based on the NUMAQ Code by Pat Gaughen. */ | ||
4 | #ifndef _ASM_X86_64_MMZONE_H | ||
5 | #define _ASM_X86_64_MMZONE_H 1 | ||
6 | |||
7 | |||
8 | #ifdef CONFIG_NUMA | ||
9 | |||
10 | #define VIRTUAL_BUG_ON(x) | ||
11 | |||
12 | #include <asm/smp.h> | ||
13 | |||
14 | /* Simple perfect hash to map physical addresses to node numbers */ | ||
15 | struct memnode { | ||
16 | int shift; | ||
17 | unsigned int mapsize; | ||
18 | u8 *map; | ||
19 | u8 embedded_map[64-16]; | ||
20 | } ____cacheline_aligned; /* total size = 64 bytes */ | ||
21 | extern struct memnode memnode; | ||
22 | #define memnode_shift memnode.shift | ||
23 | #define memnodemap memnode.map | ||
24 | #define memnodemapsize memnode.mapsize | ||
25 | |||
26 | extern struct pglist_data *node_data[]; | ||
27 | |||
28 | static inline __attribute__((pure)) int phys_to_nid(unsigned long addr) | ||
29 | { | ||
30 | unsigned nid; | ||
31 | VIRTUAL_BUG_ON(!memnodemap); | ||
32 | VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize); | ||
33 | nid = memnodemap[addr >> memnode_shift]; | ||
34 | VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]); | ||
35 | return nid; | ||
36 | } | ||
37 | |||
38 | #define NODE_DATA(nid) (node_data[nid]) | ||
39 | |||
40 | #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) | ||
41 | #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ | ||
42 | NODE_DATA(nid)->node_spanned_pages) | ||
43 | |||
44 | #ifdef CONFIG_DISCONTIGMEM | ||
45 | #define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT) | ||
46 | |||
47 | extern int pfn_valid(unsigned long pfn); | ||
48 | #endif | ||
49 | |||
50 | #ifdef CONFIG_NUMA_EMU | ||
51 | #define FAKE_NODE_MIN_SIZE (64*1024*1024) | ||
52 | #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1uL)) | ||
53 | #endif | ||
54 | |||
55 | #endif | ||
56 | #endif | ||
diff --git a/include/asm-x86/module.h b/include/asm-x86/module.h new file mode 100644 index 000000000000..2b2f18d8a531 --- /dev/null +++ b/include/asm-x86/module.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "module_32.h" | ||
3 | #else | ||
4 | # include "module_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/module_32.h b/include/asm-x86/module_32.h new file mode 100644 index 000000000000..7e5fda6c3976 --- /dev/null +++ b/include/asm-x86/module_32.h | |||
@@ -0,0 +1,75 @@ | |||
1 | #ifndef _ASM_I386_MODULE_H | ||
2 | #define _ASM_I386_MODULE_H | ||
3 | |||
4 | /* x86 is simple */ | ||
5 | struct mod_arch_specific | ||
6 | { | ||
7 | }; | ||
8 | |||
9 | #define Elf_Shdr Elf32_Shdr | ||
10 | #define Elf_Sym Elf32_Sym | ||
11 | #define Elf_Ehdr Elf32_Ehdr | ||
12 | |||
13 | #ifdef CONFIG_M386 | ||
14 | #define MODULE_PROC_FAMILY "386 " | ||
15 | #elif defined CONFIG_M486 | ||
16 | #define MODULE_PROC_FAMILY "486 " | ||
17 | #elif defined CONFIG_M586 | ||
18 | #define MODULE_PROC_FAMILY "586 " | ||
19 | #elif defined CONFIG_M586TSC | ||
20 | #define MODULE_PROC_FAMILY "586TSC " | ||
21 | #elif defined CONFIG_M586MMX | ||
22 | #define MODULE_PROC_FAMILY "586MMX " | ||
23 | #elif defined CONFIG_MCORE2 | ||
24 | #define MODULE_PROC_FAMILY "CORE2 " | ||
25 | #elif defined CONFIG_M686 | ||
26 | #define MODULE_PROC_FAMILY "686 " | ||
27 | #elif defined CONFIG_MPENTIUMII | ||
28 | #define MODULE_PROC_FAMILY "PENTIUMII " | ||
29 | #elif defined CONFIG_MPENTIUMIII | ||
30 | #define MODULE_PROC_FAMILY "PENTIUMIII " | ||
31 | #elif defined CONFIG_MPENTIUMM | ||
32 | #define MODULE_PROC_FAMILY "PENTIUMM " | ||
33 | #elif defined CONFIG_MPENTIUM4 | ||
34 | #define MODULE_PROC_FAMILY "PENTIUM4 " | ||
35 | #elif defined CONFIG_MK6 | ||
36 | #define MODULE_PROC_FAMILY "K6 " | ||
37 | #elif defined CONFIG_MK7 | ||
38 | #define MODULE_PROC_FAMILY "K7 " | ||
39 | #elif defined CONFIG_MK8 | ||
40 | #define MODULE_PROC_FAMILY "K8 " | ||
41 | #elif defined CONFIG_X86_ELAN | ||
42 | #define MODULE_PROC_FAMILY "ELAN " | ||
43 | #elif defined CONFIG_MCRUSOE | ||
44 | #define MODULE_PROC_FAMILY "CRUSOE " | ||
45 | #elif defined CONFIG_MEFFICEON | ||
46 | #define MODULE_PROC_FAMILY "EFFICEON " | ||
47 | #elif defined CONFIG_MWINCHIPC6 | ||
48 | #define MODULE_PROC_FAMILY "WINCHIPC6 " | ||
49 | #elif defined CONFIG_MWINCHIP2 | ||
50 | #define MODULE_PROC_FAMILY "WINCHIP2 " | ||
51 | #elif defined CONFIG_MWINCHIP3D | ||
52 | #define MODULE_PROC_FAMILY "WINCHIP3D " | ||
53 | #elif defined CONFIG_MCYRIXIII | ||
54 | #define MODULE_PROC_FAMILY "CYRIXIII " | ||
55 | #elif defined CONFIG_MVIAC3_2 | ||
56 | #define MODULE_PROC_FAMILY "VIAC3-2 " | ||
57 | #elif defined CONFIG_MVIAC7 | ||
58 | #define MODULE_PROC_FAMILY "VIAC7 " | ||
59 | #elif defined CONFIG_MGEODEGX1 | ||
60 | #define MODULE_PROC_FAMILY "GEODEGX1 " | ||
61 | #elif defined CONFIG_MGEODE_LX | ||
62 | #define MODULE_PROC_FAMILY "GEODE " | ||
63 | #else | ||
64 | #error unknown processor family | ||
65 | #endif | ||
66 | |||
67 | #ifdef CONFIG_4KSTACKS | ||
68 | #define MODULE_STACKSIZE "4KSTACKS " | ||
69 | #else | ||
70 | #define MODULE_STACKSIZE "" | ||
71 | #endif | ||
72 | |||
73 | #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE | ||
74 | |||
75 | #endif /* _ASM_I386_MODULE_H */ | ||
diff --git a/include/asm-x86/module_64.h b/include/asm-x86/module_64.h new file mode 100644 index 000000000000..67f8f69fa7b1 --- /dev/null +++ b/include/asm-x86/module_64.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _ASM_X8664_MODULE_H | ||
2 | #define _ASM_X8664_MODULE_H | ||
3 | |||
4 | struct mod_arch_specific {}; | ||
5 | |||
6 | #define Elf_Shdr Elf64_Shdr | ||
7 | #define Elf_Sym Elf64_Sym | ||
8 | #define Elf_Ehdr Elf64_Ehdr | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/mpspec.h b/include/asm-x86/mpspec.h new file mode 100644 index 000000000000..8f268e8fd2e9 --- /dev/null +++ b/include/asm-x86/mpspec.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mpspec_32.h" | ||
3 | #else | ||
4 | # include "mpspec_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mpspec_32.h b/include/asm-x86/mpspec_32.h new file mode 100644 index 000000000000..f21349399d14 --- /dev/null +++ b/include/asm-x86/mpspec_32.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef __ASM_MPSPEC_H | ||
2 | #define __ASM_MPSPEC_H | ||
3 | |||
4 | #include <linux/cpumask.h> | ||
5 | #include <asm/mpspec_def.h> | ||
6 | #include <mach_mpspec.h> | ||
7 | |||
8 | extern int mp_bus_id_to_type [MAX_MP_BUSSES]; | ||
9 | extern int mp_bus_id_to_node [MAX_MP_BUSSES]; | ||
10 | extern int mp_bus_id_to_local [MAX_MP_BUSSES]; | ||
11 | extern int quad_local_to_mp_bus_id [NR_CPUS/4][4]; | ||
12 | extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES]; | ||
13 | |||
14 | extern unsigned int def_to_bigsmp; | ||
15 | extern unsigned int boot_cpu_physical_apicid; | ||
16 | extern int smp_found_config; | ||
17 | extern void find_smp_config (void); | ||
18 | extern void get_smp_config (void); | ||
19 | extern int nr_ioapics; | ||
20 | extern int apic_version [MAX_APICS]; | ||
21 | extern int mp_irq_entries; | ||
22 | extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES]; | ||
23 | extern int mpc_default_type; | ||
24 | extern unsigned long mp_lapic_addr; | ||
25 | extern int pic_mode; | ||
26 | |||
27 | #ifdef CONFIG_ACPI | ||
28 | extern void mp_register_lapic (u8 id, u8 enabled); | ||
29 | extern void mp_register_lapic_address (u64 address); | ||
30 | extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); | ||
31 | extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); | ||
32 | extern void mp_config_acpi_legacy_irqs (void); | ||
33 | extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); | ||
34 | #endif /* CONFIG_ACPI */ | ||
35 | |||
36 | #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) | ||
37 | |||
38 | struct physid_mask | ||
39 | { | ||
40 | unsigned long mask[PHYSID_ARRAY_SIZE]; | ||
41 | }; | ||
42 | |||
43 | typedef struct physid_mask physid_mask_t; | ||
44 | |||
45 | #define physid_set(physid, map) set_bit(physid, (map).mask) | ||
46 | #define physid_clear(physid, map) clear_bit(physid, (map).mask) | ||
47 | #define physid_isset(physid, map) test_bit(physid, (map).mask) | ||
48 | #define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask) | ||
49 | |||
50 | #define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS) | ||
51 | #define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS) | ||
52 | #define physids_clear(map) bitmap_zero((map).mask, MAX_APICS) | ||
53 | #define physids_complement(dst, src) bitmap_complement((dst).mask,(src).mask, MAX_APICS) | ||
54 | #define physids_empty(map) bitmap_empty((map).mask, MAX_APICS) | ||
55 | #define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS) | ||
56 | #define physids_weight(map) bitmap_weight((map).mask, MAX_APICS) | ||
57 | #define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS) | ||
58 | #define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS) | ||
59 | #define physids_coerce(map) ((map).mask[0]) | ||
60 | |||
61 | #define physids_promote(physids) \ | ||
62 | ({ \ | ||
63 | physid_mask_t __physid_mask = PHYSID_MASK_NONE; \ | ||
64 | __physid_mask.mask[0] = physids; \ | ||
65 | __physid_mask; \ | ||
66 | }) | ||
67 | |||
68 | #define physid_mask_of_physid(physid) \ | ||
69 | ({ \ | ||
70 | physid_mask_t __physid_mask = PHYSID_MASK_NONE; \ | ||
71 | physid_set(physid, __physid_mask); \ | ||
72 | __physid_mask; \ | ||
73 | }) | ||
74 | |||
75 | #define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} } | ||
76 | #define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} } | ||
77 | |||
78 | extern physid_mask_t phys_cpu_present_map; | ||
79 | |||
80 | #endif | ||
81 | |||
diff --git a/include/asm-x86/mpspec_64.h b/include/asm-x86/mpspec_64.h new file mode 100644 index 000000000000..017fddb61dc5 --- /dev/null +++ b/include/asm-x86/mpspec_64.h | |||
@@ -0,0 +1,233 @@ | |||
1 | #ifndef __ASM_MPSPEC_H | ||
2 | #define __ASM_MPSPEC_H | ||
3 | |||
4 | /* | ||
5 | * Structure definitions for SMP machines following the | ||
6 | * Intel Multiprocessing Specification 1.1 and 1.4. | ||
7 | */ | ||
8 | |||
9 | /* | ||
10 | * This tag identifies where the SMP configuration | ||
11 | * information is. | ||
12 | */ | ||
13 | |||
14 | #define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_') | ||
15 | |||
16 | /* | ||
17 | * A maximum of 255 APICs with the current APIC ID architecture. | ||
18 | */ | ||
19 | #define MAX_APICS 255 | ||
20 | |||
21 | struct intel_mp_floating | ||
22 | { | ||
23 | char mpf_signature[4]; /* "_MP_" */ | ||
24 | unsigned int mpf_physptr; /* Configuration table address */ | ||
25 | unsigned char mpf_length; /* Our length (paragraphs) */ | ||
26 | unsigned char mpf_specification;/* Specification version */ | ||
27 | unsigned char mpf_checksum; /* Checksum (makes sum 0) */ | ||
28 | unsigned char mpf_feature1; /* Standard or configuration ? */ | ||
29 | unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */ | ||
30 | unsigned char mpf_feature3; /* Unused (0) */ | ||
31 | unsigned char mpf_feature4; /* Unused (0) */ | ||
32 | unsigned char mpf_feature5; /* Unused (0) */ | ||
33 | }; | ||
34 | |||
35 | struct mp_config_table | ||
36 | { | ||
37 | char mpc_signature[4]; | ||
38 | #define MPC_SIGNATURE "PCMP" | ||
39 | unsigned short mpc_length; /* Size of table */ | ||
40 | char mpc_spec; /* 0x01 */ | ||
41 | char mpc_checksum; | ||
42 | char mpc_oem[8]; | ||
43 | char mpc_productid[12]; | ||
44 | unsigned int mpc_oemptr; /* 0 if not present */ | ||
45 | unsigned short mpc_oemsize; /* 0 if not present */ | ||
46 | unsigned short mpc_oemcount; | ||
47 | unsigned int mpc_lapic; /* APIC address */ | ||
48 | unsigned int reserved; | ||
49 | }; | ||
50 | |||
51 | /* Followed by entries */ | ||
52 | |||
53 | #define MP_PROCESSOR 0 | ||
54 | #define MP_BUS 1 | ||
55 | #define MP_IOAPIC 2 | ||
56 | #define MP_INTSRC 3 | ||
57 | #define MP_LINTSRC 4 | ||
58 | |||
59 | struct mpc_config_processor | ||
60 | { | ||
61 | unsigned char mpc_type; | ||
62 | unsigned char mpc_apicid; /* Local APIC number */ | ||
63 | unsigned char mpc_apicver; /* Its versions */ | ||
64 | unsigned char mpc_cpuflag; | ||
65 | #define CPU_ENABLED 1 /* Processor is available */ | ||
66 | #define CPU_BOOTPROCESSOR 2 /* Processor is the BP */ | ||
67 | unsigned int mpc_cpufeature; | ||
68 | #define CPU_STEPPING_MASK 0x0F | ||
69 | #define CPU_MODEL_MASK 0xF0 | ||
70 | #define CPU_FAMILY_MASK 0xF00 | ||
71 | unsigned int mpc_featureflag; /* CPUID feature value */ | ||
72 | unsigned int mpc_reserved[2]; | ||
73 | }; | ||
74 | |||
75 | struct mpc_config_bus | ||
76 | { | ||
77 | unsigned char mpc_type; | ||
78 | unsigned char mpc_busid; | ||
79 | unsigned char mpc_bustype[6]; | ||
80 | }; | ||
81 | |||
82 | /* List of Bus Type string values, Intel MP Spec. */ | ||
83 | #define BUSTYPE_EISA "EISA" | ||
84 | #define BUSTYPE_ISA "ISA" | ||
85 | #define BUSTYPE_INTERN "INTERN" /* Internal BUS */ | ||
86 | #define BUSTYPE_MCA "MCA" | ||
87 | #define BUSTYPE_VL "VL" /* Local bus */ | ||
88 | #define BUSTYPE_PCI "PCI" | ||
89 | #define BUSTYPE_PCMCIA "PCMCIA" | ||
90 | #define BUSTYPE_CBUS "CBUS" | ||
91 | #define BUSTYPE_CBUSII "CBUSII" | ||
92 | #define BUSTYPE_FUTURE "FUTURE" | ||
93 | #define BUSTYPE_MBI "MBI" | ||
94 | #define BUSTYPE_MBII "MBII" | ||
95 | #define BUSTYPE_MPI "MPI" | ||
96 | #define BUSTYPE_MPSA "MPSA" | ||
97 | #define BUSTYPE_NUBUS "NUBUS" | ||
98 | #define BUSTYPE_TC "TC" | ||
99 | #define BUSTYPE_VME "VME" | ||
100 | #define BUSTYPE_XPRESS "XPRESS" | ||
101 | |||
102 | struct mpc_config_ioapic | ||
103 | { | ||
104 | unsigned char mpc_type; | ||
105 | unsigned char mpc_apicid; | ||
106 | unsigned char mpc_apicver; | ||
107 | unsigned char mpc_flags; | ||
108 | #define MPC_APIC_USABLE 0x01 | ||
109 | unsigned int mpc_apicaddr; | ||
110 | }; | ||
111 | |||
112 | struct mpc_config_intsrc | ||
113 | { | ||
114 | unsigned char mpc_type; | ||
115 | unsigned char mpc_irqtype; | ||
116 | unsigned short mpc_irqflag; | ||
117 | unsigned char mpc_srcbus; | ||
118 | unsigned char mpc_srcbusirq; | ||
119 | unsigned char mpc_dstapic; | ||
120 | unsigned char mpc_dstirq; | ||
121 | }; | ||
122 | |||
123 | enum mp_irq_source_types { | ||
124 | mp_INT = 0, | ||
125 | mp_NMI = 1, | ||
126 | mp_SMI = 2, | ||
127 | mp_ExtINT = 3 | ||
128 | }; | ||
129 | |||
130 | #define MP_IRQDIR_DEFAULT 0 | ||
131 | #define MP_IRQDIR_HIGH 1 | ||
132 | #define MP_IRQDIR_LOW 3 | ||
133 | |||
134 | |||
135 | struct mpc_config_lintsrc | ||
136 | { | ||
137 | unsigned char mpc_type; | ||
138 | unsigned char mpc_irqtype; | ||
139 | unsigned short mpc_irqflag; | ||
140 | unsigned char mpc_srcbusid; | ||
141 | unsigned char mpc_srcbusirq; | ||
142 | unsigned char mpc_destapic; | ||
143 | #define MP_APIC_ALL 0xFF | ||
144 | unsigned char mpc_destapiclint; | ||
145 | }; | ||
146 | |||
147 | /* | ||
148 | * Default configurations | ||
149 | * | ||
150 | * 1 2 CPU ISA 82489DX | ||
151 | * 2 2 CPU EISA 82489DX neither IRQ 0 timer nor IRQ 13 DMA chaining | ||
152 | * 3 2 CPU EISA 82489DX | ||
153 | * 4 2 CPU MCA 82489DX | ||
154 | * 5 2 CPU ISA+PCI | ||
155 | * 6 2 CPU EISA+PCI | ||
156 | * 7 2 CPU MCA+PCI | ||
157 | */ | ||
158 | |||
159 | #define MAX_MP_BUSSES 256 | ||
160 | /* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */ | ||
161 | #define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4) | ||
162 | extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); | ||
163 | extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES]; | ||
164 | |||
165 | extern unsigned int boot_cpu_physical_apicid; | ||
166 | extern int smp_found_config; | ||
167 | extern void find_smp_config (void); | ||
168 | extern void get_smp_config (void); | ||
169 | extern int nr_ioapics; | ||
170 | extern unsigned char apic_version [MAX_APICS]; | ||
171 | extern int mp_irq_entries; | ||
172 | extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES]; | ||
173 | extern int mpc_default_type; | ||
174 | extern unsigned long mp_lapic_addr; | ||
175 | |||
176 | #ifdef CONFIG_ACPI | ||
177 | extern void mp_register_lapic (u8 id, u8 enabled); | ||
178 | extern void mp_register_lapic_address (u64 address); | ||
179 | |||
180 | extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); | ||
181 | extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); | ||
182 | extern void mp_config_acpi_legacy_irqs (void); | ||
183 | extern int mp_register_gsi (u32 gsi, int triggering, int polarity); | ||
184 | #endif | ||
185 | |||
186 | extern int using_apic_timer; | ||
187 | |||
188 | #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) | ||
189 | |||
190 | struct physid_mask | ||
191 | { | ||
192 | unsigned long mask[PHYSID_ARRAY_SIZE]; | ||
193 | }; | ||
194 | |||
195 | typedef struct physid_mask physid_mask_t; | ||
196 | |||
197 | #define physid_set(physid, map) set_bit(physid, (map).mask) | ||
198 | #define physid_clear(physid, map) clear_bit(physid, (map).mask) | ||
199 | #define physid_isset(physid, map) test_bit(physid, (map).mask) | ||
200 | #define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask) | ||
201 | |||
202 | #define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS) | ||
203 | #define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS) | ||
204 | #define physids_clear(map) bitmap_zero((map).mask, MAX_APICS) | ||
205 | #define physids_complement(dst, src) bitmap_complement((dst).mask, (src).mask, MAX_APICS) | ||
206 | #define physids_empty(map) bitmap_empty((map).mask, MAX_APICS) | ||
207 | #define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS) | ||
208 | #define physids_weight(map) bitmap_weight((map).mask, MAX_APICS) | ||
209 | #define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS) | ||
210 | #define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS) | ||
211 | #define physids_coerce(map) ((map).mask[0]) | ||
212 | |||
213 | #define physids_promote(physids) \ | ||
214 | ({ \ | ||
215 | physid_mask_t __physid_mask = PHYSID_MASK_NONE; \ | ||
216 | __physid_mask.mask[0] = physids; \ | ||
217 | __physid_mask; \ | ||
218 | }) | ||
219 | |||
220 | #define physid_mask_of_physid(physid) \ | ||
221 | ({ \ | ||
222 | physid_mask_t __physid_mask = PHYSID_MASK_NONE; \ | ||
223 | physid_set(physid, __physid_mask); \ | ||
224 | __physid_mask; \ | ||
225 | }) | ||
226 | |||
227 | #define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} } | ||
228 | #define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} } | ||
229 | |||
230 | extern physid_mask_t phys_cpu_present_map; | ||
231 | |||
232 | #endif | ||
233 | |||
diff --git a/include/asm-x86/mpspec_def.h b/include/asm-x86/mpspec_def.h new file mode 100644 index 000000000000..13bafb16e7af --- /dev/null +++ b/include/asm-x86/mpspec_def.h | |||
@@ -0,0 +1,186 @@ | |||
1 | #ifndef __ASM_MPSPEC_DEF_H | ||
2 | #define __ASM_MPSPEC_DEF_H | ||
3 | |||
4 | /* | ||
5 | * Structure definitions for SMP machines following the | ||
6 | * Intel Multiprocessing Specification 1.1 and 1.4. | ||
7 | */ | ||
8 | |||
9 | /* | ||
10 | * This tag identifies where the SMP configuration | ||
11 | * information is. | ||
12 | */ | ||
13 | |||
14 | #define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_') | ||
15 | |||
16 | #define MAX_MPC_ENTRY 1024 | ||
17 | #define MAX_APICS 256 | ||
18 | |||
19 | struct intel_mp_floating | ||
20 | { | ||
21 | char mpf_signature[4]; /* "_MP_" */ | ||
22 | unsigned long mpf_physptr; /* Configuration table address */ | ||
23 | unsigned char mpf_length; /* Our length (paragraphs) */ | ||
24 | unsigned char mpf_specification;/* Specification version */ | ||
25 | unsigned char mpf_checksum; /* Checksum (makes sum 0) */ | ||
26 | unsigned char mpf_feature1; /* Standard or configuration ? */ | ||
27 | unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */ | ||
28 | unsigned char mpf_feature3; /* Unused (0) */ | ||
29 | unsigned char mpf_feature4; /* Unused (0) */ | ||
30 | unsigned char mpf_feature5; /* Unused (0) */ | ||
31 | }; | ||
32 | |||
33 | struct mp_config_table | ||
34 | { | ||
35 | char mpc_signature[4]; | ||
36 | #define MPC_SIGNATURE "PCMP" | ||
37 | unsigned short mpc_length; /* Size of table */ | ||
38 | char mpc_spec; /* 0x01 */ | ||
39 | char mpc_checksum; | ||
40 | char mpc_oem[8]; | ||
41 | char mpc_productid[12]; | ||
42 | unsigned long mpc_oemptr; /* 0 if not present */ | ||
43 | unsigned short mpc_oemsize; /* 0 if not present */ | ||
44 | unsigned short mpc_oemcount; | ||
45 | unsigned long mpc_lapic; /* APIC address */ | ||
46 | unsigned long reserved; | ||
47 | }; | ||
48 | |||
49 | /* Followed by entries */ | ||
50 | |||
51 | #define MP_PROCESSOR 0 | ||
52 | #define MP_BUS 1 | ||
53 | #define MP_IOAPIC 2 | ||
54 | #define MP_INTSRC 3 | ||
55 | #define MP_LINTSRC 4 | ||
56 | #define MP_TRANSLATION 192 /* Used by IBM NUMA-Q to describe node locality */ | ||
57 | |||
58 | struct mpc_config_processor | ||
59 | { | ||
60 | unsigned char mpc_type; | ||
61 | unsigned char mpc_apicid; /* Local APIC number */ | ||
62 | unsigned char mpc_apicver; /* Its versions */ | ||
63 | unsigned char mpc_cpuflag; | ||
64 | #define CPU_ENABLED 1 /* Processor is available */ | ||
65 | #define CPU_BOOTPROCESSOR 2 /* Processor is the BP */ | ||
66 | unsigned long mpc_cpufeature; | ||
67 | #define CPU_STEPPING_MASK 0x0F | ||
68 | #define CPU_MODEL_MASK 0xF0 | ||
69 | #define CPU_FAMILY_MASK 0xF00 | ||
70 | unsigned long mpc_featureflag; /* CPUID feature value */ | ||
71 | unsigned long mpc_reserved[2]; | ||
72 | }; | ||
73 | |||
74 | struct mpc_config_bus | ||
75 | { | ||
76 | unsigned char mpc_type; | ||
77 | unsigned char mpc_busid; | ||
78 | unsigned char mpc_bustype[6]; | ||
79 | }; | ||
80 | |||
81 | /* List of Bus Type string values, Intel MP Spec. */ | ||
82 | #define BUSTYPE_EISA "EISA" | ||
83 | #define BUSTYPE_ISA "ISA" | ||
84 | #define BUSTYPE_INTERN "INTERN" /* Internal BUS */ | ||
85 | #define BUSTYPE_MCA "MCA" | ||
86 | #define BUSTYPE_VL "VL" /* Local bus */ | ||
87 | #define BUSTYPE_PCI "PCI" | ||
88 | #define BUSTYPE_PCMCIA "PCMCIA" | ||
89 | #define BUSTYPE_CBUS "CBUS" | ||
90 | #define BUSTYPE_CBUSII "CBUSII" | ||
91 | #define BUSTYPE_FUTURE "FUTURE" | ||
92 | #define BUSTYPE_MBI "MBI" | ||
93 | #define BUSTYPE_MBII "MBII" | ||
94 | #define BUSTYPE_MPI "MPI" | ||
95 | #define BUSTYPE_MPSA "MPSA" | ||
96 | #define BUSTYPE_NUBUS "NUBUS" | ||
97 | #define BUSTYPE_TC "TC" | ||
98 | #define BUSTYPE_VME "VME" | ||
99 | #define BUSTYPE_XPRESS "XPRESS" | ||
100 | |||
101 | struct mpc_config_ioapic | ||
102 | { | ||
103 | unsigned char mpc_type; | ||
104 | unsigned char mpc_apicid; | ||
105 | unsigned char mpc_apicver; | ||
106 | unsigned char mpc_flags; | ||
107 | #define MPC_APIC_USABLE 0x01 | ||
108 | unsigned long mpc_apicaddr; | ||
109 | }; | ||
110 | |||
111 | struct mpc_config_intsrc | ||
112 | { | ||
113 | unsigned char mpc_type; | ||
114 | unsigned char mpc_irqtype; | ||
115 | unsigned short mpc_irqflag; | ||
116 | unsigned char mpc_srcbus; | ||
117 | unsigned char mpc_srcbusirq; | ||
118 | unsigned char mpc_dstapic; | ||
119 | unsigned char mpc_dstirq; | ||
120 | }; | ||
121 | |||
122 | enum mp_irq_source_types { | ||
123 | mp_INT = 0, | ||
124 | mp_NMI = 1, | ||
125 | mp_SMI = 2, | ||
126 | mp_ExtINT = 3 | ||
127 | }; | ||
128 | |||
129 | #define MP_IRQDIR_DEFAULT 0 | ||
130 | #define MP_IRQDIR_HIGH 1 | ||
131 | #define MP_IRQDIR_LOW 3 | ||
132 | |||
133 | |||
134 | struct mpc_config_lintsrc | ||
135 | { | ||
136 | unsigned char mpc_type; | ||
137 | unsigned char mpc_irqtype; | ||
138 | unsigned short mpc_irqflag; | ||
139 | unsigned char mpc_srcbusid; | ||
140 | unsigned char mpc_srcbusirq; | ||
141 | unsigned char mpc_destapic; | ||
142 | #define MP_APIC_ALL 0xFF | ||
143 | unsigned char mpc_destapiclint; | ||
144 | }; | ||
145 | |||
146 | struct mp_config_oemtable | ||
147 | { | ||
148 | char oem_signature[4]; | ||
149 | #define MPC_OEM_SIGNATURE "_OEM" | ||
150 | unsigned short oem_length; /* Size of table */ | ||
151 | char oem_rev; /* 0x01 */ | ||
152 | char oem_checksum; | ||
153 | char mpc_oem[8]; | ||
154 | }; | ||
155 | |||
156 | struct mpc_config_translation | ||
157 | { | ||
158 | unsigned char mpc_type; | ||
159 | unsigned char trans_len; | ||
160 | unsigned char trans_type; | ||
161 | unsigned char trans_quad; | ||
162 | unsigned char trans_global; | ||
163 | unsigned char trans_local; | ||
164 | unsigned short trans_reserved; | ||
165 | }; | ||
166 | |||
167 | /* | ||
168 | * Default configurations | ||
169 | * | ||
170 | * 1 2 CPU ISA 82489DX | ||
171 | * 2 2 CPU EISA 82489DX neither IRQ 0 timer nor IRQ 13 DMA chaining | ||
172 | * 3 2 CPU EISA 82489DX | ||
173 | * 4 2 CPU MCA 82489DX | ||
174 | * 5 2 CPU ISA+PCI | ||
175 | * 6 2 CPU EISA+PCI | ||
176 | * 7 2 CPU MCA+PCI | ||
177 | */ | ||
178 | |||
179 | enum mp_bustype { | ||
180 | MP_BUS_ISA = 1, | ||
181 | MP_BUS_EISA, | ||
182 | MP_BUS_PCI, | ||
183 | MP_BUS_MCA, | ||
184 | }; | ||
185 | #endif | ||
186 | |||
diff --git a/include/asm-x86/msgbuf.h b/include/asm-x86/msgbuf.h new file mode 100644 index 000000000000..154f7d64e862 --- /dev/null +++ b/include/asm-x86/msgbuf.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "msgbuf_32.h" | ||
4 | # else | ||
5 | # include "msgbuf_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "msgbuf_32.h" | ||
10 | # else | ||
11 | # include "msgbuf_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/msgbuf_32.h b/include/asm-x86/msgbuf_32.h new file mode 100644 index 000000000000..b8d659c157ae --- /dev/null +++ b/include/asm-x86/msgbuf_32.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _I386_MSGBUF_H | ||
2 | #define _I386_MSGBUF_H | ||
3 | |||
4 | /* | ||
5 | * The msqid64_ds structure for i386 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 64-bit time_t to solve y2038 problem | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct msqid64_ds { | ||
15 | struct ipc64_perm msg_perm; | ||
16 | __kernel_time_t msg_stime; /* last msgsnd time */ | ||
17 | unsigned long __unused1; | ||
18 | __kernel_time_t msg_rtime; /* last msgrcv time */ | ||
19 | unsigned long __unused2; | ||
20 | __kernel_time_t msg_ctime; /* last change time */ | ||
21 | unsigned long __unused3; | ||
22 | unsigned long msg_cbytes; /* current number of bytes on queue */ | ||
23 | unsigned long msg_qnum; /* number of messages in queue */ | ||
24 | unsigned long msg_qbytes; /* max number of bytes on queue */ | ||
25 | __kernel_pid_t msg_lspid; /* pid of last msgsnd */ | ||
26 | __kernel_pid_t msg_lrpid; /* last receive pid */ | ||
27 | unsigned long __unused4; | ||
28 | unsigned long __unused5; | ||
29 | }; | ||
30 | |||
31 | #endif /* _I386_MSGBUF_H */ | ||
diff --git a/include/asm-x86/msgbuf_64.h b/include/asm-x86/msgbuf_64.h new file mode 100644 index 000000000000..cd6f95dd54da --- /dev/null +++ b/include/asm-x86/msgbuf_64.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef _X8664_MSGBUF_H | ||
2 | #define _X8664_MSGBUF_H | ||
3 | |||
4 | /* | ||
5 | * The msqid64_ds structure for x86-64 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 2 miscellaneous 64-bit values | ||
11 | */ | ||
12 | |||
13 | struct msqid64_ds { | ||
14 | struct ipc64_perm msg_perm; | ||
15 | __kernel_time_t msg_stime; /* last msgsnd time */ | ||
16 | __kernel_time_t msg_rtime; /* last msgrcv time */ | ||
17 | __kernel_time_t msg_ctime; /* last change time */ | ||
18 | unsigned long msg_cbytes; /* current number of bytes on queue */ | ||
19 | unsigned long msg_qnum; /* number of messages in queue */ | ||
20 | unsigned long msg_qbytes; /* max number of bytes on queue */ | ||
21 | __kernel_pid_t msg_lspid; /* pid of last msgsnd */ | ||
22 | __kernel_pid_t msg_lrpid; /* last receive pid */ | ||
23 | unsigned long __unused4; | ||
24 | unsigned long __unused5; | ||
25 | }; | ||
26 | |||
27 | #endif | ||
diff --git a/include/asm-x86/msidef.h b/include/asm-x86/msidef.h new file mode 100644 index 000000000000..5b8acddb70fb --- /dev/null +++ b/include/asm-x86/msidef.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef ASM_MSIDEF_H | ||
2 | #define ASM_MSIDEF_H | ||
3 | |||
4 | /* | ||
5 | * Constants for Intel APIC based MSI messages. | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * Shifts for MSI data | ||
10 | */ | ||
11 | |||
12 | #define MSI_DATA_VECTOR_SHIFT 0 | ||
13 | #define MSI_DATA_VECTOR_MASK 0x000000ff | ||
14 | #define MSI_DATA_VECTOR(v) (((v) << MSI_DATA_VECTOR_SHIFT) & MSI_DATA_VECTOR_MASK) | ||
15 | |||
16 | #define MSI_DATA_DELIVERY_MODE_SHIFT 8 | ||
17 | #define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_MODE_SHIFT) | ||
18 | #define MSI_DATA_DELIVERY_LOWPRI (1 << MSI_DATA_DELIVERY_MODE_SHIFT) | ||
19 | |||
20 | #define MSI_DATA_LEVEL_SHIFT 14 | ||
21 | #define MSI_DATA_LEVEL_DEASSERT (0 << MSI_DATA_LEVEL_SHIFT) | ||
22 | #define MSI_DATA_LEVEL_ASSERT (1 << MSI_DATA_LEVEL_SHIFT) | ||
23 | |||
24 | #define MSI_DATA_TRIGGER_SHIFT 15 | ||
25 | #define MSI_DATA_TRIGGER_EDGE (0 << MSI_DATA_TRIGGER_SHIFT) | ||
26 | #define MSI_DATA_TRIGGER_LEVEL (1 << MSI_DATA_TRIGGER_SHIFT) | ||
27 | |||
28 | /* | ||
29 | * Shift/mask fields for msi address | ||
30 | */ | ||
31 | |||
32 | #define MSI_ADDR_BASE_HI 0 | ||
33 | #define MSI_ADDR_BASE_LO 0xfee00000 | ||
34 | |||
35 | #define MSI_ADDR_DEST_MODE_SHIFT 2 | ||
36 | #define MSI_ADDR_DEST_MODE_PHYSICAL (0 << MSI_ADDR_DEST_MODE_SHIFT) | ||
37 | #define MSI_ADDR_DEST_MODE_LOGICAL (1 << MSI_ADDR_DEST_MODE_SHIFT) | ||
38 | |||
39 | #define MSI_ADDR_REDIRECTION_SHIFT 3 | ||
40 | #define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT) /* dedicated cpu */ | ||
41 | #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT) /* lowest priority */ | ||
42 | |||
43 | #define MSI_ADDR_DEST_ID_SHIFT 12 | ||
44 | #define MSI_ADDR_DEST_ID_MASK 0x00ffff0 | ||
45 | #define MSI_ADDR_DEST_ID(dest) (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK) | ||
46 | |||
47 | #endif /* ASM_MSIDEF_H */ | ||
diff --git a/include/asm-x86/msr-index.h b/include/asm-x86/msr-index.h new file mode 100644 index 000000000000..a02eb2991349 --- /dev/null +++ b/include/asm-x86/msr-index.h | |||
@@ -0,0 +1,278 @@ | |||
1 | #ifndef __ASM_MSR_INDEX_H | ||
2 | #define __ASM_MSR_INDEX_H | ||
3 | |||
4 | /* CPU model specific register (MSR) numbers */ | ||
5 | |||
6 | /* x86-64 specific MSRs */ | ||
7 | #define MSR_EFER 0xc0000080 /* extended feature register */ | ||
8 | #define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */ | ||
9 | #define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */ | ||
10 | #define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */ | ||
11 | #define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */ | ||
12 | #define MSR_FS_BASE 0xc0000100 /* 64bit FS base */ | ||
13 | #define MSR_GS_BASE 0xc0000101 /* 64bit GS base */ | ||
14 | #define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow */ | ||
15 | |||
16 | /* EFER bits: */ | ||
17 | #define _EFER_SCE 0 /* SYSCALL/SYSRET */ | ||
18 | #define _EFER_LME 8 /* Long mode enable */ | ||
19 | #define _EFER_LMA 10 /* Long mode active (read-only) */ | ||
20 | #define _EFER_NX 11 /* No execute enable */ | ||
21 | |||
22 | #define EFER_SCE (1<<_EFER_SCE) | ||
23 | #define EFER_LME (1<<_EFER_LME) | ||
24 | #define EFER_LMA (1<<_EFER_LMA) | ||
25 | #define EFER_NX (1<<_EFER_NX) | ||
26 | |||
27 | /* Intel MSRs. Some also available on other CPUs */ | ||
28 | #define MSR_IA32_PERFCTR0 0x000000c1 | ||
29 | #define MSR_IA32_PERFCTR1 0x000000c2 | ||
30 | #define MSR_FSB_FREQ 0x000000cd | ||
31 | |||
32 | #define MSR_MTRRcap 0x000000fe | ||
33 | #define MSR_IA32_BBL_CR_CTL 0x00000119 | ||
34 | |||
35 | #define MSR_IA32_SYSENTER_CS 0x00000174 | ||
36 | #define MSR_IA32_SYSENTER_ESP 0x00000175 | ||
37 | #define MSR_IA32_SYSENTER_EIP 0x00000176 | ||
38 | |||
39 | #define MSR_IA32_MCG_CAP 0x00000179 | ||
40 | #define MSR_IA32_MCG_STATUS 0x0000017a | ||
41 | #define MSR_IA32_MCG_CTL 0x0000017b | ||
42 | |||
43 | #define MSR_IA32_PEBS_ENABLE 0x000003f1 | ||
44 | #define MSR_IA32_DS_AREA 0x00000600 | ||
45 | #define MSR_IA32_PERF_CAPABILITIES 0x00000345 | ||
46 | |||
47 | #define MSR_MTRRfix64K_00000 0x00000250 | ||
48 | #define MSR_MTRRfix16K_80000 0x00000258 | ||
49 | #define MSR_MTRRfix16K_A0000 0x00000259 | ||
50 | #define MSR_MTRRfix4K_C0000 0x00000268 | ||
51 | #define MSR_MTRRfix4K_C8000 0x00000269 | ||
52 | #define MSR_MTRRfix4K_D0000 0x0000026a | ||
53 | #define MSR_MTRRfix4K_D8000 0x0000026b | ||
54 | #define MSR_MTRRfix4K_E0000 0x0000026c | ||
55 | #define MSR_MTRRfix4K_E8000 0x0000026d | ||
56 | #define MSR_MTRRfix4K_F0000 0x0000026e | ||
57 | #define MSR_MTRRfix4K_F8000 0x0000026f | ||
58 | #define MSR_MTRRdefType 0x000002ff | ||
59 | |||
60 | #define MSR_IA32_DEBUGCTLMSR 0x000001d9 | ||
61 | #define MSR_IA32_LASTBRANCHFROMIP 0x000001db | ||
62 | #define MSR_IA32_LASTBRANCHTOIP 0x000001dc | ||
63 | #define MSR_IA32_LASTINTFROMIP 0x000001dd | ||
64 | #define MSR_IA32_LASTINTTOIP 0x000001de | ||
65 | |||
66 | #define MSR_IA32_MC0_CTL 0x00000400 | ||
67 | #define MSR_IA32_MC0_STATUS 0x00000401 | ||
68 | #define MSR_IA32_MC0_ADDR 0x00000402 | ||
69 | #define MSR_IA32_MC0_MISC 0x00000403 | ||
70 | |||
71 | #define MSR_P6_PERFCTR0 0x000000c1 | ||
72 | #define MSR_P6_PERFCTR1 0x000000c2 | ||
73 | #define MSR_P6_EVNTSEL0 0x00000186 | ||
74 | #define MSR_P6_EVNTSEL1 0x00000187 | ||
75 | |||
76 | /* K7/K8 MSRs. Not complete. See the architecture manual for a more | ||
77 | complete list. */ | ||
78 | #define MSR_K7_EVNTSEL0 0xc0010000 | ||
79 | #define MSR_K7_PERFCTR0 0xc0010004 | ||
80 | #define MSR_K7_EVNTSEL1 0xc0010001 | ||
81 | #define MSR_K7_PERFCTR1 0xc0010005 | ||
82 | #define MSR_K7_EVNTSEL2 0xc0010002 | ||
83 | #define MSR_K7_PERFCTR2 0xc0010006 | ||
84 | #define MSR_K7_EVNTSEL3 0xc0010003 | ||
85 | #define MSR_K7_PERFCTR3 0xc0010007 | ||
86 | #define MSR_K8_TOP_MEM1 0xc001001a | ||
87 | #define MSR_K7_CLK_CTL 0xc001001b | ||
88 | #define MSR_K8_TOP_MEM2 0xc001001d | ||
89 | #define MSR_K8_SYSCFG 0xc0010010 | ||
90 | |||
91 | #define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000 /* MtrrFixDramEn bit */ | ||
92 | #define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000 /* MtrrFixDramModEn bit */ | ||
93 | #define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818 /* Mask: RdMem|WrMem */ | ||
94 | |||
95 | #define MSR_K7_HWCR 0xc0010015 | ||
96 | #define MSR_K8_HWCR 0xc0010015 | ||
97 | #define MSR_K7_FID_VID_CTL 0xc0010041 | ||
98 | #define MSR_K7_FID_VID_STATUS 0xc0010042 | ||
99 | #define MSR_K8_ENABLE_C1E 0xc0010055 | ||
100 | |||
101 | /* K6 MSRs */ | ||
102 | #define MSR_K6_EFER 0xc0000080 | ||
103 | #define MSR_K6_STAR 0xc0000081 | ||
104 | #define MSR_K6_WHCR 0xc0000082 | ||
105 | #define MSR_K6_UWCCR 0xc0000085 | ||
106 | #define MSR_K6_EPMR 0xc0000086 | ||
107 | #define MSR_K6_PSOR 0xc0000087 | ||
108 | #define MSR_K6_PFIR 0xc0000088 | ||
109 | |||
110 | /* Centaur-Hauls/IDT defined MSRs. */ | ||
111 | #define MSR_IDT_FCR1 0x00000107 | ||
112 | #define MSR_IDT_FCR2 0x00000108 | ||
113 | #define MSR_IDT_FCR3 0x00000109 | ||
114 | #define MSR_IDT_FCR4 0x0000010a | ||
115 | |||
116 | #define MSR_IDT_MCR0 0x00000110 | ||
117 | #define MSR_IDT_MCR1 0x00000111 | ||
118 | #define MSR_IDT_MCR2 0x00000112 | ||
119 | #define MSR_IDT_MCR3 0x00000113 | ||
120 | #define MSR_IDT_MCR4 0x00000114 | ||
121 | #define MSR_IDT_MCR5 0x00000115 | ||
122 | #define MSR_IDT_MCR6 0x00000116 | ||
123 | #define MSR_IDT_MCR7 0x00000117 | ||
124 | #define MSR_IDT_MCR_CTRL 0x00000120 | ||
125 | |||
126 | /* VIA Cyrix defined MSRs*/ | ||
127 | #define MSR_VIA_FCR 0x00001107 | ||
128 | #define MSR_VIA_LONGHAUL 0x0000110a | ||
129 | #define MSR_VIA_RNG 0x0000110b | ||
130 | #define MSR_VIA_BCR2 0x00001147 | ||
131 | |||
132 | /* Transmeta defined MSRs */ | ||
133 | #define MSR_TMTA_LONGRUN_CTRL 0x80868010 | ||
134 | #define MSR_TMTA_LONGRUN_FLAGS 0x80868011 | ||
135 | #define MSR_TMTA_LRTI_READOUT 0x80868018 | ||
136 | #define MSR_TMTA_LRTI_VOLT_MHZ 0x8086801a | ||
137 | |||
138 | /* Intel defined MSRs. */ | ||
139 | #define MSR_IA32_P5_MC_ADDR 0x00000000 | ||
140 | #define MSR_IA32_P5_MC_TYPE 0x00000001 | ||
141 | #define MSR_IA32_TSC 0x00000010 | ||
142 | #define MSR_IA32_PLATFORM_ID 0x00000017 | ||
143 | #define MSR_IA32_EBL_CR_POWERON 0x0000002a | ||
144 | |||
145 | #define MSR_IA32_APICBASE 0x0000001b | ||
146 | #define MSR_IA32_APICBASE_BSP (1<<8) | ||
147 | #define MSR_IA32_APICBASE_ENABLE (1<<11) | ||
148 | #define MSR_IA32_APICBASE_BASE (0xfffff<<12) | ||
149 | |||
150 | #define MSR_IA32_UCODE_WRITE 0x00000079 | ||
151 | #define MSR_IA32_UCODE_REV 0x0000008b | ||
152 | |||
153 | #define MSR_IA32_PERF_STATUS 0x00000198 | ||
154 | #define MSR_IA32_PERF_CTL 0x00000199 | ||
155 | |||
156 | #define MSR_IA32_MPERF 0x000000e7 | ||
157 | #define MSR_IA32_APERF 0x000000e8 | ||
158 | |||
159 | #define MSR_IA32_THERM_CONTROL 0x0000019a | ||
160 | #define MSR_IA32_THERM_INTERRUPT 0x0000019b | ||
161 | #define MSR_IA32_THERM_STATUS 0x0000019c | ||
162 | #define MSR_IA32_MISC_ENABLE 0x000001a0 | ||
163 | |||
164 | /* Intel Model 6 */ | ||
165 | #define MSR_P6_EVNTSEL0 0x00000186 | ||
166 | #define MSR_P6_EVNTSEL1 0x00000187 | ||
167 | |||
168 | /* P4/Xeon+ specific */ | ||
169 | #define MSR_IA32_MCG_EAX 0x00000180 | ||
170 | #define MSR_IA32_MCG_EBX 0x00000181 | ||
171 | #define MSR_IA32_MCG_ECX 0x00000182 | ||
172 | #define MSR_IA32_MCG_EDX 0x00000183 | ||
173 | #define MSR_IA32_MCG_ESI 0x00000184 | ||
174 | #define MSR_IA32_MCG_EDI 0x00000185 | ||
175 | #define MSR_IA32_MCG_EBP 0x00000186 | ||
176 | #define MSR_IA32_MCG_ESP 0x00000187 | ||
177 | #define MSR_IA32_MCG_EFLAGS 0x00000188 | ||
178 | #define MSR_IA32_MCG_EIP 0x00000189 | ||
179 | #define MSR_IA32_MCG_RESERVED 0x0000018a | ||
180 | |||
181 | /* Pentium IV performance counter MSRs */ | ||
182 | #define MSR_P4_BPU_PERFCTR0 0x00000300 | ||
183 | #define MSR_P4_BPU_PERFCTR1 0x00000301 | ||
184 | #define MSR_P4_BPU_PERFCTR2 0x00000302 | ||
185 | #define MSR_P4_BPU_PERFCTR3 0x00000303 | ||
186 | #define MSR_P4_MS_PERFCTR0 0x00000304 | ||
187 | #define MSR_P4_MS_PERFCTR1 0x00000305 | ||
188 | #define MSR_P4_MS_PERFCTR2 0x00000306 | ||
189 | #define MSR_P4_MS_PERFCTR3 0x00000307 | ||
190 | #define MSR_P4_FLAME_PERFCTR0 0x00000308 | ||
191 | #define MSR_P4_FLAME_PERFCTR1 0x00000309 | ||
192 | #define MSR_P4_FLAME_PERFCTR2 0x0000030a | ||
193 | #define MSR_P4_FLAME_PERFCTR3 0x0000030b | ||
194 | #define MSR_P4_IQ_PERFCTR0 0x0000030c | ||
195 | #define MSR_P4_IQ_PERFCTR1 0x0000030d | ||
196 | #define MSR_P4_IQ_PERFCTR2 0x0000030e | ||
197 | #define MSR_P4_IQ_PERFCTR3 0x0000030f | ||
198 | #define MSR_P4_IQ_PERFCTR4 0x00000310 | ||
199 | #define MSR_P4_IQ_PERFCTR5 0x00000311 | ||
200 | #define MSR_P4_BPU_CCCR0 0x00000360 | ||
201 | #define MSR_P4_BPU_CCCR1 0x00000361 | ||
202 | #define MSR_P4_BPU_CCCR2 0x00000362 | ||
203 | #define MSR_P4_BPU_CCCR3 0x00000363 | ||
204 | #define MSR_P4_MS_CCCR0 0x00000364 | ||
205 | #define MSR_P4_MS_CCCR1 0x00000365 | ||
206 | #define MSR_P4_MS_CCCR2 0x00000366 | ||
207 | #define MSR_P4_MS_CCCR3 0x00000367 | ||
208 | #define MSR_P4_FLAME_CCCR0 0x00000368 | ||
209 | #define MSR_P4_FLAME_CCCR1 0x00000369 | ||
210 | #define MSR_P4_FLAME_CCCR2 0x0000036a | ||
211 | #define MSR_P4_FLAME_CCCR3 0x0000036b | ||
212 | #define MSR_P4_IQ_CCCR0 0x0000036c | ||
213 | #define MSR_P4_IQ_CCCR1 0x0000036d | ||
214 | #define MSR_P4_IQ_CCCR2 0x0000036e | ||
215 | #define MSR_P4_IQ_CCCR3 0x0000036f | ||
216 | #define MSR_P4_IQ_CCCR4 0x00000370 | ||
217 | #define MSR_P4_IQ_CCCR5 0x00000371 | ||
218 | #define MSR_P4_ALF_ESCR0 0x000003ca | ||
219 | #define MSR_P4_ALF_ESCR1 0x000003cb | ||
220 | #define MSR_P4_BPU_ESCR0 0x000003b2 | ||
221 | #define MSR_P4_BPU_ESCR1 0x000003b3 | ||
222 | #define MSR_P4_BSU_ESCR0 0x000003a0 | ||
223 | #define MSR_P4_BSU_ESCR1 0x000003a1 | ||
224 | #define MSR_P4_CRU_ESCR0 0x000003b8 | ||
225 | #define MSR_P4_CRU_ESCR1 0x000003b9 | ||
226 | #define MSR_P4_CRU_ESCR2 0x000003cc | ||
227 | #define MSR_P4_CRU_ESCR3 0x000003cd | ||
228 | #define MSR_P4_CRU_ESCR4 0x000003e0 | ||
229 | #define MSR_P4_CRU_ESCR5 0x000003e1 | ||
230 | #define MSR_P4_DAC_ESCR0 0x000003a8 | ||
231 | #define MSR_P4_DAC_ESCR1 0x000003a9 | ||
232 | #define MSR_P4_FIRM_ESCR0 0x000003a4 | ||
233 | #define MSR_P4_FIRM_ESCR1 0x000003a5 | ||
234 | #define MSR_P4_FLAME_ESCR0 0x000003a6 | ||
235 | #define MSR_P4_FLAME_ESCR1 0x000003a7 | ||
236 | #define MSR_P4_FSB_ESCR0 0x000003a2 | ||
237 | #define MSR_P4_FSB_ESCR1 0x000003a3 | ||
238 | #define MSR_P4_IQ_ESCR0 0x000003ba | ||
239 | #define MSR_P4_IQ_ESCR1 0x000003bb | ||
240 | #define MSR_P4_IS_ESCR0 0x000003b4 | ||
241 | #define MSR_P4_IS_ESCR1 0x000003b5 | ||
242 | #define MSR_P4_ITLB_ESCR0 0x000003b6 | ||
243 | #define MSR_P4_ITLB_ESCR1 0x000003b7 | ||
244 | #define MSR_P4_IX_ESCR0 0x000003c8 | ||
245 | #define MSR_P4_IX_ESCR1 0x000003c9 | ||
246 | #define MSR_P4_MOB_ESCR0 0x000003aa | ||
247 | #define MSR_P4_MOB_ESCR1 0x000003ab | ||
248 | #define MSR_P4_MS_ESCR0 0x000003c0 | ||
249 | #define MSR_P4_MS_ESCR1 0x000003c1 | ||
250 | #define MSR_P4_PMH_ESCR0 0x000003ac | ||
251 | #define MSR_P4_PMH_ESCR1 0x000003ad | ||
252 | #define MSR_P4_RAT_ESCR0 0x000003bc | ||
253 | #define MSR_P4_RAT_ESCR1 0x000003bd | ||
254 | #define MSR_P4_SAAT_ESCR0 0x000003ae | ||
255 | #define MSR_P4_SAAT_ESCR1 0x000003af | ||
256 | #define MSR_P4_SSU_ESCR0 0x000003be | ||
257 | #define MSR_P4_SSU_ESCR1 0x000003bf /* guess: not in manual */ | ||
258 | |||
259 | #define MSR_P4_TBPU_ESCR0 0x000003c2 | ||
260 | #define MSR_P4_TBPU_ESCR1 0x000003c3 | ||
261 | #define MSR_P4_TC_ESCR0 0x000003c4 | ||
262 | #define MSR_P4_TC_ESCR1 0x000003c5 | ||
263 | #define MSR_P4_U2L_ESCR0 0x000003b0 | ||
264 | #define MSR_P4_U2L_ESCR1 0x000003b1 | ||
265 | |||
266 | /* Intel Core-based CPU performance counters */ | ||
267 | #define MSR_CORE_PERF_FIXED_CTR0 0x00000309 | ||
268 | #define MSR_CORE_PERF_FIXED_CTR1 0x0000030a | ||
269 | #define MSR_CORE_PERF_FIXED_CTR2 0x0000030b | ||
270 | #define MSR_CORE_PERF_FIXED_CTR_CTRL 0x0000038d | ||
271 | #define MSR_CORE_PERF_GLOBAL_STATUS 0x0000038e | ||
272 | #define MSR_CORE_PERF_GLOBAL_CTRL 0x0000038f | ||
273 | #define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x00000390 | ||
274 | |||
275 | /* Geode defined MSRs */ | ||
276 | #define MSR_GEODE_BUSCONT_CONF0 0x00001900 | ||
277 | |||
278 | #endif /* __ASM_MSR_INDEX_H */ | ||
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h new file mode 100644 index 000000000000..2f87ce007002 --- /dev/null +++ b/include/asm-x86/msr.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "msr_32.h" | ||
4 | # else | ||
5 | # include "msr_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "msr_32.h" | ||
10 | # else | ||
11 | # include "msr_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/msr_32.h b/include/asm-x86/msr_32.h new file mode 100644 index 000000000000..df21ea049369 --- /dev/null +++ b/include/asm-x86/msr_32.h | |||
@@ -0,0 +1,161 @@ | |||
1 | #ifndef __ASM_MSR_H | ||
2 | #define __ASM_MSR_H | ||
3 | |||
4 | #include <asm/msr-index.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | #ifndef __ASSEMBLY__ | ||
8 | |||
9 | #include <asm/errno.h> | ||
10 | |||
11 | static inline unsigned long long native_read_msr(unsigned int msr) | ||
12 | { | ||
13 | unsigned long long val; | ||
14 | |||
15 | asm volatile("rdmsr" : "=A" (val) : "c" (msr)); | ||
16 | return val; | ||
17 | } | ||
18 | |||
19 | static inline unsigned long long native_read_msr_safe(unsigned int msr, | ||
20 | int *err) | ||
21 | { | ||
22 | unsigned long long val; | ||
23 | |||
24 | asm volatile("2: rdmsr ; xorl %0,%0\n" | ||
25 | "1:\n\t" | ||
26 | ".section .fixup,\"ax\"\n\t" | ||
27 | "3: movl %3,%0 ; jmp 1b\n\t" | ||
28 | ".previous\n\t" | ||
29 | ".section __ex_table,\"a\"\n" | ||
30 | " .align 4\n\t" | ||
31 | " .long 2b,3b\n\t" | ||
32 | ".previous" | ||
33 | : "=r" (*err), "=A" (val) | ||
34 | : "c" (msr), "i" (-EFAULT)); | ||
35 | |||
36 | return val; | ||
37 | } | ||
38 | |||
39 | static inline void native_write_msr(unsigned int msr, unsigned long long val) | ||
40 | { | ||
41 | asm volatile("wrmsr" : : "c" (msr), "A"(val)); | ||
42 | } | ||
43 | |||
44 | static inline int native_write_msr_safe(unsigned int msr, | ||
45 | unsigned long long val) | ||
46 | { | ||
47 | int err; | ||
48 | asm volatile("2: wrmsr ; xorl %0,%0\n" | ||
49 | "1:\n\t" | ||
50 | ".section .fixup,\"ax\"\n\t" | ||
51 | "3: movl %4,%0 ; jmp 1b\n\t" | ||
52 | ".previous\n\t" | ||
53 | ".section __ex_table,\"a\"\n" | ||
54 | " .align 4\n\t" | ||
55 | " .long 2b,3b\n\t" | ||
56 | ".previous" | ||
57 | : "=a" (err) | ||
58 | : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)), | ||
59 | "i" (-EFAULT)); | ||
60 | return err; | ||
61 | } | ||
62 | |||
63 | static inline unsigned long long native_read_tsc(void) | ||
64 | { | ||
65 | unsigned long long val; | ||
66 | asm volatile("rdtsc" : "=A" (val)); | ||
67 | return val; | ||
68 | } | ||
69 | |||
70 | static inline unsigned long long native_read_pmc(void) | ||
71 | { | ||
72 | unsigned long long val; | ||
73 | asm volatile("rdpmc" : "=A" (val)); | ||
74 | return val; | ||
75 | } | ||
76 | |||
77 | #ifdef CONFIG_PARAVIRT | ||
78 | #include <asm/paravirt.h> | ||
79 | #else | ||
80 | #include <linux/errno.h> | ||
81 | /* | ||
82 | * Access to machine-specific registers (available on 586 and better only) | ||
83 | * Note: the rd* operations modify the parameters directly (without using | ||
84 | * pointer indirection), this allows gcc to optimize better | ||
85 | */ | ||
86 | |||
87 | #define rdmsr(msr,val1,val2) \ | ||
88 | do { \ | ||
89 | u64 __val = native_read_msr(msr); \ | ||
90 | (val1) = (u32)__val; \ | ||
91 | (val2) = (u32)(__val >> 32); \ | ||
92 | } while(0) | ||
93 | |||
94 | static inline void wrmsr(u32 __msr, u32 __low, u32 __high) | ||
95 | { | ||
96 | native_write_msr(__msr, ((u64)__high << 32) | __low); | ||
97 | } | ||
98 | |||
99 | #define rdmsrl(msr,val) \ | ||
100 | ((val) = native_read_msr(msr)) | ||
101 | |||
102 | #define wrmsrl(msr,val) native_write_msr(msr, val) | ||
103 | |||
104 | /* wrmsr with exception handling */ | ||
105 | static inline int wrmsr_safe(u32 __msr, u32 __low, u32 __high) | ||
106 | { | ||
107 | return native_write_msr_safe(__msr, ((u64)__high << 32) | __low); | ||
108 | } | ||
109 | |||
110 | /* rdmsr with exception handling */ | ||
111 | #define rdmsr_safe(msr,p1,p2) \ | ||
112 | ({ \ | ||
113 | int __err; \ | ||
114 | u64 __val = native_read_msr_safe(msr, &__err); \ | ||
115 | (*p1) = (u32)__val; \ | ||
116 | (*p2) = (u32)(__val >> 32); \ | ||
117 | __err; \ | ||
118 | }) | ||
119 | |||
120 | #define rdtscl(low) \ | ||
121 | ((low) = (u32)native_read_tsc()) | ||
122 | |||
123 | #define rdtscll(val) \ | ||
124 | ((val) = native_read_tsc()) | ||
125 | |||
126 | #define write_tsc(val1,val2) wrmsr(0x10, val1, val2) | ||
127 | |||
128 | #define rdpmc(counter,low,high) \ | ||
129 | do { \ | ||
130 | u64 _l = native_read_pmc(); \ | ||
131 | (low) = (u32)_l; \ | ||
132 | (high) = (u32)(_l >> 32); \ | ||
133 | } while(0) | ||
134 | #endif /* !CONFIG_PARAVIRT */ | ||
135 | |||
136 | #ifdef CONFIG_SMP | ||
137 | void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | ||
138 | void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | ||
139 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | ||
140 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | ||
141 | #else /* CONFIG_SMP */ | ||
142 | static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
143 | { | ||
144 | rdmsr(msr_no, *l, *h); | ||
145 | } | ||
146 | static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
147 | { | ||
148 | wrmsr(msr_no, l, h); | ||
149 | } | ||
150 | static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
151 | { | ||
152 | return rdmsr_safe(msr_no, l, h); | ||
153 | } | ||
154 | static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
155 | { | ||
156 | return wrmsr_safe(msr_no, l, h); | ||
157 | } | ||
158 | #endif /* CONFIG_SMP */ | ||
159 | #endif | ||
160 | #endif | ||
161 | #endif /* __ASM_MSR_H */ | ||
diff --git a/include/asm-x86/msr_64.h b/include/asm-x86/msr_64.h new file mode 100644 index 000000000000..d5c55b80da54 --- /dev/null +++ b/include/asm-x86/msr_64.h | |||
@@ -0,0 +1,187 @@ | |||
1 | #ifndef X86_64_MSR_H | ||
2 | #define X86_64_MSR_H 1 | ||
3 | |||
4 | #include <asm/msr-index.h> | ||
5 | |||
6 | #ifndef __ASSEMBLY__ | ||
7 | #include <linux/errno.h> | ||
8 | /* | ||
9 | * Access to machine-specific registers (available on 586 and better only) | ||
10 | * Note: the rd* operations modify the parameters directly (without using | ||
11 | * pointer indirection), this allows gcc to optimize better | ||
12 | */ | ||
13 | |||
14 | #define rdmsr(msr,val1,val2) \ | ||
15 | __asm__ __volatile__("rdmsr" \ | ||
16 | : "=a" (val1), "=d" (val2) \ | ||
17 | : "c" (msr)) | ||
18 | |||
19 | |||
20 | #define rdmsrl(msr,val) do { unsigned long a__,b__; \ | ||
21 | __asm__ __volatile__("rdmsr" \ | ||
22 | : "=a" (a__), "=d" (b__) \ | ||
23 | : "c" (msr)); \ | ||
24 | val = a__ | (b__<<32); \ | ||
25 | } while(0) | ||
26 | |||
27 | #define wrmsr(msr,val1,val2) \ | ||
28 | __asm__ __volatile__("wrmsr" \ | ||
29 | : /* no outputs */ \ | ||
30 | : "c" (msr), "a" (val1), "d" (val2)) | ||
31 | |||
32 | #define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32) | ||
33 | |||
34 | /* wrmsr with exception handling */ | ||
35 | #define wrmsr_safe(msr,a,b) ({ int ret__; \ | ||
36 | asm volatile("2: wrmsr ; xorl %0,%0\n" \ | ||
37 | "1:\n\t" \ | ||
38 | ".section .fixup,\"ax\"\n\t" \ | ||
39 | "3: movl %4,%0 ; jmp 1b\n\t" \ | ||
40 | ".previous\n\t" \ | ||
41 | ".section __ex_table,\"a\"\n" \ | ||
42 | " .align 8\n\t" \ | ||
43 | " .quad 2b,3b\n\t" \ | ||
44 | ".previous" \ | ||
45 | : "=a" (ret__) \ | ||
46 | : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \ | ||
47 | ret__; }) | ||
48 | |||
49 | #define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) | ||
50 | |||
51 | #define rdmsr_safe(msr,a,b) \ | ||
52 | ({ int ret__; \ | ||
53 | asm volatile ("1: rdmsr\n" \ | ||
54 | "2:\n" \ | ||
55 | ".section .fixup,\"ax\"\n" \ | ||
56 | "3: movl %4,%0\n" \ | ||
57 | " jmp 2b\n" \ | ||
58 | ".previous\n" \ | ||
59 | ".section __ex_table,\"a\"\n" \ | ||
60 | " .align 8\n" \ | ||
61 | " .quad 1b,3b\n" \ | ||
62 | ".previous":"=&bDS" (ret__), "=a"(*(a)), "=d"(*(b))\ | ||
63 | :"c"(msr), "i"(-EIO), "0"(0)); \ | ||
64 | ret__; }) | ||
65 | |||
66 | #define rdtsc(low,high) \ | ||
67 | __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) | ||
68 | |||
69 | #define rdtscl(low) \ | ||
70 | __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") | ||
71 | |||
72 | #define rdtscp(low,high,aux) \ | ||
73 | asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux)) | ||
74 | |||
75 | #define rdtscll(val) do { \ | ||
76 | unsigned int __a,__d; \ | ||
77 | asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ | ||
78 | (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ | ||
79 | } while(0) | ||
80 | |||
81 | #define rdtscpll(val, aux) do { \ | ||
82 | unsigned long __a, __d; \ | ||
83 | asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \ | ||
84 | (val) = (__d << 32) | __a; \ | ||
85 | } while (0) | ||
86 | |||
87 | #define write_tsc(val1,val2) wrmsr(0x10, val1, val2) | ||
88 | |||
89 | #define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0) | ||
90 | |||
91 | #define rdpmc(counter,low,high) \ | ||
92 | __asm__ __volatile__("rdpmc" \ | ||
93 | : "=a" (low), "=d" (high) \ | ||
94 | : "c" (counter)) | ||
95 | |||
96 | static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx, | ||
97 | unsigned int *ecx, unsigned int *edx) | ||
98 | { | ||
99 | __asm__("cpuid" | ||
100 | : "=a" (*eax), | ||
101 | "=b" (*ebx), | ||
102 | "=c" (*ecx), | ||
103 | "=d" (*edx) | ||
104 | : "0" (op)); | ||
105 | } | ||
106 | |||
107 | /* Some CPUID calls want 'count' to be placed in ecx */ | ||
108 | static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, | ||
109 | int *edx) | ||
110 | { | ||
111 | __asm__("cpuid" | ||
112 | : "=a" (*eax), | ||
113 | "=b" (*ebx), | ||
114 | "=c" (*ecx), | ||
115 | "=d" (*edx) | ||
116 | : "0" (op), "c" (count)); | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * CPUID functions returning a single datum | ||
121 | */ | ||
122 | static inline unsigned int cpuid_eax(unsigned int op) | ||
123 | { | ||
124 | unsigned int eax; | ||
125 | |||
126 | __asm__("cpuid" | ||
127 | : "=a" (eax) | ||
128 | : "0" (op) | ||
129 | : "bx", "cx", "dx"); | ||
130 | return eax; | ||
131 | } | ||
132 | static inline unsigned int cpuid_ebx(unsigned int op) | ||
133 | { | ||
134 | unsigned int eax, ebx; | ||
135 | |||
136 | __asm__("cpuid" | ||
137 | : "=a" (eax), "=b" (ebx) | ||
138 | : "0" (op) | ||
139 | : "cx", "dx" ); | ||
140 | return ebx; | ||
141 | } | ||
142 | static inline unsigned int cpuid_ecx(unsigned int op) | ||
143 | { | ||
144 | unsigned int eax, ecx; | ||
145 | |||
146 | __asm__("cpuid" | ||
147 | : "=a" (eax), "=c" (ecx) | ||
148 | : "0" (op) | ||
149 | : "bx", "dx" ); | ||
150 | return ecx; | ||
151 | } | ||
152 | static inline unsigned int cpuid_edx(unsigned int op) | ||
153 | { | ||
154 | unsigned int eax, edx; | ||
155 | |||
156 | __asm__("cpuid" | ||
157 | : "=a" (eax), "=d" (edx) | ||
158 | : "0" (op) | ||
159 | : "bx", "cx"); | ||
160 | return edx; | ||
161 | } | ||
162 | |||
163 | #ifdef CONFIG_SMP | ||
164 | void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | ||
165 | void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | ||
166 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | ||
167 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | ||
168 | #else /* CONFIG_SMP */ | ||
169 | static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
170 | { | ||
171 | rdmsr(msr_no, *l, *h); | ||
172 | } | ||
173 | static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
174 | { | ||
175 | wrmsr(msr_no, l, h); | ||
176 | } | ||
177 | static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
178 | { | ||
179 | return rdmsr_safe(msr_no, l, h); | ||
180 | } | ||
181 | static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
182 | { | ||
183 | return wrmsr_safe(msr_no, l, h); | ||
184 | } | ||
185 | #endif /* CONFIG_SMP */ | ||
186 | #endif /* __ASSEMBLY__ */ | ||
187 | #endif /* X86_64_MSR_H */ | ||
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h new file mode 100644 index 000000000000..34f633b3e00c --- /dev/null +++ b/include/asm-x86/mtrr.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "mtrr_32.h" | ||
4 | # else | ||
5 | # include "mtrr_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "mtrr_32.h" | ||
10 | # else | ||
11 | # include "mtrr_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/mtrr_32.h b/include/asm-x86/mtrr_32.h new file mode 100644 index 000000000000..7e9c7ccbdcfe --- /dev/null +++ b/include/asm-x86/mtrr_32.h | |||
@@ -0,0 +1,115 @@ | |||
1 | /* Generic MTRR (Memory Type Range Register) ioctls. | ||
2 | |||
3 | Copyright (C) 1997-1999 Richard Gooch | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public | ||
16 | License along with this library; if not, write to the Free | ||
17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | |||
19 | Richard Gooch may be reached by email at rgooch@atnf.csiro.au | ||
20 | The postal address is: | ||
21 | Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. | ||
22 | */ | ||
23 | #ifndef _LINUX_MTRR_H | ||
24 | #define _LINUX_MTRR_H | ||
25 | |||
26 | #include <linux/ioctl.h> | ||
27 | #include <linux/errno.h> | ||
28 | |||
29 | #define MTRR_IOCTL_BASE 'M' | ||
30 | |||
31 | struct mtrr_sentry | ||
32 | { | ||
33 | unsigned long base; /* Base address */ | ||
34 | unsigned int size; /* Size of region */ | ||
35 | unsigned int type; /* Type of region */ | ||
36 | }; | ||
37 | |||
38 | struct mtrr_gentry | ||
39 | { | ||
40 | unsigned int regnum; /* Register number */ | ||
41 | unsigned long base; /* Base address */ | ||
42 | unsigned int size; /* Size of region */ | ||
43 | unsigned int type; /* Type of region */ | ||
44 | }; | ||
45 | |||
46 | /* These are the various ioctls */ | ||
47 | #define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) | ||
48 | #define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) | ||
49 | #define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) | ||
50 | #define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) | ||
51 | #define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) | ||
52 | #define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) | ||
53 | #define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) | ||
54 | #define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) | ||
55 | #define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) | ||
56 | #define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) | ||
57 | |||
58 | /* These are the region types */ | ||
59 | #define MTRR_TYPE_UNCACHABLE 0 | ||
60 | #define MTRR_TYPE_WRCOMB 1 | ||
61 | /*#define MTRR_TYPE_ 2*/ | ||
62 | /*#define MTRR_TYPE_ 3*/ | ||
63 | #define MTRR_TYPE_WRTHROUGH 4 | ||
64 | #define MTRR_TYPE_WRPROT 5 | ||
65 | #define MTRR_TYPE_WRBACK 6 | ||
66 | #define MTRR_NUM_TYPES 7 | ||
67 | |||
68 | #ifdef __KERNEL__ | ||
69 | |||
70 | /* The following functions are for use by other drivers */ | ||
71 | # ifdef CONFIG_MTRR | ||
72 | extern void mtrr_save_fixed_ranges(void *); | ||
73 | extern void mtrr_save_state(void); | ||
74 | extern int mtrr_add (unsigned long base, unsigned long size, | ||
75 | unsigned int type, char increment); | ||
76 | extern int mtrr_add_page (unsigned long base, unsigned long size, | ||
77 | unsigned int type, char increment); | ||
78 | extern int mtrr_del (int reg, unsigned long base, unsigned long size); | ||
79 | extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); | ||
80 | extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); | ||
81 | extern void mtrr_ap_init(void); | ||
82 | extern void mtrr_bp_init(void); | ||
83 | # else | ||
84 | #define mtrr_save_fixed_ranges(arg) do {} while (0) | ||
85 | #define mtrr_save_state() do {} while (0) | ||
86 | static __inline__ int mtrr_add (unsigned long base, unsigned long size, | ||
87 | unsigned int type, char increment) | ||
88 | { | ||
89 | return -ENODEV; | ||
90 | } | ||
91 | static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, | ||
92 | unsigned int type, char increment) | ||
93 | { | ||
94 | return -ENODEV; | ||
95 | } | ||
96 | static __inline__ int mtrr_del (int reg, unsigned long base, | ||
97 | unsigned long size) | ||
98 | { | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | static __inline__ int mtrr_del_page (int reg, unsigned long base, | ||
102 | unsigned long size) | ||
103 | { | ||
104 | return -ENODEV; | ||
105 | } | ||
106 | |||
107 | static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} | ||
108 | |||
109 | #define mtrr_ap_init() do {} while (0) | ||
110 | #define mtrr_bp_init() do {} while (0) | ||
111 | # endif | ||
112 | |||
113 | #endif | ||
114 | |||
115 | #endif /* _LINUX_MTRR_H */ | ||
diff --git a/include/asm-x86/mtrr_64.h b/include/asm-x86/mtrr_64.h new file mode 100644 index 000000000000..b557c486bef8 --- /dev/null +++ b/include/asm-x86/mtrr_64.h | |||
@@ -0,0 +1,152 @@ | |||
1 | /* Generic MTRR (Memory Type Range Register) ioctls. | ||
2 | |||
3 | Copyright (C) 1997-1999 Richard Gooch | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public | ||
16 | License along with this library; if not, write to the Free | ||
17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | |||
19 | Richard Gooch may be reached by email at rgooch@atnf.csiro.au | ||
20 | The postal address is: | ||
21 | Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. | ||
22 | */ | ||
23 | #ifndef _LINUX_MTRR_H | ||
24 | #define _LINUX_MTRR_H | ||
25 | |||
26 | #include <linux/ioctl.h> | ||
27 | |||
28 | #define MTRR_IOCTL_BASE 'M' | ||
29 | |||
30 | struct mtrr_sentry | ||
31 | { | ||
32 | unsigned long base; /* Base address */ | ||
33 | unsigned int size; /* Size of region */ | ||
34 | unsigned int type; /* Type of region */ | ||
35 | }; | ||
36 | |||
37 | /* Warning: this structure has a different order from i386 | ||
38 | on x86-64. The 32bit emulation code takes care of that. | ||
39 | But you need to use this for 64bit, otherwise your X server | ||
40 | will break. */ | ||
41 | struct mtrr_gentry | ||
42 | { | ||
43 | unsigned long base; /* Base address */ | ||
44 | unsigned int size; /* Size of region */ | ||
45 | unsigned int regnum; /* Register number */ | ||
46 | unsigned int type; /* Type of region */ | ||
47 | }; | ||
48 | |||
49 | /* These are the various ioctls */ | ||
50 | #define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) | ||
51 | #define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) | ||
52 | #define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) | ||
53 | #define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) | ||
54 | #define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) | ||
55 | #define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) | ||
56 | #define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) | ||
57 | #define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) | ||
58 | #define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) | ||
59 | #define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) | ||
60 | |||
61 | /* These are the region types */ | ||
62 | #define MTRR_TYPE_UNCACHABLE 0 | ||
63 | #define MTRR_TYPE_WRCOMB 1 | ||
64 | /*#define MTRR_TYPE_ 2*/ | ||
65 | /*#define MTRR_TYPE_ 3*/ | ||
66 | #define MTRR_TYPE_WRTHROUGH 4 | ||
67 | #define MTRR_TYPE_WRPROT 5 | ||
68 | #define MTRR_TYPE_WRBACK 6 | ||
69 | #define MTRR_NUM_TYPES 7 | ||
70 | |||
71 | #ifdef __KERNEL__ | ||
72 | |||
73 | /* The following functions are for use by other drivers */ | ||
74 | # ifdef CONFIG_MTRR | ||
75 | extern int mtrr_add (unsigned long base, unsigned long size, | ||
76 | unsigned int type, char increment); | ||
77 | extern int mtrr_add_page (unsigned long base, unsigned long size, | ||
78 | unsigned int type, char increment); | ||
79 | extern int mtrr_del (int reg, unsigned long base, unsigned long size); | ||
80 | extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); | ||
81 | # else | ||
82 | static __inline__ int mtrr_add (unsigned long base, unsigned long size, | ||
83 | unsigned int type, char increment) | ||
84 | { | ||
85 | return -ENODEV; | ||
86 | } | ||
87 | static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, | ||
88 | unsigned int type, char increment) | ||
89 | { | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | static __inline__ int mtrr_del (int reg, unsigned long base, | ||
93 | unsigned long size) | ||
94 | { | ||
95 | return -ENODEV; | ||
96 | } | ||
97 | static __inline__ int mtrr_del_page (int reg, unsigned long base, | ||
98 | unsigned long size) | ||
99 | { | ||
100 | return -ENODEV; | ||
101 | } | ||
102 | |||
103 | #endif /* CONFIG_MTRR */ | ||
104 | |||
105 | #ifdef CONFIG_COMPAT | ||
106 | #include <linux/compat.h> | ||
107 | |||
108 | struct mtrr_sentry32 | ||
109 | { | ||
110 | compat_ulong_t base; /* Base address */ | ||
111 | compat_uint_t size; /* Size of region */ | ||
112 | compat_uint_t type; /* Type of region */ | ||
113 | }; | ||
114 | |||
115 | struct mtrr_gentry32 | ||
116 | { | ||
117 | compat_ulong_t regnum; /* Register number */ | ||
118 | compat_uint_t base; /* Base address */ | ||
119 | compat_uint_t size; /* Size of region */ | ||
120 | compat_uint_t type; /* Type of region */ | ||
121 | }; | ||
122 | |||
123 | #define MTRR_IOCTL_BASE 'M' | ||
124 | |||
125 | #define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32) | ||
126 | #define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32) | ||
127 | #define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32) | ||
128 | #define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32) | ||
129 | #define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32) | ||
130 | #define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32) | ||
131 | #define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32) | ||
132 | #define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32) | ||
133 | #define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32) | ||
134 | #define MTRRIOC32_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32) | ||
135 | |||
136 | #endif /* CONFIG_COMPAT */ | ||
137 | |||
138 | #ifdef CONFIG_MTRR | ||
139 | extern void mtrr_ap_init(void); | ||
140 | extern void mtrr_bp_init(void); | ||
141 | extern void mtrr_save_fixed_ranges(void *); | ||
142 | extern void mtrr_save_state(void); | ||
143 | #else | ||
144 | #define mtrr_ap_init() do {} while (0) | ||
145 | #define mtrr_bp_init() do {} while (0) | ||
146 | #define mtrr_save_fixed_ranges(arg) do {} while (0) | ||
147 | #define mtrr_save_state() do {} while (0) | ||
148 | #endif | ||
149 | |||
150 | #endif /* __KERNEL__ */ | ||
151 | |||
152 | #endif /* _LINUX_MTRR_H */ | ||
diff --git a/include/asm-x86/mutex.h b/include/asm-x86/mutex.h new file mode 100644 index 000000000000..a731b9c573a6 --- /dev/null +++ b/include/asm-x86/mutex.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "mutex_32.h" | ||
3 | #else | ||
4 | # include "mutex_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/mutex_32.h b/include/asm-x86/mutex_32.h new file mode 100644 index 000000000000..7a17d9e58ad6 --- /dev/null +++ b/include/asm-x86/mutex_32.h | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * Assembly implementation of the mutex fastpath, based on atomic | ||
3 | * decrement/increment. | ||
4 | * | ||
5 | * started by Ingo Molnar: | ||
6 | * | ||
7 | * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> | ||
8 | */ | ||
9 | #ifndef _ASM_MUTEX_H | ||
10 | #define _ASM_MUTEX_H | ||
11 | |||
12 | #include "asm/alternative.h" | ||
13 | |||
14 | /** | ||
15 | * __mutex_fastpath_lock - try to take the lock by moving the count | ||
16 | * from 1 to a 0 value | ||
17 | * @count: pointer of type atomic_t | ||
18 | * @fn: function to call if the original value was not 1 | ||
19 | * | ||
20 | * Change the count from 1 to a value lower than 1, and call <fn> if it | ||
21 | * wasn't 1 originally. This function MUST leave the value lower than 1 | ||
22 | * even when the "1" assertion wasn't true. | ||
23 | */ | ||
24 | #define __mutex_fastpath_lock(count, fail_fn) \ | ||
25 | do { \ | ||
26 | unsigned int dummy; \ | ||
27 | \ | ||
28 | typecheck(atomic_t *, count); \ | ||
29 | typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ | ||
30 | \ | ||
31 | __asm__ __volatile__( \ | ||
32 | LOCK_PREFIX " decl (%%eax) \n" \ | ||
33 | " jns 1f \n" \ | ||
34 | " call "#fail_fn" \n" \ | ||
35 | "1: \n" \ | ||
36 | \ | ||
37 | :"=a" (dummy) \ | ||
38 | : "a" (count) \ | ||
39 | : "memory", "ecx", "edx"); \ | ||
40 | } while (0) | ||
41 | |||
42 | |||
43 | /** | ||
44 | * __mutex_fastpath_lock_retval - try to take the lock by moving the count | ||
45 | * from 1 to a 0 value | ||
46 | * @count: pointer of type atomic_t | ||
47 | * @fail_fn: function to call if the original value was not 1 | ||
48 | * | ||
49 | * Change the count from 1 to a value lower than 1, and call <fail_fn> if it | ||
50 | * wasn't 1 originally. This function returns 0 if the fastpath succeeds, | ||
51 | * or anything the slow path function returns | ||
52 | */ | ||
53 | static inline int | ||
54 | __mutex_fastpath_lock_retval(atomic_t *count, | ||
55 | int fastcall (*fail_fn)(atomic_t *)) | ||
56 | { | ||
57 | if (unlikely(atomic_dec_return(count) < 0)) | ||
58 | return fail_fn(count); | ||
59 | else | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * __mutex_fastpath_unlock - try to promote the mutex from 0 to 1 | ||
65 | * @count: pointer of type atomic_t | ||
66 | * @fail_fn: function to call if the original value was not 0 | ||
67 | * | ||
68 | * try to promote the mutex from 0 to 1. if it wasn't 0, call <fail_fn>. | ||
69 | * In the failure case, this function is allowed to either set the value | ||
70 | * to 1, or to set it to a value lower than 1. | ||
71 | * | ||
72 | * If the implementation sets it to a value of lower than 1, the | ||
73 | * __mutex_slowpath_needs_to_unlock() macro needs to return 1, it needs | ||
74 | * to return 0 otherwise. | ||
75 | */ | ||
76 | #define __mutex_fastpath_unlock(count, fail_fn) \ | ||
77 | do { \ | ||
78 | unsigned int dummy; \ | ||
79 | \ | ||
80 | typecheck(atomic_t *, count); \ | ||
81 | typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ | ||
82 | \ | ||
83 | __asm__ __volatile__( \ | ||
84 | LOCK_PREFIX " incl (%%eax) \n" \ | ||
85 | " jg 1f \n" \ | ||
86 | " call "#fail_fn" \n" \ | ||
87 | "1: \n" \ | ||
88 | \ | ||
89 | :"=a" (dummy) \ | ||
90 | : "a" (count) \ | ||
91 | : "memory", "ecx", "edx"); \ | ||
92 | } while (0) | ||
93 | |||
94 | #define __mutex_slowpath_needs_to_unlock() 1 | ||
95 | |||
96 | /** | ||
97 | * __mutex_fastpath_trylock - try to acquire the mutex, without waiting | ||
98 | * | ||
99 | * @count: pointer of type atomic_t | ||
100 | * @fail_fn: fallback function | ||
101 | * | ||
102 | * Change the count from 1 to a value lower than 1, and return 0 (failure) | ||
103 | * if it wasn't 1 originally, or return 1 (success) otherwise. This function | ||
104 | * MUST leave the value lower than 1 even when the "1" assertion wasn't true. | ||
105 | * Additionally, if the value was < 0 originally, this function must not leave | ||
106 | * it to 0 on failure. | ||
107 | */ | ||
108 | static inline int | ||
109 | __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) | ||
110 | { | ||
111 | /* | ||
112 | * We have two variants here. The cmpxchg based one is the best one | ||
113 | * because it never induce a false contention state. It is included | ||
114 | * here because architectures using the inc/dec algorithms over the | ||
115 | * xchg ones are much more likely to support cmpxchg natively. | ||
116 | * | ||
117 | * If not we fall back to the spinlock based variant - that is | ||
118 | * just as efficient (and simpler) as a 'destructive' probing of | ||
119 | * the mutex state would be. | ||
120 | */ | ||
121 | #ifdef __HAVE_ARCH_CMPXCHG | ||
122 | if (likely(atomic_cmpxchg(count, 1, 0) == 1)) | ||
123 | return 1; | ||
124 | return 0; | ||
125 | #else | ||
126 | return fail_fn(count); | ||
127 | #endif | ||
128 | } | ||
129 | |||
130 | #endif | ||
diff --git a/include/asm-x86/mutex_64.h b/include/asm-x86/mutex_64.h new file mode 100644 index 000000000000..6c2949a3c677 --- /dev/null +++ b/include/asm-x86/mutex_64.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Assembly implementation of the mutex fastpath, based on atomic | ||
3 | * decrement/increment. | ||
4 | * | ||
5 | * started by Ingo Molnar: | ||
6 | * | ||
7 | * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> | ||
8 | */ | ||
9 | #ifndef _ASM_MUTEX_H | ||
10 | #define _ASM_MUTEX_H | ||
11 | |||
12 | /** | ||
13 | * __mutex_fastpath_lock - decrement and call function if negative | ||
14 | * @v: pointer of type atomic_t | ||
15 | * @fail_fn: function to call if the result is negative | ||
16 | * | ||
17 | * Atomically decrements @v and calls <fail_fn> if the result is negative. | ||
18 | */ | ||
19 | #define __mutex_fastpath_lock(v, fail_fn) \ | ||
20 | do { \ | ||
21 | unsigned long dummy; \ | ||
22 | \ | ||
23 | typecheck(atomic_t *, v); \ | ||
24 | typecheck_fn(void (*)(atomic_t *), fail_fn); \ | ||
25 | \ | ||
26 | __asm__ __volatile__( \ | ||
27 | LOCK_PREFIX " decl (%%rdi) \n" \ | ||
28 | " jns 1f \n" \ | ||
29 | " call "#fail_fn" \n" \ | ||
30 | "1:" \ | ||
31 | \ | ||
32 | :"=D" (dummy) \ | ||
33 | : "D" (v) \ | ||
34 | : "rax", "rsi", "rdx", "rcx", \ | ||
35 | "r8", "r9", "r10", "r11", "memory"); \ | ||
36 | } while (0) | ||
37 | |||
38 | /** | ||
39 | * __mutex_fastpath_lock_retval - try to take the lock by moving the count | ||
40 | * from 1 to a 0 value | ||
41 | * @count: pointer of type atomic_t | ||
42 | * @fail_fn: function to call if the original value was not 1 | ||
43 | * | ||
44 | * Change the count from 1 to a value lower than 1, and call <fail_fn> if | ||
45 | * it wasn't 1 originally. This function returns 0 if the fastpath succeeds, | ||
46 | * or anything the slow path function returns | ||
47 | */ | ||
48 | static inline int | ||
49 | __mutex_fastpath_lock_retval(atomic_t *count, | ||
50 | int (*fail_fn)(atomic_t *)) | ||
51 | { | ||
52 | if (unlikely(atomic_dec_return(count) < 0)) | ||
53 | return fail_fn(count); | ||
54 | else | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * __mutex_fastpath_unlock - increment and call function if nonpositive | ||
60 | * @v: pointer of type atomic_t | ||
61 | * @fail_fn: function to call if the result is nonpositive | ||
62 | * | ||
63 | * Atomically increments @v and calls <fail_fn> if the result is nonpositive. | ||
64 | */ | ||
65 | #define __mutex_fastpath_unlock(v, fail_fn) \ | ||
66 | do { \ | ||
67 | unsigned long dummy; \ | ||
68 | \ | ||
69 | typecheck(atomic_t *, v); \ | ||
70 | typecheck_fn(void (*)(atomic_t *), fail_fn); \ | ||
71 | \ | ||
72 | __asm__ __volatile__( \ | ||
73 | LOCK_PREFIX " incl (%%rdi) \n" \ | ||
74 | " jg 1f \n" \ | ||
75 | " call "#fail_fn" \n" \ | ||
76 | "1: " \ | ||
77 | \ | ||
78 | :"=D" (dummy) \ | ||
79 | : "D" (v) \ | ||
80 | : "rax", "rsi", "rdx", "rcx", \ | ||
81 | "r8", "r9", "r10", "r11", "memory"); \ | ||
82 | } while (0) | ||
83 | |||
84 | #define __mutex_slowpath_needs_to_unlock() 1 | ||
85 | |||
86 | /** | ||
87 | * __mutex_fastpath_trylock - try to acquire the mutex, without waiting | ||
88 | * | ||
89 | * @count: pointer of type atomic_t | ||
90 | * @fail_fn: fallback function | ||
91 | * | ||
92 | * Change the count from 1 to 0 and return 1 (success), or return 0 (failure) | ||
93 | * if it wasn't 1 originally. [the fallback function is never used on | ||
94 | * x86_64, because all x86_64 CPUs have a CMPXCHG instruction.] | ||
95 | */ | ||
96 | static inline int | ||
97 | __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) | ||
98 | { | ||
99 | if (likely(atomic_cmpxchg(count, 1, 0) == 1)) | ||
100 | return 1; | ||
101 | else | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | #endif | ||
diff --git a/include/asm-x86/namei.h b/include/asm-x86/namei.h new file mode 100644 index 000000000000..732f8f0b3dcd --- /dev/null +++ b/include/asm-x86/namei.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "namei_32.h" | ||
3 | #else | ||
4 | # include "namei_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/namei_32.h b/include/asm-x86/namei_32.h new file mode 100644 index 000000000000..814865088617 --- /dev/null +++ b/include/asm-x86/namei_32.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* $Id: namei.h,v 1.1 1996/12/13 14:48:21 jj Exp $ | ||
2 | * linux/include/asm-i386/namei.h | ||
3 | * | ||
4 | * Included from linux/fs/namei.c | ||
5 | */ | ||
6 | |||
7 | #ifndef __I386_NAMEI_H | ||
8 | #define __I386_NAMEI_H | ||
9 | |||
10 | /* This dummy routine maybe changed to something useful | ||
11 | * for /usr/gnemul/ emulation stuff. | ||
12 | * Look at asm-sparc/namei.h for details. | ||
13 | */ | ||
14 | |||
15 | #define __emul_prefix() NULL | ||
16 | |||
17 | #endif /* __I386_NAMEI_H */ | ||
diff --git a/include/asm-x86/namei_64.h b/include/asm-x86/namei_64.h new file mode 100644 index 000000000000..bef239f5318f --- /dev/null +++ b/include/asm-x86/namei_64.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __X8664_NAMEI_H | ||
2 | #define __X8664_NAMEI_H | ||
3 | |||
4 | /* This dummy routine maybe changed to something useful | ||
5 | * for /usr/gnemul/ emulation stuff. | ||
6 | * Look at asm-sparc/namei.h for details. | ||
7 | */ | ||
8 | |||
9 | #define __emul_prefix() NULL | ||
10 | |||
11 | #endif | ||
diff --git a/include/asm-x86/nmi.h b/include/asm-x86/nmi.h new file mode 100644 index 000000000000..53ccac14cead --- /dev/null +++ b/include/asm-x86/nmi.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "nmi_32.h" | ||
3 | #else | ||
4 | # include "nmi_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/nmi_32.h b/include/asm-x86/nmi_32.h new file mode 100644 index 000000000000..70a958a8e381 --- /dev/null +++ b/include/asm-x86/nmi_32.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/nmi.h | ||
3 | */ | ||
4 | #ifndef ASM_NMI_H | ||
5 | #define ASM_NMI_H | ||
6 | |||
7 | #include <linux/pm.h> | ||
8 | #include <asm/irq.h> | ||
9 | |||
10 | #ifdef ARCH_HAS_NMI_WATCHDOG | ||
11 | |||
12 | /** | ||
13 | * do_nmi_callback | ||
14 | * | ||
15 | * Check to see if a callback exists and execute it. Return 1 | ||
16 | * if the handler exists and was handled successfully. | ||
17 | */ | ||
18 | int do_nmi_callback(struct pt_regs *regs, int cpu); | ||
19 | |||
20 | extern int nmi_watchdog_enabled; | ||
21 | extern int avail_to_resrv_perfctr_nmi_bit(unsigned int); | ||
22 | extern int avail_to_resrv_perfctr_nmi(unsigned int); | ||
23 | extern int reserve_perfctr_nmi(unsigned int); | ||
24 | extern void release_perfctr_nmi(unsigned int); | ||
25 | extern int reserve_evntsel_nmi(unsigned int); | ||
26 | extern void release_evntsel_nmi(unsigned int); | ||
27 | |||
28 | extern void setup_apic_nmi_watchdog (void *); | ||
29 | extern void stop_apic_nmi_watchdog (void *); | ||
30 | extern void disable_timer_nmi_watchdog(void); | ||
31 | extern void enable_timer_nmi_watchdog(void); | ||
32 | extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason); | ||
33 | |||
34 | extern atomic_t nmi_active; | ||
35 | extern unsigned int nmi_watchdog; | ||
36 | #define NMI_DISABLED -1 | ||
37 | #define NMI_NONE 0 | ||
38 | #define NMI_IO_APIC 1 | ||
39 | #define NMI_LOCAL_APIC 2 | ||
40 | #define NMI_INVALID 3 | ||
41 | #define NMI_DEFAULT NMI_DISABLED | ||
42 | |||
43 | struct ctl_table; | ||
44 | struct file; | ||
45 | extern int proc_nmi_enabled(struct ctl_table *, int , struct file *, | ||
46 | void __user *, size_t *, loff_t *); | ||
47 | extern int unknown_nmi_panic; | ||
48 | |||
49 | void __trigger_all_cpu_backtrace(void); | ||
50 | #define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace() | ||
51 | |||
52 | #endif | ||
53 | |||
54 | void lapic_watchdog_stop(void); | ||
55 | int lapic_watchdog_init(unsigned nmi_hz); | ||
56 | int lapic_wd_event(unsigned nmi_hz); | ||
57 | unsigned lapic_adjust_nmi_hz(unsigned hz); | ||
58 | int lapic_watchdog_ok(void); | ||
59 | void disable_lapic_nmi_watchdog(void); | ||
60 | void enable_lapic_nmi_watchdog(void); | ||
61 | void stop_nmi(void); | ||
62 | void restart_nmi(void); | ||
63 | |||
64 | #endif /* ASM_NMI_H */ | ||
diff --git a/include/asm-x86/nmi_64.h b/include/asm-x86/nmi_64.h new file mode 100644 index 000000000000..65b6acf3bb59 --- /dev/null +++ b/include/asm-x86/nmi_64.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/nmi.h | ||
3 | */ | ||
4 | #ifndef ASM_NMI_H | ||
5 | #define ASM_NMI_H | ||
6 | |||
7 | #include <linux/pm.h> | ||
8 | #include <asm/io.h> | ||
9 | |||
10 | /** | ||
11 | * do_nmi_callback | ||
12 | * | ||
13 | * Check to see if a callback exists and execute it. Return 1 | ||
14 | * if the handler exists and was handled successfully. | ||
15 | */ | ||
16 | int do_nmi_callback(struct pt_regs *regs, int cpu); | ||
17 | |||
18 | #ifdef CONFIG_PM | ||
19 | |||
20 | /** Replace the PM callback routine for NMI. */ | ||
21 | struct pm_dev * set_nmi_pm_callback(pm_callback callback); | ||
22 | |||
23 | /** Unset the PM callback routine back to the default. */ | ||
24 | void unset_nmi_pm_callback(struct pm_dev * dev); | ||
25 | |||
26 | #else | ||
27 | |||
28 | static inline struct pm_dev * set_nmi_pm_callback(pm_callback callback) | ||
29 | { | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static inline void unset_nmi_pm_callback(struct pm_dev * dev) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | #endif /* CONFIG_PM */ | ||
38 | |||
39 | extern void default_do_nmi(struct pt_regs *); | ||
40 | extern void die_nmi(char *str, struct pt_regs *regs, int do_panic); | ||
41 | |||
42 | #define get_nmi_reason() inb(0x61) | ||
43 | |||
44 | extern int panic_on_timeout; | ||
45 | extern int unknown_nmi_panic; | ||
46 | extern int nmi_watchdog_enabled; | ||
47 | |||
48 | extern int check_nmi_watchdog(void); | ||
49 | extern int avail_to_resrv_perfctr_nmi_bit(unsigned int); | ||
50 | extern int avail_to_resrv_perfctr_nmi(unsigned int); | ||
51 | extern int reserve_perfctr_nmi(unsigned int); | ||
52 | extern void release_perfctr_nmi(unsigned int); | ||
53 | extern int reserve_evntsel_nmi(unsigned int); | ||
54 | extern void release_evntsel_nmi(unsigned int); | ||
55 | |||
56 | extern void setup_apic_nmi_watchdog (void *); | ||
57 | extern void stop_apic_nmi_watchdog (void *); | ||
58 | extern void disable_timer_nmi_watchdog(void); | ||
59 | extern void enable_timer_nmi_watchdog(void); | ||
60 | extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason); | ||
61 | |||
62 | extern void nmi_watchdog_default(void); | ||
63 | extern int setup_nmi_watchdog(char *); | ||
64 | |||
65 | extern atomic_t nmi_active; | ||
66 | extern unsigned int nmi_watchdog; | ||
67 | #define NMI_DISABLED -1 | ||
68 | #define NMI_NONE 0 | ||
69 | #define NMI_IO_APIC 1 | ||
70 | #define NMI_LOCAL_APIC 2 | ||
71 | #define NMI_INVALID 3 | ||
72 | #define NMI_DEFAULT NMI_DISABLED | ||
73 | |||
74 | struct ctl_table; | ||
75 | struct file; | ||
76 | extern int proc_nmi_enabled(struct ctl_table *, int , struct file *, | ||
77 | void __user *, size_t *, loff_t *); | ||
78 | |||
79 | extern int unknown_nmi_panic; | ||
80 | |||
81 | void __trigger_all_cpu_backtrace(void); | ||
82 | #define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace() | ||
83 | |||
84 | |||
85 | void lapic_watchdog_stop(void); | ||
86 | int lapic_watchdog_init(unsigned nmi_hz); | ||
87 | int lapic_wd_event(unsigned nmi_hz); | ||
88 | unsigned lapic_adjust_nmi_hz(unsigned hz); | ||
89 | int lapic_watchdog_ok(void); | ||
90 | void disable_lapic_nmi_watchdog(void); | ||
91 | void enable_lapic_nmi_watchdog(void); | ||
92 | void stop_nmi(void); | ||
93 | void restart_nmi(void); | ||
94 | |||
95 | #endif /* ASM_NMI_H */ | ||
diff --git a/include/asm-x86/numa.h b/include/asm-x86/numa.h new file mode 100644 index 000000000000..27da400d3138 --- /dev/null +++ b/include/asm-x86/numa.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "numa_32.h" | ||
3 | #else | ||
4 | # include "numa_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/numa_32.h b/include/asm-x86/numa_32.h new file mode 100644 index 000000000000..96fcb157db1d --- /dev/null +++ b/include/asm-x86/numa_32.h | |||
@@ -0,0 +1,3 @@ | |||
1 | |||
2 | int pxm_to_nid(int pxm); | ||
3 | |||
diff --git a/include/asm-x86/numa_64.h b/include/asm-x86/numa_64.h new file mode 100644 index 000000000000..933ff11ece15 --- /dev/null +++ b/include/asm-x86/numa_64.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _ASM_X8664_NUMA_H | ||
2 | #define _ASM_X8664_NUMA_H 1 | ||
3 | |||
4 | #include <linux/nodemask.h> | ||
5 | |||
6 | struct bootnode { | ||
7 | u64 start,end; | ||
8 | }; | ||
9 | |||
10 | extern int compute_hash_shift(struct bootnode *nodes, int numnodes); | ||
11 | |||
12 | #define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT)) | ||
13 | |||
14 | extern void numa_add_cpu(int cpu); | ||
15 | extern void numa_init_array(void); | ||
16 | extern int numa_off; | ||
17 | |||
18 | extern void numa_set_node(int cpu, int node); | ||
19 | extern void srat_reserve_add_area(int nodeid); | ||
20 | extern int hotadd_percent; | ||
21 | |||
22 | extern unsigned char apicid_to_node[256]; | ||
23 | #ifdef CONFIG_NUMA | ||
24 | extern void __init init_cpu_to_node(void); | ||
25 | |||
26 | static inline void clear_node_cpumask(int cpu) | ||
27 | { | ||
28 | clear_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]); | ||
29 | } | ||
30 | |||
31 | #else | ||
32 | #define init_cpu_to_node() do {} while (0) | ||
33 | #define clear_node_cpumask(cpu) do {} while (0) | ||
34 | #endif | ||
35 | |||
36 | #define NUMA_NO_NODE 0xff | ||
37 | |||
38 | #endif | ||
diff --git a/include/asm-x86/numaq.h b/include/asm-x86/numaq.h new file mode 100644 index 000000000000..38f710dc37f2 --- /dev/null +++ b/include/asm-x86/numaq.h | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * Written by: Patricia Gaughen, IBM Corporation | ||
3 | * | ||
4 | * Copyright (C) 2002, IBM Corp. | ||
5 | * | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <gone@us.ibm.com> | ||
24 | */ | ||
25 | |||
26 | #ifndef NUMAQ_H | ||
27 | #define NUMAQ_H | ||
28 | |||
29 | #ifdef CONFIG_X86_NUMAQ | ||
30 | |||
31 | extern int get_memcfg_numaq(void); | ||
32 | |||
33 | /* | ||
34 | * SYS_CFG_DATA_PRIV_ADDR, struct eachquadmem, and struct sys_cfg_data are the | ||
35 | */ | ||
36 | #define SYS_CFG_DATA_PRIV_ADDR 0x0009d000 /* place for scd in private quad space */ | ||
37 | |||
38 | /* | ||
39 | * Communication area for each processor on lynxer-processor tests. | ||
40 | * | ||
41 | * NOTE: If you change the size of this eachproc structure you need | ||
42 | * to change the definition for EACH_QUAD_SIZE. | ||
43 | */ | ||
44 | struct eachquadmem { | ||
45 | unsigned int priv_mem_start; /* Starting address of this */ | ||
46 | /* quad's private memory. */ | ||
47 | /* This is always 0. */ | ||
48 | /* In MB. */ | ||
49 | unsigned int priv_mem_size; /* Size of this quad's */ | ||
50 | /* private memory. */ | ||
51 | /* In MB. */ | ||
52 | unsigned int low_shrd_mem_strp_start;/* Starting address of this */ | ||
53 | /* quad's low shared block */ | ||
54 | /* (untranslated). */ | ||
55 | /* In MB. */ | ||
56 | unsigned int low_shrd_mem_start; /* Starting address of this */ | ||
57 | /* quad's low shared memory */ | ||
58 | /* (untranslated). */ | ||
59 | /* In MB. */ | ||
60 | unsigned int low_shrd_mem_size; /* Size of this quad's low */ | ||
61 | /* shared memory. */ | ||
62 | /* In MB. */ | ||
63 | unsigned int lmmio_copb_start; /* Starting address of this */ | ||
64 | /* quad's local memory */ | ||
65 | /* mapped I/O in the */ | ||
66 | /* compatibility OPB. */ | ||
67 | /* In MB. */ | ||
68 | unsigned int lmmio_copb_size; /* Size of this quad's local */ | ||
69 | /* memory mapped I/O in the */ | ||
70 | /* compatibility OPB. */ | ||
71 | /* In MB. */ | ||
72 | unsigned int lmmio_nopb_start; /* Starting address of this */ | ||
73 | /* quad's local memory */ | ||
74 | /* mapped I/O in the */ | ||
75 | /* non-compatibility OPB. */ | ||
76 | /* In MB. */ | ||
77 | unsigned int lmmio_nopb_size; /* Size of this quad's local */ | ||
78 | /* memory mapped I/O in the */ | ||
79 | /* non-compatibility OPB. */ | ||
80 | /* In MB. */ | ||
81 | unsigned int io_apic_0_start; /* Starting address of I/O */ | ||
82 | /* APIC 0. */ | ||
83 | unsigned int io_apic_0_sz; /* Size I/O APIC 0. */ | ||
84 | unsigned int io_apic_1_start; /* Starting address of I/O */ | ||
85 | /* APIC 1. */ | ||
86 | unsigned int io_apic_1_sz; /* Size I/O APIC 1. */ | ||
87 | unsigned int hi_shrd_mem_start; /* Starting address of this */ | ||
88 | /* quad's high shared memory.*/ | ||
89 | /* In MB. */ | ||
90 | unsigned int hi_shrd_mem_size; /* Size of this quad's high */ | ||
91 | /* shared memory. */ | ||
92 | /* In MB. */ | ||
93 | unsigned int mps_table_addr; /* Address of this quad's */ | ||
94 | /* MPS tables from BIOS, */ | ||
95 | /* in system space.*/ | ||
96 | unsigned int lcl_MDC_pio_addr; /* Port-I/O address for */ | ||
97 | /* local access of MDC. */ | ||
98 | unsigned int rmt_MDC_mmpio_addr; /* MM-Port-I/O address for */ | ||
99 | /* remote access of MDC. */ | ||
100 | unsigned int mm_port_io_start; /* Starting address of this */ | ||
101 | /* quad's memory mapped Port */ | ||
102 | /* I/O space. */ | ||
103 | unsigned int mm_port_io_size; /* Size of this quad's memory*/ | ||
104 | /* mapped Port I/O space. */ | ||
105 | unsigned int mm_rmt_io_apic_start; /* Starting address of this */ | ||
106 | /* quad's memory mapped */ | ||
107 | /* remote I/O APIC space. */ | ||
108 | unsigned int mm_rmt_io_apic_size; /* Size of this quad's memory*/ | ||
109 | /* mapped remote I/O APIC */ | ||
110 | /* space. */ | ||
111 | unsigned int mm_isa_start; /* Starting address of this */ | ||
112 | /* quad's memory mapped ISA */ | ||
113 | /* space (contains MDC */ | ||
114 | /* memory space). */ | ||
115 | unsigned int mm_isa_size; /* Size of this quad's memory*/ | ||
116 | /* mapped ISA space (contains*/ | ||
117 | /* MDC memory space). */ | ||
118 | unsigned int rmt_qmi_addr; /* Remote addr to access QMI.*/ | ||
119 | unsigned int lcl_qmi_addr; /* Local addr to access QMI. */ | ||
120 | }; | ||
121 | |||
122 | /* | ||
123 | * Note: This structure must be NOT be changed unless the multiproc and | ||
124 | * OS are changed to reflect the new structure. | ||
125 | */ | ||
126 | struct sys_cfg_data { | ||
127 | unsigned int quad_id; | ||
128 | unsigned int bsp_proc_id; /* Boot Strap Processor in this quad. */ | ||
129 | unsigned int scd_version; /* Version number of this table. */ | ||
130 | unsigned int first_quad_id; | ||
131 | unsigned int quads_present31_0; /* 1 bit for each quad */ | ||
132 | unsigned int quads_present63_32; /* 1 bit for each quad */ | ||
133 | unsigned int config_flags; | ||
134 | unsigned int boot_flags; | ||
135 | unsigned int csr_start_addr; /* Absolute value (not in MB) */ | ||
136 | unsigned int csr_size; /* Absolute value (not in MB) */ | ||
137 | unsigned int lcl_apic_start_addr; /* Absolute value (not in MB) */ | ||
138 | unsigned int lcl_apic_size; /* Absolute value (not in MB) */ | ||
139 | unsigned int low_shrd_mem_base; /* 0 or 512MB or 1GB */ | ||
140 | unsigned int low_shrd_mem_quad_offset; /* 0,128M,256M,512M,1G */ | ||
141 | /* may not be totally populated */ | ||
142 | unsigned int split_mem_enbl; /* 0 for no low shared memory */ | ||
143 | unsigned int mmio_sz; /* Size of total system memory mapped I/O */ | ||
144 | /* (in MB). */ | ||
145 | unsigned int quad_spin_lock; /* Spare location used for quad */ | ||
146 | /* bringup. */ | ||
147 | unsigned int nonzero55; /* For checksumming. */ | ||
148 | unsigned int nonzeroaa; /* For checksumming. */ | ||
149 | unsigned int scd_magic_number; | ||
150 | unsigned int system_type; | ||
151 | unsigned int checksum; | ||
152 | /* | ||
153 | * memory configuration area for each quad | ||
154 | */ | ||
155 | struct eachquadmem eq[MAX_NUMNODES]; /* indexed by quad id */ | ||
156 | }; | ||
157 | |||
158 | static inline unsigned long *get_zholes_size(int nid) | ||
159 | { | ||
160 | return NULL; | ||
161 | } | ||
162 | #endif /* CONFIG_X86_NUMAQ */ | ||
163 | #endif /* NUMAQ_H */ | ||
164 | |||
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h new file mode 100644 index 000000000000..a757eb26141d --- /dev/null +++ b/include/asm-x86/page.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "page_32.h" | ||
4 | # else | ||
5 | # include "page_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "page_32.h" | ||
10 | # else | ||
11 | # include "page_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h new file mode 100644 index 000000000000..80ecc66b6d86 --- /dev/null +++ b/include/asm-x86/page_32.h | |||
@@ -0,0 +1,206 @@ | |||
1 | #ifndef _I386_PAGE_H | ||
2 | #define _I386_PAGE_H | ||
3 | |||
4 | /* PAGE_SHIFT determines the page size */ | ||
5 | #define PAGE_SHIFT 12 | ||
6 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | ||
7 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
8 | |||
9 | #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) | ||
10 | #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT) | ||
11 | |||
12 | #ifdef __KERNEL__ | ||
13 | #ifndef __ASSEMBLY__ | ||
14 | |||
15 | #ifdef CONFIG_X86_USE_3DNOW | ||
16 | |||
17 | #include <asm/mmx.h> | ||
18 | |||
19 | #define clear_page(page) mmx_clear_page((void *)(page)) | ||
20 | #define copy_page(to,from) mmx_copy_page(to,from) | ||
21 | |||
22 | #else | ||
23 | |||
24 | /* | ||
25 | * On older X86 processors it's not a win to use MMX here it seems. | ||
26 | * Maybe the K6-III ? | ||
27 | */ | ||
28 | |||
29 | #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) | ||
30 | #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) | ||
31 | |||
32 | #endif | ||
33 | |||
34 | #define clear_user_page(page, vaddr, pg) clear_page(page) | ||
35 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | ||
36 | |||
37 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ | ||
38 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) | ||
39 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE | ||
40 | |||
41 | /* | ||
42 | * These are used to make use of C type-checking.. | ||
43 | */ | ||
44 | extern int nx_enabled; | ||
45 | |||
46 | #ifdef CONFIG_X86_PAE | ||
47 | typedef struct { unsigned long pte_low, pte_high; } pte_t; | ||
48 | typedef struct { unsigned long long pmd; } pmd_t; | ||
49 | typedef struct { unsigned long long pgd; } pgd_t; | ||
50 | typedef struct { unsigned long long pgprot; } pgprot_t; | ||
51 | |||
52 | static inline unsigned long long native_pgd_val(pgd_t pgd) | ||
53 | { | ||
54 | return pgd.pgd; | ||
55 | } | ||
56 | |||
57 | static inline unsigned long long native_pmd_val(pmd_t pmd) | ||
58 | { | ||
59 | return pmd.pmd; | ||
60 | } | ||
61 | |||
62 | static inline unsigned long long native_pte_val(pte_t pte) | ||
63 | { | ||
64 | return pte.pte_low | ((unsigned long long)pte.pte_high << 32); | ||
65 | } | ||
66 | |||
67 | static inline pgd_t native_make_pgd(unsigned long long val) | ||
68 | { | ||
69 | return (pgd_t) { val }; | ||
70 | } | ||
71 | |||
72 | static inline pmd_t native_make_pmd(unsigned long long val) | ||
73 | { | ||
74 | return (pmd_t) { val }; | ||
75 | } | ||
76 | |||
77 | static inline pte_t native_make_pte(unsigned long long val) | ||
78 | { | ||
79 | return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ; | ||
80 | } | ||
81 | |||
82 | #ifndef CONFIG_PARAVIRT | ||
83 | #define pmd_val(x) native_pmd_val(x) | ||
84 | #define __pmd(x) native_make_pmd(x) | ||
85 | #endif | ||
86 | |||
87 | #define HPAGE_SHIFT 21 | ||
88 | #include <asm-generic/pgtable-nopud.h> | ||
89 | #else /* !CONFIG_X86_PAE */ | ||
90 | typedef struct { unsigned long pte_low; } pte_t; | ||
91 | typedef struct { unsigned long pgd; } pgd_t; | ||
92 | typedef struct { unsigned long pgprot; } pgprot_t; | ||
93 | #define boot_pte_t pte_t /* or would you rather have a typedef */ | ||
94 | |||
95 | static inline unsigned long native_pgd_val(pgd_t pgd) | ||
96 | { | ||
97 | return pgd.pgd; | ||
98 | } | ||
99 | |||
100 | static inline unsigned long native_pte_val(pte_t pte) | ||
101 | { | ||
102 | return pte.pte_low; | ||
103 | } | ||
104 | |||
105 | static inline pgd_t native_make_pgd(unsigned long val) | ||
106 | { | ||
107 | return (pgd_t) { val }; | ||
108 | } | ||
109 | |||
110 | static inline pte_t native_make_pte(unsigned long val) | ||
111 | { | ||
112 | return (pte_t) { .pte_low = val }; | ||
113 | } | ||
114 | |||
115 | #define HPAGE_SHIFT 22 | ||
116 | #include <asm-generic/pgtable-nopmd.h> | ||
117 | #endif /* CONFIG_X86_PAE */ | ||
118 | |||
119 | #define PTE_MASK PAGE_MASK | ||
120 | |||
121 | #ifdef CONFIG_HUGETLB_PAGE | ||
122 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) | ||
123 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) | ||
124 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | ||
125 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA | ||
126 | #endif | ||
127 | |||
128 | #define pgprot_val(x) ((x).pgprot) | ||
129 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
130 | |||
131 | #ifndef CONFIG_PARAVIRT | ||
132 | #define pgd_val(x) native_pgd_val(x) | ||
133 | #define __pgd(x) native_make_pgd(x) | ||
134 | #define pte_val(x) native_pte_val(x) | ||
135 | #define __pte(x) native_make_pte(x) | ||
136 | #endif | ||
137 | |||
138 | #endif /* !__ASSEMBLY__ */ | ||
139 | |||
140 | /* to align the pointer to the (next) page boundary */ | ||
141 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | ||
142 | |||
143 | /* | ||
144 | * This handles the memory map.. We could make this a config | ||
145 | * option, but too many people screw it up, and too few need | ||
146 | * it. | ||
147 | * | ||
148 | * A __PAGE_OFFSET of 0xC0000000 means that the kernel has | ||
149 | * a virtual address space of one gigabyte, which limits the | ||
150 | * amount of physical memory you can use to about 950MB. | ||
151 | * | ||
152 | * If you want more physical memory than this then see the CONFIG_HIGHMEM4G | ||
153 | * and CONFIG_HIGHMEM64G options in the kernel configuration. | ||
154 | */ | ||
155 | |||
156 | #ifndef __ASSEMBLY__ | ||
157 | |||
158 | struct vm_area_struct; | ||
159 | |||
160 | /* | ||
161 | * This much address space is reserved for vmalloc() and iomap() | ||
162 | * as well as fixmap mappings. | ||
163 | */ | ||
164 | extern unsigned int __VMALLOC_RESERVE; | ||
165 | |||
166 | extern int sysctl_legacy_va_layout; | ||
167 | |||
168 | extern int page_is_ram(unsigned long pagenr); | ||
169 | |||
170 | #endif /* __ASSEMBLY__ */ | ||
171 | |||
172 | #ifdef __ASSEMBLY__ | ||
173 | #define __PAGE_OFFSET CONFIG_PAGE_OFFSET | ||
174 | #else | ||
175 | #define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) | ||
176 | #endif | ||
177 | |||
178 | |||
179 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) | ||
180 | #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) | ||
181 | #define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) | ||
182 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) | ||
183 | /* __pa_symbol should be used for C visible symbols. | ||
184 | This seems to be the official gcc blessed way to do such arithmetic. */ | ||
185 | #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0)) | ||
186 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
187 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
188 | #ifdef CONFIG_FLATMEM | ||
189 | #define pfn_valid(pfn) ((pfn) < max_mapnr) | ||
190 | #endif /* CONFIG_FLATMEM */ | ||
191 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | ||
192 | |||
193 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | ||
194 | |||
195 | #define VM_DATA_DEFAULT_FLAGS \ | ||
196 | (VM_READ | VM_WRITE | \ | ||
197 | ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ | ||
198 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
199 | |||
200 | #include <asm-generic/memory_model.h> | ||
201 | #include <asm-generic/page.h> | ||
202 | |||
203 | #define __HAVE_ARCH_GATE_AREA 1 | ||
204 | #endif /* __KERNEL__ */ | ||
205 | |||
206 | #endif /* _I386_PAGE_H */ | ||
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h new file mode 100644 index 000000000000..88adf1afb0a2 --- /dev/null +++ b/include/asm-x86/page_64.h | |||
@@ -0,0 +1,143 @@ | |||
1 | #ifndef _X86_64_PAGE_H | ||
2 | #define _X86_64_PAGE_H | ||
3 | |||
4 | #include <linux/const.h> | ||
5 | |||
6 | /* PAGE_SHIFT determines the page size */ | ||
7 | #define PAGE_SHIFT 12 | ||
8 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) | ||
9 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
10 | #define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK) | ||
11 | |||
12 | #define THREAD_ORDER 1 | ||
13 | #define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) | ||
14 | #define CURRENT_MASK (~(THREAD_SIZE-1)) | ||
15 | |||
16 | #define EXCEPTION_STACK_ORDER 0 | ||
17 | #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) | ||
18 | |||
19 | #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1) | ||
20 | #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER) | ||
21 | |||
22 | #define IRQSTACK_ORDER 2 | ||
23 | #define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER) | ||
24 | |||
25 | #define STACKFAULT_STACK 1 | ||
26 | #define DOUBLEFAULT_STACK 2 | ||
27 | #define NMI_STACK 3 | ||
28 | #define DEBUG_STACK 4 | ||
29 | #define MCE_STACK 5 | ||
30 | #define N_EXCEPTION_STACKS 5 /* hw limit: 7 */ | ||
31 | |||
32 | #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) | ||
33 | #define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT) | ||
34 | |||
35 | #define HPAGE_SHIFT PMD_SHIFT | ||
36 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) | ||
37 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) | ||
38 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | #ifndef __ASSEMBLY__ | ||
42 | |||
43 | extern unsigned long end_pfn; | ||
44 | |||
45 | void clear_page(void *); | ||
46 | void copy_page(void *, void *); | ||
47 | |||
48 | #define clear_user_page(page, vaddr, pg) clear_page(page) | ||
49 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | ||
50 | |||
51 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ | ||
52 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) | ||
53 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE | ||
54 | /* | ||
55 | * These are used to make use of C type-checking.. | ||
56 | */ | ||
57 | typedef struct { unsigned long pte; } pte_t; | ||
58 | typedef struct { unsigned long pmd; } pmd_t; | ||
59 | typedef struct { unsigned long pud; } pud_t; | ||
60 | typedef struct { unsigned long pgd; } pgd_t; | ||
61 | #define PTE_MASK PHYSICAL_PAGE_MASK | ||
62 | |||
63 | typedef struct { unsigned long pgprot; } pgprot_t; | ||
64 | |||
65 | extern unsigned long phys_base; | ||
66 | |||
67 | #define pte_val(x) ((x).pte) | ||
68 | #define pmd_val(x) ((x).pmd) | ||
69 | #define pud_val(x) ((x).pud) | ||
70 | #define pgd_val(x) ((x).pgd) | ||
71 | #define pgprot_val(x) ((x).pgprot) | ||
72 | |||
73 | #define __pte(x) ((pte_t) { (x) } ) | ||
74 | #define __pmd(x) ((pmd_t) { (x) } ) | ||
75 | #define __pud(x) ((pud_t) { (x) } ) | ||
76 | #define __pgd(x) ((pgd_t) { (x) } ) | ||
77 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
78 | |||
79 | #endif /* !__ASSEMBLY__ */ | ||
80 | |||
81 | #define __PHYSICAL_START CONFIG_PHYSICAL_START | ||
82 | #define __KERNEL_ALIGN 0x200000 | ||
83 | |||
84 | /* | ||
85 | * Make sure kernel is aligned to 2MB address. Catching it at compile | ||
86 | * time is better. Change your config file and compile the kernel | ||
87 | * for a 2MB aligned address (CONFIG_PHYSICAL_START) | ||
88 | */ | ||
89 | #if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0 | ||
90 | #error "CONFIG_PHYSICAL_START must be a multiple of 2MB" | ||
91 | #endif | ||
92 | |||
93 | #define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) | ||
94 | #define __START_KERNEL_map _AC(0xffffffff80000000, UL) | ||
95 | #define __PAGE_OFFSET _AC(0xffff810000000000, UL) | ||
96 | |||
97 | /* to align the pointer to the (next) page boundary */ | ||
98 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | ||
99 | |||
100 | /* See Documentation/x86_64/mm.txt for a description of the memory map. */ | ||
101 | #define __PHYSICAL_MASK_SHIFT 46 | ||
102 | #define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1) | ||
103 | #define __VIRTUAL_MASK_SHIFT 48 | ||
104 | #define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1) | ||
105 | |||
106 | #define KERNEL_TEXT_SIZE (40*1024*1024) | ||
107 | #define KERNEL_TEXT_START _AC(0xffffffff80000000, UL) | ||
108 | #define PAGE_OFFSET __PAGE_OFFSET | ||
109 | |||
110 | #ifndef __ASSEMBLY__ | ||
111 | |||
112 | #include <asm/bug.h> | ||
113 | |||
114 | extern unsigned long __phys_addr(unsigned long); | ||
115 | |||
116 | #endif /* __ASSEMBLY__ */ | ||
117 | |||
118 | #define __pa(x) __phys_addr((unsigned long)(x)) | ||
119 | #define __pa_symbol(x) __phys_addr((unsigned long)(x)) | ||
120 | |||
121 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
122 | #define __boot_va(x) __va(x) | ||
123 | #define __boot_pa(x) __pa(x) | ||
124 | #ifdef CONFIG_FLATMEM | ||
125 | #define pfn_valid(pfn) ((pfn) < end_pfn) | ||
126 | #endif | ||
127 | |||
128 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | ||
129 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | ||
130 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
131 | |||
132 | #define VM_DATA_DEFAULT_FLAGS \ | ||
133 | (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ | ||
134 | VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
135 | |||
136 | #define __HAVE_ARCH_GATE_AREA 1 | ||
137 | |||
138 | #include <asm-generic/memory_model.h> | ||
139 | #include <asm-generic/page.h> | ||
140 | |||
141 | #endif /* __KERNEL__ */ | ||
142 | |||
143 | #endif /* _X86_64_PAGE_H */ | ||
diff --git a/include/asm-x86/param.h b/include/asm-x86/param.h new file mode 100644 index 000000000000..640851bab124 --- /dev/null +++ b/include/asm-x86/param.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "param_32.h" | ||
4 | # else | ||
5 | # include "param_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "param_32.h" | ||
10 | # else | ||
11 | # include "param_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/param_32.h b/include/asm-x86/param_32.h new file mode 100644 index 000000000000..21b32466fcdc --- /dev/null +++ b/include/asm-x86/param_32.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef _ASMi386_PARAM_H | ||
2 | #define _ASMi386_PARAM_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | # define HZ CONFIG_HZ /* Internal kernel timer frequency */ | ||
6 | # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ | ||
7 | # define CLOCKS_PER_SEC (USER_HZ) /* like times() */ | ||
8 | #endif | ||
9 | |||
10 | #ifndef HZ | ||
11 | #define HZ 100 | ||
12 | #endif | ||
13 | |||
14 | #define EXEC_PAGESIZE 4096 | ||
15 | |||
16 | #ifndef NOGROUP | ||
17 | #define NOGROUP (-1) | ||
18 | #endif | ||
19 | |||
20 | #define MAXHOSTNAMELEN 64 /* max length of hostname */ | ||
21 | |||
22 | #endif | ||
diff --git a/include/asm-x86/param_64.h b/include/asm-x86/param_64.h new file mode 100644 index 000000000000..a728786c3c7c --- /dev/null +++ b/include/asm-x86/param_64.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef _ASMx86_64_PARAM_H | ||
2 | #define _ASMx86_64_PARAM_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | # define HZ CONFIG_HZ /* Internal kernel timer frequency */ | ||
6 | # define USER_HZ 100 /* .. some user interfaces are in "ticks */ | ||
7 | #define CLOCKS_PER_SEC (USER_HZ) /* like times() */ | ||
8 | #endif | ||
9 | |||
10 | #ifndef HZ | ||
11 | #define HZ 100 | ||
12 | #endif | ||
13 | |||
14 | #define EXEC_PAGESIZE 4096 | ||
15 | |||
16 | #ifndef NOGROUP | ||
17 | #define NOGROUP (-1) | ||
18 | #endif | ||
19 | |||
20 | #define MAXHOSTNAMELEN 64 /* max length of hostname */ | ||
21 | |||
22 | #endif | ||
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h new file mode 100644 index 000000000000..9fa3fa9e62d1 --- /dev/null +++ b/include/asm-x86/paravirt.h | |||
@@ -0,0 +1,1085 @@ | |||
1 | #ifndef __ASM_PARAVIRT_H | ||
2 | #define __ASM_PARAVIRT_H | ||
3 | /* Various instructions on x86 need to be replaced for | ||
4 | * para-virtualization: those hooks are defined here. */ | ||
5 | |||
6 | #ifdef CONFIG_PARAVIRT | ||
7 | #include <asm/page.h> | ||
8 | |||
9 | /* Bitmask of what can be clobbered: usually at least eax. */ | ||
10 | #define CLBR_NONE 0x0 | ||
11 | #define CLBR_EAX 0x1 | ||
12 | #define CLBR_ECX 0x2 | ||
13 | #define CLBR_EDX 0x4 | ||
14 | #define CLBR_ANY 0x7 | ||
15 | |||
16 | #ifndef __ASSEMBLY__ | ||
17 | #include <linux/types.h> | ||
18 | #include <linux/cpumask.h> | ||
19 | #include <asm/kmap_types.h> | ||
20 | |||
21 | struct page; | ||
22 | struct thread_struct; | ||
23 | struct Xgt_desc_struct; | ||
24 | struct tss_struct; | ||
25 | struct mm_struct; | ||
26 | struct desc_struct; | ||
27 | |||
28 | /* Lazy mode for batching updates / context switch */ | ||
29 | enum paravirt_lazy_mode { | ||
30 | PARAVIRT_LAZY_NONE = 0, | ||
31 | PARAVIRT_LAZY_MMU = 1, | ||
32 | PARAVIRT_LAZY_CPU = 2, | ||
33 | PARAVIRT_LAZY_FLUSH = 3, | ||
34 | }; | ||
35 | |||
36 | struct paravirt_ops | ||
37 | { | ||
38 | unsigned int kernel_rpl; | ||
39 | int shared_kernel_pmd; | ||
40 | int paravirt_enabled; | ||
41 | const char *name; | ||
42 | |||
43 | /* | ||
44 | * Patch may replace one of the defined code sequences with arbitrary | ||
45 | * code, subject to the same register constraints. This generally | ||
46 | * means the code is not free to clobber any registers other than EAX. | ||
47 | * The patch function should return the number of bytes of code | ||
48 | * generated, as we nop pad the rest in generic code. | ||
49 | */ | ||
50 | unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, | ||
51 | unsigned long addr, unsigned len); | ||
52 | |||
53 | /* Basic arch-specific setup */ | ||
54 | void (*arch_setup)(void); | ||
55 | char *(*memory_setup)(void); | ||
56 | void (*post_allocator_init)(void); | ||
57 | |||
58 | void (*init_IRQ)(void); | ||
59 | void (*time_init)(void); | ||
60 | |||
61 | /* | ||
62 | * Called before/after init_mm pagetable setup. setup_start | ||
63 | * may reset %cr3, and may pre-install parts of the pagetable; | ||
64 | * pagetable setup is expected to preserve any existing | ||
65 | * mapping. | ||
66 | */ | ||
67 | void (*pagetable_setup_start)(pgd_t *pgd_base); | ||
68 | void (*pagetable_setup_done)(pgd_t *pgd_base); | ||
69 | |||
70 | /* Print a banner to identify the environment */ | ||
71 | void (*banner)(void); | ||
72 | |||
73 | /* Set and set time of day */ | ||
74 | unsigned long (*get_wallclock)(void); | ||
75 | int (*set_wallclock)(unsigned long); | ||
76 | |||
77 | /* cpuid emulation, mostly so that caps bits can be disabled */ | ||
78 | void (*cpuid)(unsigned int *eax, unsigned int *ebx, | ||
79 | unsigned int *ecx, unsigned int *edx); | ||
80 | |||
81 | /* hooks for various privileged instructions */ | ||
82 | unsigned long (*get_debugreg)(int regno); | ||
83 | void (*set_debugreg)(int regno, unsigned long value); | ||
84 | |||
85 | void (*clts)(void); | ||
86 | |||
87 | unsigned long (*read_cr0)(void); | ||
88 | void (*write_cr0)(unsigned long); | ||
89 | |||
90 | unsigned long (*read_cr2)(void); | ||
91 | void (*write_cr2)(unsigned long); | ||
92 | |||
93 | unsigned long (*read_cr3)(void); | ||
94 | void (*write_cr3)(unsigned long); | ||
95 | |||
96 | unsigned long (*read_cr4_safe)(void); | ||
97 | unsigned long (*read_cr4)(void); | ||
98 | void (*write_cr4)(unsigned long); | ||
99 | |||
100 | /* | ||
101 | * Get/set interrupt state. save_fl and restore_fl are only | ||
102 | * expected to use X86_EFLAGS_IF; all other bits | ||
103 | * returned from save_fl are undefined, and may be ignored by | ||
104 | * restore_fl. | ||
105 | */ | ||
106 | unsigned long (*save_fl)(void); | ||
107 | void (*restore_fl)(unsigned long); | ||
108 | void (*irq_disable)(void); | ||
109 | void (*irq_enable)(void); | ||
110 | void (*safe_halt)(void); | ||
111 | void (*halt)(void); | ||
112 | |||
113 | void (*wbinvd)(void); | ||
114 | |||
115 | /* MSR, PMC and TSR operations. | ||
116 | err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */ | ||
117 | u64 (*read_msr)(unsigned int msr, int *err); | ||
118 | int (*write_msr)(unsigned int msr, u64 val); | ||
119 | |||
120 | u64 (*read_tsc)(void); | ||
121 | u64 (*read_pmc)(void); | ||
122 | unsigned long long (*sched_clock)(void); | ||
123 | unsigned long (*get_cpu_khz)(void); | ||
124 | |||
125 | /* Segment descriptor handling */ | ||
126 | void (*load_tr_desc)(void); | ||
127 | void (*load_gdt)(const struct Xgt_desc_struct *); | ||
128 | void (*load_idt)(const struct Xgt_desc_struct *); | ||
129 | void (*store_gdt)(struct Xgt_desc_struct *); | ||
130 | void (*store_idt)(struct Xgt_desc_struct *); | ||
131 | void (*set_ldt)(const void *desc, unsigned entries); | ||
132 | unsigned long (*store_tr)(void); | ||
133 | void (*load_tls)(struct thread_struct *t, unsigned int cpu); | ||
134 | void (*write_ldt_entry)(struct desc_struct *, | ||
135 | int entrynum, u32 low, u32 high); | ||
136 | void (*write_gdt_entry)(struct desc_struct *, | ||
137 | int entrynum, u32 low, u32 high); | ||
138 | void (*write_idt_entry)(struct desc_struct *, | ||
139 | int entrynum, u32 low, u32 high); | ||
140 | void (*load_esp0)(struct tss_struct *tss, struct thread_struct *t); | ||
141 | |||
142 | void (*set_iopl_mask)(unsigned mask); | ||
143 | void (*io_delay)(void); | ||
144 | |||
145 | /* | ||
146 | * Hooks for intercepting the creation/use/destruction of an | ||
147 | * mm_struct. | ||
148 | */ | ||
149 | void (*activate_mm)(struct mm_struct *prev, | ||
150 | struct mm_struct *next); | ||
151 | void (*dup_mmap)(struct mm_struct *oldmm, | ||
152 | struct mm_struct *mm); | ||
153 | void (*exit_mmap)(struct mm_struct *mm); | ||
154 | |||
155 | #ifdef CONFIG_X86_LOCAL_APIC | ||
156 | /* | ||
157 | * Direct APIC operations, principally for VMI. Ideally | ||
158 | * these shouldn't be in this interface. | ||
159 | */ | ||
160 | void (*apic_write)(unsigned long reg, unsigned long v); | ||
161 | void (*apic_write_atomic)(unsigned long reg, unsigned long v); | ||
162 | unsigned long (*apic_read)(unsigned long reg); | ||
163 | void (*setup_boot_clock)(void); | ||
164 | void (*setup_secondary_clock)(void); | ||
165 | |||
166 | void (*startup_ipi_hook)(int phys_apicid, | ||
167 | unsigned long start_eip, | ||
168 | unsigned long start_esp); | ||
169 | #endif | ||
170 | |||
171 | /* TLB operations */ | ||
172 | void (*flush_tlb_user)(void); | ||
173 | void (*flush_tlb_kernel)(void); | ||
174 | void (*flush_tlb_single)(unsigned long addr); | ||
175 | void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm, | ||
176 | unsigned long va); | ||
177 | |||
178 | /* Hooks for allocating/releasing pagetable pages */ | ||
179 | void (*alloc_pt)(struct mm_struct *mm, u32 pfn); | ||
180 | void (*alloc_pd)(u32 pfn); | ||
181 | void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count); | ||
182 | void (*release_pt)(u32 pfn); | ||
183 | void (*release_pd)(u32 pfn); | ||
184 | |||
185 | /* Pagetable manipulation functions */ | ||
186 | void (*set_pte)(pte_t *ptep, pte_t pteval); | ||
187 | void (*set_pte_at)(struct mm_struct *mm, unsigned long addr, | ||
188 | pte_t *ptep, pte_t pteval); | ||
189 | void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval); | ||
190 | void (*pte_update)(struct mm_struct *mm, unsigned long addr, pte_t *ptep); | ||
191 | void (*pte_update_defer)(struct mm_struct *mm, | ||
192 | unsigned long addr, pte_t *ptep); | ||
193 | |||
194 | #ifdef CONFIG_HIGHPTE | ||
195 | void *(*kmap_atomic_pte)(struct page *page, enum km_type type); | ||
196 | #endif | ||
197 | |||
198 | #ifdef CONFIG_X86_PAE | ||
199 | void (*set_pte_atomic)(pte_t *ptep, pte_t pteval); | ||
200 | void (*set_pte_present)(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte); | ||
201 | void (*set_pud)(pud_t *pudp, pud_t pudval); | ||
202 | void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep); | ||
203 | void (*pmd_clear)(pmd_t *pmdp); | ||
204 | |||
205 | unsigned long long (*pte_val)(pte_t); | ||
206 | unsigned long long (*pmd_val)(pmd_t); | ||
207 | unsigned long long (*pgd_val)(pgd_t); | ||
208 | |||
209 | pte_t (*make_pte)(unsigned long long pte); | ||
210 | pmd_t (*make_pmd)(unsigned long long pmd); | ||
211 | pgd_t (*make_pgd)(unsigned long long pgd); | ||
212 | #else | ||
213 | unsigned long (*pte_val)(pte_t); | ||
214 | unsigned long (*pgd_val)(pgd_t); | ||
215 | |||
216 | pte_t (*make_pte)(unsigned long pte); | ||
217 | pgd_t (*make_pgd)(unsigned long pgd); | ||
218 | #endif | ||
219 | |||
220 | /* Set deferred update mode, used for batching operations. */ | ||
221 | void (*set_lazy_mode)(enum paravirt_lazy_mode mode); | ||
222 | |||
223 | /* These two are jmp to, not actually called. */ | ||
224 | void (*irq_enable_sysexit)(void); | ||
225 | void (*iret)(void); | ||
226 | }; | ||
227 | |||
228 | extern struct paravirt_ops paravirt_ops; | ||
229 | |||
230 | #define PARAVIRT_PATCH(x) \ | ||
231 | (offsetof(struct paravirt_ops, x) / sizeof(void *)) | ||
232 | |||
233 | #define paravirt_type(type) \ | ||
234 | [paravirt_typenum] "i" (PARAVIRT_PATCH(type)) | ||
235 | #define paravirt_clobber(clobber) \ | ||
236 | [paravirt_clobber] "i" (clobber) | ||
237 | |||
238 | /* | ||
239 | * Generate some code, and mark it as patchable by the | ||
240 | * apply_paravirt() alternate instruction patcher. | ||
241 | */ | ||
242 | #define _paravirt_alt(insn_string, type, clobber) \ | ||
243 | "771:\n\t" insn_string "\n" "772:\n" \ | ||
244 | ".pushsection .parainstructions,\"a\"\n" \ | ||
245 | " .long 771b\n" \ | ||
246 | " .byte " type "\n" \ | ||
247 | " .byte 772b-771b\n" \ | ||
248 | " .short " clobber "\n" \ | ||
249 | ".popsection\n" | ||
250 | |||
251 | /* Generate patchable code, with the default asm parameters. */ | ||
252 | #define paravirt_alt(insn_string) \ | ||
253 | _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") | ||
254 | |||
255 | unsigned paravirt_patch_nop(void); | ||
256 | unsigned paravirt_patch_ignore(unsigned len); | ||
257 | unsigned paravirt_patch_call(void *insnbuf, | ||
258 | const void *target, u16 tgt_clobbers, | ||
259 | unsigned long addr, u16 site_clobbers, | ||
260 | unsigned len); | ||
261 | unsigned paravirt_patch_jmp(const void *target, void *insnbuf, | ||
262 | unsigned long addr, unsigned len); | ||
263 | unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf, | ||
264 | unsigned long addr, unsigned len); | ||
265 | |||
266 | unsigned paravirt_patch_insns(void *insnbuf, unsigned len, | ||
267 | const char *start, const char *end); | ||
268 | |||
269 | int paravirt_disable_iospace(void); | ||
270 | |||
271 | /* | ||
272 | * This generates an indirect call based on the operation type number. | ||
273 | * The type number, computed in PARAVIRT_PATCH, is derived from the | ||
274 | * offset into the paravirt_ops structure, and can therefore be freely | ||
275 | * converted back into a structure offset. | ||
276 | */ | ||
277 | #define PARAVIRT_CALL "call *(paravirt_ops+%c[paravirt_typenum]*4);" | ||
278 | |||
279 | /* | ||
280 | * These macros are intended to wrap calls into a paravirt_ops | ||
281 | * operation, so that they can be later identified and patched at | ||
282 | * runtime. | ||
283 | * | ||
284 | * Normally, a call to a pv_op function is a simple indirect call: | ||
285 | * (paravirt_ops.operations)(args...). | ||
286 | * | ||
287 | * Unfortunately, this is a relatively slow operation for modern CPUs, | ||
288 | * because it cannot necessarily determine what the destination | ||
289 | * address is. In this case, the address is a runtime constant, so at | ||
290 | * the very least we can patch the call to e a simple direct call, or | ||
291 | * ideally, patch an inline implementation into the callsite. (Direct | ||
292 | * calls are essentially free, because the call and return addresses | ||
293 | * are completely predictable.) | ||
294 | * | ||
295 | * These macros rely on the standard gcc "regparm(3)" calling | ||
296 | * convention, in which the first three arguments are placed in %eax, | ||
297 | * %edx, %ecx (in that order), and the remaining arguments are placed | ||
298 | * on the stack. All caller-save registers (eax,edx,ecx) are expected | ||
299 | * to be modified (either clobbered or used for return values). | ||
300 | * | ||
301 | * The call instruction itself is marked by placing its start address | ||
302 | * and size into the .parainstructions section, so that | ||
303 | * apply_paravirt() in arch/i386/kernel/alternative.c can do the | ||
304 | * appropriate patching under the control of the backend paravirt_ops | ||
305 | * implementation. | ||
306 | * | ||
307 | * Unfortunately there's no way to get gcc to generate the args setup | ||
308 | * for the call, and then allow the call itself to be generated by an | ||
309 | * inline asm. Because of this, we must do the complete arg setup and | ||
310 | * return value handling from within these macros. This is fairly | ||
311 | * cumbersome. | ||
312 | * | ||
313 | * There are 5 sets of PVOP_* macros for dealing with 0-4 arguments. | ||
314 | * It could be extended to more arguments, but there would be little | ||
315 | * to be gained from that. For each number of arguments, there are | ||
316 | * the two VCALL and CALL variants for void and non-void functions. | ||
317 | * | ||
318 | * When there is a return value, the invoker of the macro must specify | ||
319 | * the return type. The macro then uses sizeof() on that type to | ||
320 | * determine whether its a 32 or 64 bit value, and places the return | ||
321 | * in the right register(s) (just %eax for 32-bit, and %edx:%eax for | ||
322 | * 64-bit). | ||
323 | * | ||
324 | * 64-bit arguments are passed as a pair of adjacent 32-bit arguments | ||
325 | * in low,high order. | ||
326 | * | ||
327 | * Small structures are passed and returned in registers. The macro | ||
328 | * calling convention can't directly deal with this, so the wrapper | ||
329 | * functions must do this. | ||
330 | * | ||
331 | * These PVOP_* macros are only defined within this header. This | ||
332 | * means that all uses must be wrapped in inline functions. This also | ||
333 | * makes sure the incoming and outgoing types are always correct. | ||
334 | */ | ||
335 | #define __PVOP_CALL(rettype, op, pre, post, ...) \ | ||
336 | ({ \ | ||
337 | rettype __ret; \ | ||
338 | unsigned long __eax, __edx, __ecx; \ | ||
339 | if (sizeof(rettype) > sizeof(unsigned long)) { \ | ||
340 | asm volatile(pre \ | ||
341 | paravirt_alt(PARAVIRT_CALL) \ | ||
342 | post \ | ||
343 | : "=a" (__eax), "=d" (__edx), \ | ||
344 | "=c" (__ecx) \ | ||
345 | : paravirt_type(op), \ | ||
346 | paravirt_clobber(CLBR_ANY), \ | ||
347 | ##__VA_ARGS__ \ | ||
348 | : "memory", "cc"); \ | ||
349 | __ret = (rettype)((((u64)__edx) << 32) | __eax); \ | ||
350 | } else { \ | ||
351 | asm volatile(pre \ | ||
352 | paravirt_alt(PARAVIRT_CALL) \ | ||
353 | post \ | ||
354 | : "=a" (__eax), "=d" (__edx), \ | ||
355 | "=c" (__ecx) \ | ||
356 | : paravirt_type(op), \ | ||
357 | paravirt_clobber(CLBR_ANY), \ | ||
358 | ##__VA_ARGS__ \ | ||
359 | : "memory", "cc"); \ | ||
360 | __ret = (rettype)__eax; \ | ||
361 | } \ | ||
362 | __ret; \ | ||
363 | }) | ||
364 | #define __PVOP_VCALL(op, pre, post, ...) \ | ||
365 | ({ \ | ||
366 | unsigned long __eax, __edx, __ecx; \ | ||
367 | asm volatile(pre \ | ||
368 | paravirt_alt(PARAVIRT_CALL) \ | ||
369 | post \ | ||
370 | : "=a" (__eax), "=d" (__edx), "=c" (__ecx) \ | ||
371 | : paravirt_type(op), \ | ||
372 | paravirt_clobber(CLBR_ANY), \ | ||
373 | ##__VA_ARGS__ \ | ||
374 | : "memory", "cc"); \ | ||
375 | }) | ||
376 | |||
377 | #define PVOP_CALL0(rettype, op) \ | ||
378 | __PVOP_CALL(rettype, op, "", "") | ||
379 | #define PVOP_VCALL0(op) \ | ||
380 | __PVOP_VCALL(op, "", "") | ||
381 | |||
382 | #define PVOP_CALL1(rettype, op, arg1) \ | ||
383 | __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1))) | ||
384 | #define PVOP_VCALL1(op, arg1) \ | ||
385 | __PVOP_VCALL(op, "", "", "0" ((u32)(arg1))) | ||
386 | |||
387 | #define PVOP_CALL2(rettype, op, arg1, arg2) \ | ||
388 | __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2))) | ||
389 | #define PVOP_VCALL2(op, arg1, arg2) \ | ||
390 | __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2))) | ||
391 | |||
392 | #define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \ | ||
393 | __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), \ | ||
394 | "1"((u32)(arg2)), "2"((u32)(arg3))) | ||
395 | #define PVOP_VCALL3(op, arg1, arg2, arg3) \ | ||
396 | __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1"((u32)(arg2)), \ | ||
397 | "2"((u32)(arg3))) | ||
398 | |||
399 | #define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \ | ||
400 | __PVOP_CALL(rettype, op, \ | ||
401 | "push %[_arg4];", "lea 4(%%esp),%%esp;", \ | ||
402 | "0" ((u32)(arg1)), "1" ((u32)(arg2)), \ | ||
403 | "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4))) | ||
404 | #define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \ | ||
405 | __PVOP_VCALL(op, \ | ||
406 | "push %[_arg4];", "lea 4(%%esp),%%esp;", \ | ||
407 | "0" ((u32)(arg1)), "1" ((u32)(arg2)), \ | ||
408 | "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4))) | ||
409 | |||
410 | static inline int paravirt_enabled(void) | ||
411 | { | ||
412 | return paravirt_ops.paravirt_enabled; | ||
413 | } | ||
414 | |||
415 | static inline void load_esp0(struct tss_struct *tss, | ||
416 | struct thread_struct *thread) | ||
417 | { | ||
418 | PVOP_VCALL2(load_esp0, tss, thread); | ||
419 | } | ||
420 | |||
421 | #define ARCH_SETUP paravirt_ops.arch_setup(); | ||
422 | static inline unsigned long get_wallclock(void) | ||
423 | { | ||
424 | return PVOP_CALL0(unsigned long, get_wallclock); | ||
425 | } | ||
426 | |||
427 | static inline int set_wallclock(unsigned long nowtime) | ||
428 | { | ||
429 | return PVOP_CALL1(int, set_wallclock, nowtime); | ||
430 | } | ||
431 | |||
432 | static inline void (*choose_time_init(void))(void) | ||
433 | { | ||
434 | return paravirt_ops.time_init; | ||
435 | } | ||
436 | |||
437 | /* The paravirtualized CPUID instruction. */ | ||
438 | static inline void __cpuid(unsigned int *eax, unsigned int *ebx, | ||
439 | unsigned int *ecx, unsigned int *edx) | ||
440 | { | ||
441 | PVOP_VCALL4(cpuid, eax, ebx, ecx, edx); | ||
442 | } | ||
443 | |||
444 | /* | ||
445 | * These special macros can be used to get or set a debugging register | ||
446 | */ | ||
447 | static inline unsigned long paravirt_get_debugreg(int reg) | ||
448 | { | ||
449 | return PVOP_CALL1(unsigned long, get_debugreg, reg); | ||
450 | } | ||
451 | #define get_debugreg(var, reg) var = paravirt_get_debugreg(reg) | ||
452 | static inline void set_debugreg(unsigned long val, int reg) | ||
453 | { | ||
454 | PVOP_VCALL2(set_debugreg, reg, val); | ||
455 | } | ||
456 | |||
457 | static inline void clts(void) | ||
458 | { | ||
459 | PVOP_VCALL0(clts); | ||
460 | } | ||
461 | |||
462 | static inline unsigned long read_cr0(void) | ||
463 | { | ||
464 | return PVOP_CALL0(unsigned long, read_cr0); | ||
465 | } | ||
466 | |||
467 | static inline void write_cr0(unsigned long x) | ||
468 | { | ||
469 | PVOP_VCALL1(write_cr0, x); | ||
470 | } | ||
471 | |||
472 | static inline unsigned long read_cr2(void) | ||
473 | { | ||
474 | return PVOP_CALL0(unsigned long, read_cr2); | ||
475 | } | ||
476 | |||
477 | static inline void write_cr2(unsigned long x) | ||
478 | { | ||
479 | PVOP_VCALL1(write_cr2, x); | ||
480 | } | ||
481 | |||
482 | static inline unsigned long read_cr3(void) | ||
483 | { | ||
484 | return PVOP_CALL0(unsigned long, read_cr3); | ||
485 | } | ||
486 | |||
487 | static inline void write_cr3(unsigned long x) | ||
488 | { | ||
489 | PVOP_VCALL1(write_cr3, x); | ||
490 | } | ||
491 | |||
492 | static inline unsigned long read_cr4(void) | ||
493 | { | ||
494 | return PVOP_CALL0(unsigned long, read_cr4); | ||
495 | } | ||
496 | static inline unsigned long read_cr4_safe(void) | ||
497 | { | ||
498 | return PVOP_CALL0(unsigned long, read_cr4_safe); | ||
499 | } | ||
500 | |||
501 | static inline void write_cr4(unsigned long x) | ||
502 | { | ||
503 | PVOP_VCALL1(write_cr4, x); | ||
504 | } | ||
505 | |||
506 | static inline void raw_safe_halt(void) | ||
507 | { | ||
508 | PVOP_VCALL0(safe_halt); | ||
509 | } | ||
510 | |||
511 | static inline void halt(void) | ||
512 | { | ||
513 | PVOP_VCALL0(safe_halt); | ||
514 | } | ||
515 | |||
516 | static inline void wbinvd(void) | ||
517 | { | ||
518 | PVOP_VCALL0(wbinvd); | ||
519 | } | ||
520 | |||
521 | #define get_kernel_rpl() (paravirt_ops.kernel_rpl) | ||
522 | |||
523 | static inline u64 paravirt_read_msr(unsigned msr, int *err) | ||
524 | { | ||
525 | return PVOP_CALL2(u64, read_msr, msr, err); | ||
526 | } | ||
527 | static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high) | ||
528 | { | ||
529 | return PVOP_CALL3(int, write_msr, msr, low, high); | ||
530 | } | ||
531 | |||
532 | /* These should all do BUG_ON(_err), but our headers are too tangled. */ | ||
533 | #define rdmsr(msr,val1,val2) do { \ | ||
534 | int _err; \ | ||
535 | u64 _l = paravirt_read_msr(msr, &_err); \ | ||
536 | val1 = (u32)_l; \ | ||
537 | val2 = _l >> 32; \ | ||
538 | } while(0) | ||
539 | |||
540 | #define wrmsr(msr,val1,val2) do { \ | ||
541 | paravirt_write_msr(msr, val1, val2); \ | ||
542 | } while(0) | ||
543 | |||
544 | #define rdmsrl(msr,val) do { \ | ||
545 | int _err; \ | ||
546 | val = paravirt_read_msr(msr, &_err); \ | ||
547 | } while(0) | ||
548 | |||
549 | #define wrmsrl(msr,val) wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32) | ||
550 | #define wrmsr_safe(msr,a,b) paravirt_write_msr(msr, a, b) | ||
551 | |||
552 | /* rdmsr with exception handling */ | ||
553 | #define rdmsr_safe(msr,a,b) ({ \ | ||
554 | int _err; \ | ||
555 | u64 _l = paravirt_read_msr(msr, &_err); \ | ||
556 | (*a) = (u32)_l; \ | ||
557 | (*b) = _l >> 32; \ | ||
558 | _err; }) | ||
559 | |||
560 | |||
561 | static inline u64 paravirt_read_tsc(void) | ||
562 | { | ||
563 | return PVOP_CALL0(u64, read_tsc); | ||
564 | } | ||
565 | |||
566 | #define rdtscl(low) do { \ | ||
567 | u64 _l = paravirt_read_tsc(); \ | ||
568 | low = (int)_l; \ | ||
569 | } while(0) | ||
570 | |||
571 | #define rdtscll(val) (val = paravirt_read_tsc()) | ||
572 | |||
573 | static inline unsigned long long paravirt_sched_clock(void) | ||
574 | { | ||
575 | return PVOP_CALL0(unsigned long long, sched_clock); | ||
576 | } | ||
577 | #define calculate_cpu_khz() (paravirt_ops.get_cpu_khz()) | ||
578 | |||
579 | #define write_tsc(val1,val2) wrmsr(0x10, val1, val2) | ||
580 | |||
581 | static inline unsigned long long paravirt_read_pmc(int counter) | ||
582 | { | ||
583 | return PVOP_CALL1(u64, read_pmc, counter); | ||
584 | } | ||
585 | |||
586 | #define rdpmc(counter,low,high) do { \ | ||
587 | u64 _l = paravirt_read_pmc(counter); \ | ||
588 | low = (u32)_l; \ | ||
589 | high = _l >> 32; \ | ||
590 | } while(0) | ||
591 | |||
592 | static inline void load_TR_desc(void) | ||
593 | { | ||
594 | PVOP_VCALL0(load_tr_desc); | ||
595 | } | ||
596 | static inline void load_gdt(const struct Xgt_desc_struct *dtr) | ||
597 | { | ||
598 | PVOP_VCALL1(load_gdt, dtr); | ||
599 | } | ||
600 | static inline void load_idt(const struct Xgt_desc_struct *dtr) | ||
601 | { | ||
602 | PVOP_VCALL1(load_idt, dtr); | ||
603 | } | ||
604 | static inline void set_ldt(const void *addr, unsigned entries) | ||
605 | { | ||
606 | PVOP_VCALL2(set_ldt, addr, entries); | ||
607 | } | ||
608 | static inline void store_gdt(struct Xgt_desc_struct *dtr) | ||
609 | { | ||
610 | PVOP_VCALL1(store_gdt, dtr); | ||
611 | } | ||
612 | static inline void store_idt(struct Xgt_desc_struct *dtr) | ||
613 | { | ||
614 | PVOP_VCALL1(store_idt, dtr); | ||
615 | } | ||
616 | static inline unsigned long paravirt_store_tr(void) | ||
617 | { | ||
618 | return PVOP_CALL0(unsigned long, store_tr); | ||
619 | } | ||
620 | #define store_tr(tr) ((tr) = paravirt_store_tr()) | ||
621 | static inline void load_TLS(struct thread_struct *t, unsigned cpu) | ||
622 | { | ||
623 | PVOP_VCALL2(load_tls, t, cpu); | ||
624 | } | ||
625 | static inline void write_ldt_entry(void *dt, int entry, u32 low, u32 high) | ||
626 | { | ||
627 | PVOP_VCALL4(write_ldt_entry, dt, entry, low, high); | ||
628 | } | ||
629 | static inline void write_gdt_entry(void *dt, int entry, u32 low, u32 high) | ||
630 | { | ||
631 | PVOP_VCALL4(write_gdt_entry, dt, entry, low, high); | ||
632 | } | ||
633 | static inline void write_idt_entry(void *dt, int entry, u32 low, u32 high) | ||
634 | { | ||
635 | PVOP_VCALL4(write_idt_entry, dt, entry, low, high); | ||
636 | } | ||
637 | static inline void set_iopl_mask(unsigned mask) | ||
638 | { | ||
639 | PVOP_VCALL1(set_iopl_mask, mask); | ||
640 | } | ||
641 | |||
642 | /* The paravirtualized I/O functions */ | ||
643 | static inline void slow_down_io(void) { | ||
644 | paravirt_ops.io_delay(); | ||
645 | #ifdef REALLY_SLOW_IO | ||
646 | paravirt_ops.io_delay(); | ||
647 | paravirt_ops.io_delay(); | ||
648 | paravirt_ops.io_delay(); | ||
649 | #endif | ||
650 | } | ||
651 | |||
652 | #ifdef CONFIG_X86_LOCAL_APIC | ||
653 | /* | ||
654 | * Basic functions accessing APICs. | ||
655 | */ | ||
656 | static inline void apic_write(unsigned long reg, unsigned long v) | ||
657 | { | ||
658 | PVOP_VCALL2(apic_write, reg, v); | ||
659 | } | ||
660 | |||
661 | static inline void apic_write_atomic(unsigned long reg, unsigned long v) | ||
662 | { | ||
663 | PVOP_VCALL2(apic_write_atomic, reg, v); | ||
664 | } | ||
665 | |||
666 | static inline unsigned long apic_read(unsigned long reg) | ||
667 | { | ||
668 | return PVOP_CALL1(unsigned long, apic_read, reg); | ||
669 | } | ||
670 | |||
671 | static inline void setup_boot_clock(void) | ||
672 | { | ||
673 | PVOP_VCALL0(setup_boot_clock); | ||
674 | } | ||
675 | |||
676 | static inline void setup_secondary_clock(void) | ||
677 | { | ||
678 | PVOP_VCALL0(setup_secondary_clock); | ||
679 | } | ||
680 | #endif | ||
681 | |||
682 | static inline void paravirt_post_allocator_init(void) | ||
683 | { | ||
684 | if (paravirt_ops.post_allocator_init) | ||
685 | (*paravirt_ops.post_allocator_init)(); | ||
686 | } | ||
687 | |||
688 | static inline void paravirt_pagetable_setup_start(pgd_t *base) | ||
689 | { | ||
690 | if (paravirt_ops.pagetable_setup_start) | ||
691 | (*paravirt_ops.pagetable_setup_start)(base); | ||
692 | } | ||
693 | |||
694 | static inline void paravirt_pagetable_setup_done(pgd_t *base) | ||
695 | { | ||
696 | if (paravirt_ops.pagetable_setup_done) | ||
697 | (*paravirt_ops.pagetable_setup_done)(base); | ||
698 | } | ||
699 | |||
700 | #ifdef CONFIG_SMP | ||
701 | static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip, | ||
702 | unsigned long start_esp) | ||
703 | { | ||
704 | PVOP_VCALL3(startup_ipi_hook, phys_apicid, start_eip, start_esp); | ||
705 | } | ||
706 | #endif | ||
707 | |||
708 | static inline void paravirt_activate_mm(struct mm_struct *prev, | ||
709 | struct mm_struct *next) | ||
710 | { | ||
711 | PVOP_VCALL2(activate_mm, prev, next); | ||
712 | } | ||
713 | |||
714 | static inline void arch_dup_mmap(struct mm_struct *oldmm, | ||
715 | struct mm_struct *mm) | ||
716 | { | ||
717 | PVOP_VCALL2(dup_mmap, oldmm, mm); | ||
718 | } | ||
719 | |||
720 | static inline void arch_exit_mmap(struct mm_struct *mm) | ||
721 | { | ||
722 | PVOP_VCALL1(exit_mmap, mm); | ||
723 | } | ||
724 | |||
725 | static inline void __flush_tlb(void) | ||
726 | { | ||
727 | PVOP_VCALL0(flush_tlb_user); | ||
728 | } | ||
729 | static inline void __flush_tlb_global(void) | ||
730 | { | ||
731 | PVOP_VCALL0(flush_tlb_kernel); | ||
732 | } | ||
733 | static inline void __flush_tlb_single(unsigned long addr) | ||
734 | { | ||
735 | PVOP_VCALL1(flush_tlb_single, addr); | ||
736 | } | ||
737 | |||
738 | static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, | ||
739 | unsigned long va) | ||
740 | { | ||
741 | PVOP_VCALL3(flush_tlb_others, &cpumask, mm, va); | ||
742 | } | ||
743 | |||
744 | static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn) | ||
745 | { | ||
746 | PVOP_VCALL2(alloc_pt, mm, pfn); | ||
747 | } | ||
748 | static inline void paravirt_release_pt(unsigned pfn) | ||
749 | { | ||
750 | PVOP_VCALL1(release_pt, pfn); | ||
751 | } | ||
752 | |||
753 | static inline void paravirt_alloc_pd(unsigned pfn) | ||
754 | { | ||
755 | PVOP_VCALL1(alloc_pd, pfn); | ||
756 | } | ||
757 | |||
758 | static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn, | ||
759 | unsigned start, unsigned count) | ||
760 | { | ||
761 | PVOP_VCALL4(alloc_pd_clone, pfn, clonepfn, start, count); | ||
762 | } | ||
763 | static inline void paravirt_release_pd(unsigned pfn) | ||
764 | { | ||
765 | PVOP_VCALL1(release_pd, pfn); | ||
766 | } | ||
767 | |||
768 | #ifdef CONFIG_HIGHPTE | ||
769 | static inline void *kmap_atomic_pte(struct page *page, enum km_type type) | ||
770 | { | ||
771 | unsigned long ret; | ||
772 | ret = PVOP_CALL2(unsigned long, kmap_atomic_pte, page, type); | ||
773 | return (void *)ret; | ||
774 | } | ||
775 | #endif | ||
776 | |||
777 | static inline void pte_update(struct mm_struct *mm, unsigned long addr, | ||
778 | pte_t *ptep) | ||
779 | { | ||
780 | PVOP_VCALL3(pte_update, mm, addr, ptep); | ||
781 | } | ||
782 | |||
783 | static inline void pte_update_defer(struct mm_struct *mm, unsigned long addr, | ||
784 | pte_t *ptep) | ||
785 | { | ||
786 | PVOP_VCALL3(pte_update_defer, mm, addr, ptep); | ||
787 | } | ||
788 | |||
789 | #ifdef CONFIG_X86_PAE | ||
790 | static inline pte_t __pte(unsigned long long val) | ||
791 | { | ||
792 | unsigned long long ret = PVOP_CALL2(unsigned long long, make_pte, | ||
793 | val, val >> 32); | ||
794 | return (pte_t) { ret, ret >> 32 }; | ||
795 | } | ||
796 | |||
797 | static inline pmd_t __pmd(unsigned long long val) | ||
798 | { | ||
799 | return (pmd_t) { PVOP_CALL2(unsigned long long, make_pmd, val, val >> 32) }; | ||
800 | } | ||
801 | |||
802 | static inline pgd_t __pgd(unsigned long long val) | ||
803 | { | ||
804 | return (pgd_t) { PVOP_CALL2(unsigned long long, make_pgd, val, val >> 32) }; | ||
805 | } | ||
806 | |||
807 | static inline unsigned long long pte_val(pte_t x) | ||
808 | { | ||
809 | return PVOP_CALL2(unsigned long long, pte_val, x.pte_low, x.pte_high); | ||
810 | } | ||
811 | |||
812 | static inline unsigned long long pmd_val(pmd_t x) | ||
813 | { | ||
814 | return PVOP_CALL2(unsigned long long, pmd_val, x.pmd, x.pmd >> 32); | ||
815 | } | ||
816 | |||
817 | static inline unsigned long long pgd_val(pgd_t x) | ||
818 | { | ||
819 | return PVOP_CALL2(unsigned long long, pgd_val, x.pgd, x.pgd >> 32); | ||
820 | } | ||
821 | |||
822 | static inline void set_pte(pte_t *ptep, pte_t pteval) | ||
823 | { | ||
824 | PVOP_VCALL3(set_pte, ptep, pteval.pte_low, pteval.pte_high); | ||
825 | } | ||
826 | |||
827 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | ||
828 | pte_t *ptep, pte_t pteval) | ||
829 | { | ||
830 | /* 5 arg words */ | ||
831 | paravirt_ops.set_pte_at(mm, addr, ptep, pteval); | ||
832 | } | ||
833 | |||
834 | static inline void set_pte_atomic(pte_t *ptep, pte_t pteval) | ||
835 | { | ||
836 | PVOP_VCALL3(set_pte_atomic, ptep, pteval.pte_low, pteval.pte_high); | ||
837 | } | ||
838 | |||
839 | static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, | ||
840 | pte_t *ptep, pte_t pte) | ||
841 | { | ||
842 | /* 5 arg words */ | ||
843 | paravirt_ops.set_pte_present(mm, addr, ptep, pte); | ||
844 | } | ||
845 | |||
846 | static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval) | ||
847 | { | ||
848 | PVOP_VCALL3(set_pmd, pmdp, pmdval.pmd, pmdval.pmd >> 32); | ||
849 | } | ||
850 | |||
851 | static inline void set_pud(pud_t *pudp, pud_t pudval) | ||
852 | { | ||
853 | PVOP_VCALL3(set_pud, pudp, pudval.pgd.pgd, pudval.pgd.pgd >> 32); | ||
854 | } | ||
855 | |||
856 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
857 | { | ||
858 | PVOP_VCALL3(pte_clear, mm, addr, ptep); | ||
859 | } | ||
860 | |||
861 | static inline void pmd_clear(pmd_t *pmdp) | ||
862 | { | ||
863 | PVOP_VCALL1(pmd_clear, pmdp); | ||
864 | } | ||
865 | |||
866 | #else /* !CONFIG_X86_PAE */ | ||
867 | |||
868 | static inline pte_t __pte(unsigned long val) | ||
869 | { | ||
870 | return (pte_t) { PVOP_CALL1(unsigned long, make_pte, val) }; | ||
871 | } | ||
872 | |||
873 | static inline pgd_t __pgd(unsigned long val) | ||
874 | { | ||
875 | return (pgd_t) { PVOP_CALL1(unsigned long, make_pgd, val) }; | ||
876 | } | ||
877 | |||
878 | static inline unsigned long pte_val(pte_t x) | ||
879 | { | ||
880 | return PVOP_CALL1(unsigned long, pte_val, x.pte_low); | ||
881 | } | ||
882 | |||
883 | static inline unsigned long pgd_val(pgd_t x) | ||
884 | { | ||
885 | return PVOP_CALL1(unsigned long, pgd_val, x.pgd); | ||
886 | } | ||
887 | |||
888 | static inline void set_pte(pte_t *ptep, pte_t pteval) | ||
889 | { | ||
890 | PVOP_VCALL2(set_pte, ptep, pteval.pte_low); | ||
891 | } | ||
892 | |||
893 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | ||
894 | pte_t *ptep, pte_t pteval) | ||
895 | { | ||
896 | PVOP_VCALL4(set_pte_at, mm, addr, ptep, pteval.pte_low); | ||
897 | } | ||
898 | |||
899 | static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval) | ||
900 | { | ||
901 | PVOP_VCALL2(set_pmd, pmdp, pmdval.pud.pgd.pgd); | ||
902 | } | ||
903 | #endif /* CONFIG_X86_PAE */ | ||
904 | |||
905 | #define __HAVE_ARCH_ENTER_LAZY_CPU_MODE | ||
906 | static inline void arch_enter_lazy_cpu_mode(void) | ||
907 | { | ||
908 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_CPU); | ||
909 | } | ||
910 | |||
911 | static inline void arch_leave_lazy_cpu_mode(void) | ||
912 | { | ||
913 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_NONE); | ||
914 | } | ||
915 | |||
916 | static inline void arch_flush_lazy_cpu_mode(void) | ||
917 | { | ||
918 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_FLUSH); | ||
919 | } | ||
920 | |||
921 | |||
922 | #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE | ||
923 | static inline void arch_enter_lazy_mmu_mode(void) | ||
924 | { | ||
925 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_MMU); | ||
926 | } | ||
927 | |||
928 | static inline void arch_leave_lazy_mmu_mode(void) | ||
929 | { | ||
930 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_NONE); | ||
931 | } | ||
932 | |||
933 | static inline void arch_flush_lazy_mmu_mode(void) | ||
934 | { | ||
935 | PVOP_VCALL1(set_lazy_mode, PARAVIRT_LAZY_FLUSH); | ||
936 | } | ||
937 | |||
938 | void _paravirt_nop(void); | ||
939 | #define paravirt_nop ((void *)_paravirt_nop) | ||
940 | |||
941 | /* These all sit in the .parainstructions section to tell us what to patch. */ | ||
942 | struct paravirt_patch_site { | ||
943 | u8 *instr; /* original instructions */ | ||
944 | u8 instrtype; /* type of this instruction */ | ||
945 | u8 len; /* length of original instruction */ | ||
946 | u16 clobbers; /* what registers you may clobber */ | ||
947 | }; | ||
948 | |||
949 | extern struct paravirt_patch_site __parainstructions[], | ||
950 | __parainstructions_end[]; | ||
951 | |||
952 | static inline unsigned long __raw_local_save_flags(void) | ||
953 | { | ||
954 | unsigned long f; | ||
955 | |||
956 | asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" | ||
957 | PARAVIRT_CALL | ||
958 | "popl %%edx; popl %%ecx") | ||
959 | : "=a"(f) | ||
960 | : paravirt_type(save_fl), | ||
961 | paravirt_clobber(CLBR_EAX) | ||
962 | : "memory", "cc"); | ||
963 | return f; | ||
964 | } | ||
965 | |||
966 | static inline void raw_local_irq_restore(unsigned long f) | ||
967 | { | ||
968 | asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" | ||
969 | PARAVIRT_CALL | ||
970 | "popl %%edx; popl %%ecx") | ||
971 | : "=a"(f) | ||
972 | : "0"(f), | ||
973 | paravirt_type(restore_fl), | ||
974 | paravirt_clobber(CLBR_EAX) | ||
975 | : "memory", "cc"); | ||
976 | } | ||
977 | |||
978 | static inline void raw_local_irq_disable(void) | ||
979 | { | ||
980 | asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" | ||
981 | PARAVIRT_CALL | ||
982 | "popl %%edx; popl %%ecx") | ||
983 | : | ||
984 | : paravirt_type(irq_disable), | ||
985 | paravirt_clobber(CLBR_EAX) | ||
986 | : "memory", "eax", "cc"); | ||
987 | } | ||
988 | |||
989 | static inline void raw_local_irq_enable(void) | ||
990 | { | ||
991 | asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" | ||
992 | PARAVIRT_CALL | ||
993 | "popl %%edx; popl %%ecx") | ||
994 | : | ||
995 | : paravirt_type(irq_enable), | ||
996 | paravirt_clobber(CLBR_EAX) | ||
997 | : "memory", "eax", "cc"); | ||
998 | } | ||
999 | |||
1000 | static inline unsigned long __raw_local_irq_save(void) | ||
1001 | { | ||
1002 | unsigned long f; | ||
1003 | |||
1004 | f = __raw_local_save_flags(); | ||
1005 | raw_local_irq_disable(); | ||
1006 | return f; | ||
1007 | } | ||
1008 | |||
1009 | #define CLI_STRING \ | ||
1010 | _paravirt_alt("pushl %%ecx; pushl %%edx;" \ | ||
1011 | "call *paravirt_ops+%c[paravirt_cli_type]*4;" \ | ||
1012 | "popl %%edx; popl %%ecx", \ | ||
1013 | "%c[paravirt_cli_type]", "%c[paravirt_clobber]") | ||
1014 | |||
1015 | #define STI_STRING \ | ||
1016 | _paravirt_alt("pushl %%ecx; pushl %%edx;" \ | ||
1017 | "call *paravirt_ops+%c[paravirt_sti_type]*4;" \ | ||
1018 | "popl %%edx; popl %%ecx", \ | ||
1019 | "%c[paravirt_sti_type]", "%c[paravirt_clobber]") | ||
1020 | |||
1021 | #define CLI_STI_CLOBBERS , "%eax" | ||
1022 | #define CLI_STI_INPUT_ARGS \ | ||
1023 | , \ | ||
1024 | [paravirt_cli_type] "i" (PARAVIRT_PATCH(irq_disable)), \ | ||
1025 | [paravirt_sti_type] "i" (PARAVIRT_PATCH(irq_enable)), \ | ||
1026 | paravirt_clobber(CLBR_EAX) | ||
1027 | |||
1028 | /* Make sure as little as possible of this mess escapes. */ | ||
1029 | #undef PARAVIRT_CALL | ||
1030 | #undef __PVOP_CALL | ||
1031 | #undef __PVOP_VCALL | ||
1032 | #undef PVOP_VCALL0 | ||
1033 | #undef PVOP_CALL0 | ||
1034 | #undef PVOP_VCALL1 | ||
1035 | #undef PVOP_CALL1 | ||
1036 | #undef PVOP_VCALL2 | ||
1037 | #undef PVOP_CALL2 | ||
1038 | #undef PVOP_VCALL3 | ||
1039 | #undef PVOP_CALL3 | ||
1040 | #undef PVOP_VCALL4 | ||
1041 | #undef PVOP_CALL4 | ||
1042 | |||
1043 | #else /* __ASSEMBLY__ */ | ||
1044 | |||
1045 | #define PARA_PATCH(off) ((off) / 4) | ||
1046 | |||
1047 | #define PARA_SITE(ptype, clobbers, ops) \ | ||
1048 | 771:; \ | ||
1049 | ops; \ | ||
1050 | 772:; \ | ||
1051 | .pushsection .parainstructions,"a"; \ | ||
1052 | .long 771b; \ | ||
1053 | .byte ptype; \ | ||
1054 | .byte 772b-771b; \ | ||
1055 | .short clobbers; \ | ||
1056 | .popsection | ||
1057 | |||
1058 | #define INTERRUPT_RETURN \ | ||
1059 | PARA_SITE(PARA_PATCH(PARAVIRT_iret), CLBR_NONE, \ | ||
1060 | jmp *%cs:paravirt_ops+PARAVIRT_iret) | ||
1061 | |||
1062 | #define DISABLE_INTERRUPTS(clobbers) \ | ||
1063 | PARA_SITE(PARA_PATCH(PARAVIRT_irq_disable), clobbers, \ | ||
1064 | pushl %eax; pushl %ecx; pushl %edx; \ | ||
1065 | call *%cs:paravirt_ops+PARAVIRT_irq_disable; \ | ||
1066 | popl %edx; popl %ecx; popl %eax) \ | ||
1067 | |||
1068 | #define ENABLE_INTERRUPTS(clobbers) \ | ||
1069 | PARA_SITE(PARA_PATCH(PARAVIRT_irq_enable), clobbers, \ | ||
1070 | pushl %eax; pushl %ecx; pushl %edx; \ | ||
1071 | call *%cs:paravirt_ops+PARAVIRT_irq_enable; \ | ||
1072 | popl %edx; popl %ecx; popl %eax) | ||
1073 | |||
1074 | #define ENABLE_INTERRUPTS_SYSEXIT \ | ||
1075 | PARA_SITE(PARA_PATCH(PARAVIRT_irq_enable_sysexit), CLBR_NONE, \ | ||
1076 | jmp *%cs:paravirt_ops+PARAVIRT_irq_enable_sysexit) | ||
1077 | |||
1078 | #define GET_CR0_INTO_EAX \ | ||
1079 | push %ecx; push %edx; \ | ||
1080 | call *paravirt_ops+PARAVIRT_read_cr0; \ | ||
1081 | pop %edx; pop %ecx | ||
1082 | |||
1083 | #endif /* __ASSEMBLY__ */ | ||
1084 | #endif /* CONFIG_PARAVIRT */ | ||
1085 | #endif /* __ASM_PARAVIRT_H */ | ||
diff --git a/include/asm-x86/parport.h b/include/asm-x86/parport.h new file mode 100644 index 000000000000..2a31157349c9 --- /dev/null +++ b/include/asm-x86/parport.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "parport_32.h" | ||
3 | #else | ||
4 | # include "parport_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/parport_32.h b/include/asm-x86/parport_32.h new file mode 100644 index 000000000000..fa0e321e498e --- /dev/null +++ b/include/asm-x86/parport_32.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * parport.h: ia32-specific parport initialisation | ||
3 | * | ||
4 | * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk> | ||
5 | * | ||
6 | * This file should only be included by drivers/parport/parport_pc.c. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_I386_PARPORT_H | ||
10 | #define _ASM_I386_PARPORT_H 1 | ||
11 | |||
12 | static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma); | ||
13 | static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma) | ||
14 | { | ||
15 | return parport_pc_find_isa_ports (autoirq, autodma); | ||
16 | } | ||
17 | |||
18 | #endif /* !(_ASM_I386_PARPORT_H) */ | ||
diff --git a/include/asm-x86/parport_64.h b/include/asm-x86/parport_64.h new file mode 100644 index 000000000000..7135ef977c96 --- /dev/null +++ b/include/asm-x86/parport_64.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * parport.h: ia32-specific parport initialisation | ||
3 | * | ||
4 | * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk> | ||
5 | * | ||
6 | * This file should only be included by drivers/parport/parport_pc.c. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_X8664_PARPORT_H | ||
10 | #define _ASM_X8664_PARPORT_H 1 | ||
11 | |||
12 | static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma); | ||
13 | static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma) | ||
14 | { | ||
15 | return parport_pc_find_isa_ports (autoirq, autodma); | ||
16 | } | ||
17 | |||
18 | #endif | ||
diff --git a/include/asm-x86/pci-direct.h b/include/asm-x86/pci-direct.h new file mode 100644 index 000000000000..6823fa4f1afa --- /dev/null +++ b/include/asm-x86/pci-direct.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef ASM_PCI_DIRECT_H | ||
2 | #define ASM_PCI_DIRECT_H 1 | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | /* Direct PCI access. This is used for PCI accesses in early boot before | ||
7 | the PCI subsystem works. */ | ||
8 | |||
9 | extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset); | ||
10 | extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset); | ||
11 | extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset); | ||
12 | extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val); | ||
13 | extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val); | ||
14 | |||
15 | extern int early_pci_allowed(void); | ||
16 | |||
17 | #endif | ||
diff --git a/include/asm-x86/pci.h b/include/asm-x86/pci.h new file mode 100644 index 000000000000..a8cac8c2cde7 --- /dev/null +++ b/include/asm-x86/pci.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "pci_32.h" | ||
3 | #else | ||
4 | # include "pci_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/pci_32.h b/include/asm-x86/pci_32.h new file mode 100644 index 000000000000..4fcacc711385 --- /dev/null +++ b/include/asm-x86/pci_32.h | |||
@@ -0,0 +1,90 @@ | |||
1 | #ifndef __i386_PCI_H | ||
2 | #define __i386_PCI_H | ||
3 | |||
4 | |||
5 | #ifdef __KERNEL__ | ||
6 | |||
7 | struct pci_sysdata { | ||
8 | int node; /* NUMA node */ | ||
9 | }; | ||
10 | |||
11 | /* scan a bus after allocating a pci_sysdata for it */ | ||
12 | extern struct pci_bus *pci_scan_bus_with_sysdata(int busno); | ||
13 | |||
14 | #include <linux/mm.h> /* for struct page */ | ||
15 | |||
16 | /* Can be used to override the logic in pci_scan_bus for skipping | ||
17 | already-configured bus numbers - to be used for buggy BIOSes | ||
18 | or architectures with incomplete PCI setup by the loader */ | ||
19 | |||
20 | #ifdef CONFIG_PCI | ||
21 | extern unsigned int pcibios_assign_all_busses(void); | ||
22 | #else | ||
23 | #define pcibios_assign_all_busses() 0 | ||
24 | #endif | ||
25 | #define pcibios_scan_all_fns(a, b) 0 | ||
26 | |||
27 | extern unsigned long pci_mem_start; | ||
28 | #define PCIBIOS_MIN_IO 0x1000 | ||
29 | #define PCIBIOS_MIN_MEM (pci_mem_start) | ||
30 | |||
31 | #define PCIBIOS_MIN_CARDBUS_IO 0x4000 | ||
32 | |||
33 | void pcibios_config_init(void); | ||
34 | struct pci_bus * pcibios_scan_root(int bus); | ||
35 | |||
36 | void pcibios_set_master(struct pci_dev *dev); | ||
37 | void pcibios_penalize_isa_irq(int irq, int active); | ||
38 | struct irq_routing_table *pcibios_get_irq_routing_table(void); | ||
39 | int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq); | ||
40 | |||
41 | /* Dynamic DMA mapping stuff. | ||
42 | * i386 has everything mapped statically. | ||
43 | */ | ||
44 | |||
45 | #include <linux/types.h> | ||
46 | #include <linux/slab.h> | ||
47 | #include <asm/scatterlist.h> | ||
48 | #include <linux/string.h> | ||
49 | #include <asm/io.h> | ||
50 | |||
51 | struct pci_dev; | ||
52 | |||
53 | /* The PCI address space does equal the physical memory | ||
54 | * address space. The networking and block device layers use | ||
55 | * this boolean for bounce buffer decisions. | ||
56 | */ | ||
57 | #define PCI_DMA_BUS_IS_PHYS (1) | ||
58 | |||
59 | /* pci_unmap_{page,single} is a nop so... */ | ||
60 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) | ||
61 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) | ||
62 | #define pci_unmap_addr(PTR, ADDR_NAME) (0) | ||
63 | #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) | ||
64 | #define pci_unmap_len(PTR, LEN_NAME) (0) | ||
65 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) | ||
66 | |||
67 | #define HAVE_PCI_MMAP | ||
68 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | ||
69 | enum pci_mmap_state mmap_state, int write_combine); | ||
70 | |||
71 | |||
72 | #ifdef CONFIG_PCI | ||
73 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
74 | enum pci_dma_burst_strategy *strat, | ||
75 | unsigned long *strategy_parameter) | ||
76 | { | ||
77 | *strat = PCI_DMA_BURST_INFINITY; | ||
78 | *strategy_parameter = ~0UL; | ||
79 | } | ||
80 | #endif | ||
81 | |||
82 | #endif /* __KERNEL__ */ | ||
83 | |||
84 | /* implement the pci_ DMA API in terms of the generic device dma_ one */ | ||
85 | #include <asm-generic/pci-dma-compat.h> | ||
86 | |||
87 | /* generic pci stuff */ | ||
88 | #include <asm-generic/pci.h> | ||
89 | |||
90 | #endif /* __i386_PCI_H */ | ||
diff --git a/include/asm-x86/pci_64.h b/include/asm-x86/pci_64.h new file mode 100644 index 000000000000..5da8cb0c0599 --- /dev/null +++ b/include/asm-x86/pci_64.h | |||
@@ -0,0 +1,126 @@ | |||
1 | #ifndef __x8664_PCI_H | ||
2 | #define __x8664_PCI_H | ||
3 | |||
4 | #include <asm/io.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | |||
8 | struct pci_sysdata { | ||
9 | int node; /* NUMA node */ | ||
10 | void* iommu; /* IOMMU private data */ | ||
11 | }; | ||
12 | |||
13 | extern struct pci_bus *pci_scan_bus_with_sysdata(int busno); | ||
14 | |||
15 | #ifdef CONFIG_CALGARY_IOMMU | ||
16 | static inline void* pci_iommu(struct pci_bus *bus) | ||
17 | { | ||
18 | struct pci_sysdata *sd = bus->sysdata; | ||
19 | return sd->iommu; | ||
20 | } | ||
21 | |||
22 | static inline void set_pci_iommu(struct pci_bus *bus, void *val) | ||
23 | { | ||
24 | struct pci_sysdata *sd = bus->sysdata; | ||
25 | sd->iommu = val; | ||
26 | } | ||
27 | #endif /* CONFIG_CALGARY_IOMMU */ | ||
28 | |||
29 | #include <linux/mm.h> /* for struct page */ | ||
30 | |||
31 | /* Can be used to override the logic in pci_scan_bus for skipping | ||
32 | already-configured bus numbers - to be used for buggy BIOSes | ||
33 | or architectures with incomplete PCI setup by the loader */ | ||
34 | |||
35 | #ifdef CONFIG_PCI | ||
36 | extern unsigned int pcibios_assign_all_busses(void); | ||
37 | #else | ||
38 | #define pcibios_assign_all_busses() 0 | ||
39 | #endif | ||
40 | #define pcibios_scan_all_fns(a, b) 0 | ||
41 | |||
42 | extern unsigned long pci_mem_start; | ||
43 | #define PCIBIOS_MIN_IO 0x1000 | ||
44 | #define PCIBIOS_MIN_MEM (pci_mem_start) | ||
45 | |||
46 | #define PCIBIOS_MIN_CARDBUS_IO 0x4000 | ||
47 | |||
48 | void pcibios_config_init(void); | ||
49 | struct pci_bus * pcibios_scan_root(int bus); | ||
50 | extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value); | ||
51 | extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value); | ||
52 | |||
53 | void pcibios_set_master(struct pci_dev *dev); | ||
54 | void pcibios_penalize_isa_irq(int irq, int active); | ||
55 | struct irq_routing_table *pcibios_get_irq_routing_table(void); | ||
56 | int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq); | ||
57 | |||
58 | #include <linux/types.h> | ||
59 | #include <linux/slab.h> | ||
60 | #include <asm/scatterlist.h> | ||
61 | #include <linux/string.h> | ||
62 | #include <asm/page.h> | ||
63 | |||
64 | extern void pci_iommu_alloc(void); | ||
65 | extern int iommu_setup(char *opt); | ||
66 | |||
67 | /* The PCI address space does equal the physical memory | ||
68 | * address space. The networking and block device layers use | ||
69 | * this boolean for bounce buffer decisions | ||
70 | * | ||
71 | * On AMD64 it mostly equals, but we set it to zero if a hardware | ||
72 | * IOMMU (gart) of sotware IOMMU (swiotlb) is available. | ||
73 | */ | ||
74 | #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) | ||
75 | |||
76 | #if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU) | ||
77 | |||
78 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ | ||
79 | dma_addr_t ADDR_NAME; | ||
80 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ | ||
81 | __u32 LEN_NAME; | ||
82 | #define pci_unmap_addr(PTR, ADDR_NAME) \ | ||
83 | ((PTR)->ADDR_NAME) | ||
84 | #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \ | ||
85 | (((PTR)->ADDR_NAME) = (VAL)) | ||
86 | #define pci_unmap_len(PTR, LEN_NAME) \ | ||
87 | ((PTR)->LEN_NAME) | ||
88 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \ | ||
89 | (((PTR)->LEN_NAME) = (VAL)) | ||
90 | |||
91 | #else | ||
92 | /* No IOMMU */ | ||
93 | |||
94 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) | ||
95 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) | ||
96 | #define pci_unmap_addr(PTR, ADDR_NAME) (0) | ||
97 | #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) | ||
98 | #define pci_unmap_len(PTR, LEN_NAME) (0) | ||
99 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) | ||
100 | |||
101 | #endif | ||
102 | |||
103 | #include <asm-generic/pci-dma-compat.h> | ||
104 | |||
105 | #ifdef CONFIG_PCI | ||
106 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
107 | enum pci_dma_burst_strategy *strat, | ||
108 | unsigned long *strategy_parameter) | ||
109 | { | ||
110 | *strat = PCI_DMA_BURST_INFINITY; | ||
111 | *strategy_parameter = ~0UL; | ||
112 | } | ||
113 | #endif | ||
114 | |||
115 | #define HAVE_PCI_MMAP | ||
116 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | ||
117 | enum pci_mmap_state mmap_state, int write_combine); | ||
118 | |||
119 | #endif /* __KERNEL__ */ | ||
120 | |||
121 | /* generic pci stuff */ | ||
122 | #ifdef CONFIG_PCI | ||
123 | #include <asm-generic/pci.h> | ||
124 | #endif | ||
125 | |||
126 | #endif /* __x8664_PCI_H */ | ||
diff --git a/include/asm-x86/pda.h b/include/asm-x86/pda.h new file mode 100644 index 000000000000..5642634843c4 --- /dev/null +++ b/include/asm-x86/pda.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef X86_64_PDA_H | ||
2 | #define X86_64_PDA_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | #include <linux/stddef.h> | ||
6 | #include <linux/types.h> | ||
7 | #include <linux/cache.h> | ||
8 | #include <asm/page.h> | ||
9 | |||
10 | /* Per processor datastructure. %gs points to it while the kernel runs */ | ||
11 | struct x8664_pda { | ||
12 | struct task_struct *pcurrent; /* 0 Current process */ | ||
13 | unsigned long data_offset; /* 8 Per cpu data offset from linker | ||
14 | address */ | ||
15 | unsigned long kernelstack; /* 16 top of kernel stack for current */ | ||
16 | unsigned long oldrsp; /* 24 user rsp for system call */ | ||
17 | int irqcount; /* 32 Irq nesting counter. Starts with -1 */ | ||
18 | int cpunumber; /* 36 Logical CPU number */ | ||
19 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
20 | unsigned long stack_canary; /* 40 stack canary value */ | ||
21 | /* gcc-ABI: this canary MUST be at | ||
22 | offset 40!!! */ | ||
23 | #endif | ||
24 | char *irqstackptr; | ||
25 | int nodenumber; /* number of current node */ | ||
26 | unsigned int __softirq_pending; | ||
27 | unsigned int __nmi_count; /* number of NMI on this CPUs */ | ||
28 | short mmu_state; | ||
29 | short isidle; | ||
30 | struct mm_struct *active_mm; | ||
31 | unsigned apic_timer_irqs; | ||
32 | } ____cacheline_aligned_in_smp; | ||
33 | |||
34 | extern struct x8664_pda *_cpu_pda[]; | ||
35 | extern struct x8664_pda boot_cpu_pda[]; | ||
36 | |||
37 | #define cpu_pda(i) (_cpu_pda[i]) | ||
38 | |||
39 | /* | ||
40 | * There is no fast way to get the base address of the PDA, all the accesses | ||
41 | * have to mention %fs/%gs. So it needs to be done this Torvaldian way. | ||
42 | */ | ||
43 | extern void __bad_pda_field(void) __attribute__((noreturn)); | ||
44 | |||
45 | /* | ||
46 | * proxy_pda doesn't actually exist, but tell gcc it is accessed for | ||
47 | * all PDA accesses so it gets read/write dependencies right. | ||
48 | */ | ||
49 | extern struct x8664_pda _proxy_pda; | ||
50 | |||
51 | #define pda_offset(field) offsetof(struct x8664_pda, field) | ||
52 | |||
53 | #define pda_to_op(op,field,val) do { \ | ||
54 | typedef typeof(_proxy_pda.field) T__; \ | ||
55 | if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \ | ||
56 | switch (sizeof(_proxy_pda.field)) { \ | ||
57 | case 2: \ | ||
58 | asm(op "w %1,%%gs:%c2" : \ | ||
59 | "+m" (_proxy_pda.field) : \ | ||
60 | "ri" ((T__)val), \ | ||
61 | "i"(pda_offset(field))); \ | ||
62 | break; \ | ||
63 | case 4: \ | ||
64 | asm(op "l %1,%%gs:%c2" : \ | ||
65 | "+m" (_proxy_pda.field) : \ | ||
66 | "ri" ((T__)val), \ | ||
67 | "i" (pda_offset(field))); \ | ||
68 | break; \ | ||
69 | case 8: \ | ||
70 | asm(op "q %1,%%gs:%c2": \ | ||
71 | "+m" (_proxy_pda.field) : \ | ||
72 | "ri" ((T__)val), \ | ||
73 | "i"(pda_offset(field))); \ | ||
74 | break; \ | ||
75 | default: \ | ||
76 | __bad_pda_field(); \ | ||
77 | } \ | ||
78 | } while (0) | ||
79 | |||
80 | #define pda_from_op(op,field) ({ \ | ||
81 | typeof(_proxy_pda.field) ret__; \ | ||
82 | switch (sizeof(_proxy_pda.field)) { \ | ||
83 | case 2: \ | ||
84 | asm(op "w %%gs:%c1,%0" : \ | ||
85 | "=r" (ret__) : \ | ||
86 | "i" (pda_offset(field)), \ | ||
87 | "m" (_proxy_pda.field)); \ | ||
88 | break; \ | ||
89 | case 4: \ | ||
90 | asm(op "l %%gs:%c1,%0": \ | ||
91 | "=r" (ret__): \ | ||
92 | "i" (pda_offset(field)), \ | ||
93 | "m" (_proxy_pda.field)); \ | ||
94 | break; \ | ||
95 | case 8: \ | ||
96 | asm(op "q %%gs:%c1,%0": \ | ||
97 | "=r" (ret__) : \ | ||
98 | "i" (pda_offset(field)), \ | ||
99 | "m" (_proxy_pda.field)); \ | ||
100 | break; \ | ||
101 | default: \ | ||
102 | __bad_pda_field(); \ | ||
103 | } \ | ||
104 | ret__; }) | ||
105 | |||
106 | #define read_pda(field) pda_from_op("mov",field) | ||
107 | #define write_pda(field,val) pda_to_op("mov",field,val) | ||
108 | #define add_pda(field,val) pda_to_op("add",field,val) | ||
109 | #define sub_pda(field,val) pda_to_op("sub",field,val) | ||
110 | #define or_pda(field,val) pda_to_op("or",field,val) | ||
111 | |||
112 | /* This is not atomic against other CPUs -- CPU preemption needs to be off */ | ||
113 | #define test_and_clear_bit_pda(bit,field) ({ \ | ||
114 | int old__; \ | ||
115 | asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \ | ||
116 | : "=r" (old__), "+m" (_proxy_pda.field) \ | ||
117 | : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \ | ||
118 | old__; \ | ||
119 | }) | ||
120 | |||
121 | #endif | ||
122 | |||
123 | #define PDA_STACKOFFSET (5*8) | ||
124 | |||
125 | #endif | ||
diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h new file mode 100644 index 000000000000..a1aaad274cca --- /dev/null +++ b/include/asm-x86/percpu.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "percpu_32.h" | ||
3 | #else | ||
4 | # include "percpu_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/percpu_32.h b/include/asm-x86/percpu_32.h new file mode 100644 index 000000000000..a7ebd436f3cc --- /dev/null +++ b/include/asm-x86/percpu_32.h | |||
@@ -0,0 +1,154 @@ | |||
1 | #ifndef __ARCH_I386_PERCPU__ | ||
2 | #define __ARCH_I386_PERCPU__ | ||
3 | |||
4 | #ifdef __ASSEMBLY__ | ||
5 | |||
6 | /* | ||
7 | * PER_CPU finds an address of a per-cpu variable. | ||
8 | * | ||
9 | * Args: | ||
10 | * var - variable name | ||
11 | * reg - 32bit register | ||
12 | * | ||
13 | * The resulting address is stored in the "reg" argument. | ||
14 | * | ||
15 | * Example: | ||
16 | * PER_CPU(cpu_gdt_descr, %ebx) | ||
17 | */ | ||
18 | #ifdef CONFIG_SMP | ||
19 | #define PER_CPU(var, reg) \ | ||
20 | movl %fs:per_cpu__##this_cpu_off, reg; \ | ||
21 | lea per_cpu__##var(reg), reg | ||
22 | #define PER_CPU_VAR(var) %fs:per_cpu__##var | ||
23 | #else /* ! SMP */ | ||
24 | #define PER_CPU(var, reg) \ | ||
25 | movl $per_cpu__##var, reg | ||
26 | #define PER_CPU_VAR(var) per_cpu__##var | ||
27 | #endif /* SMP */ | ||
28 | |||
29 | #else /* ...!ASSEMBLY */ | ||
30 | |||
31 | /* | ||
32 | * PER_CPU finds an address of a per-cpu variable. | ||
33 | * | ||
34 | * Args: | ||
35 | * var - variable name | ||
36 | * cpu - 32bit register containing the current CPU number | ||
37 | * | ||
38 | * The resulting address is stored in the "cpu" argument. | ||
39 | * | ||
40 | * Example: | ||
41 | * PER_CPU(cpu_gdt_descr, %ebx) | ||
42 | */ | ||
43 | #ifdef CONFIG_SMP | ||
44 | /* Same as generic implementation except for optimized local access. */ | ||
45 | #define __GENERIC_PER_CPU | ||
46 | |||
47 | /* This is used for other cpus to find our section. */ | ||
48 | extern unsigned long __per_cpu_offset[]; | ||
49 | |||
50 | #define per_cpu_offset(x) (__per_cpu_offset[x]) | ||
51 | |||
52 | /* Separate out the type, so (int[3], foo) works. */ | ||
53 | #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name | ||
54 | #define DEFINE_PER_CPU(type, name) \ | ||
55 | __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name | ||
56 | |||
57 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
58 | __attribute__((__section__(".data.percpu.shared_aligned"))) \ | ||
59 | __typeof__(type) per_cpu__##name \ | ||
60 | ____cacheline_aligned_in_smp | ||
61 | |||
62 | /* We can use this directly for local CPU (faster). */ | ||
63 | DECLARE_PER_CPU(unsigned long, this_cpu_off); | ||
64 | |||
65 | /* var is in discarded region: offset to particular copy we want */ | ||
66 | #define per_cpu(var, cpu) (*({ \ | ||
67 | extern int simple_indentifier_##var(void); \ | ||
68 | RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); })) | ||
69 | |||
70 | #define __raw_get_cpu_var(var) (*({ \ | ||
71 | extern int simple_indentifier_##var(void); \ | ||
72 | RELOC_HIDE(&per_cpu__##var, x86_read_percpu(this_cpu_off)); \ | ||
73 | })) | ||
74 | |||
75 | #define __get_cpu_var(var) __raw_get_cpu_var(var) | ||
76 | |||
77 | /* A macro to avoid #include hell... */ | ||
78 | #define percpu_modcopy(pcpudst, src, size) \ | ||
79 | do { \ | ||
80 | unsigned int __i; \ | ||
81 | for_each_possible_cpu(__i) \ | ||
82 | memcpy((pcpudst)+__per_cpu_offset[__i], \ | ||
83 | (src), (size)); \ | ||
84 | } while (0) | ||
85 | |||
86 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | ||
87 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | ||
88 | |||
89 | /* fs segment starts at (positive) offset == __per_cpu_offset[cpu] */ | ||
90 | #define __percpu_seg "%%fs:" | ||
91 | #else /* !SMP */ | ||
92 | #include <asm-generic/percpu.h> | ||
93 | #define __percpu_seg "" | ||
94 | #endif /* SMP */ | ||
95 | |||
96 | /* For arch-specific code, we can use direct single-insn ops (they | ||
97 | * don't give an lvalue though). */ | ||
98 | extern void __bad_percpu_size(void); | ||
99 | |||
100 | #define percpu_to_op(op,var,val) \ | ||
101 | do { \ | ||
102 | typedef typeof(var) T__; \ | ||
103 | if (0) { T__ tmp__; tmp__ = (val); } \ | ||
104 | switch (sizeof(var)) { \ | ||
105 | case 1: \ | ||
106 | asm(op "b %1,"__percpu_seg"%0" \ | ||
107 | : "+m" (var) \ | ||
108 | :"ri" ((T__)val)); \ | ||
109 | break; \ | ||
110 | case 2: \ | ||
111 | asm(op "w %1,"__percpu_seg"%0" \ | ||
112 | : "+m" (var) \ | ||
113 | :"ri" ((T__)val)); \ | ||
114 | break; \ | ||
115 | case 4: \ | ||
116 | asm(op "l %1,"__percpu_seg"%0" \ | ||
117 | : "+m" (var) \ | ||
118 | :"ri" ((T__)val)); \ | ||
119 | break; \ | ||
120 | default: __bad_percpu_size(); \ | ||
121 | } \ | ||
122 | } while (0) | ||
123 | |||
124 | #define percpu_from_op(op,var) \ | ||
125 | ({ \ | ||
126 | typeof(var) ret__; \ | ||
127 | switch (sizeof(var)) { \ | ||
128 | case 1: \ | ||
129 | asm(op "b "__percpu_seg"%1,%0" \ | ||
130 | : "=r" (ret__) \ | ||
131 | : "m" (var)); \ | ||
132 | break; \ | ||
133 | case 2: \ | ||
134 | asm(op "w "__percpu_seg"%1,%0" \ | ||
135 | : "=r" (ret__) \ | ||
136 | : "m" (var)); \ | ||
137 | break; \ | ||
138 | case 4: \ | ||
139 | asm(op "l "__percpu_seg"%1,%0" \ | ||
140 | : "=r" (ret__) \ | ||
141 | : "m" (var)); \ | ||
142 | break; \ | ||
143 | default: __bad_percpu_size(); \ | ||
144 | } \ | ||
145 | ret__; }) | ||
146 | |||
147 | #define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var) | ||
148 | #define x86_write_percpu(var,val) percpu_to_op("mov", per_cpu__##var, val) | ||
149 | #define x86_add_percpu(var,val) percpu_to_op("add", per_cpu__##var, val) | ||
150 | #define x86_sub_percpu(var,val) percpu_to_op("sub", per_cpu__##var, val) | ||
151 | #define x86_or_percpu(var,val) percpu_to_op("or", per_cpu__##var, val) | ||
152 | #endif /* !__ASSEMBLY__ */ | ||
153 | |||
154 | #endif /* __ARCH_I386_PERCPU__ */ | ||
diff --git a/include/asm-x86/percpu_64.h b/include/asm-x86/percpu_64.h new file mode 100644 index 000000000000..5abd48270101 --- /dev/null +++ b/include/asm-x86/percpu_64.h | |||
@@ -0,0 +1,68 @@ | |||
1 | #ifndef _ASM_X8664_PERCPU_H_ | ||
2 | #define _ASM_X8664_PERCPU_H_ | ||
3 | #include <linux/compiler.h> | ||
4 | |||
5 | /* Same as asm-generic/percpu.h, except that we store the per cpu offset | ||
6 | in the PDA. Longer term the PDA and every per cpu variable | ||
7 | should be just put into a single section and referenced directly | ||
8 | from %gs */ | ||
9 | |||
10 | #ifdef CONFIG_SMP | ||
11 | |||
12 | #include <asm/pda.h> | ||
13 | |||
14 | #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) | ||
15 | #define __my_cpu_offset() read_pda(data_offset) | ||
16 | |||
17 | #define per_cpu_offset(x) (__per_cpu_offset(x)) | ||
18 | |||
19 | /* Separate out the type, so (int[3], foo) works. */ | ||
20 | #define DEFINE_PER_CPU(type, name) \ | ||
21 | __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name | ||
22 | |||
23 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
24 | __attribute__((__section__(".data.percpu.shared_aligned"))) \ | ||
25 | __typeof__(type) per_cpu__##name \ | ||
26 | ____cacheline_internodealigned_in_smp | ||
27 | |||
28 | /* var is in discarded region: offset to particular copy we want */ | ||
29 | #define per_cpu(var, cpu) (*({ \ | ||
30 | extern int simple_identifier_##var(void); \ | ||
31 | RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)); })) | ||
32 | #define __get_cpu_var(var) (*({ \ | ||
33 | extern int simple_identifier_##var(void); \ | ||
34 | RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); })) | ||
35 | #define __raw_get_cpu_var(var) (*({ \ | ||
36 | extern int simple_identifier_##var(void); \ | ||
37 | RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); })) | ||
38 | |||
39 | /* A macro to avoid #include hell... */ | ||
40 | #define percpu_modcopy(pcpudst, src, size) \ | ||
41 | do { \ | ||
42 | unsigned int __i; \ | ||
43 | for_each_possible_cpu(__i) \ | ||
44 | memcpy((pcpudst)+__per_cpu_offset(__i), \ | ||
45 | (src), (size)); \ | ||
46 | } while (0) | ||
47 | |||
48 | extern void setup_per_cpu_areas(void); | ||
49 | |||
50 | #else /* ! SMP */ | ||
51 | |||
52 | #define DEFINE_PER_CPU(type, name) \ | ||
53 | __typeof__(type) per_cpu__##name | ||
54 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
55 | DEFINE_PER_CPU(type, name) | ||
56 | |||
57 | #define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var)) | ||
58 | #define __get_cpu_var(var) per_cpu__##var | ||
59 | #define __raw_get_cpu_var(var) per_cpu__##var | ||
60 | |||
61 | #endif /* SMP */ | ||
62 | |||
63 | #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name | ||
64 | |||
65 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | ||
66 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | ||
67 | |||
68 | #endif /* _ASM_X8664_PERCPU_H_ */ | ||
diff --git a/include/asm-x86/pgalloc.h b/include/asm-x86/pgalloc.h new file mode 100644 index 000000000000..5886eed05886 --- /dev/null +++ b/include/asm-x86/pgalloc.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "pgalloc_32.h" | ||
3 | #else | ||
4 | # include "pgalloc_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h new file mode 100644 index 000000000000..f2fc33ceb9f2 --- /dev/null +++ b/include/asm-x86/pgalloc_32.h | |||
@@ -0,0 +1,68 @@ | |||
1 | #ifndef _I386_PGALLOC_H | ||
2 | #define _I386_PGALLOC_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/mm.h> /* for struct page */ | ||
6 | |||
7 | #ifdef CONFIG_PARAVIRT | ||
8 | #include <asm/paravirt.h> | ||
9 | #else | ||
10 | #define paravirt_alloc_pt(mm, pfn) do { } while (0) | ||
11 | #define paravirt_alloc_pd(pfn) do { } while (0) | ||
12 | #define paravirt_alloc_pd(pfn) do { } while (0) | ||
13 | #define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0) | ||
14 | #define paravirt_release_pt(pfn) do { } while (0) | ||
15 | #define paravirt_release_pd(pfn) do { } while (0) | ||
16 | #endif | ||
17 | |||
18 | #define pmd_populate_kernel(mm, pmd, pte) \ | ||
19 | do { \ | ||
20 | paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \ | ||
21 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); \ | ||
22 | } while (0) | ||
23 | |||
24 | #define pmd_populate(mm, pmd, pte) \ | ||
25 | do { \ | ||
26 | paravirt_alloc_pt(mm, page_to_pfn(pte)); \ | ||
27 | set_pmd(pmd, __pmd(_PAGE_TABLE + \ | ||
28 | ((unsigned long long)page_to_pfn(pte) << \ | ||
29 | (unsigned long long) PAGE_SHIFT))); \ | ||
30 | } while (0) | ||
31 | |||
32 | /* | ||
33 | * Allocate and free page tables. | ||
34 | */ | ||
35 | extern pgd_t *pgd_alloc(struct mm_struct *); | ||
36 | extern void pgd_free(pgd_t *pgd); | ||
37 | |||
38 | extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); | ||
39 | extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); | ||
40 | |||
41 | static inline void pte_free_kernel(pte_t *pte) | ||
42 | { | ||
43 | free_page((unsigned long)pte); | ||
44 | } | ||
45 | |||
46 | static inline void pte_free(struct page *pte) | ||
47 | { | ||
48 | __free_page(pte); | ||
49 | } | ||
50 | |||
51 | |||
52 | #define __pte_free_tlb(tlb,pte) \ | ||
53 | do { \ | ||
54 | paravirt_release_pt(page_to_pfn(pte)); \ | ||
55 | tlb_remove_page((tlb),(pte)); \ | ||
56 | } while (0) | ||
57 | |||
58 | #ifdef CONFIG_X86_PAE | ||
59 | /* | ||
60 | * In the PAE case we free the pmds as part of the pgd. | ||
61 | */ | ||
62 | #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) | ||
63 | #define pmd_free(x) do { } while (0) | ||
64 | #define __pmd_free_tlb(tlb,x) do { } while (0) | ||
65 | #define pud_populate(mm, pmd, pte) BUG() | ||
66 | #endif | ||
67 | |||
68 | #endif /* _I386_PGALLOC_H */ | ||
diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h new file mode 100644 index 000000000000..8bb564687860 --- /dev/null +++ b/include/asm-x86/pgalloc_64.h | |||
@@ -0,0 +1,119 @@ | |||
1 | #ifndef _X86_64_PGALLOC_H | ||
2 | #define _X86_64_PGALLOC_H | ||
3 | |||
4 | #include <asm/pda.h> | ||
5 | #include <linux/threads.h> | ||
6 | #include <linux/mm.h> | ||
7 | |||
8 | #define pmd_populate_kernel(mm, pmd, pte) \ | ||
9 | set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte))) | ||
10 | #define pud_populate(mm, pud, pmd) \ | ||
11 | set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd))) | ||
12 | #define pgd_populate(mm, pgd, pud) \ | ||
13 | set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud))) | ||
14 | |||
15 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte) | ||
16 | { | ||
17 | set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT))); | ||
18 | } | ||
19 | |||
20 | static inline void pmd_free(pmd_t *pmd) | ||
21 | { | ||
22 | BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); | ||
23 | free_page((unsigned long)pmd); | ||
24 | } | ||
25 | |||
26 | static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr) | ||
27 | { | ||
28 | return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
29 | } | ||
30 | |||
31 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) | ||
32 | { | ||
33 | return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
34 | } | ||
35 | |||
36 | static inline void pud_free (pud_t *pud) | ||
37 | { | ||
38 | BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); | ||
39 | free_page((unsigned long)pud); | ||
40 | } | ||
41 | |||
42 | static inline void pgd_list_add(pgd_t *pgd) | ||
43 | { | ||
44 | struct page *page = virt_to_page(pgd); | ||
45 | |||
46 | spin_lock(&pgd_lock); | ||
47 | list_add(&page->lru, &pgd_list); | ||
48 | spin_unlock(&pgd_lock); | ||
49 | } | ||
50 | |||
51 | static inline void pgd_list_del(pgd_t *pgd) | ||
52 | { | ||
53 | struct page *page = virt_to_page(pgd); | ||
54 | |||
55 | spin_lock(&pgd_lock); | ||
56 | list_del(&page->lru); | ||
57 | spin_unlock(&pgd_lock); | ||
58 | } | ||
59 | |||
60 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | ||
61 | { | ||
62 | unsigned boundary; | ||
63 | pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); | ||
64 | if (!pgd) | ||
65 | return NULL; | ||
66 | pgd_list_add(pgd); | ||
67 | /* | ||
68 | * Copy kernel pointers in from init. | ||
69 | * Could keep a freelist or slab cache of those because the kernel | ||
70 | * part never changes. | ||
71 | */ | ||
72 | boundary = pgd_index(__PAGE_OFFSET); | ||
73 | memset(pgd, 0, boundary * sizeof(pgd_t)); | ||
74 | memcpy(pgd + boundary, | ||
75 | init_level4_pgt + boundary, | ||
76 | (PTRS_PER_PGD - boundary) * sizeof(pgd_t)); | ||
77 | return pgd; | ||
78 | } | ||
79 | |||
80 | static inline void pgd_free(pgd_t *pgd) | ||
81 | { | ||
82 | BUG_ON((unsigned long)pgd & (PAGE_SIZE-1)); | ||
83 | pgd_list_del(pgd); | ||
84 | free_page((unsigned long)pgd); | ||
85 | } | ||
86 | |||
87 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | ||
88 | { | ||
89 | return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
90 | } | ||
91 | |||
92 | static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | ||
93 | { | ||
94 | void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
95 | if (!p) | ||
96 | return NULL; | ||
97 | return virt_to_page(p); | ||
98 | } | ||
99 | |||
100 | /* Should really implement gc for free page table pages. This could be | ||
101 | done with a reference count in struct page. */ | ||
102 | |||
103 | static inline void pte_free_kernel(pte_t *pte) | ||
104 | { | ||
105 | BUG_ON((unsigned long)pte & (PAGE_SIZE-1)); | ||
106 | free_page((unsigned long)pte); | ||
107 | } | ||
108 | |||
109 | static inline void pte_free(struct page *pte) | ||
110 | { | ||
111 | __free_page(pte); | ||
112 | } | ||
113 | |||
114 | #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) | ||
115 | |||
116 | #define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) | ||
117 | #define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) | ||
118 | |||
119 | #endif /* _X86_64_PGALLOC_H */ | ||
diff --git a/include/asm-x86/pgtable-2level-defs.h b/include/asm-x86/pgtable-2level-defs.h new file mode 100644 index 000000000000..0f71c9f13da4 --- /dev/null +++ b/include/asm-x86/pgtable-2level-defs.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _I386_PGTABLE_2LEVEL_DEFS_H | ||
2 | #define _I386_PGTABLE_2LEVEL_DEFS_H | ||
3 | |||
4 | #define SHARED_KERNEL_PMD 0 | ||
5 | |||
6 | /* | ||
7 | * traditional i386 two-level paging structure: | ||
8 | */ | ||
9 | |||
10 | #define PGDIR_SHIFT 22 | ||
11 | #define PTRS_PER_PGD 1024 | ||
12 | |||
13 | /* | ||
14 | * the i386 is two-level, so we don't really have any | ||
15 | * PMD directory physically. | ||
16 | */ | ||
17 | |||
18 | #define PTRS_PER_PTE 1024 | ||
19 | |||
20 | #endif /* _I386_PGTABLE_2LEVEL_DEFS_H */ | ||
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h new file mode 100644 index 000000000000..84b03cf56a79 --- /dev/null +++ b/include/asm-x86/pgtable-2level.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef _I386_PGTABLE_2LEVEL_H | ||
2 | #define _I386_PGTABLE_2LEVEL_H | ||
3 | |||
4 | #define pte_ERROR(e) \ | ||
5 | printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low) | ||
6 | #define pgd_ERROR(e) \ | ||
7 | printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) | ||
8 | |||
9 | /* | ||
10 | * Certain architectures need to do special things when PTEs | ||
11 | * within a page table are directly modified. Thus, the following | ||
12 | * hook is made available. | ||
13 | */ | ||
14 | static inline void native_set_pte(pte_t *ptep , pte_t pte) | ||
15 | { | ||
16 | *ptep = pte; | ||
17 | } | ||
18 | static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr, | ||
19 | pte_t *ptep , pte_t pte) | ||
20 | { | ||
21 | native_set_pte(ptep, pte); | ||
22 | } | ||
23 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) | ||
24 | { | ||
25 | *pmdp = pmd; | ||
26 | } | ||
27 | #ifndef CONFIG_PARAVIRT | ||
28 | #define set_pte(pteptr, pteval) native_set_pte(pteptr, pteval) | ||
29 | #define set_pte_at(mm,addr,ptep,pteval) native_set_pte_at(mm, addr, ptep, pteval) | ||
30 | #define set_pmd(pmdptr, pmdval) native_set_pmd(pmdptr, pmdval) | ||
31 | #endif | ||
32 | |||
33 | #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval) | ||
34 | #define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) | ||
35 | |||
36 | #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) | ||
37 | #define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) | ||
38 | |||
39 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *xp) | ||
40 | { | ||
41 | *xp = __pte(0); | ||
42 | } | ||
43 | |||
44 | #ifdef CONFIG_SMP | ||
45 | static inline pte_t native_ptep_get_and_clear(pte_t *xp) | ||
46 | { | ||
47 | return __pte(xchg(&xp->pte_low, 0)); | ||
48 | } | ||
49 | #else | ||
50 | #define native_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp) | ||
51 | #endif | ||
52 | |||
53 | #define pte_page(x) pfn_to_page(pte_pfn(x)) | ||
54 | #define pte_none(x) (!(x).pte_low) | ||
55 | #define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT) | ||
56 | #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | ||
57 | #define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | ||
58 | |||
59 | /* | ||
60 | * All present pages are kernel-executable: | ||
61 | */ | ||
62 | static inline int pte_exec_kernel(pte_t pte) | ||
63 | { | ||
64 | return 1; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Bits 0, 6 and 7 are taken, split up the 29 bits of offset | ||
69 | * into this range: | ||
70 | */ | ||
71 | #define PTE_FILE_MAX_BITS 29 | ||
72 | |||
73 | #define pte_to_pgoff(pte) \ | ||
74 | ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) | ||
75 | |||
76 | #define pgoff_to_pte(off) \ | ||
77 | ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE }) | ||
78 | |||
79 | /* Encode and de-code a swap entry */ | ||
80 | #define __swp_type(x) (((x).val >> 1) & 0x1f) | ||
81 | #define __swp_offset(x) ((x).val >> 8) | ||
82 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) | ||
83 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) | ||
84 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) | ||
85 | |||
86 | #endif /* _I386_PGTABLE_2LEVEL_H */ | ||
diff --git a/include/asm-x86/pgtable-3level-defs.h b/include/asm-x86/pgtable-3level-defs.h new file mode 100644 index 000000000000..c0df89f66e8b --- /dev/null +++ b/include/asm-x86/pgtable-3level-defs.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _I386_PGTABLE_3LEVEL_DEFS_H | ||
2 | #define _I386_PGTABLE_3LEVEL_DEFS_H | ||
3 | |||
4 | #ifdef CONFIG_PARAVIRT | ||
5 | #define SHARED_KERNEL_PMD (paravirt_ops.shared_kernel_pmd) | ||
6 | #else | ||
7 | #define SHARED_KERNEL_PMD 1 | ||
8 | #endif | ||
9 | |||
10 | /* | ||
11 | * PGDIR_SHIFT determines what a top-level page table entry can map | ||
12 | */ | ||
13 | #define PGDIR_SHIFT 30 | ||
14 | #define PTRS_PER_PGD 4 | ||
15 | |||
16 | /* | ||
17 | * PMD_SHIFT determines the size of the area a middle-level | ||
18 | * page table can map | ||
19 | */ | ||
20 | #define PMD_SHIFT 21 | ||
21 | #define PTRS_PER_PMD 512 | ||
22 | |||
23 | /* | ||
24 | * entries per page directory level | ||
25 | */ | ||
26 | #define PTRS_PER_PTE 512 | ||
27 | |||
28 | #endif /* _I386_PGTABLE_3LEVEL_DEFS_H */ | ||
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h new file mode 100644 index 000000000000..948a33414118 --- /dev/null +++ b/include/asm-x86/pgtable-3level.h | |||
@@ -0,0 +1,192 @@ | |||
1 | #ifndef _I386_PGTABLE_3LEVEL_H | ||
2 | #define _I386_PGTABLE_3LEVEL_H | ||
3 | |||
4 | /* | ||
5 | * Intel Physical Address Extension (PAE) Mode - three-level page | ||
6 | * tables on PPro+ CPUs. | ||
7 | * | ||
8 | * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> | ||
9 | */ | ||
10 | |||
11 | #define pte_ERROR(e) \ | ||
12 | printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) | ||
13 | #define pmd_ERROR(e) \ | ||
14 | printk("%s:%d: bad pmd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pmd_val(e)) | ||
15 | #define pgd_ERROR(e) \ | ||
16 | printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) | ||
17 | |||
18 | #define pud_none(pud) 0 | ||
19 | #define pud_bad(pud) 0 | ||
20 | #define pud_present(pud) 1 | ||
21 | |||
22 | /* | ||
23 | * All present pages with !NX bit are kernel-executable: | ||
24 | */ | ||
25 | static inline int pte_exec_kernel(pte_t pte) | ||
26 | { | ||
27 | return !(pte_val(pte) & _PAGE_NX); | ||
28 | } | ||
29 | |||
30 | /* Rules for using set_pte: the pte being assigned *must* be | ||
31 | * either not present or in a state where the hardware will | ||
32 | * not attempt to update the pte. In places where this is | ||
33 | * not possible, use pte_get_and_clear to obtain the old pte | ||
34 | * value and then use set_pte to update it. -ben | ||
35 | */ | ||
36 | static inline void native_set_pte(pte_t *ptep, pte_t pte) | ||
37 | { | ||
38 | ptep->pte_high = pte.pte_high; | ||
39 | smp_wmb(); | ||
40 | ptep->pte_low = pte.pte_low; | ||
41 | } | ||
42 | static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr, | ||
43 | pte_t *ptep , pte_t pte) | ||
44 | { | ||
45 | native_set_pte(ptep, pte); | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * Since this is only called on user PTEs, and the page fault handler | ||
50 | * must handle the already racy situation of simultaneous page faults, | ||
51 | * we are justified in merely clearing the PTE present bit, followed | ||
52 | * by a set. The ordering here is important. | ||
53 | */ | ||
54 | static inline void native_set_pte_present(struct mm_struct *mm, unsigned long addr, | ||
55 | pte_t *ptep, pte_t pte) | ||
56 | { | ||
57 | ptep->pte_low = 0; | ||
58 | smp_wmb(); | ||
59 | ptep->pte_high = pte.pte_high; | ||
60 | smp_wmb(); | ||
61 | ptep->pte_low = pte.pte_low; | ||
62 | } | ||
63 | |||
64 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) | ||
65 | { | ||
66 | set_64bit((unsigned long long *)(ptep),native_pte_val(pte)); | ||
67 | } | ||
68 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) | ||
69 | { | ||
70 | set_64bit((unsigned long long *)(pmdp),native_pmd_val(pmd)); | ||
71 | } | ||
72 | static inline void native_set_pud(pud_t *pudp, pud_t pud) | ||
73 | { | ||
74 | *pudp = pud; | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * For PTEs and PDEs, we must clear the P-bit first when clearing a page table | ||
79 | * entry, so clear the bottom half first and enforce ordering with a compiler | ||
80 | * barrier. | ||
81 | */ | ||
82 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
83 | { | ||
84 | ptep->pte_low = 0; | ||
85 | smp_wmb(); | ||
86 | ptep->pte_high = 0; | ||
87 | } | ||
88 | |||
89 | static inline void native_pmd_clear(pmd_t *pmd) | ||
90 | { | ||
91 | u32 *tmp = (u32 *)pmd; | ||
92 | *tmp = 0; | ||
93 | smp_wmb(); | ||
94 | *(tmp + 1) = 0; | ||
95 | } | ||
96 | |||
97 | #ifndef CONFIG_PARAVIRT | ||
98 | #define set_pte(ptep, pte) native_set_pte(ptep, pte) | ||
99 | #define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) | ||
100 | #define set_pte_present(mm, addr, ptep, pte) native_set_pte_present(mm, addr, ptep, pte) | ||
101 | #define set_pte_atomic(ptep, pte) native_set_pte_atomic(ptep, pte) | ||
102 | #define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd) | ||
103 | #define set_pud(pudp, pud) native_set_pud(pudp, pud) | ||
104 | #define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep) | ||
105 | #define pmd_clear(pmd) native_pmd_clear(pmd) | ||
106 | #endif | ||
107 | |||
108 | /* | ||
109 | * Pentium-II erratum A13: in PAE mode we explicitly have to flush | ||
110 | * the TLB via cr3 if the top-level pgd is changed... | ||
111 | * We do not let the generic code free and clear pgd entries due to | ||
112 | * this erratum. | ||
113 | */ | ||
114 | static inline void pud_clear (pud_t * pud) { } | ||
115 | |||
116 | #define pud_page(pud) \ | ||
117 | ((struct page *) __va(pud_val(pud) & PAGE_MASK)) | ||
118 | |||
119 | #define pud_page_vaddr(pud) \ | ||
120 | ((unsigned long) __va(pud_val(pud) & PAGE_MASK)) | ||
121 | |||
122 | |||
123 | /* Find an entry in the second-level page table.. */ | ||
124 | #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \ | ||
125 | pmd_index(address)) | ||
126 | |||
127 | #ifdef CONFIG_SMP | ||
128 | static inline pte_t native_ptep_get_and_clear(pte_t *ptep) | ||
129 | { | ||
130 | pte_t res; | ||
131 | |||
132 | /* xchg acts as a barrier before the setting of the high bits */ | ||
133 | res.pte_low = xchg(&ptep->pte_low, 0); | ||
134 | res.pte_high = ptep->pte_high; | ||
135 | ptep->pte_high = 0; | ||
136 | |||
137 | return res; | ||
138 | } | ||
139 | #else | ||
140 | #define native_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp) | ||
141 | #endif | ||
142 | |||
143 | #define __HAVE_ARCH_PTE_SAME | ||
144 | static inline int pte_same(pte_t a, pte_t b) | ||
145 | { | ||
146 | return a.pte_low == b.pte_low && a.pte_high == b.pte_high; | ||
147 | } | ||
148 | |||
149 | #define pte_page(x) pfn_to_page(pte_pfn(x)) | ||
150 | |||
151 | static inline int pte_none(pte_t pte) | ||
152 | { | ||
153 | return !pte.pte_low && !pte.pte_high; | ||
154 | } | ||
155 | |||
156 | static inline unsigned long pte_pfn(pte_t pte) | ||
157 | { | ||
158 | return pte_val(pte) >> PAGE_SHIFT; | ||
159 | } | ||
160 | |||
161 | extern unsigned long long __supported_pte_mask; | ||
162 | |||
163 | static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) | ||
164 | { | ||
165 | return __pte((((unsigned long long)page_nr << PAGE_SHIFT) | | ||
166 | pgprot_val(pgprot)) & __supported_pte_mask); | ||
167 | } | ||
168 | |||
169 | static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) | ||
170 | { | ||
171 | return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | | ||
172 | pgprot_val(pgprot)) & __supported_pte_mask); | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Bits 0, 6 and 7 are taken in the low part of the pte, | ||
177 | * put the 32 bits of offset into the high part. | ||
178 | */ | ||
179 | #define pte_to_pgoff(pte) ((pte).pte_high) | ||
180 | #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) | ||
181 | #define PTE_FILE_MAX_BITS 32 | ||
182 | |||
183 | /* Encode and de-code a swap entry */ | ||
184 | #define __swp_type(x) (((x).val) & 0x1f) | ||
185 | #define __swp_offset(x) ((x).val >> 5) | ||
186 | #define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) | ||
187 | #define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) | ||
188 | #define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val }) | ||
189 | |||
190 | #define __pmd_free_tlb(tlb, x) do { } while (0) | ||
191 | |||
192 | #endif /* _I386_PGTABLE_3LEVEL_H */ | ||
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h new file mode 100644 index 000000000000..1039140652af --- /dev/null +++ b/include/asm-x86/pgtable.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "pgtable_32.h" | ||
3 | #else | ||
4 | # include "pgtable_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h new file mode 100644 index 000000000000..c7fefa6b12fd --- /dev/null +++ b/include/asm-x86/pgtable_32.h | |||
@@ -0,0 +1,512 @@ | |||
1 | #ifndef _I386_PGTABLE_H | ||
2 | #define _I386_PGTABLE_H | ||
3 | |||
4 | |||
5 | /* | ||
6 | * The Linux memory management assumes a three-level page table setup. On | ||
7 | * the i386, we use that, but "fold" the mid level into the top-level page | ||
8 | * table, so that we physically have the same two-level page table as the | ||
9 | * i386 mmu expects. | ||
10 | * | ||
11 | * This file contains the functions and defines necessary to modify and use | ||
12 | * the i386 page table tree. | ||
13 | */ | ||
14 | #ifndef __ASSEMBLY__ | ||
15 | #include <asm/processor.h> | ||
16 | #include <asm/fixmap.h> | ||
17 | #include <linux/threads.h> | ||
18 | #include <asm/paravirt.h> | ||
19 | |||
20 | #ifndef _I386_BITOPS_H | ||
21 | #include <asm/bitops.h> | ||
22 | #endif | ||
23 | |||
24 | #include <linux/slab.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | |||
28 | struct mm_struct; | ||
29 | struct vm_area_struct; | ||
30 | |||
31 | /* | ||
32 | * ZERO_PAGE is a global shared page that is always zero: used | ||
33 | * for zero-mapped memory areas etc.. | ||
34 | */ | ||
35 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) | ||
36 | extern unsigned long empty_zero_page[1024]; | ||
37 | extern pgd_t swapper_pg_dir[1024]; | ||
38 | extern struct kmem_cache *pmd_cache; | ||
39 | extern spinlock_t pgd_lock; | ||
40 | extern struct page *pgd_list; | ||
41 | void check_pgt_cache(void); | ||
42 | |||
43 | void pmd_ctor(void *, struct kmem_cache *, unsigned long); | ||
44 | void pgtable_cache_init(void); | ||
45 | void paging_init(void); | ||
46 | |||
47 | |||
48 | /* | ||
49 | * The Linux x86 paging architecture is 'compile-time dual-mode', it | ||
50 | * implements both the traditional 2-level x86 page tables and the | ||
51 | * newer 3-level PAE-mode page tables. | ||
52 | */ | ||
53 | #ifdef CONFIG_X86_PAE | ||
54 | # include <asm/pgtable-3level-defs.h> | ||
55 | # define PMD_SIZE (1UL << PMD_SHIFT) | ||
56 | # define PMD_MASK (~(PMD_SIZE-1)) | ||
57 | #else | ||
58 | # include <asm/pgtable-2level-defs.h> | ||
59 | #endif | ||
60 | |||
61 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) | ||
62 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) | ||
63 | |||
64 | #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) | ||
65 | #define FIRST_USER_ADDRESS 0 | ||
66 | |||
67 | #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT) | ||
68 | #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS) | ||
69 | |||
70 | #define TWOLEVEL_PGDIR_SHIFT 22 | ||
71 | #define BOOT_USER_PGD_PTRS (__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT) | ||
72 | #define BOOT_KERNEL_PGD_PTRS (1024-BOOT_USER_PGD_PTRS) | ||
73 | |||
74 | /* Just any arbitrary offset to the start of the vmalloc VM area: the | ||
75 | * current 8MB value just means that there will be a 8MB "hole" after the | ||
76 | * physical memory until the kernel virtual memory starts. That means that | ||
77 | * any out-of-bounds memory accesses will hopefully be caught. | ||
78 | * The vmalloc() routines leaves a hole of 4kB between each vmalloced | ||
79 | * area for the same reason. ;) | ||
80 | */ | ||
81 | #define VMALLOC_OFFSET (8*1024*1024) | ||
82 | #define VMALLOC_START (((unsigned long) high_memory + \ | ||
83 | 2*VMALLOC_OFFSET-1) & ~(VMALLOC_OFFSET-1)) | ||
84 | #ifdef CONFIG_HIGHMEM | ||
85 | # define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE) | ||
86 | #else | ||
87 | # define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) | ||
88 | #endif | ||
89 | |||
90 | /* | ||
91 | * _PAGE_PSE set in the page directory entry just means that | ||
92 | * the page directory entry points directly to a 4MB-aligned block of | ||
93 | * memory. | ||
94 | */ | ||
95 | #define _PAGE_BIT_PRESENT 0 | ||
96 | #define _PAGE_BIT_RW 1 | ||
97 | #define _PAGE_BIT_USER 2 | ||
98 | #define _PAGE_BIT_PWT 3 | ||
99 | #define _PAGE_BIT_PCD 4 | ||
100 | #define _PAGE_BIT_ACCESSED 5 | ||
101 | #define _PAGE_BIT_DIRTY 6 | ||
102 | #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page, Pentium+, if present.. */ | ||
103 | #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */ | ||
104 | #define _PAGE_BIT_UNUSED1 9 /* available for programmer */ | ||
105 | #define _PAGE_BIT_UNUSED2 10 | ||
106 | #define _PAGE_BIT_UNUSED3 11 | ||
107 | #define _PAGE_BIT_NX 63 | ||
108 | |||
109 | #define _PAGE_PRESENT 0x001 | ||
110 | #define _PAGE_RW 0x002 | ||
111 | #define _PAGE_USER 0x004 | ||
112 | #define _PAGE_PWT 0x008 | ||
113 | #define _PAGE_PCD 0x010 | ||
114 | #define _PAGE_ACCESSED 0x020 | ||
115 | #define _PAGE_DIRTY 0x040 | ||
116 | #define _PAGE_PSE 0x080 /* 4 MB (or 2MB) page, Pentium+, if present.. */ | ||
117 | #define _PAGE_GLOBAL 0x100 /* Global TLB entry PPro+ */ | ||
118 | #define _PAGE_UNUSED1 0x200 /* available for programmer */ | ||
119 | #define _PAGE_UNUSED2 0x400 | ||
120 | #define _PAGE_UNUSED3 0x800 | ||
121 | |||
122 | /* If _PAGE_PRESENT is clear, we use these: */ | ||
123 | #define _PAGE_FILE 0x040 /* nonlinear file mapping, saved PTE; unset:swap */ | ||
124 | #define _PAGE_PROTNONE 0x080 /* if the user mapped it with PROT_NONE; | ||
125 | pte_present gives true */ | ||
126 | #ifdef CONFIG_X86_PAE | ||
127 | #define _PAGE_NX (1ULL<<_PAGE_BIT_NX) | ||
128 | #else | ||
129 | #define _PAGE_NX 0 | ||
130 | #endif | ||
131 | |||
132 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
133 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
134 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
135 | |||
136 | #define PAGE_NONE \ | ||
137 | __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) | ||
138 | #define PAGE_SHARED \ | ||
139 | __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) | ||
140 | |||
141 | #define PAGE_SHARED_EXEC \ | ||
142 | __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) | ||
143 | #define PAGE_COPY_NOEXEC \ | ||
144 | __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) | ||
145 | #define PAGE_COPY_EXEC \ | ||
146 | __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) | ||
147 | #define PAGE_COPY \ | ||
148 | PAGE_COPY_NOEXEC | ||
149 | #define PAGE_READONLY \ | ||
150 | __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) | ||
151 | #define PAGE_READONLY_EXEC \ | ||
152 | __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) | ||
153 | |||
154 | #define _PAGE_KERNEL \ | ||
155 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX) | ||
156 | #define _PAGE_KERNEL_EXEC \ | ||
157 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) | ||
158 | |||
159 | extern unsigned long long __PAGE_KERNEL, __PAGE_KERNEL_EXEC; | ||
160 | #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW) | ||
161 | #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW) | ||
162 | #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD) | ||
163 | #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) | ||
164 | #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) | ||
165 | |||
166 | #define PAGE_KERNEL __pgprot(__PAGE_KERNEL) | ||
167 | #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO) | ||
168 | #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) | ||
169 | #define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX) | ||
170 | #define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE) | ||
171 | #define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE) | ||
172 | #define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC) | ||
173 | |||
174 | /* | ||
175 | * The i386 can't do page protection for execute, and considers that | ||
176 | * the same are read. Also, write permissions imply read permissions. | ||
177 | * This is the closest we can get.. | ||
178 | */ | ||
179 | #define __P000 PAGE_NONE | ||
180 | #define __P001 PAGE_READONLY | ||
181 | #define __P010 PAGE_COPY | ||
182 | #define __P011 PAGE_COPY | ||
183 | #define __P100 PAGE_READONLY_EXEC | ||
184 | #define __P101 PAGE_READONLY_EXEC | ||
185 | #define __P110 PAGE_COPY_EXEC | ||
186 | #define __P111 PAGE_COPY_EXEC | ||
187 | |||
188 | #define __S000 PAGE_NONE | ||
189 | #define __S001 PAGE_READONLY | ||
190 | #define __S010 PAGE_SHARED | ||
191 | #define __S011 PAGE_SHARED | ||
192 | #define __S100 PAGE_READONLY_EXEC | ||
193 | #define __S101 PAGE_READONLY_EXEC | ||
194 | #define __S110 PAGE_SHARED_EXEC | ||
195 | #define __S111 PAGE_SHARED_EXEC | ||
196 | |||
197 | /* | ||
198 | * Define this if things work differently on an i386 and an i486: | ||
199 | * it will (on an i486) warn about kernel memory accesses that are | ||
200 | * done without a 'access_ok(VERIFY_WRITE,..)' | ||
201 | */ | ||
202 | #undef TEST_ACCESS_OK | ||
203 | |||
204 | /* The boot page tables (all created as a single array) */ | ||
205 | extern unsigned long pg0[]; | ||
206 | |||
207 | #define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE)) | ||
208 | |||
209 | /* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ | ||
210 | #define pmd_none(x) (!(unsigned long)pmd_val(x)) | ||
211 | #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) | ||
212 | #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) | ||
213 | |||
214 | |||
215 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) | ||
216 | |||
217 | /* | ||
218 | * The following only work if pte_present() is true. | ||
219 | * Undefined behaviour if not.. | ||
220 | */ | ||
221 | static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_DIRTY; } | ||
222 | static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; } | ||
223 | static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_RW; } | ||
224 | static inline int pte_huge(pte_t pte) { return (pte).pte_low & _PAGE_PSE; } | ||
225 | |||
226 | /* | ||
227 | * The following only works if pte_present() is not true. | ||
228 | */ | ||
229 | static inline int pte_file(pte_t pte) { return (pte).pte_low & _PAGE_FILE; } | ||
230 | |||
231 | static inline pte_t pte_mkclean(pte_t pte) { (pte).pte_low &= ~_PAGE_DIRTY; return pte; } | ||
232 | static inline pte_t pte_mkold(pte_t pte) { (pte).pte_low &= ~_PAGE_ACCESSED; return pte; } | ||
233 | static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_RW; return pte; } | ||
234 | static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; } | ||
235 | static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; } | ||
236 | static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; } | ||
237 | static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PSE; return pte; } | ||
238 | |||
239 | #ifdef CONFIG_X86_PAE | ||
240 | # include <asm/pgtable-3level.h> | ||
241 | #else | ||
242 | # include <asm/pgtable-2level.h> | ||
243 | #endif | ||
244 | |||
245 | #ifndef CONFIG_PARAVIRT | ||
246 | /* | ||
247 | * Rules for using pte_update - it must be called after any PTE update which | ||
248 | * has not been done using the set_pte / clear_pte interfaces. It is used by | ||
249 | * shadow mode hypervisors to resynchronize the shadow page tables. Kernel PTE | ||
250 | * updates should either be sets, clears, or set_pte_atomic for P->P | ||
251 | * transitions, which means this hook should only be called for user PTEs. | ||
252 | * This hook implies a P->P protection or access change has taken place, which | ||
253 | * requires a subsequent TLB flush. The notification can optionally be delayed | ||
254 | * until the TLB flush event by using the pte_update_defer form of the | ||
255 | * interface, but care must be taken to assure that the flush happens while | ||
256 | * still holding the same page table lock so that the shadow and primary pages | ||
257 | * do not become out of sync on SMP. | ||
258 | */ | ||
259 | #define pte_update(mm, addr, ptep) do { } while (0) | ||
260 | #define pte_update_defer(mm, addr, ptep) do { } while (0) | ||
261 | #endif | ||
262 | |||
263 | /* local pte updates need not use xchg for locking */ | ||
264 | static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep) | ||
265 | { | ||
266 | pte_t res = *ptep; | ||
267 | |||
268 | /* Pure native function needs no input for mm, addr */ | ||
269 | native_pte_clear(NULL, 0, ptep); | ||
270 | return res; | ||
271 | } | ||
272 | |||
273 | /* | ||
274 | * We only update the dirty/accessed state if we set | ||
275 | * the dirty bit by hand in the kernel, since the hardware | ||
276 | * will do the accessed bit for us, and we don't want to | ||
277 | * race with other CPU's that might be updating the dirty | ||
278 | * bit at the same time. | ||
279 | */ | ||
280 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS | ||
281 | #define ptep_set_access_flags(vma, address, ptep, entry, dirty) \ | ||
282 | ({ \ | ||
283 | int __changed = !pte_same(*(ptep), entry); \ | ||
284 | if (__changed && dirty) { \ | ||
285 | (ptep)->pte_low = (entry).pte_low; \ | ||
286 | pte_update_defer((vma)->vm_mm, (address), (ptep)); \ | ||
287 | flush_tlb_page(vma, address); \ | ||
288 | } \ | ||
289 | __changed; \ | ||
290 | }) | ||
291 | |||
292 | #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG | ||
293 | #define ptep_test_and_clear_young(vma, addr, ptep) ({ \ | ||
294 | int __ret = 0; \ | ||
295 | if (pte_young(*(ptep))) \ | ||
296 | __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \ | ||
297 | &(ptep)->pte_low); \ | ||
298 | if (__ret) \ | ||
299 | pte_update((vma)->vm_mm, addr, ptep); \ | ||
300 | __ret; \ | ||
301 | }) | ||
302 | |||
303 | #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH | ||
304 | #define ptep_clear_flush_young(vma, address, ptep) \ | ||
305 | ({ \ | ||
306 | int __young; \ | ||
307 | __young = ptep_test_and_clear_young((vma), (address), (ptep)); \ | ||
308 | if (__young) \ | ||
309 | flush_tlb_page(vma, address); \ | ||
310 | __young; \ | ||
311 | }) | ||
312 | |||
313 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR | ||
314 | static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
315 | { | ||
316 | pte_t pte = native_ptep_get_and_clear(ptep); | ||
317 | pte_update(mm, addr, ptep); | ||
318 | return pte; | ||
319 | } | ||
320 | |||
321 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL | ||
322 | static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) | ||
323 | { | ||
324 | pte_t pte; | ||
325 | if (full) { | ||
326 | /* | ||
327 | * Full address destruction in progress; paravirt does not | ||
328 | * care about updates and native needs no locking | ||
329 | */ | ||
330 | pte = native_local_ptep_get_and_clear(ptep); | ||
331 | } else { | ||
332 | pte = ptep_get_and_clear(mm, addr, ptep); | ||
333 | } | ||
334 | return pte; | ||
335 | } | ||
336 | |||
337 | #define __HAVE_ARCH_PTEP_SET_WRPROTECT | ||
338 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
339 | { | ||
340 | clear_bit(_PAGE_BIT_RW, &ptep->pte_low); | ||
341 | pte_update(mm, addr, ptep); | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * clone_pgd_range(pgd_t *dst, pgd_t *src, int count); | ||
346 | * | ||
347 | * dst - pointer to pgd range anwhere on a pgd page | ||
348 | * src - "" | ||
349 | * count - the number of pgds to copy. | ||
350 | * | ||
351 | * dst and src can be on the same page, but the range must not overlap, | ||
352 | * and must not cross a page boundary. | ||
353 | */ | ||
354 | static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count) | ||
355 | { | ||
356 | memcpy(dst, src, count * sizeof(pgd_t)); | ||
357 | } | ||
358 | |||
359 | /* | ||
360 | * Macro to mark a page protection value as "uncacheable". On processors which do not support | ||
361 | * it, this is a no-op. | ||
362 | */ | ||
363 | #define pgprot_noncached(prot) ((boot_cpu_data.x86 > 3) \ | ||
364 | ? (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) : (prot)) | ||
365 | |||
366 | /* | ||
367 | * Conversion functions: convert a page and protection to a page entry, | ||
368 | * and a page entry and page directory to the page they refer to. | ||
369 | */ | ||
370 | |||
371 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) | ||
372 | |||
373 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) | ||
374 | { | ||
375 | pte.pte_low &= _PAGE_CHG_MASK; | ||
376 | pte.pte_low |= pgprot_val(newprot); | ||
377 | #ifdef CONFIG_X86_PAE | ||
378 | /* | ||
379 | * Chop off the NX bit (if present), and add the NX portion of | ||
380 | * the newprot (if present): | ||
381 | */ | ||
382 | pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32)); | ||
383 | pte.pte_high |= (pgprot_val(newprot) >> 32) & \ | ||
384 | (__supported_pte_mask >> 32); | ||
385 | #endif | ||
386 | return pte; | ||
387 | } | ||
388 | |||
389 | #define pmd_large(pmd) \ | ||
390 | ((pmd_val(pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT)) | ||
391 | |||
392 | /* | ||
393 | * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] | ||
394 | * | ||
395 | * this macro returns the index of the entry in the pgd page which would | ||
396 | * control the given virtual address | ||
397 | */ | ||
398 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) | ||
399 | #define pgd_index_k(addr) pgd_index(addr) | ||
400 | |||
401 | /* | ||
402 | * pgd_offset() returns a (pgd_t *) | ||
403 | * pgd_index() is used get the offset into the pgd page's array of pgd_t's; | ||
404 | */ | ||
405 | #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) | ||
406 | |||
407 | /* | ||
408 | * a shortcut which implies the use of the kernel's pgd, instead | ||
409 | * of a process's | ||
410 | */ | ||
411 | #define pgd_offset_k(address) pgd_offset(&init_mm, address) | ||
412 | |||
413 | /* | ||
414 | * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] | ||
415 | * | ||
416 | * this macro returns the index of the entry in the pmd page which would | ||
417 | * control the given virtual address | ||
418 | */ | ||
419 | #define pmd_index(address) \ | ||
420 | (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) | ||
421 | |||
422 | /* | ||
423 | * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE] | ||
424 | * | ||
425 | * this macro returns the index of the entry in the pte page which would | ||
426 | * control the given virtual address | ||
427 | */ | ||
428 | #define pte_index(address) \ | ||
429 | (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) | ||
430 | #define pte_offset_kernel(dir, address) \ | ||
431 | ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) | ||
432 | |||
433 | #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) | ||
434 | |||
435 | #define pmd_page_vaddr(pmd) \ | ||
436 | ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) | ||
437 | |||
438 | /* | ||
439 | * Helper function that returns the kernel pagetable entry controlling | ||
440 | * the virtual address 'address'. NULL means no pagetable entry present. | ||
441 | * NOTE: the return type is pte_t but if the pmd is PSE then we return it | ||
442 | * as a pte too. | ||
443 | */ | ||
444 | extern pte_t *lookup_address(unsigned long address); | ||
445 | |||
446 | /* | ||
447 | * Make a given kernel text page executable/non-executable. | ||
448 | * Returns the previous executability setting of that page (which | ||
449 | * is used to restore the previous state). Used by the SMP bootup code. | ||
450 | * NOTE: this is an __init function for security reasons. | ||
451 | */ | ||
452 | #ifdef CONFIG_X86_PAE | ||
453 | extern int set_kernel_exec(unsigned long vaddr, int enable); | ||
454 | #else | ||
455 | static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;} | ||
456 | #endif | ||
457 | |||
458 | #if defined(CONFIG_HIGHPTE) | ||
459 | #define pte_offset_map(dir, address) \ | ||
460 | ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) | ||
461 | #define pte_offset_map_nested(dir, address) \ | ||
462 | ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE1) + pte_index(address)) | ||
463 | #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0) | ||
464 | #define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1) | ||
465 | #else | ||
466 | #define pte_offset_map(dir, address) \ | ||
467 | ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) | ||
468 | #define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) | ||
469 | #define pte_unmap(pte) do { } while (0) | ||
470 | #define pte_unmap_nested(pte) do { } while (0) | ||
471 | #endif | ||
472 | |||
473 | /* Clear a kernel PTE and flush it from the TLB */ | ||
474 | #define kpte_clear_flush(ptep, vaddr) \ | ||
475 | do { \ | ||
476 | pte_clear(&init_mm, vaddr, ptep); \ | ||
477 | __flush_tlb_one(vaddr); \ | ||
478 | } while (0) | ||
479 | |||
480 | /* | ||
481 | * The i386 doesn't have any external MMU info: the kernel page | ||
482 | * tables contain all the necessary information. | ||
483 | */ | ||
484 | #define update_mmu_cache(vma,address,pte) do { } while (0) | ||
485 | |||
486 | void native_pagetable_setup_start(pgd_t *base); | ||
487 | void native_pagetable_setup_done(pgd_t *base); | ||
488 | |||
489 | #ifndef CONFIG_PARAVIRT | ||
490 | static inline void paravirt_pagetable_setup_start(pgd_t *base) | ||
491 | { | ||
492 | native_pagetable_setup_start(base); | ||
493 | } | ||
494 | |||
495 | static inline void paravirt_pagetable_setup_done(pgd_t *base) | ||
496 | { | ||
497 | native_pagetable_setup_done(base); | ||
498 | } | ||
499 | #endif /* !CONFIG_PARAVIRT */ | ||
500 | |||
501 | #endif /* !__ASSEMBLY__ */ | ||
502 | |||
503 | #ifdef CONFIG_FLATMEM | ||
504 | #define kern_addr_valid(addr) (1) | ||
505 | #endif /* CONFIG_FLATMEM */ | ||
506 | |||
507 | #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ | ||
508 | remap_pfn_range(vma, vaddr, pfn, size, prot) | ||
509 | |||
510 | #include <asm-generic/pgtable.h> | ||
511 | |||
512 | #endif /* _I386_PGTABLE_H */ | ||
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h new file mode 100644 index 000000000000..57dd6b3107ea --- /dev/null +++ b/include/asm-x86/pgtable_64.h | |||
@@ -0,0 +1,432 @@ | |||
1 | #ifndef _X86_64_PGTABLE_H | ||
2 | #define _X86_64_PGTABLE_H | ||
3 | |||
4 | #include <linux/const.h> | ||
5 | #ifndef __ASSEMBLY__ | ||
6 | |||
7 | /* | ||
8 | * This file contains the functions and defines necessary to modify and use | ||
9 | * the x86-64 page table tree. | ||
10 | */ | ||
11 | #include <asm/processor.h> | ||
12 | #include <asm/bitops.h> | ||
13 | #include <linux/threads.h> | ||
14 | #include <asm/pda.h> | ||
15 | |||
16 | extern pud_t level3_kernel_pgt[512]; | ||
17 | extern pud_t level3_ident_pgt[512]; | ||
18 | extern pmd_t level2_kernel_pgt[512]; | ||
19 | extern pgd_t init_level4_pgt[]; | ||
20 | extern unsigned long __supported_pte_mask; | ||
21 | |||
22 | #define swapper_pg_dir init_level4_pgt | ||
23 | |||
24 | extern void paging_init(void); | ||
25 | extern void clear_kernel_mapping(unsigned long addr, unsigned long size); | ||
26 | |||
27 | /* | ||
28 | * ZERO_PAGE is a global shared page that is always zero: used | ||
29 | * for zero-mapped memory areas etc.. | ||
30 | */ | ||
31 | extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)]; | ||
32 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) | ||
33 | |||
34 | #endif /* !__ASSEMBLY__ */ | ||
35 | |||
36 | /* | ||
37 | * PGDIR_SHIFT determines what a top-level page table entry can map | ||
38 | */ | ||
39 | #define PGDIR_SHIFT 39 | ||
40 | #define PTRS_PER_PGD 512 | ||
41 | |||
42 | /* | ||
43 | * 3rd level page | ||
44 | */ | ||
45 | #define PUD_SHIFT 30 | ||
46 | #define PTRS_PER_PUD 512 | ||
47 | |||
48 | /* | ||
49 | * PMD_SHIFT determines the size of the area a middle-level | ||
50 | * page table can map | ||
51 | */ | ||
52 | #define PMD_SHIFT 21 | ||
53 | #define PTRS_PER_PMD 512 | ||
54 | |||
55 | /* | ||
56 | * entries per page directory level | ||
57 | */ | ||
58 | #define PTRS_PER_PTE 512 | ||
59 | |||
60 | #ifndef __ASSEMBLY__ | ||
61 | |||
62 | #define pte_ERROR(e) \ | ||
63 | printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), pte_val(e)) | ||
64 | #define pmd_ERROR(e) \ | ||
65 | printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), pmd_val(e)) | ||
66 | #define pud_ERROR(e) \ | ||
67 | printk("%s:%d: bad pud %p(%016lx).\n", __FILE__, __LINE__, &(e), pud_val(e)) | ||
68 | #define pgd_ERROR(e) \ | ||
69 | printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) | ||
70 | |||
71 | #define pgd_none(x) (!pgd_val(x)) | ||
72 | #define pud_none(x) (!pud_val(x)) | ||
73 | |||
74 | static inline void set_pte(pte_t *dst, pte_t val) | ||
75 | { | ||
76 | pte_val(*dst) = pte_val(val); | ||
77 | } | ||
78 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | ||
79 | |||
80 | static inline void set_pmd(pmd_t *dst, pmd_t val) | ||
81 | { | ||
82 | pmd_val(*dst) = pmd_val(val); | ||
83 | } | ||
84 | |||
85 | static inline void set_pud(pud_t *dst, pud_t val) | ||
86 | { | ||
87 | pud_val(*dst) = pud_val(val); | ||
88 | } | ||
89 | |||
90 | static inline void pud_clear (pud_t *pud) | ||
91 | { | ||
92 | set_pud(pud, __pud(0)); | ||
93 | } | ||
94 | |||
95 | static inline void set_pgd(pgd_t *dst, pgd_t val) | ||
96 | { | ||
97 | pgd_val(*dst) = pgd_val(val); | ||
98 | } | ||
99 | |||
100 | static inline void pgd_clear (pgd_t * pgd) | ||
101 | { | ||
102 | set_pgd(pgd, __pgd(0)); | ||
103 | } | ||
104 | |||
105 | #define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte, 0)) | ||
106 | |||
107 | struct mm_struct; | ||
108 | |||
109 | static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) | ||
110 | { | ||
111 | pte_t pte; | ||
112 | if (full) { | ||
113 | pte = *ptep; | ||
114 | *ptep = __pte(0); | ||
115 | } else { | ||
116 | pte = ptep_get_and_clear(mm, addr, ptep); | ||
117 | } | ||
118 | return pte; | ||
119 | } | ||
120 | |||
121 | #define pte_same(a, b) ((a).pte == (b).pte) | ||
122 | |||
123 | #define pte_pgprot(a) (__pgprot((a).pte & ~PHYSICAL_PAGE_MASK)) | ||
124 | |||
125 | #endif /* !__ASSEMBLY__ */ | ||
126 | |||
127 | #define PMD_SIZE (_AC(1,UL) << PMD_SHIFT) | ||
128 | #define PMD_MASK (~(PMD_SIZE-1)) | ||
129 | #define PUD_SIZE (_AC(1,UL) << PUD_SHIFT) | ||
130 | #define PUD_MASK (~(PUD_SIZE-1)) | ||
131 | #define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT) | ||
132 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) | ||
133 | |||
134 | #define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1) | ||
135 | #define FIRST_USER_ADDRESS 0 | ||
136 | |||
137 | #define MAXMEM _AC(0x3fffffffffff, UL) | ||
138 | #define VMALLOC_START _AC(0xffffc20000000000, UL) | ||
139 | #define VMALLOC_END _AC(0xffffe1ffffffffff, UL) | ||
140 | #define MODULES_VADDR _AC(0xffffffff88000000, UL) | ||
141 | #define MODULES_END _AC(0xfffffffffff00000, UL) | ||
142 | #define MODULES_LEN (MODULES_END - MODULES_VADDR) | ||
143 | |||
144 | #define _PAGE_BIT_PRESENT 0 | ||
145 | #define _PAGE_BIT_RW 1 | ||
146 | #define _PAGE_BIT_USER 2 | ||
147 | #define _PAGE_BIT_PWT 3 | ||
148 | #define _PAGE_BIT_PCD 4 | ||
149 | #define _PAGE_BIT_ACCESSED 5 | ||
150 | #define _PAGE_BIT_DIRTY 6 | ||
151 | #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */ | ||
152 | #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */ | ||
153 | #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ | ||
154 | |||
155 | #define _PAGE_PRESENT 0x001 | ||
156 | #define _PAGE_RW 0x002 | ||
157 | #define _PAGE_USER 0x004 | ||
158 | #define _PAGE_PWT 0x008 | ||
159 | #define _PAGE_PCD 0x010 | ||
160 | #define _PAGE_ACCESSED 0x020 | ||
161 | #define _PAGE_DIRTY 0x040 | ||
162 | #define _PAGE_PSE 0x080 /* 2MB page */ | ||
163 | #define _PAGE_FILE 0x040 /* nonlinear file mapping, saved PTE; unset:swap */ | ||
164 | #define _PAGE_GLOBAL 0x100 /* Global TLB entry */ | ||
165 | |||
166 | #define _PAGE_PROTNONE 0x080 /* If not present */ | ||
167 | #define _PAGE_NX (_AC(1,UL)<<_PAGE_BIT_NX) | ||
168 | |||
169 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
170 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
171 | |||
172 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
173 | |||
174 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) | ||
175 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) | ||
176 | #define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) | ||
177 | #define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) | ||
178 | #define PAGE_COPY PAGE_COPY_NOEXEC | ||
179 | #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) | ||
180 | #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) | ||
181 | #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) | ||
182 | #define __PAGE_KERNEL \ | ||
183 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX) | ||
184 | #define __PAGE_KERNEL_EXEC \ | ||
185 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) | ||
186 | #define __PAGE_KERNEL_NOCACHE \ | ||
187 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX) | ||
188 | #define __PAGE_KERNEL_RO \ | ||
189 | (_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX) | ||
190 | #define __PAGE_KERNEL_VSYSCALL \ | ||
191 | (_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) | ||
192 | #define __PAGE_KERNEL_VSYSCALL_NOCACHE \ | ||
193 | (_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_PCD) | ||
194 | #define __PAGE_KERNEL_LARGE \ | ||
195 | (__PAGE_KERNEL | _PAGE_PSE) | ||
196 | #define __PAGE_KERNEL_LARGE_EXEC \ | ||
197 | (__PAGE_KERNEL_EXEC | _PAGE_PSE) | ||
198 | |||
199 | #define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL) | ||
200 | |||
201 | #define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL) | ||
202 | #define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC) | ||
203 | #define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO) | ||
204 | #define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE) | ||
205 | #define PAGE_KERNEL_VSYSCALL32 __pgprot(__PAGE_KERNEL_VSYSCALL) | ||
206 | #define PAGE_KERNEL_VSYSCALL MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL) | ||
207 | #define PAGE_KERNEL_LARGE MAKE_GLOBAL(__PAGE_KERNEL_LARGE) | ||
208 | #define PAGE_KERNEL_VSYSCALL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL_NOCACHE) | ||
209 | |||
210 | /* xwr */ | ||
211 | #define __P000 PAGE_NONE | ||
212 | #define __P001 PAGE_READONLY | ||
213 | #define __P010 PAGE_COPY | ||
214 | #define __P011 PAGE_COPY | ||
215 | #define __P100 PAGE_READONLY_EXEC | ||
216 | #define __P101 PAGE_READONLY_EXEC | ||
217 | #define __P110 PAGE_COPY_EXEC | ||
218 | #define __P111 PAGE_COPY_EXEC | ||
219 | |||
220 | #define __S000 PAGE_NONE | ||
221 | #define __S001 PAGE_READONLY | ||
222 | #define __S010 PAGE_SHARED | ||
223 | #define __S011 PAGE_SHARED | ||
224 | #define __S100 PAGE_READONLY_EXEC | ||
225 | #define __S101 PAGE_READONLY_EXEC | ||
226 | #define __S110 PAGE_SHARED_EXEC | ||
227 | #define __S111 PAGE_SHARED_EXEC | ||
228 | |||
229 | #ifndef __ASSEMBLY__ | ||
230 | |||
231 | static inline unsigned long pgd_bad(pgd_t pgd) | ||
232 | { | ||
233 | return pgd_val(pgd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); | ||
234 | } | ||
235 | |||
236 | static inline unsigned long pud_bad(pud_t pud) | ||
237 | { | ||
238 | return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); | ||
239 | } | ||
240 | |||
241 | static inline unsigned long pmd_bad(pmd_t pmd) | ||
242 | { | ||
243 | return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); | ||
244 | } | ||
245 | |||
246 | #define pte_none(x) (!pte_val(x)) | ||
247 | #define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) | ||
248 | #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) | ||
249 | |||
250 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this | ||
251 | right? */ | ||
252 | #define pte_page(x) pfn_to_page(pte_pfn(x)) | ||
253 | #define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) | ||
254 | |||
255 | static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) | ||
256 | { | ||
257 | pte_t pte; | ||
258 | pte_val(pte) = (page_nr << PAGE_SHIFT); | ||
259 | pte_val(pte) |= pgprot_val(pgprot); | ||
260 | pte_val(pte) &= __supported_pte_mask; | ||
261 | return pte; | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * The following only work if pte_present() is true. | ||
266 | * Undefined behaviour if not.. | ||
267 | */ | ||
268 | #define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT) | ||
269 | static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } | ||
270 | static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } | ||
271 | static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } | ||
272 | static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } | ||
273 | static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; } | ||
274 | |||
275 | static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } | ||
276 | static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; } | ||
277 | static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; } | ||
278 | static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_NX)); return pte; } | ||
279 | static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } | ||
280 | static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } | ||
281 | static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; } | ||
282 | static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_PSE)); return pte; } | ||
283 | static inline pte_t pte_clrhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_PSE)); return pte; } | ||
284 | |||
285 | struct vm_area_struct; | ||
286 | |||
287 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) | ||
288 | { | ||
289 | if (!pte_young(*ptep)) | ||
290 | return 0; | ||
291 | return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte); | ||
292 | } | ||
293 | |||
294 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
295 | { | ||
296 | clear_bit(_PAGE_BIT_RW, &ptep->pte); | ||
297 | } | ||
298 | |||
299 | /* | ||
300 | * Macro to mark a page protection value as "uncacheable". | ||
301 | */ | ||
302 | #define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) | ||
303 | |||
304 | static inline int pmd_large(pmd_t pte) { | ||
305 | return (pmd_val(pte) & __LARGE_PTE) == __LARGE_PTE; | ||
306 | } | ||
307 | |||
308 | |||
309 | /* | ||
310 | * Conversion functions: convert a page and protection to a page entry, | ||
311 | * and a page entry and page directory to the page they refer to. | ||
312 | */ | ||
313 | |||
314 | /* | ||
315 | * Level 4 access. | ||
316 | */ | ||
317 | #define pgd_page_vaddr(pgd) ((unsigned long) __va((unsigned long)pgd_val(pgd) & PTE_MASK)) | ||
318 | #define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)) | ||
319 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) | ||
320 | #define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr)) | ||
321 | #define pgd_offset_k(address) (init_level4_pgt + pgd_index(address)) | ||
322 | #define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT) | ||
323 | #define mk_kernel_pgd(address) ((pgd_t){ (address) | _KERNPG_TABLE }) | ||
324 | |||
325 | /* PUD - Level3 access */ | ||
326 | /* to find an entry in a page-table-directory. */ | ||
327 | #define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK)) | ||
328 | #define pud_page(pud) (pfn_to_page(pud_val(pud) >> PAGE_SHIFT)) | ||
329 | #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) | ||
330 | #define pud_offset(pgd, address) ((pud_t *) pgd_page_vaddr(*(pgd)) + pud_index(address)) | ||
331 | #define pud_present(pud) (pud_val(pud) & _PAGE_PRESENT) | ||
332 | |||
333 | /* PMD - Level 2 access */ | ||
334 | #define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PTE_MASK)) | ||
335 | #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) | ||
336 | |||
337 | #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) | ||
338 | #define pmd_offset(dir, address) ((pmd_t *) pud_page_vaddr(*(dir)) + \ | ||
339 | pmd_index(address)) | ||
340 | #define pmd_none(x) (!pmd_val(x)) | ||
341 | #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) | ||
342 | #define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) | ||
343 | #define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot))) | ||
344 | #define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) | ||
345 | |||
346 | #define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT) | ||
347 | #define pgoff_to_pte(off) ((pte_t) { ((off) << PAGE_SHIFT) | _PAGE_FILE }) | ||
348 | #define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT | ||
349 | |||
350 | /* PTE - Level 1 access. */ | ||
351 | |||
352 | /* page, protection -> pte */ | ||
353 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) | ||
354 | #define mk_pte_huge(entry) (pte_val(entry) |= _PAGE_PRESENT | _PAGE_PSE) | ||
355 | |||
356 | /* Change flags of a PTE */ | ||
357 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) | ||
358 | { | ||
359 | pte_val(pte) &= _PAGE_CHG_MASK; | ||
360 | pte_val(pte) |= pgprot_val(newprot); | ||
361 | pte_val(pte) &= __supported_pte_mask; | ||
362 | return pte; | ||
363 | } | ||
364 | |||
365 | #define pte_index(address) \ | ||
366 | (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) | ||
367 | #define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \ | ||
368 | pte_index(address)) | ||
369 | |||
370 | /* x86-64 always has all page tables mapped. */ | ||
371 | #define pte_offset_map(dir,address) pte_offset_kernel(dir,address) | ||
372 | #define pte_offset_map_nested(dir,address) pte_offset_kernel(dir,address) | ||
373 | #define pte_unmap(pte) /* NOP */ | ||
374 | #define pte_unmap_nested(pte) /* NOP */ | ||
375 | |||
376 | #define update_mmu_cache(vma,address,pte) do { } while (0) | ||
377 | |||
378 | /* We only update the dirty/accessed state if we set | ||
379 | * the dirty bit by hand in the kernel, since the hardware | ||
380 | * will do the accessed bit for us, and we don't want to | ||
381 | * race with other CPU's that might be updating the dirty | ||
382 | * bit at the same time. */ | ||
383 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS | ||
384 | #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \ | ||
385 | ({ \ | ||
386 | int __changed = !pte_same(*(__ptep), __entry); \ | ||
387 | if (__changed && __dirty) { \ | ||
388 | set_pte(__ptep, __entry); \ | ||
389 | flush_tlb_page(__vma, __address); \ | ||
390 | } \ | ||
391 | __changed; \ | ||
392 | }) | ||
393 | |||
394 | /* Encode and de-code a swap entry */ | ||
395 | #define __swp_type(x) (((x).val >> 1) & 0x3f) | ||
396 | #define __swp_offset(x) ((x).val >> 8) | ||
397 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) | ||
398 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) | ||
399 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) | ||
400 | |||
401 | extern spinlock_t pgd_lock; | ||
402 | extern struct list_head pgd_list; | ||
403 | |||
404 | extern int kern_addr_valid(unsigned long addr); | ||
405 | |||
406 | pte_t *lookup_address(unsigned long addr); | ||
407 | |||
408 | #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ | ||
409 | remap_pfn_range(vma, vaddr, pfn, size, prot) | ||
410 | |||
411 | #define HAVE_ARCH_UNMAPPED_AREA | ||
412 | |||
413 | #define pgtable_cache_init() do { } while (0) | ||
414 | #define check_pgt_cache() do { } while (0) | ||
415 | |||
416 | #define PAGE_AGP PAGE_KERNEL_NOCACHE | ||
417 | #define HAVE_PAGE_AGP 1 | ||
418 | |||
419 | /* fs/proc/kcore.c */ | ||
420 | #define kc_vaddr_to_offset(v) ((v) & __VIRTUAL_MASK) | ||
421 | #define kc_offset_to_vaddr(o) \ | ||
422 | (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o)) | ||
423 | |||
424 | #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG | ||
425 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR | ||
426 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL | ||
427 | #define __HAVE_ARCH_PTEP_SET_WRPROTECT | ||
428 | #define __HAVE_ARCH_PTE_SAME | ||
429 | #include <asm-generic/pgtable.h> | ||
430 | #endif /* !__ASSEMBLY__ */ | ||
431 | |||
432 | #endif /* _X86_64_PGTABLE_H */ | ||
diff --git a/include/asm-x86/poll.h b/include/asm-x86/poll.h new file mode 100644 index 000000000000..c98509d3149e --- /dev/null +++ b/include/asm-x86/poll.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/poll.h> | |||
diff --git a/include/asm-x86/posix_types.h b/include/asm-x86/posix_types.h new file mode 100644 index 000000000000..bb7133dc155d --- /dev/null +++ b/include/asm-x86/posix_types.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "posix_types_32.h" | ||
4 | # else | ||
5 | # include "posix_types_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "posix_types_32.h" | ||
10 | # else | ||
11 | # include "posix_types_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/posix_types_32.h b/include/asm-x86/posix_types_32.h new file mode 100644 index 000000000000..133e31e7dfde --- /dev/null +++ b/include/asm-x86/posix_types_32.h | |||
@@ -0,0 +1,82 @@ | |||
1 | #ifndef __ARCH_I386_POSIX_TYPES_H | ||
2 | #define __ARCH_I386_POSIX_TYPES_H | ||
3 | |||
4 | /* | ||
5 | * This file is generally used by user-level software, so you need to | ||
6 | * be a little careful about namespace pollution etc. Also, we cannot | ||
7 | * assume GCC is being used. | ||
8 | */ | ||
9 | |||
10 | typedef unsigned long __kernel_ino_t; | ||
11 | typedef unsigned short __kernel_mode_t; | ||
12 | typedef unsigned short __kernel_nlink_t; | ||
13 | typedef long __kernel_off_t; | ||
14 | typedef int __kernel_pid_t; | ||
15 | typedef unsigned short __kernel_ipc_pid_t; | ||
16 | typedef unsigned short __kernel_uid_t; | ||
17 | typedef unsigned short __kernel_gid_t; | ||
18 | typedef unsigned int __kernel_size_t; | ||
19 | typedef int __kernel_ssize_t; | ||
20 | typedef int __kernel_ptrdiff_t; | ||
21 | typedef long __kernel_time_t; | ||
22 | typedef long __kernel_suseconds_t; | ||
23 | typedef long __kernel_clock_t; | ||
24 | typedef int __kernel_timer_t; | ||
25 | typedef int __kernel_clockid_t; | ||
26 | typedef int __kernel_daddr_t; | ||
27 | typedef char * __kernel_caddr_t; | ||
28 | typedef unsigned short __kernel_uid16_t; | ||
29 | typedef unsigned short __kernel_gid16_t; | ||
30 | typedef unsigned int __kernel_uid32_t; | ||
31 | typedef unsigned int __kernel_gid32_t; | ||
32 | |||
33 | typedef unsigned short __kernel_old_uid_t; | ||
34 | typedef unsigned short __kernel_old_gid_t; | ||
35 | typedef unsigned short __kernel_old_dev_t; | ||
36 | |||
37 | #ifdef __GNUC__ | ||
38 | typedef long long __kernel_loff_t; | ||
39 | #endif | ||
40 | |||
41 | typedef struct { | ||
42 | #if defined(__KERNEL__) || defined(__USE_ALL) | ||
43 | int val[2]; | ||
44 | #else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ | ||
45 | int __val[2]; | ||
46 | #endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ | ||
47 | } __kernel_fsid_t; | ||
48 | |||
49 | #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) | ||
50 | |||
51 | #undef __FD_SET | ||
52 | #define __FD_SET(fd,fdsetp) \ | ||
53 | __asm__ __volatile__("btsl %1,%0": \ | ||
54 | "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd))) | ||
55 | |||
56 | #undef __FD_CLR | ||
57 | #define __FD_CLR(fd,fdsetp) \ | ||
58 | __asm__ __volatile__("btrl %1,%0": \ | ||
59 | "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd))) | ||
60 | |||
61 | #undef __FD_ISSET | ||
62 | #define __FD_ISSET(fd,fdsetp) (__extension__ ({ \ | ||
63 | unsigned char __result; \ | ||
64 | __asm__ __volatile__("btl %1,%2 ; setb %0" \ | ||
65 | :"=q" (__result) :"r" ((int) (fd)), \ | ||
66 | "m" (*(__kernel_fd_set *) (fdsetp))); \ | ||
67 | __result; })) | ||
68 | |||
69 | #undef __FD_ZERO | ||
70 | #define __FD_ZERO(fdsetp) \ | ||
71 | do { \ | ||
72 | int __d0, __d1; \ | ||
73 | __asm__ __volatile__("cld ; rep ; stosl" \ | ||
74 | :"=m" (*(__kernel_fd_set *) (fdsetp)), \ | ||
75 | "=&c" (__d0), "=&D" (__d1) \ | ||
76 | :"a" (0), "1" (__FDSET_LONGS), \ | ||
77 | "2" ((__kernel_fd_set *) (fdsetp)) : "memory"); \ | ||
78 | } while (0) | ||
79 | |||
80 | #endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ | ||
81 | |||
82 | #endif | ||
diff --git a/include/asm-x86/posix_types_64.h b/include/asm-x86/posix_types_64.h new file mode 100644 index 000000000000..9926aa43775b --- /dev/null +++ b/include/asm-x86/posix_types_64.h | |||
@@ -0,0 +1,119 @@ | |||
1 | #ifndef _ASM_X86_64_POSIX_TYPES_H | ||
2 | #define _ASM_X86_64_POSIX_TYPES_H | ||
3 | |||
4 | /* | ||
5 | * This file is generally used by user-level software, so you need to | ||
6 | * be a little careful about namespace pollution etc. Also, we cannot | ||
7 | * assume GCC is being used. | ||
8 | */ | ||
9 | |||
10 | typedef unsigned long __kernel_ino_t; | ||
11 | typedef unsigned int __kernel_mode_t; | ||
12 | typedef unsigned long __kernel_nlink_t; | ||
13 | typedef long __kernel_off_t; | ||
14 | typedef int __kernel_pid_t; | ||
15 | typedef int __kernel_ipc_pid_t; | ||
16 | typedef unsigned int __kernel_uid_t; | ||
17 | typedef unsigned int __kernel_gid_t; | ||
18 | typedef unsigned long __kernel_size_t; | ||
19 | typedef long __kernel_ssize_t; | ||
20 | typedef long __kernel_ptrdiff_t; | ||
21 | typedef long __kernel_time_t; | ||
22 | typedef long __kernel_suseconds_t; | ||
23 | typedef long __kernel_clock_t; | ||
24 | typedef int __kernel_timer_t; | ||
25 | typedef int __kernel_clockid_t; | ||
26 | typedef int __kernel_daddr_t; | ||
27 | typedef char * __kernel_caddr_t; | ||
28 | typedef unsigned short __kernel_uid16_t; | ||
29 | typedef unsigned short __kernel_gid16_t; | ||
30 | |||
31 | #ifdef __GNUC__ | ||
32 | typedef long long __kernel_loff_t; | ||
33 | #endif | ||
34 | |||
35 | typedef struct { | ||
36 | int val[2]; | ||
37 | } __kernel_fsid_t; | ||
38 | |||
39 | typedef unsigned short __kernel_old_uid_t; | ||
40 | typedef unsigned short __kernel_old_gid_t; | ||
41 | typedef __kernel_uid_t __kernel_uid32_t; | ||
42 | typedef __kernel_gid_t __kernel_gid32_t; | ||
43 | |||
44 | typedef unsigned long __kernel_old_dev_t; | ||
45 | |||
46 | #ifdef __KERNEL__ | ||
47 | |||
48 | #undef __FD_SET | ||
49 | static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) | ||
50 | { | ||
51 | unsigned long _tmp = fd / __NFDBITS; | ||
52 | unsigned long _rem = fd % __NFDBITS; | ||
53 | fdsetp->fds_bits[_tmp] |= (1UL<<_rem); | ||
54 | } | ||
55 | |||
56 | #undef __FD_CLR | ||
57 | static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) | ||
58 | { | ||
59 | unsigned long _tmp = fd / __NFDBITS; | ||
60 | unsigned long _rem = fd % __NFDBITS; | ||
61 | fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem); | ||
62 | } | ||
63 | |||
64 | #undef __FD_ISSET | ||
65 | static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) | ||
66 | { | ||
67 | unsigned long _tmp = fd / __NFDBITS; | ||
68 | unsigned long _rem = fd % __NFDBITS; | ||
69 | return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * This will unroll the loop for the normal constant cases (8 or 32 longs, | ||
74 | * for 256 and 1024-bit fd_sets respectively) | ||
75 | */ | ||
76 | #undef __FD_ZERO | ||
77 | static __inline__ void __FD_ZERO(__kernel_fd_set *p) | ||
78 | { | ||
79 | unsigned long *tmp = p->fds_bits; | ||
80 | int i; | ||
81 | |||
82 | if (__builtin_constant_p(__FDSET_LONGS)) { | ||
83 | switch (__FDSET_LONGS) { | ||
84 | case 32: | ||
85 | tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; | ||
86 | tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; | ||
87 | tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; | ||
88 | tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; | ||
89 | tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0; | ||
90 | tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0; | ||
91 | tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0; | ||
92 | tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0; | ||
93 | return; | ||
94 | case 16: | ||
95 | tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; | ||
96 | tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; | ||
97 | tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; | ||
98 | tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; | ||
99 | return; | ||
100 | case 8: | ||
101 | tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; | ||
102 | tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; | ||
103 | return; | ||
104 | case 4: | ||
105 | tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; | ||
106 | return; | ||
107 | } | ||
108 | } | ||
109 | i = __FDSET_LONGS; | ||
110 | while (i) { | ||
111 | i--; | ||
112 | *tmp = 0; | ||
113 | tmp++; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | #endif /* defined(__KERNEL__) */ | ||
118 | |||
119 | #endif | ||
diff --git a/include/asm-x86/prctl.h b/include/asm-x86/prctl.h new file mode 100644 index 000000000000..52952adef1ca --- /dev/null +++ b/include/asm-x86/prctl.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef X86_64_PRCTL_H | ||
2 | #define X86_64_PRCTL_H 1 | ||
3 | |||
4 | #define ARCH_SET_GS 0x1001 | ||
5 | #define ARCH_SET_FS 0x1002 | ||
6 | #define ARCH_GET_FS 0x1003 | ||
7 | #define ARCH_GET_GS 0x1004 | ||
8 | |||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/processor-cyrix.h b/include/asm-x86/processor-cyrix.h new file mode 100644 index 000000000000..97568ada1f97 --- /dev/null +++ b/include/asm-x86/processor-cyrix.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * NSC/Cyrix CPU indexed register access. Must be inlined instead of | ||
3 | * macros to ensure correct access ordering | ||
4 | * Access order is always 0x22 (=offset), 0x23 (=value) | ||
5 | * | ||
6 | * When using the old macros a line like | ||
7 | * setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88); | ||
8 | * gets expanded to: | ||
9 | * do { | ||
10 | * outb((CX86_CCR2), 0x22); | ||
11 | * outb((({ | ||
12 | * outb((CX86_CCR2), 0x22); | ||
13 | * inb(0x23); | ||
14 | * }) | 0x88), 0x23); | ||
15 | * } while (0); | ||
16 | * | ||
17 | * which in fact violates the access order (= 0x22, 0x22, 0x23, 0x23). | ||
18 | */ | ||
19 | |||
20 | static inline u8 getCx86(u8 reg) | ||
21 | { | ||
22 | outb(reg, 0x22); | ||
23 | return inb(0x23); | ||
24 | } | ||
25 | |||
26 | static inline void setCx86(u8 reg, u8 data) | ||
27 | { | ||
28 | outb(reg, 0x22); | ||
29 | outb(data, 0x23); | ||
30 | } | ||
diff --git a/include/asm-x86/processor-flags.h b/include/asm-x86/processor-flags.h new file mode 100644 index 000000000000..5404e90edd57 --- /dev/null +++ b/include/asm-x86/processor-flags.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef __ASM_I386_PROCESSOR_FLAGS_H | ||
2 | #define __ASM_I386_PROCESSOR_FLAGS_H | ||
3 | /* Various flags defined: can be included from assembler. */ | ||
4 | |||
5 | /* | ||
6 | * EFLAGS bits | ||
7 | */ | ||
8 | #define X86_EFLAGS_CF 0x00000001 /* Carry Flag */ | ||
9 | #define X86_EFLAGS_PF 0x00000004 /* Parity Flag */ | ||
10 | #define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */ | ||
11 | #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */ | ||
12 | #define X86_EFLAGS_SF 0x00000080 /* Sign Flag */ | ||
13 | #define X86_EFLAGS_TF 0x00000100 /* Trap Flag */ | ||
14 | #define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */ | ||
15 | #define X86_EFLAGS_DF 0x00000400 /* Direction Flag */ | ||
16 | #define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */ | ||
17 | #define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */ | ||
18 | #define X86_EFLAGS_NT 0x00004000 /* Nested Task */ | ||
19 | #define X86_EFLAGS_RF 0x00010000 /* Resume Flag */ | ||
20 | #define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */ | ||
21 | #define X86_EFLAGS_AC 0x00040000 /* Alignment Check */ | ||
22 | #define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */ | ||
23 | #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */ | ||
24 | #define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */ | ||
25 | |||
26 | /* | ||
27 | * Basic CPU control in CR0 | ||
28 | */ | ||
29 | #define X86_CR0_PE 0x00000001 /* Protection Enable */ | ||
30 | #define X86_CR0_MP 0x00000002 /* Monitor Coprocessor */ | ||
31 | #define X86_CR0_EM 0x00000004 /* Emulation */ | ||
32 | #define X86_CR0_TS 0x00000008 /* Task Switched */ | ||
33 | #define X86_CR0_ET 0x00000010 /* Extension Type */ | ||
34 | #define X86_CR0_NE 0x00000020 /* Numeric Error */ | ||
35 | #define X86_CR0_WP 0x00010000 /* Write Protect */ | ||
36 | #define X86_CR0_AM 0x00040000 /* Alignment Mask */ | ||
37 | #define X86_CR0_NW 0x20000000 /* Not Write-through */ | ||
38 | #define X86_CR0_CD 0x40000000 /* Cache Disable */ | ||
39 | #define X86_CR0_PG 0x80000000 /* Paging */ | ||
40 | |||
41 | /* | ||
42 | * Paging options in CR3 | ||
43 | */ | ||
44 | #define X86_CR3_PWT 0x00000008 /* Page Write Through */ | ||
45 | #define X86_CR3_PCD 0x00000010 /* Page Cache Disable */ | ||
46 | |||
47 | /* | ||
48 | * Intel CPU features in CR4 | ||
49 | */ | ||
50 | #define X86_CR4_VME 0x00000001 /* enable vm86 extensions */ | ||
51 | #define X86_CR4_PVI 0x00000002 /* virtual interrupts flag enable */ | ||
52 | #define X86_CR4_TSD 0x00000004 /* disable time stamp at ipl 3 */ | ||
53 | #define X86_CR4_DE 0x00000008 /* enable debugging extensions */ | ||
54 | #define X86_CR4_PSE 0x00000010 /* enable page size extensions */ | ||
55 | #define X86_CR4_PAE 0x00000020 /* enable physical address extensions */ | ||
56 | #define X86_CR4_MCE 0x00000040 /* Machine check enable */ | ||
57 | #define X86_CR4_PGE 0x00000080 /* enable global pages */ | ||
58 | #define X86_CR4_PCE 0x00000100 /* enable performance counters at ipl 3 */ | ||
59 | #define X86_CR4_OSFXSR 0x00000200 /* enable fast FPU save and restore */ | ||
60 | #define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */ | ||
61 | #define X86_CR4_VMXE 0x00002000 /* enable VMX virtualization */ | ||
62 | |||
63 | /* | ||
64 | * x86-64 Task Priority Register, CR8 | ||
65 | */ | ||
66 | #define X86_CR8_TPR 0x00000007 /* task priority register */ | ||
67 | |||
68 | /* | ||
69 | * AMD and Transmeta use MSRs for configuration; see <asm/msr-index.h> | ||
70 | */ | ||
71 | |||
72 | /* | ||
73 | * NSC/Cyrix CPU configuration register indexes | ||
74 | */ | ||
75 | #define CX86_PCR0 0x20 | ||
76 | #define CX86_GCR 0xb8 | ||
77 | #define CX86_CCR0 0xc0 | ||
78 | #define CX86_CCR1 0xc1 | ||
79 | #define CX86_CCR2 0xc2 | ||
80 | #define CX86_CCR3 0xc3 | ||
81 | #define CX86_CCR4 0xe8 | ||
82 | #define CX86_CCR5 0xe9 | ||
83 | #define CX86_CCR6 0xea | ||
84 | #define CX86_CCR7 0xeb | ||
85 | #define CX86_PCR1 0xf0 | ||
86 | #define CX86_DIR0 0xfe | ||
87 | #define CX86_DIR1 0xff | ||
88 | #define CX86_ARR_BASE 0xc4 | ||
89 | #define CX86_RCR_BASE 0xdc | ||
90 | |||
91 | #endif /* __ASM_I386_PROCESSOR_FLAGS_H */ | ||
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h new file mode 100644 index 000000000000..46e1c04e309c --- /dev/null +++ b/include/asm-x86/processor.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "processor_32.h" | ||
3 | #else | ||
4 | # include "processor_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/processor_32.h b/include/asm-x86/processor_32.h new file mode 100644 index 000000000000..3845fe72383e --- /dev/null +++ b/include/asm-x86/processor_32.h | |||
@@ -0,0 +1,755 @@ | |||
1 | /* | ||
2 | * include/asm-i386/processor.h | ||
3 | * | ||
4 | * Copyright (C) 1994 Linus Torvalds | ||
5 | */ | ||
6 | |||
7 | #ifndef __ASM_I386_PROCESSOR_H | ||
8 | #define __ASM_I386_PROCESSOR_H | ||
9 | |||
10 | #include <asm/vm86.h> | ||
11 | #include <asm/math_emu.h> | ||
12 | #include <asm/segment.h> | ||
13 | #include <asm/page.h> | ||
14 | #include <asm/types.h> | ||
15 | #include <asm/sigcontext.h> | ||
16 | #include <asm/cpufeature.h> | ||
17 | #include <asm/msr.h> | ||
18 | #include <asm/system.h> | ||
19 | #include <linux/cache.h> | ||
20 | #include <linux/threads.h> | ||
21 | #include <asm/percpu.h> | ||
22 | #include <linux/cpumask.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <asm/processor-flags.h> | ||
25 | |||
26 | /* flag for disabling the tsc */ | ||
27 | extern int tsc_disable; | ||
28 | |||
29 | struct desc_struct { | ||
30 | unsigned long a,b; | ||
31 | }; | ||
32 | |||
33 | #define desc_empty(desc) \ | ||
34 | (!((desc)->a | (desc)->b)) | ||
35 | |||
36 | #define desc_equal(desc1, desc2) \ | ||
37 | (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b)) | ||
38 | /* | ||
39 | * Default implementation of macro that returns current | ||
40 | * instruction pointer ("program counter"). | ||
41 | */ | ||
42 | #define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; }) | ||
43 | |||
44 | /* | ||
45 | * CPU type and hardware bug flags. Kept separately for each CPU. | ||
46 | * Members of this structure are referenced in head.S, so think twice | ||
47 | * before touching them. [mj] | ||
48 | */ | ||
49 | |||
50 | struct cpuinfo_x86 { | ||
51 | __u8 x86; /* CPU family */ | ||
52 | __u8 x86_vendor; /* CPU vendor */ | ||
53 | __u8 x86_model; | ||
54 | __u8 x86_mask; | ||
55 | char wp_works_ok; /* It doesn't on 386's */ | ||
56 | char hlt_works_ok; /* Problems on some 486Dx4's and old 386's */ | ||
57 | char hard_math; | ||
58 | char rfu; | ||
59 | int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */ | ||
60 | unsigned long x86_capability[NCAPINTS]; | ||
61 | char x86_vendor_id[16]; | ||
62 | char x86_model_id[64]; | ||
63 | int x86_cache_size; /* in KB - valid for CPUS which support this | ||
64 | call */ | ||
65 | int x86_cache_alignment; /* In bytes */ | ||
66 | char fdiv_bug; | ||
67 | char f00f_bug; | ||
68 | char coma_bug; | ||
69 | char pad0; | ||
70 | int x86_power; | ||
71 | unsigned long loops_per_jiffy; | ||
72 | #ifdef CONFIG_SMP | ||
73 | cpumask_t llc_shared_map; /* cpus sharing the last level cache */ | ||
74 | #endif | ||
75 | unsigned char x86_max_cores; /* cpuid returned max cores value */ | ||
76 | unsigned char apicid; | ||
77 | unsigned short x86_clflush_size; | ||
78 | #ifdef CONFIG_SMP | ||
79 | unsigned char booted_cores; /* number of cores as seen by OS */ | ||
80 | __u8 phys_proc_id; /* Physical processor id. */ | ||
81 | __u8 cpu_core_id; /* Core id */ | ||
82 | #endif | ||
83 | } __attribute__((__aligned__(SMP_CACHE_BYTES))); | ||
84 | |||
85 | #define X86_VENDOR_INTEL 0 | ||
86 | #define X86_VENDOR_CYRIX 1 | ||
87 | #define X86_VENDOR_AMD 2 | ||
88 | #define X86_VENDOR_UMC 3 | ||
89 | #define X86_VENDOR_NEXGEN 4 | ||
90 | #define X86_VENDOR_CENTAUR 5 | ||
91 | #define X86_VENDOR_TRANSMETA 7 | ||
92 | #define X86_VENDOR_NSC 8 | ||
93 | #define X86_VENDOR_NUM 9 | ||
94 | #define X86_VENDOR_UNKNOWN 0xff | ||
95 | |||
96 | /* | ||
97 | * capabilities of CPUs | ||
98 | */ | ||
99 | |||
100 | extern struct cpuinfo_x86 boot_cpu_data; | ||
101 | extern struct cpuinfo_x86 new_cpu_data; | ||
102 | extern struct tss_struct doublefault_tss; | ||
103 | DECLARE_PER_CPU(struct tss_struct, init_tss); | ||
104 | |||
105 | #ifdef CONFIG_SMP | ||
106 | extern struct cpuinfo_x86 cpu_data[]; | ||
107 | #define current_cpu_data cpu_data[smp_processor_id()] | ||
108 | #else | ||
109 | #define cpu_data (&boot_cpu_data) | ||
110 | #define current_cpu_data boot_cpu_data | ||
111 | #endif | ||
112 | |||
113 | extern int cpu_llc_id[NR_CPUS]; | ||
114 | extern char ignore_fpu_irq; | ||
115 | |||
116 | void __init cpu_detect(struct cpuinfo_x86 *c); | ||
117 | |||
118 | extern void identify_boot_cpu(void); | ||
119 | extern void identify_secondary_cpu(struct cpuinfo_x86 *); | ||
120 | extern void print_cpu_info(struct cpuinfo_x86 *); | ||
121 | extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); | ||
122 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); | ||
123 | extern unsigned short num_cache_leaves; | ||
124 | |||
125 | #ifdef CONFIG_X86_HT | ||
126 | extern void detect_ht(struct cpuinfo_x86 *c); | ||
127 | #else | ||
128 | static inline void detect_ht(struct cpuinfo_x86 *c) {} | ||
129 | #endif | ||
130 | |||
131 | static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, | ||
132 | unsigned int *ecx, unsigned int *edx) | ||
133 | { | ||
134 | /* ecx is often an input as well as an output. */ | ||
135 | __asm__("cpuid" | ||
136 | : "=a" (*eax), | ||
137 | "=b" (*ebx), | ||
138 | "=c" (*ecx), | ||
139 | "=d" (*edx) | ||
140 | : "0" (*eax), "2" (*ecx)); | ||
141 | } | ||
142 | |||
143 | #define load_cr3(pgdir) write_cr3(__pa(pgdir)) | ||
144 | |||
145 | /* | ||
146 | * Save the cr4 feature set we're using (ie | ||
147 | * Pentium 4MB enable and PPro Global page | ||
148 | * enable), so that any CPU's that boot up | ||
149 | * after us can get the correct flags. | ||
150 | */ | ||
151 | extern unsigned long mmu_cr4_features; | ||
152 | |||
153 | static inline void set_in_cr4 (unsigned long mask) | ||
154 | { | ||
155 | unsigned cr4; | ||
156 | mmu_cr4_features |= mask; | ||
157 | cr4 = read_cr4(); | ||
158 | cr4 |= mask; | ||
159 | write_cr4(cr4); | ||
160 | } | ||
161 | |||
162 | static inline void clear_in_cr4 (unsigned long mask) | ||
163 | { | ||
164 | unsigned cr4; | ||
165 | mmu_cr4_features &= ~mask; | ||
166 | cr4 = read_cr4(); | ||
167 | cr4 &= ~mask; | ||
168 | write_cr4(cr4); | ||
169 | } | ||
170 | |||
171 | /* Stop speculative execution */ | ||
172 | static inline void sync_core(void) | ||
173 | { | ||
174 | int tmp; | ||
175 | asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory"); | ||
176 | } | ||
177 | |||
178 | static inline void __monitor(const void *eax, unsigned long ecx, | ||
179 | unsigned long edx) | ||
180 | { | ||
181 | /* "monitor %eax,%ecx,%edx;" */ | ||
182 | asm volatile( | ||
183 | ".byte 0x0f,0x01,0xc8;" | ||
184 | : :"a" (eax), "c" (ecx), "d"(edx)); | ||
185 | } | ||
186 | |||
187 | static inline void __mwait(unsigned long eax, unsigned long ecx) | ||
188 | { | ||
189 | /* "mwait %eax,%ecx;" */ | ||
190 | asm volatile( | ||
191 | ".byte 0x0f,0x01,0xc9;" | ||
192 | : :"a" (eax), "c" (ecx)); | ||
193 | } | ||
194 | |||
195 | extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx); | ||
196 | |||
197 | /* from system description table in BIOS. Mostly for MCA use, but | ||
198 | others may find it useful. */ | ||
199 | extern unsigned int machine_id; | ||
200 | extern unsigned int machine_submodel_id; | ||
201 | extern unsigned int BIOS_revision; | ||
202 | extern unsigned int mca_pentium_flag; | ||
203 | |||
204 | /* Boot loader type from the setup header */ | ||
205 | extern int bootloader_type; | ||
206 | |||
207 | /* | ||
208 | * User space process size: 3GB (default). | ||
209 | */ | ||
210 | #define TASK_SIZE (PAGE_OFFSET) | ||
211 | |||
212 | /* This decides where the kernel will search for a free chunk of vm | ||
213 | * space during mmap's. | ||
214 | */ | ||
215 | #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) | ||
216 | |||
217 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | ||
218 | |||
219 | extern void hard_disable_TSC(void); | ||
220 | extern void disable_TSC(void); | ||
221 | extern void hard_enable_TSC(void); | ||
222 | |||
223 | /* | ||
224 | * Size of io_bitmap. | ||
225 | */ | ||
226 | #define IO_BITMAP_BITS 65536 | ||
227 | #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8) | ||
228 | #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long)) | ||
229 | #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap) | ||
230 | #define INVALID_IO_BITMAP_OFFSET 0x8000 | ||
231 | #define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000 | ||
232 | |||
233 | struct i387_fsave_struct { | ||
234 | long cwd; | ||
235 | long swd; | ||
236 | long twd; | ||
237 | long fip; | ||
238 | long fcs; | ||
239 | long foo; | ||
240 | long fos; | ||
241 | long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ | ||
242 | long status; /* software status information */ | ||
243 | }; | ||
244 | |||
245 | struct i387_fxsave_struct { | ||
246 | unsigned short cwd; | ||
247 | unsigned short swd; | ||
248 | unsigned short twd; | ||
249 | unsigned short fop; | ||
250 | long fip; | ||
251 | long fcs; | ||
252 | long foo; | ||
253 | long fos; | ||
254 | long mxcsr; | ||
255 | long mxcsr_mask; | ||
256 | long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ | ||
257 | long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ | ||
258 | long padding[56]; | ||
259 | } __attribute__ ((aligned (16))); | ||
260 | |||
261 | struct i387_soft_struct { | ||
262 | long cwd; | ||
263 | long swd; | ||
264 | long twd; | ||
265 | long fip; | ||
266 | long fcs; | ||
267 | long foo; | ||
268 | long fos; | ||
269 | long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ | ||
270 | unsigned char ftop, changed, lookahead, no_update, rm, alimit; | ||
271 | struct info *info; | ||
272 | unsigned long entry_eip; | ||
273 | }; | ||
274 | |||
275 | union i387_union { | ||
276 | struct i387_fsave_struct fsave; | ||
277 | struct i387_fxsave_struct fxsave; | ||
278 | struct i387_soft_struct soft; | ||
279 | }; | ||
280 | |||
281 | typedef struct { | ||
282 | unsigned long seg; | ||
283 | } mm_segment_t; | ||
284 | |||
285 | struct thread_struct; | ||
286 | |||
287 | /* This is the TSS defined by the hardware. */ | ||
288 | struct i386_hw_tss { | ||
289 | unsigned short back_link,__blh; | ||
290 | unsigned long esp0; | ||
291 | unsigned short ss0,__ss0h; | ||
292 | unsigned long esp1; | ||
293 | unsigned short ss1,__ss1h; /* ss1 is used to cache MSR_IA32_SYSENTER_CS */ | ||
294 | unsigned long esp2; | ||
295 | unsigned short ss2,__ss2h; | ||
296 | unsigned long __cr3; | ||
297 | unsigned long eip; | ||
298 | unsigned long eflags; | ||
299 | unsigned long eax,ecx,edx,ebx; | ||
300 | unsigned long esp; | ||
301 | unsigned long ebp; | ||
302 | unsigned long esi; | ||
303 | unsigned long edi; | ||
304 | unsigned short es, __esh; | ||
305 | unsigned short cs, __csh; | ||
306 | unsigned short ss, __ssh; | ||
307 | unsigned short ds, __dsh; | ||
308 | unsigned short fs, __fsh; | ||
309 | unsigned short gs, __gsh; | ||
310 | unsigned short ldt, __ldth; | ||
311 | unsigned short trace, io_bitmap_base; | ||
312 | } __attribute__((packed)); | ||
313 | |||
314 | struct tss_struct { | ||
315 | struct i386_hw_tss x86_tss; | ||
316 | |||
317 | /* | ||
318 | * The extra 1 is there because the CPU will access an | ||
319 | * additional byte beyond the end of the IO permission | ||
320 | * bitmap. The extra byte must be all 1 bits, and must | ||
321 | * be within the limit. | ||
322 | */ | ||
323 | unsigned long io_bitmap[IO_BITMAP_LONGS + 1]; | ||
324 | /* | ||
325 | * Cache the current maximum and the last task that used the bitmap: | ||
326 | */ | ||
327 | unsigned long io_bitmap_max; | ||
328 | struct thread_struct *io_bitmap_owner; | ||
329 | /* | ||
330 | * pads the TSS to be cacheline-aligned (size is 0x100) | ||
331 | */ | ||
332 | unsigned long __cacheline_filler[35]; | ||
333 | /* | ||
334 | * .. and then another 0x100 bytes for emergency kernel stack | ||
335 | */ | ||
336 | unsigned long stack[64]; | ||
337 | } __attribute__((packed)); | ||
338 | |||
339 | #define ARCH_MIN_TASKALIGN 16 | ||
340 | |||
341 | struct thread_struct { | ||
342 | /* cached TLS descriptors. */ | ||
343 | struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES]; | ||
344 | unsigned long esp0; | ||
345 | unsigned long sysenter_cs; | ||
346 | unsigned long eip; | ||
347 | unsigned long esp; | ||
348 | unsigned long fs; | ||
349 | unsigned long gs; | ||
350 | /* Hardware debugging registers */ | ||
351 | unsigned long debugreg[8]; /* %%db0-7 debug registers */ | ||
352 | /* fault info */ | ||
353 | unsigned long cr2, trap_no, error_code; | ||
354 | /* floating point info */ | ||
355 | union i387_union i387; | ||
356 | /* virtual 86 mode info */ | ||
357 | struct vm86_struct __user * vm86_info; | ||
358 | unsigned long screen_bitmap; | ||
359 | unsigned long v86flags, v86mask, saved_esp0; | ||
360 | unsigned int saved_fs, saved_gs; | ||
361 | /* IO permissions */ | ||
362 | unsigned long *io_bitmap_ptr; | ||
363 | unsigned long iopl; | ||
364 | /* max allowed port in the bitmap, in bytes: */ | ||
365 | unsigned long io_bitmap_max; | ||
366 | }; | ||
367 | |||
368 | #define INIT_THREAD { \ | ||
369 | .esp0 = sizeof(init_stack) + (long)&init_stack, \ | ||
370 | .vm86_info = NULL, \ | ||
371 | .sysenter_cs = __KERNEL_CS, \ | ||
372 | .io_bitmap_ptr = NULL, \ | ||
373 | .fs = __KERNEL_PERCPU, \ | ||
374 | } | ||
375 | |||
376 | /* | ||
377 | * Note that the .io_bitmap member must be extra-big. This is because | ||
378 | * the CPU will access an additional byte beyond the end of the IO | ||
379 | * permission bitmap. The extra byte must be all 1 bits, and must | ||
380 | * be within the limit. | ||
381 | */ | ||
382 | #define INIT_TSS { \ | ||
383 | .x86_tss = { \ | ||
384 | .esp0 = sizeof(init_stack) + (long)&init_stack, \ | ||
385 | .ss0 = __KERNEL_DS, \ | ||
386 | .ss1 = __KERNEL_CS, \ | ||
387 | .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \ | ||
388 | }, \ | ||
389 | .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \ | ||
390 | } | ||
391 | |||
392 | #define start_thread(regs, new_eip, new_esp) do { \ | ||
393 | __asm__("movl %0,%%gs": :"r" (0)); \ | ||
394 | regs->xfs = 0; \ | ||
395 | set_fs(USER_DS); \ | ||
396 | regs->xds = __USER_DS; \ | ||
397 | regs->xes = __USER_DS; \ | ||
398 | regs->xss = __USER_DS; \ | ||
399 | regs->xcs = __USER_CS; \ | ||
400 | regs->eip = new_eip; \ | ||
401 | regs->esp = new_esp; \ | ||
402 | } while (0) | ||
403 | |||
404 | /* Forward declaration, a strange C thing */ | ||
405 | struct task_struct; | ||
406 | struct mm_struct; | ||
407 | |||
408 | /* Free all resources held by a thread. */ | ||
409 | extern void release_thread(struct task_struct *); | ||
410 | |||
411 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
412 | extern void prepare_to_copy(struct task_struct *tsk); | ||
413 | |||
414 | /* | ||
415 | * create a kernel thread without removing it from tasklists | ||
416 | */ | ||
417 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
418 | |||
419 | extern unsigned long thread_saved_pc(struct task_struct *tsk); | ||
420 | void show_trace(struct task_struct *task, struct pt_regs *regs, unsigned long *stack); | ||
421 | |||
422 | unsigned long get_wchan(struct task_struct *p); | ||
423 | |||
424 | #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long)) | ||
425 | #define KSTK_TOP(info) \ | ||
426 | ({ \ | ||
427 | unsigned long *__ptr = (unsigned long *)(info); \ | ||
428 | (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \ | ||
429 | }) | ||
430 | |||
431 | /* | ||
432 | * The below -8 is to reserve 8 bytes on top of the ring0 stack. | ||
433 | * This is necessary to guarantee that the entire "struct pt_regs" | ||
434 | * is accessable even if the CPU haven't stored the SS/ESP registers | ||
435 | * on the stack (interrupt gate does not save these registers | ||
436 | * when switching to the same priv ring). | ||
437 | * Therefore beware: accessing the xss/esp fields of the | ||
438 | * "struct pt_regs" is possible, but they may contain the | ||
439 | * completely wrong values. | ||
440 | */ | ||
441 | #define task_pt_regs(task) \ | ||
442 | ({ \ | ||
443 | struct pt_regs *__regs__; \ | ||
444 | __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \ | ||
445 | __regs__ - 1; \ | ||
446 | }) | ||
447 | |||
448 | #define KSTK_EIP(task) (task_pt_regs(task)->eip) | ||
449 | #define KSTK_ESP(task) (task_pt_regs(task)->esp) | ||
450 | |||
451 | |||
452 | struct microcode_header { | ||
453 | unsigned int hdrver; | ||
454 | unsigned int rev; | ||
455 | unsigned int date; | ||
456 | unsigned int sig; | ||
457 | unsigned int cksum; | ||
458 | unsigned int ldrver; | ||
459 | unsigned int pf; | ||
460 | unsigned int datasize; | ||
461 | unsigned int totalsize; | ||
462 | unsigned int reserved[3]; | ||
463 | }; | ||
464 | |||
465 | struct microcode { | ||
466 | struct microcode_header hdr; | ||
467 | unsigned int bits[0]; | ||
468 | }; | ||
469 | |||
470 | typedef struct microcode microcode_t; | ||
471 | typedef struct microcode_header microcode_header_t; | ||
472 | |||
473 | /* microcode format is extended from prescott processors */ | ||
474 | struct extended_signature { | ||
475 | unsigned int sig; | ||
476 | unsigned int pf; | ||
477 | unsigned int cksum; | ||
478 | }; | ||
479 | |||
480 | struct extended_sigtable { | ||
481 | unsigned int count; | ||
482 | unsigned int cksum; | ||
483 | unsigned int reserved[3]; | ||
484 | struct extended_signature sigs[0]; | ||
485 | }; | ||
486 | |||
487 | /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ | ||
488 | static inline void rep_nop(void) | ||
489 | { | ||
490 | __asm__ __volatile__("rep;nop": : :"memory"); | ||
491 | } | ||
492 | |||
493 | #define cpu_relax() rep_nop() | ||
494 | |||
495 | static inline void native_load_esp0(struct tss_struct *tss, struct thread_struct *thread) | ||
496 | { | ||
497 | tss->x86_tss.esp0 = thread->esp0; | ||
498 | /* This can only happen when SEP is enabled, no need to test "SEP"arately */ | ||
499 | if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) { | ||
500 | tss->x86_tss.ss1 = thread->sysenter_cs; | ||
501 | wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0); | ||
502 | } | ||
503 | } | ||
504 | |||
505 | |||
506 | static inline unsigned long native_get_debugreg(int regno) | ||
507 | { | ||
508 | unsigned long val = 0; /* Damn you, gcc! */ | ||
509 | |||
510 | switch (regno) { | ||
511 | case 0: | ||
512 | asm("movl %%db0, %0" :"=r" (val)); break; | ||
513 | case 1: | ||
514 | asm("movl %%db1, %0" :"=r" (val)); break; | ||
515 | case 2: | ||
516 | asm("movl %%db2, %0" :"=r" (val)); break; | ||
517 | case 3: | ||
518 | asm("movl %%db3, %0" :"=r" (val)); break; | ||
519 | case 6: | ||
520 | asm("movl %%db6, %0" :"=r" (val)); break; | ||
521 | case 7: | ||
522 | asm("movl %%db7, %0" :"=r" (val)); break; | ||
523 | default: | ||
524 | BUG(); | ||
525 | } | ||
526 | return val; | ||
527 | } | ||
528 | |||
529 | static inline void native_set_debugreg(int regno, unsigned long value) | ||
530 | { | ||
531 | switch (regno) { | ||
532 | case 0: | ||
533 | asm("movl %0,%%db0" : /* no output */ :"r" (value)); | ||
534 | break; | ||
535 | case 1: | ||
536 | asm("movl %0,%%db1" : /* no output */ :"r" (value)); | ||
537 | break; | ||
538 | case 2: | ||
539 | asm("movl %0,%%db2" : /* no output */ :"r" (value)); | ||
540 | break; | ||
541 | case 3: | ||
542 | asm("movl %0,%%db3" : /* no output */ :"r" (value)); | ||
543 | break; | ||
544 | case 6: | ||
545 | asm("movl %0,%%db6" : /* no output */ :"r" (value)); | ||
546 | break; | ||
547 | case 7: | ||
548 | asm("movl %0,%%db7" : /* no output */ :"r" (value)); | ||
549 | break; | ||
550 | default: | ||
551 | BUG(); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | /* | ||
556 | * Set IOPL bits in EFLAGS from given mask | ||
557 | */ | ||
558 | static inline void native_set_iopl_mask(unsigned mask) | ||
559 | { | ||
560 | unsigned int reg; | ||
561 | __asm__ __volatile__ ("pushfl;" | ||
562 | "popl %0;" | ||
563 | "andl %1, %0;" | ||
564 | "orl %2, %0;" | ||
565 | "pushl %0;" | ||
566 | "popfl" | ||
567 | : "=&r" (reg) | ||
568 | : "i" (~X86_EFLAGS_IOPL), "r" (mask)); | ||
569 | } | ||
570 | |||
571 | #ifdef CONFIG_PARAVIRT | ||
572 | #include <asm/paravirt.h> | ||
573 | #else | ||
574 | #define paravirt_enabled() 0 | ||
575 | #define __cpuid native_cpuid | ||
576 | |||
577 | static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread) | ||
578 | { | ||
579 | native_load_esp0(tss, thread); | ||
580 | } | ||
581 | |||
582 | /* | ||
583 | * These special macros can be used to get or set a debugging register | ||
584 | */ | ||
585 | #define get_debugreg(var, register) \ | ||
586 | (var) = native_get_debugreg(register) | ||
587 | #define set_debugreg(value, register) \ | ||
588 | native_set_debugreg(register, value) | ||
589 | |||
590 | #define set_iopl_mask native_set_iopl_mask | ||
591 | #endif /* CONFIG_PARAVIRT */ | ||
592 | |||
593 | /* | ||
594 | * Generic CPUID function | ||
595 | * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx | ||
596 | * resulting in stale register contents being returned. | ||
597 | */ | ||
598 | static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) | ||
599 | { | ||
600 | *eax = op; | ||
601 | *ecx = 0; | ||
602 | __cpuid(eax, ebx, ecx, edx); | ||
603 | } | ||
604 | |||
605 | /* Some CPUID calls want 'count' to be placed in ecx */ | ||
606 | static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, | ||
607 | int *edx) | ||
608 | { | ||
609 | *eax = op; | ||
610 | *ecx = count; | ||
611 | __cpuid(eax, ebx, ecx, edx); | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | * CPUID functions returning a single datum | ||
616 | */ | ||
617 | static inline unsigned int cpuid_eax(unsigned int op) | ||
618 | { | ||
619 | unsigned int eax, ebx, ecx, edx; | ||
620 | |||
621 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
622 | return eax; | ||
623 | } | ||
624 | static inline unsigned int cpuid_ebx(unsigned int op) | ||
625 | { | ||
626 | unsigned int eax, ebx, ecx, edx; | ||
627 | |||
628 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
629 | return ebx; | ||
630 | } | ||
631 | static inline unsigned int cpuid_ecx(unsigned int op) | ||
632 | { | ||
633 | unsigned int eax, ebx, ecx, edx; | ||
634 | |||
635 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
636 | return ecx; | ||
637 | } | ||
638 | static inline unsigned int cpuid_edx(unsigned int op) | ||
639 | { | ||
640 | unsigned int eax, ebx, ecx, edx; | ||
641 | |||
642 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
643 | return edx; | ||
644 | } | ||
645 | |||
646 | /* generic versions from gas */ | ||
647 | #define GENERIC_NOP1 ".byte 0x90\n" | ||
648 | #define GENERIC_NOP2 ".byte 0x89,0xf6\n" | ||
649 | #define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n" | ||
650 | #define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n" | ||
651 | #define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4 | ||
652 | #define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n" | ||
653 | #define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n" | ||
654 | #define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7 | ||
655 | |||
656 | /* Opteron nops */ | ||
657 | #define K8_NOP1 GENERIC_NOP1 | ||
658 | #define K8_NOP2 ".byte 0x66,0x90\n" | ||
659 | #define K8_NOP3 ".byte 0x66,0x66,0x90\n" | ||
660 | #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" | ||
661 | #define K8_NOP5 K8_NOP3 K8_NOP2 | ||
662 | #define K8_NOP6 K8_NOP3 K8_NOP3 | ||
663 | #define K8_NOP7 K8_NOP4 K8_NOP3 | ||
664 | #define K8_NOP8 K8_NOP4 K8_NOP4 | ||
665 | |||
666 | /* K7 nops */ | ||
667 | /* uses eax dependencies (arbitary choice) */ | ||
668 | #define K7_NOP1 GENERIC_NOP1 | ||
669 | #define K7_NOP2 ".byte 0x8b,0xc0\n" | ||
670 | #define K7_NOP3 ".byte 0x8d,0x04,0x20\n" | ||
671 | #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n" | ||
672 | #define K7_NOP5 K7_NOP4 ASM_NOP1 | ||
673 | #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n" | ||
674 | #define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n" | ||
675 | #define K7_NOP8 K7_NOP7 ASM_NOP1 | ||
676 | |||
677 | #ifdef CONFIG_MK8 | ||
678 | #define ASM_NOP1 K8_NOP1 | ||
679 | #define ASM_NOP2 K8_NOP2 | ||
680 | #define ASM_NOP3 K8_NOP3 | ||
681 | #define ASM_NOP4 K8_NOP4 | ||
682 | #define ASM_NOP5 K8_NOP5 | ||
683 | #define ASM_NOP6 K8_NOP6 | ||
684 | #define ASM_NOP7 K8_NOP7 | ||
685 | #define ASM_NOP8 K8_NOP8 | ||
686 | #elif defined(CONFIG_MK7) | ||
687 | #define ASM_NOP1 K7_NOP1 | ||
688 | #define ASM_NOP2 K7_NOP2 | ||
689 | #define ASM_NOP3 K7_NOP3 | ||
690 | #define ASM_NOP4 K7_NOP4 | ||
691 | #define ASM_NOP5 K7_NOP5 | ||
692 | #define ASM_NOP6 K7_NOP6 | ||
693 | #define ASM_NOP7 K7_NOP7 | ||
694 | #define ASM_NOP8 K7_NOP8 | ||
695 | #else | ||
696 | #define ASM_NOP1 GENERIC_NOP1 | ||
697 | #define ASM_NOP2 GENERIC_NOP2 | ||
698 | #define ASM_NOP3 GENERIC_NOP3 | ||
699 | #define ASM_NOP4 GENERIC_NOP4 | ||
700 | #define ASM_NOP5 GENERIC_NOP5 | ||
701 | #define ASM_NOP6 GENERIC_NOP6 | ||
702 | #define ASM_NOP7 GENERIC_NOP7 | ||
703 | #define ASM_NOP8 GENERIC_NOP8 | ||
704 | #endif | ||
705 | |||
706 | #define ASM_NOP_MAX 8 | ||
707 | |||
708 | /* Prefetch instructions for Pentium III and AMD Athlon */ | ||
709 | /* It's not worth to care about 3dnow! prefetches for the K6 | ||
710 | because they are microcoded there and very slow. | ||
711 | However we don't do prefetches for pre XP Athlons currently | ||
712 | That should be fixed. */ | ||
713 | #define ARCH_HAS_PREFETCH | ||
714 | static inline void prefetch(const void *x) | ||
715 | { | ||
716 | alternative_input(ASM_NOP4, | ||
717 | "prefetchnta (%1)", | ||
718 | X86_FEATURE_XMM, | ||
719 | "r" (x)); | ||
720 | } | ||
721 | |||
722 | #define ARCH_HAS_PREFETCH | ||
723 | #define ARCH_HAS_PREFETCHW | ||
724 | #define ARCH_HAS_SPINLOCK_PREFETCH | ||
725 | |||
726 | /* 3dnow! prefetch to get an exclusive cache line. Useful for | ||
727 | spinlocks to avoid one state transition in the cache coherency protocol. */ | ||
728 | static inline void prefetchw(const void *x) | ||
729 | { | ||
730 | alternative_input(ASM_NOP4, | ||
731 | "prefetchw (%1)", | ||
732 | X86_FEATURE_3DNOW, | ||
733 | "r" (x)); | ||
734 | } | ||
735 | #define spin_lock_prefetch(x) prefetchw(x) | ||
736 | |||
737 | extern void select_idle_routine(const struct cpuinfo_x86 *c); | ||
738 | |||
739 | #define cache_line_size() (boot_cpu_data.x86_cache_alignment) | ||
740 | |||
741 | extern unsigned long boot_option_idle_override; | ||
742 | extern void enable_sep_cpu(void); | ||
743 | extern int sysenter_setup(void); | ||
744 | |||
745 | /* Defined in head.S */ | ||
746 | extern struct Xgt_desc_struct early_gdt_descr; | ||
747 | |||
748 | extern void cpu_set_gdt(int); | ||
749 | extern void switch_to_new_gdt(void); | ||
750 | extern void cpu_init(void); | ||
751 | extern void init_gdt(int cpu); | ||
752 | |||
753 | extern int force_mwait; | ||
754 | |||
755 | #endif /* __ASM_I386_PROCESSOR_H */ | ||
diff --git a/include/asm-x86/processor_64.h b/include/asm-x86/processor_64.h new file mode 100644 index 000000000000..31f579b828f2 --- /dev/null +++ b/include/asm-x86/processor_64.h | |||
@@ -0,0 +1,439 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/processor.h | ||
3 | * | ||
4 | * Copyright (C) 1994 Linus Torvalds | ||
5 | */ | ||
6 | |||
7 | #ifndef __ASM_X86_64_PROCESSOR_H | ||
8 | #define __ASM_X86_64_PROCESSOR_H | ||
9 | |||
10 | #include <asm/segment.h> | ||
11 | #include <asm/page.h> | ||
12 | #include <asm/types.h> | ||
13 | #include <asm/sigcontext.h> | ||
14 | #include <asm/cpufeature.h> | ||
15 | #include <linux/threads.h> | ||
16 | #include <asm/msr.h> | ||
17 | #include <asm/current.h> | ||
18 | #include <asm/system.h> | ||
19 | #include <asm/mmsegment.h> | ||
20 | #include <asm/percpu.h> | ||
21 | #include <linux/personality.h> | ||
22 | #include <linux/cpumask.h> | ||
23 | #include <asm/processor-flags.h> | ||
24 | |||
25 | #define TF_MASK 0x00000100 | ||
26 | #define IF_MASK 0x00000200 | ||
27 | #define IOPL_MASK 0x00003000 | ||
28 | #define NT_MASK 0x00004000 | ||
29 | #define VM_MASK 0x00020000 | ||
30 | #define AC_MASK 0x00040000 | ||
31 | #define VIF_MASK 0x00080000 /* virtual interrupt flag */ | ||
32 | #define VIP_MASK 0x00100000 /* virtual interrupt pending */ | ||
33 | #define ID_MASK 0x00200000 | ||
34 | |||
35 | #define desc_empty(desc) \ | ||
36 | (!((desc)->a | (desc)->b)) | ||
37 | |||
38 | #define desc_equal(desc1, desc2) \ | ||
39 | (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b)) | ||
40 | |||
41 | /* | ||
42 | * Default implementation of macro that returns current | ||
43 | * instruction pointer ("program counter"). | ||
44 | */ | ||
45 | #define current_text_addr() ({ void *pc; asm volatile("leaq 1f(%%rip),%0\n1:":"=r"(pc)); pc; }) | ||
46 | |||
47 | /* | ||
48 | * CPU type and hardware bug flags. Kept separately for each CPU. | ||
49 | */ | ||
50 | |||
51 | struct cpuinfo_x86 { | ||
52 | __u8 x86; /* CPU family */ | ||
53 | __u8 x86_vendor; /* CPU vendor */ | ||
54 | __u8 x86_model; | ||
55 | __u8 x86_mask; | ||
56 | int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */ | ||
57 | __u32 x86_capability[NCAPINTS]; | ||
58 | char x86_vendor_id[16]; | ||
59 | char x86_model_id[64]; | ||
60 | int x86_cache_size; /* in KB */ | ||
61 | int x86_clflush_size; | ||
62 | int x86_cache_alignment; | ||
63 | int x86_tlbsize; /* number of 4K pages in DTLB/ITLB combined(in pages)*/ | ||
64 | __u8 x86_virt_bits, x86_phys_bits; | ||
65 | __u8 x86_max_cores; /* cpuid returned max cores value */ | ||
66 | __u32 x86_power; | ||
67 | __u32 extended_cpuid_level; /* Max extended CPUID function supported */ | ||
68 | unsigned long loops_per_jiffy; | ||
69 | #ifdef CONFIG_SMP | ||
70 | cpumask_t llc_shared_map; /* cpus sharing the last level cache */ | ||
71 | #endif | ||
72 | __u8 apicid; | ||
73 | #ifdef CONFIG_SMP | ||
74 | __u8 booted_cores; /* number of cores as seen by OS */ | ||
75 | __u8 phys_proc_id; /* Physical Processor id. */ | ||
76 | __u8 cpu_core_id; /* Core id. */ | ||
77 | #endif | ||
78 | } ____cacheline_aligned; | ||
79 | |||
80 | #define X86_VENDOR_INTEL 0 | ||
81 | #define X86_VENDOR_CYRIX 1 | ||
82 | #define X86_VENDOR_AMD 2 | ||
83 | #define X86_VENDOR_UMC 3 | ||
84 | #define X86_VENDOR_NEXGEN 4 | ||
85 | #define X86_VENDOR_CENTAUR 5 | ||
86 | #define X86_VENDOR_TRANSMETA 7 | ||
87 | #define X86_VENDOR_NUM 8 | ||
88 | #define X86_VENDOR_UNKNOWN 0xff | ||
89 | |||
90 | #ifdef CONFIG_SMP | ||
91 | extern struct cpuinfo_x86 cpu_data[]; | ||
92 | #define current_cpu_data cpu_data[smp_processor_id()] | ||
93 | #else | ||
94 | #define cpu_data (&boot_cpu_data) | ||
95 | #define current_cpu_data boot_cpu_data | ||
96 | #endif | ||
97 | |||
98 | extern char ignore_irq13; | ||
99 | |||
100 | extern void identify_cpu(struct cpuinfo_x86 *); | ||
101 | extern void print_cpu_info(struct cpuinfo_x86 *); | ||
102 | extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); | ||
103 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); | ||
104 | extern unsigned short num_cache_leaves; | ||
105 | |||
106 | /* | ||
107 | * Save the cr4 feature set we're using (ie | ||
108 | * Pentium 4MB enable and PPro Global page | ||
109 | * enable), so that any CPU's that boot up | ||
110 | * after us can get the correct flags. | ||
111 | */ | ||
112 | extern unsigned long mmu_cr4_features; | ||
113 | |||
114 | static inline void set_in_cr4 (unsigned long mask) | ||
115 | { | ||
116 | mmu_cr4_features |= mask; | ||
117 | __asm__("movq %%cr4,%%rax\n\t" | ||
118 | "orq %0,%%rax\n\t" | ||
119 | "movq %%rax,%%cr4\n" | ||
120 | : : "irg" (mask) | ||
121 | :"ax"); | ||
122 | } | ||
123 | |||
124 | static inline void clear_in_cr4 (unsigned long mask) | ||
125 | { | ||
126 | mmu_cr4_features &= ~mask; | ||
127 | __asm__("movq %%cr4,%%rax\n\t" | ||
128 | "andq %0,%%rax\n\t" | ||
129 | "movq %%rax,%%cr4\n" | ||
130 | : : "irg" (~mask) | ||
131 | :"ax"); | ||
132 | } | ||
133 | |||
134 | |||
135 | /* | ||
136 | * User space process size. 47bits minus one guard page. | ||
137 | */ | ||
138 | #define TASK_SIZE64 (0x800000000000UL - 4096) | ||
139 | |||
140 | /* This decides where the kernel will search for a free chunk of vm | ||
141 | * space during mmap's. | ||
142 | */ | ||
143 | #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000) | ||
144 | |||
145 | #define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64) | ||
146 | #define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64) | ||
147 | |||
148 | #define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE/3) | ||
149 | |||
150 | /* | ||
151 | * Size of io_bitmap. | ||
152 | */ | ||
153 | #define IO_BITMAP_BITS 65536 | ||
154 | #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8) | ||
155 | #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long)) | ||
156 | #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap) | ||
157 | #define INVALID_IO_BITMAP_OFFSET 0x8000 | ||
158 | |||
159 | struct i387_fxsave_struct { | ||
160 | u16 cwd; | ||
161 | u16 swd; | ||
162 | u16 twd; | ||
163 | u16 fop; | ||
164 | u64 rip; | ||
165 | u64 rdp; | ||
166 | u32 mxcsr; | ||
167 | u32 mxcsr_mask; | ||
168 | u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ | ||
169 | u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */ | ||
170 | u32 padding[24]; | ||
171 | } __attribute__ ((aligned (16))); | ||
172 | |||
173 | union i387_union { | ||
174 | struct i387_fxsave_struct fxsave; | ||
175 | }; | ||
176 | |||
177 | struct tss_struct { | ||
178 | u32 reserved1; | ||
179 | u64 rsp0; | ||
180 | u64 rsp1; | ||
181 | u64 rsp2; | ||
182 | u64 reserved2; | ||
183 | u64 ist[7]; | ||
184 | u32 reserved3; | ||
185 | u32 reserved4; | ||
186 | u16 reserved5; | ||
187 | u16 io_bitmap_base; | ||
188 | /* | ||
189 | * The extra 1 is there because the CPU will access an | ||
190 | * additional byte beyond the end of the IO permission | ||
191 | * bitmap. The extra byte must be all 1 bits, and must | ||
192 | * be within the limit. Thus we have: | ||
193 | * | ||
194 | * 128 bytes, the bitmap itself, for ports 0..0x3ff | ||
195 | * 8 bytes, for an extra "long" of ~0UL | ||
196 | */ | ||
197 | unsigned long io_bitmap[IO_BITMAP_LONGS + 1]; | ||
198 | } __attribute__((packed)) ____cacheline_aligned; | ||
199 | |||
200 | |||
201 | extern struct cpuinfo_x86 boot_cpu_data; | ||
202 | DECLARE_PER_CPU(struct tss_struct,init_tss); | ||
203 | /* Save the original ist values for checking stack pointers during debugging */ | ||
204 | struct orig_ist { | ||
205 | unsigned long ist[7]; | ||
206 | }; | ||
207 | DECLARE_PER_CPU(struct orig_ist, orig_ist); | ||
208 | |||
209 | #ifdef CONFIG_X86_VSMP | ||
210 | #define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT) | ||
211 | #define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT) | ||
212 | #else | ||
213 | #define ARCH_MIN_TASKALIGN 16 | ||
214 | #define ARCH_MIN_MMSTRUCT_ALIGN 0 | ||
215 | #endif | ||
216 | |||
217 | struct thread_struct { | ||
218 | unsigned long rsp0; | ||
219 | unsigned long rsp; | ||
220 | unsigned long userrsp; /* Copy from PDA */ | ||
221 | unsigned long fs; | ||
222 | unsigned long gs; | ||
223 | unsigned short es, ds, fsindex, gsindex; | ||
224 | /* Hardware debugging registers */ | ||
225 | unsigned long debugreg0; | ||
226 | unsigned long debugreg1; | ||
227 | unsigned long debugreg2; | ||
228 | unsigned long debugreg3; | ||
229 | unsigned long debugreg6; | ||
230 | unsigned long debugreg7; | ||
231 | /* fault info */ | ||
232 | unsigned long cr2, trap_no, error_code; | ||
233 | /* floating point info */ | ||
234 | union i387_union i387 __attribute__((aligned(16))); | ||
235 | /* IO permissions. the bitmap could be moved into the GDT, that would make | ||
236 | switch faster for a limited number of ioperm using tasks. -AK */ | ||
237 | int ioperm; | ||
238 | unsigned long *io_bitmap_ptr; | ||
239 | unsigned io_bitmap_max; | ||
240 | /* cached TLS descriptors. */ | ||
241 | u64 tls_array[GDT_ENTRY_TLS_ENTRIES]; | ||
242 | } __attribute__((aligned(16))); | ||
243 | |||
244 | #define INIT_THREAD { \ | ||
245 | .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \ | ||
246 | } | ||
247 | |||
248 | #define INIT_TSS { \ | ||
249 | .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \ | ||
250 | } | ||
251 | |||
252 | #define INIT_MMAP \ | ||
253 | { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL } | ||
254 | |||
255 | #define start_thread(regs,new_rip,new_rsp) do { \ | ||
256 | asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \ | ||
257 | load_gs_index(0); \ | ||
258 | (regs)->rip = (new_rip); \ | ||
259 | (regs)->rsp = (new_rsp); \ | ||
260 | write_pda(oldrsp, (new_rsp)); \ | ||
261 | (regs)->cs = __USER_CS; \ | ||
262 | (regs)->ss = __USER_DS; \ | ||
263 | (regs)->eflags = 0x200; \ | ||
264 | set_fs(USER_DS); \ | ||
265 | } while(0) | ||
266 | |||
267 | #define get_debugreg(var, register) \ | ||
268 | __asm__("movq %%db" #register ", %0" \ | ||
269 | :"=r" (var)) | ||
270 | #define set_debugreg(value, register) \ | ||
271 | __asm__("movq %0,%%db" #register \ | ||
272 | : /* no output */ \ | ||
273 | :"r" (value)) | ||
274 | |||
275 | struct task_struct; | ||
276 | struct mm_struct; | ||
277 | |||
278 | /* Free all resources held by a thread. */ | ||
279 | extern void release_thread(struct task_struct *); | ||
280 | |||
281 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
282 | extern void prepare_to_copy(struct task_struct *tsk); | ||
283 | |||
284 | /* | ||
285 | * create a kernel thread without removing it from tasklists | ||
286 | */ | ||
287 | extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
288 | |||
289 | /* | ||
290 | * Return saved PC of a blocked thread. | ||
291 | * What is this good for? it will be always the scheduler or ret_from_fork. | ||
292 | */ | ||
293 | #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) | ||
294 | |||
295 | extern unsigned long get_wchan(struct task_struct *p); | ||
296 | #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1) | ||
297 | #define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip) | ||
298 | #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ | ||
299 | |||
300 | |||
301 | struct microcode_header { | ||
302 | unsigned int hdrver; | ||
303 | unsigned int rev; | ||
304 | unsigned int date; | ||
305 | unsigned int sig; | ||
306 | unsigned int cksum; | ||
307 | unsigned int ldrver; | ||
308 | unsigned int pf; | ||
309 | unsigned int datasize; | ||
310 | unsigned int totalsize; | ||
311 | unsigned int reserved[3]; | ||
312 | }; | ||
313 | |||
314 | struct microcode { | ||
315 | struct microcode_header hdr; | ||
316 | unsigned int bits[0]; | ||
317 | }; | ||
318 | |||
319 | typedef struct microcode microcode_t; | ||
320 | typedef struct microcode_header microcode_header_t; | ||
321 | |||
322 | /* microcode format is extended from prescott processors */ | ||
323 | struct extended_signature { | ||
324 | unsigned int sig; | ||
325 | unsigned int pf; | ||
326 | unsigned int cksum; | ||
327 | }; | ||
328 | |||
329 | struct extended_sigtable { | ||
330 | unsigned int count; | ||
331 | unsigned int cksum; | ||
332 | unsigned int reserved[3]; | ||
333 | struct extended_signature sigs[0]; | ||
334 | }; | ||
335 | |||
336 | |||
337 | #define ASM_NOP1 K8_NOP1 | ||
338 | #define ASM_NOP2 K8_NOP2 | ||
339 | #define ASM_NOP3 K8_NOP3 | ||
340 | #define ASM_NOP4 K8_NOP4 | ||
341 | #define ASM_NOP5 K8_NOP5 | ||
342 | #define ASM_NOP6 K8_NOP6 | ||
343 | #define ASM_NOP7 K8_NOP7 | ||
344 | #define ASM_NOP8 K8_NOP8 | ||
345 | |||
346 | /* Opteron nops */ | ||
347 | #define K8_NOP1 ".byte 0x90\n" | ||
348 | #define K8_NOP2 ".byte 0x66,0x90\n" | ||
349 | #define K8_NOP3 ".byte 0x66,0x66,0x90\n" | ||
350 | #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" | ||
351 | #define K8_NOP5 K8_NOP3 K8_NOP2 | ||
352 | #define K8_NOP6 K8_NOP3 K8_NOP3 | ||
353 | #define K8_NOP7 K8_NOP4 K8_NOP3 | ||
354 | #define K8_NOP8 K8_NOP4 K8_NOP4 | ||
355 | |||
356 | #define ASM_NOP_MAX 8 | ||
357 | |||
358 | /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ | ||
359 | static inline void rep_nop(void) | ||
360 | { | ||
361 | __asm__ __volatile__("rep;nop": : :"memory"); | ||
362 | } | ||
363 | |||
364 | /* Stop speculative execution */ | ||
365 | static inline void sync_core(void) | ||
366 | { | ||
367 | int tmp; | ||
368 | asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory"); | ||
369 | } | ||
370 | |||
371 | #define ARCH_HAS_PREFETCH | ||
372 | static inline void prefetch(void *x) | ||
373 | { | ||
374 | asm volatile("prefetcht0 (%0)" :: "r" (x)); | ||
375 | } | ||
376 | |||
377 | #define ARCH_HAS_PREFETCHW 1 | ||
378 | static inline void prefetchw(void *x) | ||
379 | { | ||
380 | alternative_input("prefetcht0 (%1)", | ||
381 | "prefetchw (%1)", | ||
382 | X86_FEATURE_3DNOW, | ||
383 | "r" (x)); | ||
384 | } | ||
385 | |||
386 | #define ARCH_HAS_SPINLOCK_PREFETCH 1 | ||
387 | |||
388 | #define spin_lock_prefetch(x) prefetchw(x) | ||
389 | |||
390 | #define cpu_relax() rep_nop() | ||
391 | |||
392 | static inline void serialize_cpu(void) | ||
393 | { | ||
394 | __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx"); | ||
395 | } | ||
396 | |||
397 | static inline void __monitor(const void *eax, unsigned long ecx, | ||
398 | unsigned long edx) | ||
399 | { | ||
400 | /* "monitor %eax,%ecx,%edx;" */ | ||
401 | asm volatile( | ||
402 | ".byte 0x0f,0x01,0xc8;" | ||
403 | : :"a" (eax), "c" (ecx), "d"(edx)); | ||
404 | } | ||
405 | |||
406 | static inline void __mwait(unsigned long eax, unsigned long ecx) | ||
407 | { | ||
408 | /* "mwait %eax,%ecx;" */ | ||
409 | asm volatile( | ||
410 | ".byte 0x0f,0x01,0xc9;" | ||
411 | : :"a" (eax), "c" (ecx)); | ||
412 | } | ||
413 | |||
414 | static inline void __sti_mwait(unsigned long eax, unsigned long ecx) | ||
415 | { | ||
416 | /* "mwait %eax,%ecx;" */ | ||
417 | asm volatile( | ||
418 | "sti; .byte 0x0f,0x01,0xc9;" | ||
419 | : :"a" (eax), "c" (ecx)); | ||
420 | } | ||
421 | |||
422 | extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx); | ||
423 | |||
424 | #define stack_current() \ | ||
425 | ({ \ | ||
426 | struct thread_info *ti; \ | ||
427 | asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ | ||
428 | ti->task; \ | ||
429 | }) | ||
430 | |||
431 | #define cache_line_size() (boot_cpu_data.x86_cache_alignment) | ||
432 | |||
433 | extern unsigned long boot_option_idle_override; | ||
434 | /* Boot loader type from the setup header */ | ||
435 | extern int bootloader_type; | ||
436 | |||
437 | #define HAVE_ARCH_PICK_MMAP_LAYOUT 1 | ||
438 | |||
439 | #endif /* __ASM_X86_64_PROCESSOR_H */ | ||
diff --git a/include/asm-x86/proto.h b/include/asm-x86/proto.h new file mode 100644 index 000000000000..31f20ad65876 --- /dev/null +++ b/include/asm-x86/proto.h | |||
@@ -0,0 +1,104 @@ | |||
1 | #ifndef _ASM_X8664_PROTO_H | ||
2 | #define _ASM_X8664_PROTO_H 1 | ||
3 | |||
4 | #include <asm/ldt.h> | ||
5 | |||
6 | /* misc architecture specific prototypes */ | ||
7 | |||
8 | struct cpuinfo_x86; | ||
9 | struct pt_regs; | ||
10 | |||
11 | extern void start_kernel(void); | ||
12 | extern void pda_init(int); | ||
13 | |||
14 | extern void early_idt_handler(void); | ||
15 | |||
16 | extern void mcheck_init(struct cpuinfo_x86 *c); | ||
17 | extern void init_memory_mapping(unsigned long start, unsigned long end); | ||
18 | |||
19 | extern void system_call(void); | ||
20 | extern int kernel_syscall(void); | ||
21 | extern void syscall_init(void); | ||
22 | |||
23 | extern void ia32_syscall(void); | ||
24 | extern void ia32_cstar_target(void); | ||
25 | extern void ia32_sysenter_target(void); | ||
26 | |||
27 | extern void config_acpi_tables(void); | ||
28 | extern void ia32_syscall(void); | ||
29 | |||
30 | extern int pmtimer_mark_offset(void); | ||
31 | extern void pmtimer_resume(void); | ||
32 | extern void pmtimer_wait(unsigned); | ||
33 | extern unsigned int do_gettimeoffset_pm(void); | ||
34 | #ifdef CONFIG_X86_PM_TIMER | ||
35 | extern u32 pmtmr_ioport; | ||
36 | #else | ||
37 | #define pmtmr_ioport 0 | ||
38 | #endif | ||
39 | extern int nohpet; | ||
40 | |||
41 | extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2))); | ||
42 | |||
43 | extern void early_identify_cpu(struct cpuinfo_x86 *c); | ||
44 | |||
45 | extern int k8_scan_nodes(unsigned long start, unsigned long end); | ||
46 | |||
47 | extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn); | ||
48 | extern unsigned long numa_free_all_bootmem(void); | ||
49 | |||
50 | extern void reserve_bootmem_generic(unsigned long phys, unsigned len); | ||
51 | |||
52 | extern void load_gs_index(unsigned gs); | ||
53 | |||
54 | extern void stop_timer_interrupt(void); | ||
55 | extern void main_timer_handler(void); | ||
56 | |||
57 | extern unsigned long end_pfn_map; | ||
58 | |||
59 | extern void show_trace(struct task_struct *, struct pt_regs *, unsigned long * rsp); | ||
60 | extern void show_registers(struct pt_regs *regs); | ||
61 | |||
62 | extern void exception_table_check(void); | ||
63 | |||
64 | extern void acpi_reserve_bootmem(void); | ||
65 | |||
66 | extern void swap_low_mappings(void); | ||
67 | |||
68 | extern void __show_regs(struct pt_regs * regs); | ||
69 | extern void show_regs(struct pt_regs * regs); | ||
70 | |||
71 | extern void syscall32_cpu_init(void); | ||
72 | |||
73 | extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end); | ||
74 | |||
75 | extern void early_quirks(void); | ||
76 | extern void check_efer(void); | ||
77 | |||
78 | extern void select_idle_routine(const struct cpuinfo_x86 *c); | ||
79 | |||
80 | extern unsigned long table_start, table_end; | ||
81 | |||
82 | extern int exception_trace; | ||
83 | extern unsigned cpu_khz; | ||
84 | extern unsigned tsc_khz; | ||
85 | |||
86 | extern int reboot_force; | ||
87 | extern int notsc_setup(char *); | ||
88 | |||
89 | extern int timer_over_8254; | ||
90 | |||
91 | extern int gsi_irq_sharing(int gsi); | ||
92 | |||
93 | extern void smp_local_timer_interrupt(void); | ||
94 | |||
95 | extern int force_mwait; | ||
96 | |||
97 | long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); | ||
98 | |||
99 | void i8254_timer_resume(void); | ||
100 | |||
101 | #define round_up(x,y) (((x) + (y) - 1) & ~((y)-1)) | ||
102 | #define round_down(x,y) ((x) & ~((y)-1)) | ||
103 | |||
104 | #endif | ||
diff --git a/include/asm-x86/ptrace-abi.h b/include/asm-x86/ptrace-abi.h new file mode 100644 index 000000000000..6824c49def1c --- /dev/null +++ b/include/asm-x86/ptrace-abi.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ptrace-abi_32.h" | ||
4 | # else | ||
5 | # include "ptrace-abi_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ptrace-abi_32.h" | ||
10 | # else | ||
11 | # include "ptrace-abi_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ptrace-abi_32.h b/include/asm-x86/ptrace-abi_32.h new file mode 100644 index 000000000000..a44901817a26 --- /dev/null +++ b/include/asm-x86/ptrace-abi_32.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef I386_PTRACE_ABI_H | ||
2 | #define I386_PTRACE_ABI_H | ||
3 | |||
4 | #define EBX 0 | ||
5 | #define ECX 1 | ||
6 | #define EDX 2 | ||
7 | #define ESI 3 | ||
8 | #define EDI 4 | ||
9 | #define EBP 5 | ||
10 | #define EAX 6 | ||
11 | #define DS 7 | ||
12 | #define ES 8 | ||
13 | #define FS 9 | ||
14 | #define GS 10 | ||
15 | #define ORIG_EAX 11 | ||
16 | #define EIP 12 | ||
17 | #define CS 13 | ||
18 | #define EFL 14 | ||
19 | #define UESP 15 | ||
20 | #define SS 16 | ||
21 | #define FRAME_SIZE 17 | ||
22 | |||
23 | /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ | ||
24 | #define PTRACE_GETREGS 12 | ||
25 | #define PTRACE_SETREGS 13 | ||
26 | #define PTRACE_GETFPREGS 14 | ||
27 | #define PTRACE_SETFPREGS 15 | ||
28 | #define PTRACE_GETFPXREGS 18 | ||
29 | #define PTRACE_SETFPXREGS 19 | ||
30 | |||
31 | #define PTRACE_OLDSETOPTIONS 21 | ||
32 | |||
33 | #define PTRACE_GET_THREAD_AREA 25 | ||
34 | #define PTRACE_SET_THREAD_AREA 26 | ||
35 | |||
36 | #define PTRACE_SYSEMU 31 | ||
37 | #define PTRACE_SYSEMU_SINGLESTEP 32 | ||
38 | |||
39 | #endif | ||
diff --git a/include/asm-x86/ptrace-abi_64.h b/include/asm-x86/ptrace-abi_64.h new file mode 100644 index 000000000000..19184b0806b1 --- /dev/null +++ b/include/asm-x86/ptrace-abi_64.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _X86_64_PTRACE_ABI_H | ||
2 | #define _X86_64_PTRACE_ABI_H | ||
3 | |||
4 | #if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS) | ||
5 | #define R15 0 | ||
6 | #define R14 8 | ||
7 | #define R13 16 | ||
8 | #define R12 24 | ||
9 | #define RBP 32 | ||
10 | #define RBX 40 | ||
11 | /* arguments: interrupts/non tracing syscalls only save upto here*/ | ||
12 | #define R11 48 | ||
13 | #define R10 56 | ||
14 | #define R9 64 | ||
15 | #define R8 72 | ||
16 | #define RAX 80 | ||
17 | #define RCX 88 | ||
18 | #define RDX 96 | ||
19 | #define RSI 104 | ||
20 | #define RDI 112 | ||
21 | #define ORIG_RAX 120 /* = ERROR */ | ||
22 | /* end of arguments */ | ||
23 | /* cpu exception frame or undefined in case of fast syscall. */ | ||
24 | #define RIP 128 | ||
25 | #define CS 136 | ||
26 | #define EFLAGS 144 | ||
27 | #define RSP 152 | ||
28 | #define SS 160 | ||
29 | #define ARGOFFSET R11 | ||
30 | #endif /* __ASSEMBLY__ */ | ||
31 | |||
32 | /* top of stack page */ | ||
33 | #define FRAME_SIZE 168 | ||
34 | |||
35 | #define PTRACE_OLDSETOPTIONS 21 | ||
36 | |||
37 | /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ | ||
38 | #define PTRACE_GETREGS 12 | ||
39 | #define PTRACE_SETREGS 13 | ||
40 | #define PTRACE_GETFPREGS 14 | ||
41 | #define PTRACE_SETFPREGS 15 | ||
42 | #define PTRACE_GETFPXREGS 18 | ||
43 | #define PTRACE_SETFPXREGS 19 | ||
44 | |||
45 | /* only useful for access 32bit programs */ | ||
46 | #define PTRACE_GET_THREAD_AREA 25 | ||
47 | #define PTRACE_SET_THREAD_AREA 26 | ||
48 | |||
49 | #define PTRACE_ARCH_PRCTL 30 /* arch_prctl for child */ | ||
50 | |||
51 | #endif | ||
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h new file mode 100644 index 000000000000..bc4d64a87689 --- /dev/null +++ b/include/asm-x86/ptrace.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ptrace_32.h" | ||
4 | # else | ||
5 | # include "ptrace_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ptrace_32.h" | ||
10 | # else | ||
11 | # include "ptrace_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ptrace_32.h b/include/asm-x86/ptrace_32.h new file mode 100644 index 000000000000..6002597b9e12 --- /dev/null +++ b/include/asm-x86/ptrace_32.h | |||
@@ -0,0 +1,63 @@ | |||
1 | #ifndef _I386_PTRACE_H | ||
2 | #define _I386_PTRACE_H | ||
3 | |||
4 | #include <asm/ptrace-abi.h> | ||
5 | |||
6 | /* this struct defines the way the registers are stored on the | ||
7 | stack during a system call. */ | ||
8 | |||
9 | struct pt_regs { | ||
10 | long ebx; | ||
11 | long ecx; | ||
12 | long edx; | ||
13 | long esi; | ||
14 | long edi; | ||
15 | long ebp; | ||
16 | long eax; | ||
17 | int xds; | ||
18 | int xes; | ||
19 | int xfs; | ||
20 | /* int xgs; */ | ||
21 | long orig_eax; | ||
22 | long eip; | ||
23 | int xcs; | ||
24 | long eflags; | ||
25 | long esp; | ||
26 | int xss; | ||
27 | }; | ||
28 | |||
29 | #ifdef __KERNEL__ | ||
30 | |||
31 | #include <asm/vm86.h> | ||
32 | #include <asm/segment.h> | ||
33 | |||
34 | struct task_struct; | ||
35 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); | ||
36 | |||
37 | /* | ||
38 | * user_mode_vm(regs) determines whether a register set came from user mode. | ||
39 | * This is true if V8086 mode was enabled OR if the register set was from | ||
40 | * protected mode with RPL-3 CS value. This tricky test checks that with | ||
41 | * one comparison. Many places in the kernel can bypass this full check | ||
42 | * if they have already ruled out V8086 mode, so user_mode(regs) can be used. | ||
43 | */ | ||
44 | static inline int user_mode(struct pt_regs *regs) | ||
45 | { | ||
46 | return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL; | ||
47 | } | ||
48 | static inline int user_mode_vm(struct pt_regs *regs) | ||
49 | { | ||
50 | return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL; | ||
51 | } | ||
52 | static inline int v8086_mode(struct pt_regs *regs) | ||
53 | { | ||
54 | return (regs->eflags & VM_MASK); | ||
55 | } | ||
56 | |||
57 | #define instruction_pointer(regs) ((regs)->eip) | ||
58 | #define regs_return_value(regs) ((regs)->eax) | ||
59 | |||
60 | extern unsigned long profile_pc(struct pt_regs *regs); | ||
61 | #endif /* __KERNEL__ */ | ||
62 | |||
63 | #endif | ||
diff --git a/include/asm-x86/ptrace_64.h b/include/asm-x86/ptrace_64.h new file mode 100644 index 000000000000..7f166ccb0606 --- /dev/null +++ b/include/asm-x86/ptrace_64.h | |||
@@ -0,0 +1,78 @@ | |||
1 | #ifndef _X86_64_PTRACE_H | ||
2 | #define _X86_64_PTRACE_H | ||
3 | |||
4 | #include <linux/compiler.h> /* For __user */ | ||
5 | #include <asm/ptrace-abi.h> | ||
6 | |||
7 | #ifndef __ASSEMBLY__ | ||
8 | |||
9 | struct pt_regs { | ||
10 | unsigned long r15; | ||
11 | unsigned long r14; | ||
12 | unsigned long r13; | ||
13 | unsigned long r12; | ||
14 | unsigned long rbp; | ||
15 | unsigned long rbx; | ||
16 | /* arguments: non interrupts/non tracing syscalls only save upto here*/ | ||
17 | unsigned long r11; | ||
18 | unsigned long r10; | ||
19 | unsigned long r9; | ||
20 | unsigned long r8; | ||
21 | unsigned long rax; | ||
22 | unsigned long rcx; | ||
23 | unsigned long rdx; | ||
24 | unsigned long rsi; | ||
25 | unsigned long rdi; | ||
26 | unsigned long orig_rax; | ||
27 | /* end of arguments */ | ||
28 | /* cpu exception frame or undefined */ | ||
29 | unsigned long rip; | ||
30 | unsigned long cs; | ||
31 | unsigned long eflags; | ||
32 | unsigned long rsp; | ||
33 | unsigned long ss; | ||
34 | /* top of stack page */ | ||
35 | }; | ||
36 | |||
37 | #endif | ||
38 | |||
39 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) | ||
40 | #define user_mode(regs) (!!((regs)->cs & 3)) | ||
41 | #define user_mode_vm(regs) user_mode(regs) | ||
42 | #define instruction_pointer(regs) ((regs)->rip) | ||
43 | #define regs_return_value(regs) ((regs)->rax) | ||
44 | |||
45 | extern unsigned long profile_pc(struct pt_regs *regs); | ||
46 | void signal_fault(struct pt_regs *regs, void __user *frame, char *where); | ||
47 | |||
48 | struct task_struct; | ||
49 | |||
50 | extern unsigned long | ||
51 | convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs); | ||
52 | |||
53 | enum { | ||
54 | EF_CF = 0x00000001, | ||
55 | EF_PF = 0x00000004, | ||
56 | EF_AF = 0x00000010, | ||
57 | EF_ZF = 0x00000040, | ||
58 | EF_SF = 0x00000080, | ||
59 | EF_TF = 0x00000100, | ||
60 | EF_IE = 0x00000200, | ||
61 | EF_DF = 0x00000400, | ||
62 | EF_OF = 0x00000800, | ||
63 | EF_IOPL = 0x00003000, | ||
64 | EF_IOPL_RING0 = 0x00000000, | ||
65 | EF_IOPL_RING1 = 0x00001000, | ||
66 | EF_IOPL_RING2 = 0x00002000, | ||
67 | EF_NT = 0x00004000, /* nested task */ | ||
68 | EF_RF = 0x00010000, /* resume */ | ||
69 | EF_VM = 0x00020000, /* virtual mode */ | ||
70 | EF_AC = 0x00040000, /* alignment */ | ||
71 | EF_VIF = 0x00080000, /* virtual interrupt */ | ||
72 | EF_VIP = 0x00100000, /* virtual interrupt pending */ | ||
73 | EF_ID = 0x00200000, /* id */ | ||
74 | }; | ||
75 | |||
76 | #endif | ||
77 | |||
78 | #endif | ||
diff --git a/include/asm-x86/reboot.h b/include/asm-x86/reboot.h new file mode 100644 index 000000000000..e9e3ffc22c07 --- /dev/null +++ b/include/asm-x86/reboot.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_REBOOT_H | ||
2 | #define _ASM_REBOOT_H | ||
3 | |||
4 | struct pt_regs; | ||
5 | |||
6 | struct machine_ops | ||
7 | { | ||
8 | void (*restart)(char *cmd); | ||
9 | void (*halt)(void); | ||
10 | void (*power_off)(void); | ||
11 | void (*shutdown)(void); | ||
12 | void (*crash_shutdown)(struct pt_regs *); | ||
13 | void (*emergency_restart)(void); | ||
14 | }; | ||
15 | |||
16 | extern struct machine_ops machine_ops; | ||
17 | |||
18 | void machine_real_restart(unsigned char *code, int length); | ||
19 | |||
20 | #endif /* _ASM_REBOOT_H */ | ||
diff --git a/include/asm-x86/reboot_fixups.h b/include/asm-x86/reboot_fixups.h new file mode 100644 index 000000000000..0cb7d87c2b68 --- /dev/null +++ b/include/asm-x86/reboot_fixups.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _LINUX_REBOOT_FIXUPS_H | ||
2 | #define _LINUX_REBOOT_FIXUPS_H | ||
3 | |||
4 | extern void mach_reboot_fixups(void); | ||
5 | |||
6 | #endif /* _LINUX_REBOOT_FIXUPS_H */ | ||
diff --git a/include/asm-x86/required-features.h b/include/asm-x86/required-features.h new file mode 100644 index 000000000000..8b64f3ea2b78 --- /dev/null +++ b/include/asm-x86/required-features.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "required-features_32.h" | ||
3 | #else | ||
4 | # include "required-features_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/required-features_32.h b/include/asm-x86/required-features_32.h new file mode 100644 index 000000000000..618feb98f9f5 --- /dev/null +++ b/include/asm-x86/required-features_32.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef _ASM_REQUIRED_FEATURES_H | ||
2 | #define _ASM_REQUIRED_FEATURES_H 1 | ||
3 | |||
4 | /* Define minimum CPUID feature set for kernel These bits are checked | ||
5 | really early to actually display a visible error message before the | ||
6 | kernel dies. Make sure to assign features to the proper mask! | ||
7 | |||
8 | Some requirements that are not in CPUID yet are also in the | ||
9 | CONFIG_X86_MINIMUM_CPU_FAMILY which is checked too. | ||
10 | |||
11 | The real information is in arch/i386/Kconfig.cpu, this just converts | ||
12 | the CONFIGs into a bitmask */ | ||
13 | |||
14 | #ifndef CONFIG_MATH_EMULATION | ||
15 | # define NEED_FPU (1<<(X86_FEATURE_FPU & 31)) | ||
16 | #else | ||
17 | # define NEED_FPU 0 | ||
18 | #endif | ||
19 | |||
20 | #ifdef CONFIG_X86_PAE | ||
21 | # define NEED_PAE (1<<(X86_FEATURE_PAE & 31)) | ||
22 | #else | ||
23 | # define NEED_PAE 0 | ||
24 | #endif | ||
25 | |||
26 | #ifdef CONFIG_X86_CMOV | ||
27 | # define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31)) | ||
28 | #else | ||
29 | # define NEED_CMOV 0 | ||
30 | #endif | ||
31 | |||
32 | #ifdef CONFIG_X86_PAE | ||
33 | # define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) | ||
34 | #else | ||
35 | # define NEED_CX8 0 | ||
36 | #endif | ||
37 | |||
38 | #define REQUIRED_MASK0 (NEED_FPU|NEED_PAE|NEED_CMOV|NEED_CX8) | ||
39 | |||
40 | #ifdef CONFIG_X86_USE_3DNOW | ||
41 | # define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) | ||
42 | #else | ||
43 | # define NEED_3DNOW 0 | ||
44 | #endif | ||
45 | |||
46 | #define REQUIRED_MASK1 (NEED_3DNOW) | ||
47 | |||
48 | #define REQUIRED_MASK2 0 | ||
49 | #define REQUIRED_MASK3 0 | ||
50 | #define REQUIRED_MASK4 0 | ||
51 | #define REQUIRED_MASK5 0 | ||
52 | #define REQUIRED_MASK6 0 | ||
53 | #define REQUIRED_MASK7 0 | ||
54 | |||
55 | #endif | ||
diff --git a/include/asm-x86/required-features_64.h b/include/asm-x86/required-features_64.h new file mode 100644 index 000000000000..e80d5761b00a --- /dev/null +++ b/include/asm-x86/required-features_64.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef _ASM_REQUIRED_FEATURES_H | ||
2 | #define _ASM_REQUIRED_FEATURES_H 1 | ||
3 | |||
4 | /* Define minimum CPUID feature set for kernel These bits are checked | ||
5 | really early to actually display a visible error message before the | ||
6 | kernel dies. Make sure to assign features to the proper mask! | ||
7 | |||
8 | The real information is in arch/x86_64/Kconfig.cpu, this just converts | ||
9 | the CONFIGs into a bitmask */ | ||
10 | |||
11 | /* x86-64 baseline features */ | ||
12 | #define NEED_FPU (1<<(X86_FEATURE_FPU & 31)) | ||
13 | #define NEED_PSE (1<<(X86_FEATURE_PSE & 31)) | ||
14 | #define NEED_MSR (1<<(X86_FEATURE_MSR & 31)) | ||
15 | #define NEED_PAE (1<<(X86_FEATURE_PAE & 31)) | ||
16 | #define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) | ||
17 | #define NEED_PGE (1<<(X86_FEATURE_PGE & 31)) | ||
18 | #define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31)) | ||
19 | #define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31)) | ||
20 | #define NEED_XMM (1<<(X86_FEATURE_XMM & 31)) | ||
21 | #define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31)) | ||
22 | |||
23 | #define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\ | ||
24 | NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\ | ||
25 | NEED_XMM|NEED_XMM2) | ||
26 | #define SSE_MASK (NEED_XMM|NEED_XMM2) | ||
27 | |||
28 | /* x86-64 baseline features */ | ||
29 | #define NEED_LM (1<<(X86_FEATURE_LM & 31)) | ||
30 | |||
31 | #ifdef CONFIG_X86_USE_3DNOW | ||
32 | # define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) | ||
33 | #else | ||
34 | # define NEED_3DNOW 0 | ||
35 | #endif | ||
36 | |||
37 | #define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW) | ||
38 | |||
39 | #define REQUIRED_MASK2 0 | ||
40 | #define REQUIRED_MASK3 0 | ||
41 | #define REQUIRED_MASK4 0 | ||
42 | #define REQUIRED_MASK5 0 | ||
43 | #define REQUIRED_MASK6 0 | ||
44 | #define REQUIRED_MASK7 0 | ||
45 | |||
46 | #endif | ||
diff --git a/include/asm-x86/resource.h b/include/asm-x86/resource.h new file mode 100644 index 000000000000..732410a8c02a --- /dev/null +++ b/include/asm-x86/resource.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "resource_32.h" | ||
4 | # else | ||
5 | # include "resource_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "resource_32.h" | ||
10 | # else | ||
11 | # include "resource_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/resource_32.h b/include/asm-x86/resource_32.h new file mode 100644 index 000000000000..6c1ea37c7718 --- /dev/null +++ b/include/asm-x86/resource_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _I386_RESOURCE_H | ||
2 | #define _I386_RESOURCE_H | ||
3 | |||
4 | #include <asm-generic/resource.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/resource_64.h b/include/asm-x86/resource_64.h new file mode 100644 index 000000000000..f40b40623234 --- /dev/null +++ b/include/asm-x86/resource_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _X8664_RESOURCE_H | ||
2 | #define _X8664_RESOURCE_H | ||
3 | |||
4 | #include <asm-generic/resource.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/resume-trace.h b/include/asm-x86/resume-trace.h new file mode 100644 index 000000000000..9b6dd093a9f7 --- /dev/null +++ b/include/asm-x86/resume-trace.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "resume-trace_32.h" | ||
3 | #else | ||
4 | # include "resume-trace_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/resume-trace_32.h b/include/asm-x86/resume-trace_32.h new file mode 100644 index 000000000000..ec9cfd656230 --- /dev/null +++ b/include/asm-x86/resume-trace_32.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #define TRACE_RESUME(user) do { \ | ||
2 | if (pm_trace_enabled) { \ | ||
3 | void *tracedata; \ | ||
4 | asm volatile("movl $1f,%0\n" \ | ||
5 | ".section .tracedata,\"a\"\n" \ | ||
6 | "1:\t.word %c1\n" \ | ||
7 | "\t.long %c2\n" \ | ||
8 | ".previous" \ | ||
9 | :"=r" (tracedata) \ | ||
10 | : "i" (__LINE__), "i" (__FILE__)); \ | ||
11 | generate_resume_trace(tracedata, user); \ | ||
12 | } \ | ||
13 | } while (0) | ||
diff --git a/include/asm-x86/resume-trace_64.h b/include/asm-x86/resume-trace_64.h new file mode 100644 index 000000000000..34bf998fdf62 --- /dev/null +++ b/include/asm-x86/resume-trace_64.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #define TRACE_RESUME(user) do { \ | ||
2 | if (pm_trace_enabled) { \ | ||
3 | void *tracedata; \ | ||
4 | asm volatile("movq $1f,%0\n" \ | ||
5 | ".section .tracedata,\"a\"\n" \ | ||
6 | "1:\t.word %c1\n" \ | ||
7 | "\t.quad %c2\n" \ | ||
8 | ".previous" \ | ||
9 | :"=r" (tracedata) \ | ||
10 | : "i" (__LINE__), "i" (__FILE__)); \ | ||
11 | generate_resume_trace(tracedata, user); \ | ||
12 | } \ | ||
13 | } while (0) | ||
diff --git a/include/asm-x86/rio.h b/include/asm-x86/rio.h new file mode 100644 index 000000000000..c7350f6d2015 --- /dev/null +++ b/include/asm-x86/rio.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Derived from include/asm-i386/mach-summit/mach_mpparse.h | ||
3 | * and include/asm-i386/mach-default/bios_ebda.h | ||
4 | * | ||
5 | * Author: Laurent Vivier <Laurent.Vivier@bull.net> | ||
6 | */ | ||
7 | |||
8 | #ifndef __ASM_RIO_H | ||
9 | #define __ASM_RIO_H | ||
10 | |||
11 | #define RIO_TABLE_VERSION 3 | ||
12 | |||
13 | struct rio_table_hdr { | ||
14 | u8 version; /* Version number of this data structure */ | ||
15 | u8 num_scal_dev; /* # of Scalability devices */ | ||
16 | u8 num_rio_dev; /* # of RIO I/O devices */ | ||
17 | } __attribute__((packed)); | ||
18 | |||
19 | struct scal_detail { | ||
20 | u8 node_id; /* Scalability Node ID */ | ||
21 | u32 CBAR; /* Address of 1MB register space */ | ||
22 | u8 port0node; /* Node ID port connected to: 0xFF=None */ | ||
23 | u8 port0port; /* Port num port connected to: 0,1,2, or */ | ||
24 | /* 0xFF=None */ | ||
25 | u8 port1node; /* Node ID port connected to: 0xFF = None */ | ||
26 | u8 port1port; /* Port num port connected to: 0,1,2, or */ | ||
27 | /* 0xFF=None */ | ||
28 | u8 port2node; /* Node ID port connected to: 0xFF = None */ | ||
29 | u8 port2port; /* Port num port connected to: 0,1,2, or */ | ||
30 | /* 0xFF=None */ | ||
31 | u8 chassis_num; /* 1 based Chassis number (1 = boot node) */ | ||
32 | } __attribute__((packed)); | ||
33 | |||
34 | struct rio_detail { | ||
35 | u8 node_id; /* RIO Node ID */ | ||
36 | u32 BBAR; /* Address of 1MB register space */ | ||
37 | u8 type; /* Type of device */ | ||
38 | u8 owner_id; /* Node ID of Hurricane that owns this */ | ||
39 | /* node */ | ||
40 | u8 port0node; /* Node ID port connected to: 0xFF=None */ | ||
41 | u8 port0port; /* Port num port connected to: 0,1,2, or */ | ||
42 | /* 0xFF=None */ | ||
43 | u8 port1node; /* Node ID port connected to: 0xFF=None */ | ||
44 | u8 port1port; /* Port num port connected to: 0,1,2, or */ | ||
45 | /* 0xFF=None */ | ||
46 | u8 first_slot; /* Lowest slot number below this Calgary */ | ||
47 | u8 status; /* Bit 0 = 1 : the XAPIC is used */ | ||
48 | /* = 0 : the XAPIC is not used, ie: */ | ||
49 | /* ints fwded to another XAPIC */ | ||
50 | /* Bits1:7 Reserved */ | ||
51 | u8 WP_index; /* instance index - lower ones have */ | ||
52 | /* lower slot numbers/PCI bus numbers */ | ||
53 | u8 chassis_num; /* 1 based Chassis number */ | ||
54 | } __attribute__((packed)); | ||
55 | |||
56 | enum { | ||
57 | HURR_SCALABILTY = 0, /* Hurricane Scalability info */ | ||
58 | HURR_RIOIB = 2, /* Hurricane RIOIB info */ | ||
59 | COMPAT_CALGARY = 4, /* Compatibility Calgary */ | ||
60 | ALT_CALGARY = 5, /* Second Planar Calgary */ | ||
61 | }; | ||
62 | |||
63 | /* | ||
64 | * there is a real-mode segmented pointer pointing to the | ||
65 | * 4K EBDA area at 0x40E. | ||
66 | */ | ||
67 | static inline unsigned long get_bios_ebda(void) | ||
68 | { | ||
69 | unsigned long address = *(unsigned short *)phys_to_virt(0x40EUL); | ||
70 | address <<= 4; | ||
71 | return address; | ||
72 | } | ||
73 | |||
74 | #endif /* __ASM_RIO_H */ | ||
diff --git a/include/asm-x86/rtc.h b/include/asm-x86/rtc.h new file mode 100644 index 000000000000..1f0c98eb2e38 --- /dev/null +++ b/include/asm-x86/rtc.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "rtc_32.h" | ||
3 | #else | ||
4 | # include "rtc_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/rtc_32.h b/include/asm-x86/rtc_32.h new file mode 100644 index 000000000000..ffd02109a0e5 --- /dev/null +++ b/include/asm-x86/rtc_32.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _I386_RTC_H | ||
2 | #define _I386_RTC_H | ||
3 | |||
4 | /* | ||
5 | * x86 uses the default access methods for the RTC. | ||
6 | */ | ||
7 | |||
8 | #include <asm-generic/rtc.h> | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/rtc_64.h b/include/asm-x86/rtc_64.h new file mode 100644 index 000000000000..18ed713ac7de --- /dev/null +++ b/include/asm-x86/rtc_64.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _X86_64_RTC_H | ||
2 | #define _X86_64_RTC_H | ||
3 | |||
4 | /* | ||
5 | * x86 uses the default access methods for the RTC. | ||
6 | */ | ||
7 | |||
8 | #include <asm-generic/rtc.h> | ||
9 | |||
10 | #endif | ||
diff --git a/include/asm-x86/rwlock.h b/include/asm-x86/rwlock.h new file mode 100644 index 000000000000..a3be7d8364af --- /dev/null +++ b/include/asm-x86/rwlock.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "rwlock_32.h" | ||
3 | #else | ||
4 | # include "rwlock_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/rwlock_32.h b/include/asm-x86/rwlock_32.h new file mode 100644 index 000000000000..c3e5db32fa48 --- /dev/null +++ b/include/asm-x86/rwlock_32.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* include/asm-i386/rwlock.h | ||
2 | * | ||
3 | * Helpers used by both rw spinlocks and rw semaphores. | ||
4 | * | ||
5 | * Based in part on code from semaphore.h and | ||
6 | * spinlock.h Copyright 1996 Linus Torvalds. | ||
7 | * | ||
8 | * Copyright 1999 Red Hat, Inc. | ||
9 | * | ||
10 | * Written by Benjamin LaHaise. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | */ | ||
17 | #ifndef _ASM_I386_RWLOCK_H | ||
18 | #define _ASM_I386_RWLOCK_H | ||
19 | |||
20 | #define RW_LOCK_BIAS 0x01000000 | ||
21 | #define RW_LOCK_BIAS_STR "0x01000000" | ||
22 | |||
23 | /* Code is in asm-i386/spinlock.h */ | ||
24 | |||
25 | #endif | ||
diff --git a/include/asm-x86/rwlock_64.h b/include/asm-x86/rwlock_64.h new file mode 100644 index 000000000000..72aeebed920b --- /dev/null +++ b/include/asm-x86/rwlock_64.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* include/asm-x86_64/rwlock.h | ||
2 | * | ||
3 | * Helpers used by both rw spinlocks and rw semaphores. | ||
4 | * | ||
5 | * Based in part on code from semaphore.h and | ||
6 | * spinlock.h Copyright 1996 Linus Torvalds. | ||
7 | * | ||
8 | * Copyright 1999 Red Hat, Inc. | ||
9 | * Copyright 2001,2002 SuSE labs | ||
10 | * | ||
11 | * Written by Benjamin LaHaise. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | #ifndef _ASM_X86_64_RWLOCK_H | ||
19 | #define _ASM_X86_64_RWLOCK_H | ||
20 | |||
21 | #define RW_LOCK_BIAS 0x01000000 | ||
22 | #define RW_LOCK_BIAS_STR "0x01000000" | ||
23 | |||
24 | /* Actual code is in asm/spinlock.h or in arch/x86_64/lib/rwlock.S */ | ||
25 | |||
26 | #endif | ||
diff --git a/include/asm-x86/rwsem.h b/include/asm-x86/rwsem.h new file mode 100644 index 000000000000..041906f3c6df --- /dev/null +++ b/include/asm-x86/rwsem.h | |||
@@ -0,0 +1,258 @@ | |||
1 | /* rwsem.h: R/W semaphores implemented using XADD/CMPXCHG for i486+ | ||
2 | * | ||
3 | * Written by David Howells (dhowells@redhat.com). | ||
4 | * | ||
5 | * Derived from asm-i386/semaphore.h | ||
6 | * | ||
7 | * | ||
8 | * The MSW of the count is the negated number of active writers and waiting | ||
9 | * lockers, and the LSW is the total number of active locks | ||
10 | * | ||
11 | * The lock count is initialized to 0 (no active and no waiting lockers). | ||
12 | * | ||
13 | * When a writer subtracts WRITE_BIAS, it'll get 0xffff0001 for the case of an | ||
14 | * uncontended lock. This can be determined because XADD returns the old value. | ||
15 | * Readers increment by 1 and see a positive value when uncontended, negative | ||
16 | * if there are writers (and maybe) readers waiting (in which case it goes to | ||
17 | * sleep). | ||
18 | * | ||
19 | * The value of WAITING_BIAS supports up to 32766 waiting processes. This can | ||
20 | * be extended to 65534 by manually checking the whole MSW rather than relying | ||
21 | * on the S flag. | ||
22 | * | ||
23 | * The value of ACTIVE_BIAS supports up to 65535 active processes. | ||
24 | * | ||
25 | * This should be totally fair - if anything is waiting, a process that wants a | ||
26 | * lock will go to the back of the queue. When the currently active lock is | ||
27 | * released, if there's a writer at the front of the queue, then that and only | ||
28 | * that will be woken up; if there's a bunch of consequtive readers at the | ||
29 | * front, then they'll all be woken up, but no other readers will be. | ||
30 | */ | ||
31 | |||
32 | #ifndef _I386_RWSEM_H | ||
33 | #define _I386_RWSEM_H | ||
34 | |||
35 | #ifndef _LINUX_RWSEM_H | ||
36 | #error "please don't include asm/rwsem.h directly, use linux/rwsem.h instead" | ||
37 | #endif | ||
38 | |||
39 | #ifdef __KERNEL__ | ||
40 | |||
41 | #include <linux/list.h> | ||
42 | #include <linux/spinlock.h> | ||
43 | #include <linux/lockdep.h> | ||
44 | |||
45 | struct rwsem_waiter; | ||
46 | |||
47 | extern struct rw_semaphore *FASTCALL(rwsem_down_read_failed(struct rw_semaphore *sem)); | ||
48 | extern struct rw_semaphore *FASTCALL(rwsem_down_write_failed(struct rw_semaphore *sem)); | ||
49 | extern struct rw_semaphore *FASTCALL(rwsem_wake(struct rw_semaphore *)); | ||
50 | extern struct rw_semaphore *FASTCALL(rwsem_downgrade_wake(struct rw_semaphore *sem)); | ||
51 | |||
52 | /* | ||
53 | * the semaphore definition | ||
54 | */ | ||
55 | struct rw_semaphore { | ||
56 | signed long count; | ||
57 | #define RWSEM_UNLOCKED_VALUE 0x00000000 | ||
58 | #define RWSEM_ACTIVE_BIAS 0x00000001 | ||
59 | #define RWSEM_ACTIVE_MASK 0x0000ffff | ||
60 | #define RWSEM_WAITING_BIAS (-0x00010000) | ||
61 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | ||
62 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | ||
63 | spinlock_t wait_lock; | ||
64 | struct list_head wait_list; | ||
65 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
66 | struct lockdep_map dep_map; | ||
67 | #endif | ||
68 | }; | ||
69 | |||
70 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
71 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
72 | #else | ||
73 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
74 | #endif | ||
75 | |||
76 | |||
77 | #define __RWSEM_INITIALIZER(name) \ | ||
78 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
79 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
80 | |||
81 | #define DECLARE_RWSEM(name) \ | ||
82 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
83 | |||
84 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
85 | struct lock_class_key *key); | ||
86 | |||
87 | #define init_rwsem(sem) \ | ||
88 | do { \ | ||
89 | static struct lock_class_key __key; \ | ||
90 | \ | ||
91 | __init_rwsem((sem), #sem, &__key); \ | ||
92 | } while (0) | ||
93 | |||
94 | /* | ||
95 | * lock for reading | ||
96 | */ | ||
97 | static inline void __down_read(struct rw_semaphore *sem) | ||
98 | { | ||
99 | __asm__ __volatile__( | ||
100 | "# beginning down_read\n\t" | ||
101 | LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */ | ||
102 | " jns 1f\n" | ||
103 | " call call_rwsem_down_read_failed\n" | ||
104 | "1:\n\t" | ||
105 | "# ending down_read\n\t" | ||
106 | : "+m" (sem->count) | ||
107 | : "a" (sem) | ||
108 | : "memory", "cc"); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * trylock for reading -- returns 1 if successful, 0 if contention | ||
113 | */ | ||
114 | static inline int __down_read_trylock(struct rw_semaphore *sem) | ||
115 | { | ||
116 | __s32 result, tmp; | ||
117 | __asm__ __volatile__( | ||
118 | "# beginning __down_read_trylock\n\t" | ||
119 | " movl %0,%1\n\t" | ||
120 | "1:\n\t" | ||
121 | " movl %1,%2\n\t" | ||
122 | " addl %3,%2\n\t" | ||
123 | " jle 2f\n\t" | ||
124 | LOCK_PREFIX " cmpxchgl %2,%0\n\t" | ||
125 | " jnz 1b\n\t" | ||
126 | "2:\n\t" | ||
127 | "# ending __down_read_trylock\n\t" | ||
128 | : "+m" (sem->count), "=&a" (result), "=&r" (tmp) | ||
129 | : "i" (RWSEM_ACTIVE_READ_BIAS) | ||
130 | : "memory", "cc"); | ||
131 | return result>=0 ? 1 : 0; | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * lock for writing | ||
136 | */ | ||
137 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) | ||
138 | { | ||
139 | int tmp; | ||
140 | |||
141 | tmp = RWSEM_ACTIVE_WRITE_BIAS; | ||
142 | __asm__ __volatile__( | ||
143 | "# beginning down_write\n\t" | ||
144 | LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */ | ||
145 | " testl %%edx,%%edx\n\t" /* was the count 0 before? */ | ||
146 | " jz 1f\n" | ||
147 | " call call_rwsem_down_write_failed\n" | ||
148 | "1:\n" | ||
149 | "# ending down_write" | ||
150 | : "+m" (sem->count), "=d" (tmp) | ||
151 | : "a" (sem), "1" (tmp) | ||
152 | : "memory", "cc"); | ||
153 | } | ||
154 | |||
155 | static inline void __down_write(struct rw_semaphore *sem) | ||
156 | { | ||
157 | __down_write_nested(sem, 0); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * trylock for writing -- returns 1 if successful, 0 if contention | ||
162 | */ | ||
163 | static inline int __down_write_trylock(struct rw_semaphore *sem) | ||
164 | { | ||
165 | signed long ret = cmpxchg(&sem->count, | ||
166 | RWSEM_UNLOCKED_VALUE, | ||
167 | RWSEM_ACTIVE_WRITE_BIAS); | ||
168 | if (ret == RWSEM_UNLOCKED_VALUE) | ||
169 | return 1; | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * unlock after reading | ||
175 | */ | ||
176 | static inline void __up_read(struct rw_semaphore *sem) | ||
177 | { | ||
178 | __s32 tmp = -RWSEM_ACTIVE_READ_BIAS; | ||
179 | __asm__ __volatile__( | ||
180 | "# beginning __up_read\n\t" | ||
181 | LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */ | ||
182 | " jns 1f\n\t" | ||
183 | " call call_rwsem_wake\n" | ||
184 | "1:\n" | ||
185 | "# ending __up_read\n" | ||
186 | : "+m" (sem->count), "=d" (tmp) | ||
187 | : "a" (sem), "1" (tmp) | ||
188 | : "memory", "cc"); | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * unlock after writing | ||
193 | */ | ||
194 | static inline void __up_write(struct rw_semaphore *sem) | ||
195 | { | ||
196 | __asm__ __volatile__( | ||
197 | "# beginning __up_write\n\t" | ||
198 | " movl %2,%%edx\n\t" | ||
199 | LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */ | ||
200 | " jz 1f\n" | ||
201 | " call call_rwsem_wake\n" | ||
202 | "1:\n\t" | ||
203 | "# ending __up_write\n" | ||
204 | : "+m" (sem->count) | ||
205 | : "a" (sem), "i" (-RWSEM_ACTIVE_WRITE_BIAS) | ||
206 | : "memory", "cc", "edx"); | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * downgrade write lock to read lock | ||
211 | */ | ||
212 | static inline void __downgrade_write(struct rw_semaphore *sem) | ||
213 | { | ||
214 | __asm__ __volatile__( | ||
215 | "# beginning __downgrade_write\n\t" | ||
216 | LOCK_PREFIX " addl %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */ | ||
217 | " jns 1f\n\t" | ||
218 | " call call_rwsem_downgrade_wake\n" | ||
219 | "1:\n\t" | ||
220 | "# ending __downgrade_write\n" | ||
221 | : "+m" (sem->count) | ||
222 | : "a" (sem), "i" (-RWSEM_WAITING_BIAS) | ||
223 | : "memory", "cc"); | ||
224 | } | ||
225 | |||
226 | /* | ||
227 | * implement atomic add functionality | ||
228 | */ | ||
229 | static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) | ||
230 | { | ||
231 | __asm__ __volatile__( | ||
232 | LOCK_PREFIX "addl %1,%0" | ||
233 | : "+m" (sem->count) | ||
234 | : "ir" (delta)); | ||
235 | } | ||
236 | |||
237 | /* | ||
238 | * implement exchange and add functionality | ||
239 | */ | ||
240 | static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | ||
241 | { | ||
242 | int tmp = delta; | ||
243 | |||
244 | __asm__ __volatile__( | ||
245 | LOCK_PREFIX "xadd %0,%1" | ||
246 | : "+r" (tmp), "+m" (sem->count) | ||
247 | : : "memory"); | ||
248 | |||
249 | return tmp+delta; | ||
250 | } | ||
251 | |||
252 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
253 | { | ||
254 | return (sem->count != 0); | ||
255 | } | ||
256 | |||
257 | #endif /* __KERNEL__ */ | ||
258 | #endif /* _I386_RWSEM_H */ | ||
diff --git a/include/asm-x86/scatterlist.h b/include/asm-x86/scatterlist.h new file mode 100644 index 000000000000..3a1e76257a27 --- /dev/null +++ b/include/asm-x86/scatterlist.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "scatterlist_32.h" | ||
3 | #else | ||
4 | # include "scatterlist_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/scatterlist_32.h b/include/asm-x86/scatterlist_32.h new file mode 100644 index 000000000000..d7e45a8f1aae --- /dev/null +++ b/include/asm-x86/scatterlist_32.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef _I386_SCATTERLIST_H | ||
2 | #define _I386_SCATTERLIST_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | struct scatterlist { | ||
7 | struct page *page; | ||
8 | unsigned int offset; | ||
9 | dma_addr_t dma_address; | ||
10 | unsigned int length; | ||
11 | }; | ||
12 | |||
13 | /* These macros should be used after a pci_map_sg call has been done | ||
14 | * to get bus addresses of each of the SG entries and their lengths. | ||
15 | * You should only work with the number of sg entries pci_map_sg | ||
16 | * returns. | ||
17 | */ | ||
18 | #define sg_dma_address(sg) ((sg)->dma_address) | ||
19 | #define sg_dma_len(sg) ((sg)->length) | ||
20 | |||
21 | #define ISA_DMA_THRESHOLD (0x00ffffff) | ||
22 | |||
23 | #endif /* !(_I386_SCATTERLIST_H) */ | ||
diff --git a/include/asm-x86/scatterlist_64.h b/include/asm-x86/scatterlist_64.h new file mode 100644 index 000000000000..eaf7ada27e14 --- /dev/null +++ b/include/asm-x86/scatterlist_64.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef _X8664_SCATTERLIST_H | ||
2 | #define _X8664_SCATTERLIST_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | struct scatterlist { | ||
7 | struct page *page; | ||
8 | unsigned int offset; | ||
9 | unsigned int length; | ||
10 | dma_addr_t dma_address; | ||
11 | unsigned int dma_length; | ||
12 | }; | ||
13 | |||
14 | #define ISA_DMA_THRESHOLD (0x00ffffff) | ||
15 | |||
16 | /* These macros should be used after a pci_map_sg call has been done | ||
17 | * to get bus addresses of each of the SG entries and their lengths. | ||
18 | * You should only work with the number of sg entries pci_map_sg | ||
19 | * returns. | ||
20 | */ | ||
21 | #define sg_dma_address(sg) ((sg)->dma_address) | ||
22 | #define sg_dma_len(sg) ((sg)->dma_length) | ||
23 | |||
24 | #endif | ||
diff --git a/include/asm-x86/seccomp.h b/include/asm-x86/seccomp.h new file mode 100644 index 000000000000..c62e58a5a90d --- /dev/null +++ b/include/asm-x86/seccomp.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "seccomp_32.h" | ||
3 | #else | ||
4 | # include "seccomp_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/seccomp_32.h b/include/asm-x86/seccomp_32.h new file mode 100644 index 000000000000..18da19e89bff --- /dev/null +++ b/include/asm-x86/seccomp_32.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _ASM_SECCOMP_H | ||
2 | |||
3 | #include <linux/thread_info.h> | ||
4 | |||
5 | #ifdef TIF_32BIT | ||
6 | #error "unexpected TIF_32BIT on i386" | ||
7 | #endif | ||
8 | |||
9 | #include <linux/unistd.h> | ||
10 | |||
11 | #define __NR_seccomp_read __NR_read | ||
12 | #define __NR_seccomp_write __NR_write | ||
13 | #define __NR_seccomp_exit __NR_exit | ||
14 | #define __NR_seccomp_sigreturn __NR_sigreturn | ||
15 | |||
16 | #endif /* _ASM_SECCOMP_H */ | ||
diff --git a/include/asm-x86/seccomp_64.h b/include/asm-x86/seccomp_64.h new file mode 100644 index 000000000000..553af65a2287 --- /dev/null +++ b/include/asm-x86/seccomp_64.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef _ASM_SECCOMP_H | ||
2 | |||
3 | #include <linux/thread_info.h> | ||
4 | |||
5 | #ifdef TIF_32BIT | ||
6 | #error "unexpected TIF_32BIT on x86_64" | ||
7 | #else | ||
8 | #define TIF_32BIT TIF_IA32 | ||
9 | #endif | ||
10 | |||
11 | #include <linux/unistd.h> | ||
12 | #include <asm/ia32_unistd.h> | ||
13 | |||
14 | #define __NR_seccomp_read __NR_read | ||
15 | #define __NR_seccomp_write __NR_write | ||
16 | #define __NR_seccomp_exit __NR_exit | ||
17 | #define __NR_seccomp_sigreturn __NR_rt_sigreturn | ||
18 | |||
19 | #define __NR_seccomp_read_32 __NR_ia32_read | ||
20 | #define __NR_seccomp_write_32 __NR_ia32_write | ||
21 | #define __NR_seccomp_exit_32 __NR_ia32_exit | ||
22 | #define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn | ||
23 | |||
24 | #endif /* _ASM_SECCOMP_H */ | ||
diff --git a/include/asm-x86/sections.h b/include/asm-x86/sections.h new file mode 100644 index 000000000000..ae6c69d9be3f --- /dev/null +++ b/include/asm-x86/sections.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "sections_32.h" | ||
3 | #else | ||
4 | # include "sections_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/sections_32.h b/include/asm-x86/sections_32.h new file mode 100644 index 000000000000..2dcbb92918b2 --- /dev/null +++ b/include/asm-x86/sections_32.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _I386_SECTIONS_H | ||
2 | #define _I386_SECTIONS_H | ||
3 | |||
4 | /* nothing to see, move along */ | ||
5 | #include <asm-generic/sections.h> | ||
6 | |||
7 | #endif | ||
diff --git a/include/asm-x86/sections_64.h b/include/asm-x86/sections_64.h new file mode 100644 index 000000000000..c746d9f1e70c --- /dev/null +++ b/include/asm-x86/sections_64.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _X8664_SECTIONS_H | ||
2 | #define _X8664_SECTIONS_H | ||
3 | |||
4 | /* nothing to see, move along */ | ||
5 | #include <asm-generic/sections.h> | ||
6 | |||
7 | #endif | ||
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h new file mode 100644 index 000000000000..605068280e28 --- /dev/null +++ b/include/asm-x86/segment.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "segment_32.h" | ||
3 | #else | ||
4 | # include "segment_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/segment_32.h b/include/asm-x86/segment_32.h new file mode 100644 index 000000000000..597a47c2515f --- /dev/null +++ b/include/asm-x86/segment_32.h | |||
@@ -0,0 +1,148 @@ | |||
1 | #ifndef _ASM_SEGMENT_H | ||
2 | #define _ASM_SEGMENT_H | ||
3 | |||
4 | /* | ||
5 | * The layout of the per-CPU GDT under Linux: | ||
6 | * | ||
7 | * 0 - null | ||
8 | * 1 - reserved | ||
9 | * 2 - reserved | ||
10 | * 3 - reserved | ||
11 | * | ||
12 | * 4 - unused <==== new cacheline | ||
13 | * 5 - unused | ||
14 | * | ||
15 | * ------- start of TLS (Thread-Local Storage) segments: | ||
16 | * | ||
17 | * 6 - TLS segment #1 [ glibc's TLS segment ] | ||
18 | * 7 - TLS segment #2 [ Wine's %fs Win32 segment ] | ||
19 | * 8 - TLS segment #3 | ||
20 | * 9 - reserved | ||
21 | * 10 - reserved | ||
22 | * 11 - reserved | ||
23 | * | ||
24 | * ------- start of kernel segments: | ||
25 | * | ||
26 | * 12 - kernel code segment <==== new cacheline | ||
27 | * 13 - kernel data segment | ||
28 | * 14 - default user CS | ||
29 | * 15 - default user DS | ||
30 | * 16 - TSS | ||
31 | * 17 - LDT | ||
32 | * 18 - PNPBIOS support (16->32 gate) | ||
33 | * 19 - PNPBIOS support | ||
34 | * 20 - PNPBIOS support | ||
35 | * 21 - PNPBIOS support | ||
36 | * 22 - PNPBIOS support | ||
37 | * 23 - APM BIOS support | ||
38 | * 24 - APM BIOS support | ||
39 | * 25 - APM BIOS support | ||
40 | * | ||
41 | * 26 - ESPFIX small SS | ||
42 | * 27 - per-cpu [ offset to per-cpu data area ] | ||
43 | * 28 - unused | ||
44 | * 29 - unused | ||
45 | * 30 - unused | ||
46 | * 31 - TSS for double fault handler | ||
47 | */ | ||
48 | #define GDT_ENTRY_TLS_ENTRIES 3 | ||
49 | #define GDT_ENTRY_TLS_MIN 6 | ||
50 | #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) | ||
51 | |||
52 | #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) | ||
53 | |||
54 | #define GDT_ENTRY_DEFAULT_USER_CS 14 | ||
55 | #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3) | ||
56 | |||
57 | #define GDT_ENTRY_DEFAULT_USER_DS 15 | ||
58 | #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3) | ||
59 | |||
60 | #define GDT_ENTRY_KERNEL_BASE 12 | ||
61 | |||
62 | #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0) | ||
63 | #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8) | ||
64 | |||
65 | #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1) | ||
66 | #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8) | ||
67 | |||
68 | #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4) | ||
69 | #define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5) | ||
70 | |||
71 | #define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6) | ||
72 | #define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11) | ||
73 | |||
74 | #define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14) | ||
75 | #define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) | ||
76 | |||
77 | #define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15) | ||
78 | #ifdef CONFIG_SMP | ||
79 | #define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8) | ||
80 | #else | ||
81 | #define __KERNEL_PERCPU 0 | ||
82 | #endif | ||
83 | |||
84 | #define GDT_ENTRY_DOUBLEFAULT_TSS 31 | ||
85 | |||
86 | /* | ||
87 | * The GDT has 32 entries | ||
88 | */ | ||
89 | #define GDT_ENTRIES 32 | ||
90 | #define GDT_SIZE (GDT_ENTRIES * 8) | ||
91 | |||
92 | /* Simple and small GDT entries for booting only */ | ||
93 | |||
94 | #define GDT_ENTRY_BOOT_CS 2 | ||
95 | #define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8) | ||
96 | |||
97 | #define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1) | ||
98 | #define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8) | ||
99 | |||
100 | /* The PnP BIOS entries in the GDT */ | ||
101 | #define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0) | ||
102 | #define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1) | ||
103 | #define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2) | ||
104 | #define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3) | ||
105 | #define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4) | ||
106 | |||
107 | /* The PnP BIOS selectors */ | ||
108 | #define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */ | ||
109 | #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */ | ||
110 | #define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */ | ||
111 | #define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */ | ||
112 | #define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */ | ||
113 | |||
114 | /* | ||
115 | * The interrupt descriptor table has room for 256 idt's, | ||
116 | * the global descriptor table is dependent on the number | ||
117 | * of tasks we can have.. | ||
118 | */ | ||
119 | #define IDT_ENTRIES 256 | ||
120 | |||
121 | /* Bottom two bits of selector give the ring privilege level */ | ||
122 | #define SEGMENT_RPL_MASK 0x3 | ||
123 | /* Bit 2 is table indicator (LDT/GDT) */ | ||
124 | #define SEGMENT_TI_MASK 0x4 | ||
125 | |||
126 | /* User mode is privilege level 3 */ | ||
127 | #define USER_RPL 0x3 | ||
128 | /* LDT segment has TI set, GDT has it cleared */ | ||
129 | #define SEGMENT_LDT 0x4 | ||
130 | #define SEGMENT_GDT 0x0 | ||
131 | |||
132 | #ifndef CONFIG_PARAVIRT | ||
133 | #define get_kernel_rpl() 0 | ||
134 | #endif | ||
135 | /* | ||
136 | * Matching rules for certain types of segments. | ||
137 | */ | ||
138 | |||
139 | /* Matches only __KERNEL_CS, ignoring PnP / USER / APM segments */ | ||
140 | #define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8) | ||
141 | |||
142 | /* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */ | ||
143 | #define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8) | ||
144 | |||
145 | /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */ | ||
146 | #define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8) | ||
147 | |||
148 | #endif | ||
diff --git a/include/asm-x86/segment_64.h b/include/asm-x86/segment_64.h new file mode 100644 index 000000000000..04b8ab21328f --- /dev/null +++ b/include/asm-x86/segment_64.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef _ASM_SEGMENT_H | ||
2 | #define _ASM_SEGMENT_H | ||
3 | |||
4 | #include <asm/cache.h> | ||
5 | |||
6 | /* Simple and small GDT entries for booting only */ | ||
7 | |||
8 | #define GDT_ENTRY_BOOT_CS 2 | ||
9 | #define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8) | ||
10 | |||
11 | #define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1) | ||
12 | #define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8) | ||
13 | |||
14 | #define __KERNEL_CS 0x10 | ||
15 | #define __KERNEL_DS 0x18 | ||
16 | |||
17 | #define __KERNEL32_CS 0x08 | ||
18 | |||
19 | /* | ||
20 | * we cannot use the same code segment descriptor for user and kernel | ||
21 | * -- not even in the long flat mode, because of different DPL /kkeil | ||
22 | * The segment offset needs to contain a RPL. Grr. -AK | ||
23 | * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) | ||
24 | */ | ||
25 | |||
26 | #define __USER32_CS 0x23 /* 4*8+3 */ | ||
27 | #define __USER_DS 0x2b /* 5*8+3 */ | ||
28 | #define __USER_CS 0x33 /* 6*8+3 */ | ||
29 | #define __USER32_DS __USER_DS | ||
30 | |||
31 | #define GDT_ENTRY_TSS 8 /* needs two entries */ | ||
32 | #define GDT_ENTRY_LDT 10 /* needs two entries */ | ||
33 | #define GDT_ENTRY_TLS_MIN 12 | ||
34 | #define GDT_ENTRY_TLS_MAX 14 | ||
35 | |||
36 | #define GDT_ENTRY_TLS_ENTRIES 3 | ||
37 | |||
38 | #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */ | ||
39 | #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3) | ||
40 | |||
41 | /* TLS indexes for 64bit - hardcoded in arch_prctl */ | ||
42 | #define FS_TLS 0 | ||
43 | #define GS_TLS 1 | ||
44 | |||
45 | #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3) | ||
46 | #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3) | ||
47 | |||
48 | #define IDT_ENTRIES 256 | ||
49 | #define GDT_ENTRIES 16 | ||
50 | #define GDT_SIZE (GDT_ENTRIES * 8) | ||
51 | #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) | ||
52 | |||
53 | #endif | ||
diff --git a/include/asm-x86/semaphore.h b/include/asm-x86/semaphore.h new file mode 100644 index 000000000000..572c0b67a6b0 --- /dev/null +++ b/include/asm-x86/semaphore.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "semaphore_32.h" | ||
3 | #else | ||
4 | # include "semaphore_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/semaphore_32.h b/include/asm-x86/semaphore_32.h new file mode 100644 index 000000000000..4e34a468c383 --- /dev/null +++ b/include/asm-x86/semaphore_32.h | |||
@@ -0,0 +1,176 @@ | |||
1 | #ifndef _I386_SEMAPHORE_H | ||
2 | #define _I386_SEMAPHORE_H | ||
3 | |||
4 | #include <linux/linkage.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | |||
8 | /* | ||
9 | * SMP- and interrupt-safe semaphores.. | ||
10 | * | ||
11 | * (C) Copyright 1996 Linus Torvalds | ||
12 | * | ||
13 | * Modified 1996-12-23 by Dave Grothe <dave@gcom.com> to fix bugs in | ||
14 | * the original code and to make semaphore waits | ||
15 | * interruptible so that processes waiting on | ||
16 | * semaphores can be killed. | ||
17 | * Modified 1999-02-14 by Andrea Arcangeli, split the sched.c helper | ||
18 | * functions in asm/sempahore-helper.h while fixing a | ||
19 | * potential and subtle race discovered by Ulrich Schmid | ||
20 | * in down_interruptible(). Since I started to play here I | ||
21 | * also implemented the `trylock' semaphore operation. | ||
22 | * 1999-07-02 Artur Skawina <skawina@geocities.com> | ||
23 | * Optimized "0(ecx)" -> "(ecx)" (the assembler does not | ||
24 | * do this). Changed calling sequences from push/jmp to | ||
25 | * traditional call/ret. | ||
26 | * Modified 2001-01-01 Andreas Franck <afranck@gmx.de> | ||
27 | * Some hacks to ensure compatibility with recent | ||
28 | * GCC snapshots, to avoid stack corruption when compiling | ||
29 | * with -fomit-frame-pointer. It's not sure if this will | ||
30 | * be fixed in GCC, as our previous implementation was a | ||
31 | * bit dubious. | ||
32 | * | ||
33 | * If you would like to see an analysis of this implementation, please | ||
34 | * ftp to gcom.com and download the file | ||
35 | * /pub/linux/src/semaphore/semaphore-2.0.24.tar.gz. | ||
36 | * | ||
37 | */ | ||
38 | |||
39 | #include <asm/system.h> | ||
40 | #include <asm/atomic.h> | ||
41 | #include <linux/wait.h> | ||
42 | #include <linux/rwsem.h> | ||
43 | |||
44 | struct semaphore { | ||
45 | atomic_t count; | ||
46 | int sleepers; | ||
47 | wait_queue_head_t wait; | ||
48 | }; | ||
49 | |||
50 | |||
51 | #define __SEMAPHORE_INITIALIZER(name, n) \ | ||
52 | { \ | ||
53 | .count = ATOMIC_INIT(n), \ | ||
54 | .sleepers = 0, \ | ||
55 | .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ | ||
56 | } | ||
57 | |||
58 | #define __DECLARE_SEMAPHORE_GENERIC(name,count) \ | ||
59 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) | ||
60 | |||
61 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) | ||
62 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) | ||
63 | |||
64 | static inline void sema_init (struct semaphore *sem, int val) | ||
65 | { | ||
66 | /* | ||
67 | * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); | ||
68 | * | ||
69 | * i'd rather use the more flexible initialization above, but sadly | ||
70 | * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well. | ||
71 | */ | ||
72 | atomic_set(&sem->count, val); | ||
73 | sem->sleepers = 0; | ||
74 | init_waitqueue_head(&sem->wait); | ||
75 | } | ||
76 | |||
77 | static inline void init_MUTEX (struct semaphore *sem) | ||
78 | { | ||
79 | sema_init(sem, 1); | ||
80 | } | ||
81 | |||
82 | static inline void init_MUTEX_LOCKED (struct semaphore *sem) | ||
83 | { | ||
84 | sema_init(sem, 0); | ||
85 | } | ||
86 | |||
87 | fastcall void __down_failed(void /* special register calling convention */); | ||
88 | fastcall int __down_failed_interruptible(void /* params in registers */); | ||
89 | fastcall int __down_failed_trylock(void /* params in registers */); | ||
90 | fastcall void __up_wakeup(void /* special register calling convention */); | ||
91 | |||
92 | /* | ||
93 | * This is ugly, but we want the default case to fall through. | ||
94 | * "__down_failed" is a special asm handler that calls the C | ||
95 | * routine that actually waits. See arch/i386/kernel/semaphore.c | ||
96 | */ | ||
97 | static inline void down(struct semaphore * sem) | ||
98 | { | ||
99 | might_sleep(); | ||
100 | __asm__ __volatile__( | ||
101 | "# atomic down operation\n\t" | ||
102 | LOCK_PREFIX "decl %0\n\t" /* --sem->count */ | ||
103 | "jns 2f\n" | ||
104 | "\tlea %0,%%eax\n\t" | ||
105 | "call __down_failed\n" | ||
106 | "2:" | ||
107 | :"+m" (sem->count) | ||
108 | : | ||
109 | :"memory","ax"); | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Interruptible try to acquire a semaphore. If we obtained | ||
114 | * it, return zero. If we were interrupted, returns -EINTR | ||
115 | */ | ||
116 | static inline int down_interruptible(struct semaphore * sem) | ||
117 | { | ||
118 | int result; | ||
119 | |||
120 | might_sleep(); | ||
121 | __asm__ __volatile__( | ||
122 | "# atomic interruptible down operation\n\t" | ||
123 | "xorl %0,%0\n\t" | ||
124 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | ||
125 | "jns 2f\n\t" | ||
126 | "lea %1,%%eax\n\t" | ||
127 | "call __down_failed_interruptible\n" | ||
128 | "2:" | ||
129 | :"=&a" (result), "+m" (sem->count) | ||
130 | : | ||
131 | :"memory"); | ||
132 | return result; | ||
133 | } | ||
134 | |||
135 | /* | ||
136 | * Non-blockingly attempt to down() a semaphore. | ||
137 | * Returns zero if we acquired it | ||
138 | */ | ||
139 | static inline int down_trylock(struct semaphore * sem) | ||
140 | { | ||
141 | int result; | ||
142 | |||
143 | __asm__ __volatile__( | ||
144 | "# atomic interruptible down operation\n\t" | ||
145 | "xorl %0,%0\n\t" | ||
146 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | ||
147 | "jns 2f\n\t" | ||
148 | "lea %1,%%eax\n\t" | ||
149 | "call __down_failed_trylock\n\t" | ||
150 | "2:\n" | ||
151 | :"=&a" (result), "+m" (sem->count) | ||
152 | : | ||
153 | :"memory"); | ||
154 | return result; | ||
155 | } | ||
156 | |||
157 | /* | ||
158 | * Note! This is subtle. We jump to wake people up only if | ||
159 | * the semaphore was negative (== somebody was waiting on it). | ||
160 | */ | ||
161 | static inline void up(struct semaphore * sem) | ||
162 | { | ||
163 | __asm__ __volatile__( | ||
164 | "# atomic up operation\n\t" | ||
165 | LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ | ||
166 | "jg 1f\n\t" | ||
167 | "lea %0,%%eax\n\t" | ||
168 | "call __up_wakeup\n" | ||
169 | "1:" | ||
170 | :"+m" (sem->count) | ||
171 | : | ||
172 | :"memory","ax"); | ||
173 | } | ||
174 | |||
175 | #endif | ||
176 | #endif | ||
diff --git a/include/asm-x86/semaphore_64.h b/include/asm-x86/semaphore_64.h new file mode 100644 index 000000000000..1194888536b9 --- /dev/null +++ b/include/asm-x86/semaphore_64.h | |||
@@ -0,0 +1,181 @@ | |||
1 | #ifndef _X86_64_SEMAPHORE_H | ||
2 | #define _X86_64_SEMAPHORE_H | ||
3 | |||
4 | #include <linux/linkage.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | |||
8 | /* | ||
9 | * SMP- and interrupt-safe semaphores.. | ||
10 | * | ||
11 | * (C) Copyright 1996 Linus Torvalds | ||
12 | * | ||
13 | * Modified 1996-12-23 by Dave Grothe <dave@gcom.com> to fix bugs in | ||
14 | * the original code and to make semaphore waits | ||
15 | * interruptible so that processes waiting on | ||
16 | * semaphores can be killed. | ||
17 | * Modified 1999-02-14 by Andrea Arcangeli, split the sched.c helper | ||
18 | * functions in asm/sempahore-helper.h while fixing a | ||
19 | * potential and subtle race discovered by Ulrich Schmid | ||
20 | * in down_interruptible(). Since I started to play here I | ||
21 | * also implemented the `trylock' semaphore operation. | ||
22 | * 1999-07-02 Artur Skawina <skawina@geocities.com> | ||
23 | * Optimized "0(ecx)" -> "(ecx)" (the assembler does not | ||
24 | * do this). Changed calling sequences from push/jmp to | ||
25 | * traditional call/ret. | ||
26 | * Modified 2001-01-01 Andreas Franck <afranck@gmx.de> | ||
27 | * Some hacks to ensure compatibility with recent | ||
28 | * GCC snapshots, to avoid stack corruption when compiling | ||
29 | * with -fomit-frame-pointer. It's not sure if this will | ||
30 | * be fixed in GCC, as our previous implementation was a | ||
31 | * bit dubious. | ||
32 | * | ||
33 | * If you would like to see an analysis of this implementation, please | ||
34 | * ftp to gcom.com and download the file | ||
35 | * /pub/linux/src/semaphore/semaphore-2.0.24.tar.gz. | ||
36 | * | ||
37 | */ | ||
38 | |||
39 | #include <asm/system.h> | ||
40 | #include <asm/atomic.h> | ||
41 | #include <asm/rwlock.h> | ||
42 | #include <linux/wait.h> | ||
43 | #include <linux/rwsem.h> | ||
44 | #include <linux/stringify.h> | ||
45 | |||
46 | struct semaphore { | ||
47 | atomic_t count; | ||
48 | int sleepers; | ||
49 | wait_queue_head_t wait; | ||
50 | }; | ||
51 | |||
52 | #define __SEMAPHORE_INITIALIZER(name, n) \ | ||
53 | { \ | ||
54 | .count = ATOMIC_INIT(n), \ | ||
55 | .sleepers = 0, \ | ||
56 | .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ | ||
57 | } | ||
58 | |||
59 | #define __DECLARE_SEMAPHORE_GENERIC(name,count) \ | ||
60 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) | ||
61 | |||
62 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) | ||
63 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) | ||
64 | |||
65 | static inline void sema_init (struct semaphore *sem, int val) | ||
66 | { | ||
67 | /* | ||
68 | * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); | ||
69 | * | ||
70 | * i'd rather use the more flexible initialization above, but sadly | ||
71 | * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well. | ||
72 | */ | ||
73 | atomic_set(&sem->count, val); | ||
74 | sem->sleepers = 0; | ||
75 | init_waitqueue_head(&sem->wait); | ||
76 | } | ||
77 | |||
78 | static inline void init_MUTEX (struct semaphore *sem) | ||
79 | { | ||
80 | sema_init(sem, 1); | ||
81 | } | ||
82 | |||
83 | static inline void init_MUTEX_LOCKED (struct semaphore *sem) | ||
84 | { | ||
85 | sema_init(sem, 0); | ||
86 | } | ||
87 | |||
88 | asmlinkage void __down_failed(void /* special register calling convention */); | ||
89 | asmlinkage int __down_failed_interruptible(void /* params in registers */); | ||
90 | asmlinkage int __down_failed_trylock(void /* params in registers */); | ||
91 | asmlinkage void __up_wakeup(void /* special register calling convention */); | ||
92 | |||
93 | asmlinkage void __down(struct semaphore * sem); | ||
94 | asmlinkage int __down_interruptible(struct semaphore * sem); | ||
95 | asmlinkage int __down_trylock(struct semaphore * sem); | ||
96 | asmlinkage void __up(struct semaphore * sem); | ||
97 | |||
98 | /* | ||
99 | * This is ugly, but we want the default case to fall through. | ||
100 | * "__down_failed" is a special asm handler that calls the C | ||
101 | * routine that actually waits. See arch/x86_64/kernel/semaphore.c | ||
102 | */ | ||
103 | static inline void down(struct semaphore * sem) | ||
104 | { | ||
105 | might_sleep(); | ||
106 | |||
107 | __asm__ __volatile__( | ||
108 | "# atomic down operation\n\t" | ||
109 | LOCK_PREFIX "decl %0\n\t" /* --sem->count */ | ||
110 | "jns 1f\n\t" | ||
111 | "call __down_failed\n" | ||
112 | "1:" | ||
113 | :"=m" (sem->count) | ||
114 | :"D" (sem) | ||
115 | :"memory"); | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Interruptible try to acquire a semaphore. If we obtained | ||
120 | * it, return zero. If we were interrupted, returns -EINTR | ||
121 | */ | ||
122 | static inline int down_interruptible(struct semaphore * sem) | ||
123 | { | ||
124 | int result; | ||
125 | |||
126 | might_sleep(); | ||
127 | |||
128 | __asm__ __volatile__( | ||
129 | "# atomic interruptible down operation\n\t" | ||
130 | "xorl %0,%0\n\t" | ||
131 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | ||
132 | "jns 2f\n\t" | ||
133 | "call __down_failed_interruptible\n" | ||
134 | "2:\n" | ||
135 | :"=&a" (result), "=m" (sem->count) | ||
136 | :"D" (sem) | ||
137 | :"memory"); | ||
138 | return result; | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * Non-blockingly attempt to down() a semaphore. | ||
143 | * Returns zero if we acquired it | ||
144 | */ | ||
145 | static inline int down_trylock(struct semaphore * sem) | ||
146 | { | ||
147 | int result; | ||
148 | |||
149 | __asm__ __volatile__( | ||
150 | "# atomic interruptible down operation\n\t" | ||
151 | "xorl %0,%0\n\t" | ||
152 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | ||
153 | "jns 2f\n\t" | ||
154 | "call __down_failed_trylock\n\t" | ||
155 | "2:\n" | ||
156 | :"=&a" (result), "=m" (sem->count) | ||
157 | :"D" (sem) | ||
158 | :"memory","cc"); | ||
159 | return result; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Note! This is subtle. We jump to wake people up only if | ||
164 | * the semaphore was negative (== somebody was waiting on it). | ||
165 | * The default case (no contention) will result in NO | ||
166 | * jumps for both down() and up(). | ||
167 | */ | ||
168 | static inline void up(struct semaphore * sem) | ||
169 | { | ||
170 | __asm__ __volatile__( | ||
171 | "# atomic up operation\n\t" | ||
172 | LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ | ||
173 | "jg 1f\n\t" | ||
174 | "call __up_wakeup\n" | ||
175 | "1:" | ||
176 | :"=m" (sem->count) | ||
177 | :"D" (sem) | ||
178 | :"memory"); | ||
179 | } | ||
180 | #endif /* __KERNEL__ */ | ||
181 | #endif | ||
diff --git a/include/asm-x86/sembuf.h b/include/asm-x86/sembuf.h new file mode 100644 index 000000000000..e42c971e383f --- /dev/null +++ b/include/asm-x86/sembuf.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "sembuf_32.h" | ||
4 | # else | ||
5 | # include "sembuf_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "sembuf_32.h" | ||
10 | # else | ||
11 | # include "sembuf_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/sembuf_32.h b/include/asm-x86/sembuf_32.h new file mode 100644 index 000000000000..323835166c14 --- /dev/null +++ b/include/asm-x86/sembuf_32.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _I386_SEMBUF_H | ||
2 | #define _I386_SEMBUF_H | ||
3 | |||
4 | /* | ||
5 | * The semid64_ds structure for i386 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 64-bit time_t to solve y2038 problem | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct semid64_ds { | ||
15 | struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ | ||
16 | __kernel_time_t sem_otime; /* last semop time */ | ||
17 | unsigned long __unused1; | ||
18 | __kernel_time_t sem_ctime; /* last change time */ | ||
19 | unsigned long __unused2; | ||
20 | unsigned long sem_nsems; /* no. of semaphores in array */ | ||
21 | unsigned long __unused3; | ||
22 | unsigned long __unused4; | ||
23 | }; | ||
24 | |||
25 | #endif /* _I386_SEMBUF_H */ | ||
diff --git a/include/asm-x86/sembuf_64.h b/include/asm-x86/sembuf_64.h new file mode 100644 index 000000000000..63b52925ae2a --- /dev/null +++ b/include/asm-x86/sembuf_64.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _X86_64_SEMBUF_H | ||
2 | #define _X86_64_SEMBUF_H | ||
3 | |||
4 | /* | ||
5 | * The semid64_ds structure for x86_64 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 64-bit time_t to solve y2038 problem | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct semid64_ds { | ||
15 | struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ | ||
16 | __kernel_time_t sem_otime; /* last semop time */ | ||
17 | unsigned long __unused1; | ||
18 | __kernel_time_t sem_ctime; /* last change time */ | ||
19 | unsigned long __unused2; | ||
20 | unsigned long sem_nsems; /* no. of semaphores in array */ | ||
21 | unsigned long __unused3; | ||
22 | unsigned long __unused4; | ||
23 | }; | ||
24 | |||
25 | #endif /* _X86_64_SEMBUF_H */ | ||
diff --git a/include/asm-x86/serial.h b/include/asm-x86/serial.h new file mode 100644 index 000000000000..cf1b05227b29 --- /dev/null +++ b/include/asm-x86/serial.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "serial_32.h" | ||
3 | #else | ||
4 | # include "serial_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/serial_32.h b/include/asm-x86/serial_32.h new file mode 100644 index 000000000000..bd67480ca109 --- /dev/null +++ b/include/asm-x86/serial_32.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * include/asm-i386/serial.h | ||
3 | */ | ||
4 | |||
5 | |||
6 | /* | ||
7 | * This assumes you have a 1.8432 MHz clock for your UART. | ||
8 | * | ||
9 | * It'd be nice if someone built a serial card with a 24.576 MHz | ||
10 | * clock, since the 16550A is capable of handling a top speed of 1.5 | ||
11 | * megabits/second; but this requires the faster clock. | ||
12 | */ | ||
13 | #define BASE_BAUD ( 1843200 / 16 ) | ||
14 | |||
15 | /* Standard COM flags (except for COM4, because of the 8514 problem) */ | ||
16 | #ifdef CONFIG_SERIAL_DETECT_IRQ | ||
17 | #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ) | ||
18 | #define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ) | ||
19 | #else | ||
20 | #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) | ||
21 | #define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF | ||
22 | #endif | ||
23 | |||
24 | #define SERIAL_PORT_DFNS \ | ||
25 | /* UART CLK PORT IRQ FLAGS */ \ | ||
26 | { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \ | ||
27 | { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \ | ||
28 | { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \ | ||
29 | { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */ | ||
diff --git a/include/asm-x86/serial_64.h b/include/asm-x86/serial_64.h new file mode 100644 index 000000000000..b0496e0d72a6 --- /dev/null +++ b/include/asm-x86/serial_64.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/serial.h | ||
3 | */ | ||
4 | |||
5 | |||
6 | /* | ||
7 | * This assumes you have a 1.8432 MHz clock for your UART. | ||
8 | * | ||
9 | * It'd be nice if someone built a serial card with a 24.576 MHz | ||
10 | * clock, since the 16550A is capable of handling a top speed of 1.5 | ||
11 | * megabits/second; but this requires the faster clock. | ||
12 | */ | ||
13 | #define BASE_BAUD ( 1843200 / 16 ) | ||
14 | |||
15 | /* Standard COM flags (except for COM4, because of the 8514 problem) */ | ||
16 | #ifdef CONFIG_SERIAL_DETECT_IRQ | ||
17 | #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ) | ||
18 | #define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ) | ||
19 | #else | ||
20 | #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) | ||
21 | #define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF | ||
22 | #endif | ||
23 | |||
24 | #define SERIAL_PORT_DFNS \ | ||
25 | /* UART CLK PORT IRQ FLAGS */ \ | ||
26 | { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \ | ||
27 | { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \ | ||
28 | { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \ | ||
29 | { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */ | ||
diff --git a/include/asm-x86/setup.h b/include/asm-x86/setup.h new file mode 100644 index 000000000000..81c0d98bb1c8 --- /dev/null +++ b/include/asm-x86/setup.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "setup_32.h" | ||
4 | # else | ||
5 | # include "setup_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "setup_32.h" | ||
10 | # else | ||
11 | # include "setup_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/setup_32.h b/include/asm-x86/setup_32.h new file mode 100644 index 000000000000..7862fe858a9e --- /dev/null +++ b/include/asm-x86/setup_32.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Just a place holder. We don't want to have to test x86 before | ||
3 | * we include stuff | ||
4 | */ | ||
5 | |||
6 | #ifndef _i386_SETUP_H | ||
7 | #define _i386_SETUP_H | ||
8 | |||
9 | #define COMMAND_LINE_SIZE 2048 | ||
10 | |||
11 | #ifdef __KERNEL__ | ||
12 | #include <linux/pfn.h> | ||
13 | |||
14 | /* | ||
15 | * Reserved space for vmalloc and iomap - defined in asm/page.h | ||
16 | */ | ||
17 | #define MAXMEM_PFN PFN_DOWN(MAXMEM) | ||
18 | #define MAX_NONPAE_PFN (1 << 20) | ||
19 | |||
20 | #define PARAM_SIZE 4096 | ||
21 | |||
22 | #define OLD_CL_MAGIC_ADDR 0x90020 | ||
23 | #define OLD_CL_MAGIC 0xA33F | ||
24 | #define OLD_CL_BASE_ADDR 0x90000 | ||
25 | #define OLD_CL_OFFSET 0x90022 | ||
26 | #define NEW_CL_POINTER 0x228 /* Relative to real mode data */ | ||
27 | |||
28 | #ifndef __ASSEMBLY__ | ||
29 | |||
30 | #include <asm/bootparam.h> | ||
31 | |||
32 | /* | ||
33 | * This is set up by the setup-routine at boot-time | ||
34 | */ | ||
35 | extern struct boot_params boot_params; | ||
36 | |||
37 | #define PARAM ((char *)&boot_params) | ||
38 | #define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) | ||
39 | #define EXT_MEM_K (*(unsigned short *) (PARAM+2)) | ||
40 | #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0)) | ||
41 | #define E820_MAP_NR (*(char*) (PARAM+E820NR)) | ||
42 | #define E820_MAP ((struct e820entry *) (PARAM+E820MAP)) | ||
43 | #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40)) | ||
44 | #define IST_INFO (*(struct ist_info *) (PARAM+0x60)) | ||
45 | #define SYS_DESC_TABLE (*(struct sys_desc_table *)(PARAM+0xa0)) | ||
46 | #define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4))) | ||
47 | #define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8))) | ||
48 | #define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc))) | ||
49 | #define EFI_MEMMAP ((void *) *((unsigned long *)(PARAM+0x1d0))) | ||
50 | #define EFI_MEMMAP_SIZE (*((unsigned long *) (PARAM+0x1d4))) | ||
51 | #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2)) | ||
52 | #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8)) | ||
53 | #define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA)) | ||
54 | #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC)) | ||
55 | #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF)) | ||
56 | #define LOADER_TYPE (*(unsigned char *) (PARAM+0x210)) | ||
57 | #define KERNEL_START (*(unsigned long *) (PARAM+0x214)) | ||
58 | #define INITRD_START (*(unsigned long *) (PARAM+0x218)) | ||
59 | #define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c)) | ||
60 | #define EDID_INFO (*(struct edid_info *) (PARAM+0x140)) | ||
61 | #define EDD_NR (*(unsigned char *) (PARAM+EDDNR)) | ||
62 | #define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF)) | ||
63 | #define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF)) | ||
64 | #define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF)) | ||
65 | |||
66 | /* | ||
67 | * Do NOT EVER look at the BIOS memory size location. | ||
68 | * It does not work on many machines. | ||
69 | */ | ||
70 | #define LOWMEMSIZE() (0x9f000) | ||
71 | |||
72 | struct e820entry; | ||
73 | |||
74 | char * __init machine_specific_memory_setup(void); | ||
75 | char *memory_setup(void); | ||
76 | |||
77 | int __init copy_e820_map(struct e820entry * biosmap, int nr_map); | ||
78 | int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map); | ||
79 | void __init add_memory_region(unsigned long long start, | ||
80 | unsigned long long size, int type); | ||
81 | |||
82 | extern unsigned long init_pg_tables_end; | ||
83 | |||
84 | #ifndef CONFIG_PARAVIRT | ||
85 | #define paravirt_post_allocator_init() do {} while (0) | ||
86 | #endif | ||
87 | |||
88 | #endif /* __ASSEMBLY__ */ | ||
89 | |||
90 | #endif /* __KERNEL__ */ | ||
91 | |||
92 | #endif /* _i386_SETUP_H */ | ||
diff --git a/include/asm-x86/setup_64.h b/include/asm-x86/setup_64.h new file mode 100644 index 000000000000..eaeff73d6c10 --- /dev/null +++ b/include/asm-x86/setup_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _x8664_SETUP_H | ||
2 | #define _x8664_SETUP_H | ||
3 | |||
4 | #define COMMAND_LINE_SIZE 2048 | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/shmbuf.h b/include/asm-x86/shmbuf.h new file mode 100644 index 000000000000..e85f1cb11217 --- /dev/null +++ b/include/asm-x86/shmbuf.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "shmbuf_32.h" | ||
4 | # else | ||
5 | # include "shmbuf_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "shmbuf_32.h" | ||
10 | # else | ||
11 | # include "shmbuf_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/shmbuf_32.h b/include/asm-x86/shmbuf_32.h new file mode 100644 index 000000000000..d1cdc3cb079b --- /dev/null +++ b/include/asm-x86/shmbuf_32.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _I386_SHMBUF_H | ||
2 | #define _I386_SHMBUF_H | ||
3 | |||
4 | /* | ||
5 | * The shmid64_ds structure for i386 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 64-bit time_t to solve y2038 problem | ||
11 | * - 2 miscellaneous 32-bit values | ||
12 | */ | ||
13 | |||
14 | struct shmid64_ds { | ||
15 | struct ipc64_perm shm_perm; /* operation perms */ | ||
16 | size_t shm_segsz; /* size of segment (bytes) */ | ||
17 | __kernel_time_t shm_atime; /* last attach time */ | ||
18 | unsigned long __unused1; | ||
19 | __kernel_time_t shm_dtime; /* last detach time */ | ||
20 | unsigned long __unused2; | ||
21 | __kernel_time_t shm_ctime; /* last change time */ | ||
22 | unsigned long __unused3; | ||
23 | __kernel_pid_t shm_cpid; /* pid of creator */ | ||
24 | __kernel_pid_t shm_lpid; /* pid of last operator */ | ||
25 | unsigned long shm_nattch; /* no. of current attaches */ | ||
26 | unsigned long __unused4; | ||
27 | unsigned long __unused5; | ||
28 | }; | ||
29 | |||
30 | struct shminfo64 { | ||
31 | unsigned long shmmax; | ||
32 | unsigned long shmmin; | ||
33 | unsigned long shmmni; | ||
34 | unsigned long shmseg; | ||
35 | unsigned long shmall; | ||
36 | unsigned long __unused1; | ||
37 | unsigned long __unused2; | ||
38 | unsigned long __unused3; | ||
39 | unsigned long __unused4; | ||
40 | }; | ||
41 | |||
42 | #endif /* _I386_SHMBUF_H */ | ||
diff --git a/include/asm-x86/shmbuf_64.h b/include/asm-x86/shmbuf_64.h new file mode 100644 index 000000000000..5a6d6dda7c48 --- /dev/null +++ b/include/asm-x86/shmbuf_64.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _X8664_SHMBUF_H | ||
2 | #define _X8664_SHMBUF_H | ||
3 | |||
4 | /* | ||
5 | * The shmid64_ds structure for x8664 architecture. | ||
6 | * Note extra padding because this structure is passed back and forth | ||
7 | * between kernel and user space. | ||
8 | * | ||
9 | * Pad space is left for: | ||
10 | * - 2 miscellaneous 64-bit values | ||
11 | */ | ||
12 | |||
13 | struct shmid64_ds { | ||
14 | struct ipc64_perm shm_perm; /* operation perms */ | ||
15 | size_t shm_segsz; /* size of segment (bytes) */ | ||
16 | __kernel_time_t shm_atime; /* last attach time */ | ||
17 | __kernel_time_t shm_dtime; /* last detach time */ | ||
18 | __kernel_time_t shm_ctime; /* last change time */ | ||
19 | __kernel_pid_t shm_cpid; /* pid of creator */ | ||
20 | __kernel_pid_t shm_lpid; /* pid of last operator */ | ||
21 | unsigned long shm_nattch; /* no. of current attaches */ | ||
22 | unsigned long __unused4; | ||
23 | unsigned long __unused5; | ||
24 | }; | ||
25 | |||
26 | struct shminfo64 { | ||
27 | unsigned long shmmax; | ||
28 | unsigned long shmmin; | ||
29 | unsigned long shmmni; | ||
30 | unsigned long shmseg; | ||
31 | unsigned long shmall; | ||
32 | unsigned long __unused1; | ||
33 | unsigned long __unused2; | ||
34 | unsigned long __unused3; | ||
35 | unsigned long __unused4; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/include/asm-x86/shmparam.h b/include/asm-x86/shmparam.h new file mode 100644 index 000000000000..165627cc5345 --- /dev/null +++ b/include/asm-x86/shmparam.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "shmparam_32.h" | ||
4 | # else | ||
5 | # include "shmparam_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "shmparam_32.h" | ||
10 | # else | ||
11 | # include "shmparam_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/shmparam_32.h b/include/asm-x86/shmparam_32.h new file mode 100644 index 000000000000..786243a5b319 --- /dev/null +++ b/include/asm-x86/shmparam_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASMI386_SHMPARAM_H | ||
2 | #define _ASMI386_SHMPARAM_H | ||
3 | |||
4 | #define SHMLBA PAGE_SIZE /* attach addr a multiple of this */ | ||
5 | |||
6 | #endif /* _ASMI386_SHMPARAM_H */ | ||
diff --git a/include/asm-x86/shmparam_64.h b/include/asm-x86/shmparam_64.h new file mode 100644 index 000000000000..d7021620dcb7 --- /dev/null +++ b/include/asm-x86/shmparam_64.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASMX8664_SHMPARAM_H | ||
2 | #define _ASMX8664_SHMPARAM_H | ||
3 | |||
4 | #define SHMLBA PAGE_SIZE /* attach addr a multiple of this */ | ||
5 | |||
6 | #endif /* _ASMX8664_SHMPARAM_H */ | ||
diff --git a/include/asm-x86/sigcontext.h b/include/asm-x86/sigcontext.h new file mode 100644 index 000000000000..0d16ceff1599 --- /dev/null +++ b/include/asm-x86/sigcontext.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "sigcontext_32.h" | ||
4 | # else | ||
5 | # include "sigcontext_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "sigcontext_32.h" | ||
10 | # else | ||
11 | # include "sigcontext_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/sigcontext32.h b/include/asm-x86/sigcontext32.h new file mode 100644 index 000000000000..3d657038ab7c --- /dev/null +++ b/include/asm-x86/sigcontext32.h | |||
@@ -0,0 +1,71 @@ | |||
1 | #ifndef _SIGCONTEXT32_H | ||
2 | #define _SIGCONTEXT32_H 1 | ||
3 | |||
4 | /* signal context for 32bit programs. */ | ||
5 | |||
6 | #define X86_FXSR_MAGIC 0x0000 | ||
7 | |||
8 | struct _fpreg { | ||
9 | unsigned short significand[4]; | ||
10 | unsigned short exponent; | ||
11 | }; | ||
12 | |||
13 | struct _fpxreg { | ||
14 | unsigned short significand[4]; | ||
15 | unsigned short exponent; | ||
16 | unsigned short padding[3]; | ||
17 | }; | ||
18 | |||
19 | struct _xmmreg { | ||
20 | __u32 element[4]; | ||
21 | }; | ||
22 | |||
23 | /* FSAVE frame with extensions */ | ||
24 | struct _fpstate_ia32 { | ||
25 | /* Regular FPU environment */ | ||
26 | __u32 cw; | ||
27 | __u32 sw; | ||
28 | __u32 tag; /* not compatible to 64bit twd */ | ||
29 | __u32 ipoff; | ||
30 | __u32 cssel; | ||
31 | __u32 dataoff; | ||
32 | __u32 datasel; | ||
33 | struct _fpreg _st[8]; | ||
34 | unsigned short status; | ||
35 | unsigned short magic; /* 0xffff = regular FPU data only */ | ||
36 | |||
37 | /* FXSR FPU environment */ | ||
38 | __u32 _fxsr_env[6]; | ||
39 | __u32 mxcsr; | ||
40 | __u32 reserved; | ||
41 | struct _fpxreg _fxsr_st[8]; | ||
42 | struct _xmmreg _xmm[8]; /* It's actually 16 */ | ||
43 | __u32 padding[56]; | ||
44 | }; | ||
45 | |||
46 | struct sigcontext_ia32 { | ||
47 | unsigned short gs, __gsh; | ||
48 | unsigned short fs, __fsh; | ||
49 | unsigned short es, __esh; | ||
50 | unsigned short ds, __dsh; | ||
51 | unsigned int edi; | ||
52 | unsigned int esi; | ||
53 | unsigned int ebp; | ||
54 | unsigned int esp; | ||
55 | unsigned int ebx; | ||
56 | unsigned int edx; | ||
57 | unsigned int ecx; | ||
58 | unsigned int eax; | ||
59 | unsigned int trapno; | ||
60 | unsigned int err; | ||
61 | unsigned int eip; | ||
62 | unsigned short cs, __csh; | ||
63 | unsigned int eflags; | ||
64 | unsigned int esp_at_signal; | ||
65 | unsigned short ss, __ssh; | ||
66 | unsigned int fpstate; /* really (struct _fpstate_ia32 *) */ | ||
67 | unsigned int oldmask; | ||
68 | unsigned int cr2; | ||
69 | }; | ||
70 | |||
71 | #endif | ||
diff --git a/include/asm-x86/sigcontext_32.h b/include/asm-x86/sigcontext_32.h new file mode 100644 index 000000000000..aaef089a7787 --- /dev/null +++ b/include/asm-x86/sigcontext_32.h | |||
@@ -0,0 +1,85 @@ | |||
1 | #ifndef _ASMi386_SIGCONTEXT_H | ||
2 | #define _ASMi386_SIGCONTEXT_H | ||
3 | |||
4 | #include <linux/compiler.h> | ||
5 | |||
6 | /* | ||
7 | * As documented in the iBCS2 standard.. | ||
8 | * | ||
9 | * The first part of "struct _fpstate" is just the normal i387 | ||
10 | * hardware setup, the extra "status" word is used to save the | ||
11 | * coprocessor status word before entering the handler. | ||
12 | * | ||
13 | * Pentium III FXSR, SSE support | ||
14 | * Gareth Hughes <gareth@valinux.com>, May 2000 | ||
15 | * | ||
16 | * The FPU state data structure has had to grow to accommodate the | ||
17 | * extended FPU state required by the Streaming SIMD Extensions. | ||
18 | * There is no documented standard to accomplish this at the moment. | ||
19 | */ | ||
20 | struct _fpreg { | ||
21 | unsigned short significand[4]; | ||
22 | unsigned short exponent; | ||
23 | }; | ||
24 | |||
25 | struct _fpxreg { | ||
26 | unsigned short significand[4]; | ||
27 | unsigned short exponent; | ||
28 | unsigned short padding[3]; | ||
29 | }; | ||
30 | |||
31 | struct _xmmreg { | ||
32 | unsigned long element[4]; | ||
33 | }; | ||
34 | |||
35 | struct _fpstate { | ||
36 | /* Regular FPU environment */ | ||
37 | unsigned long cw; | ||
38 | unsigned long sw; | ||
39 | unsigned long tag; | ||
40 | unsigned long ipoff; | ||
41 | unsigned long cssel; | ||
42 | unsigned long dataoff; | ||
43 | unsigned long datasel; | ||
44 | struct _fpreg _st[8]; | ||
45 | unsigned short status; | ||
46 | unsigned short magic; /* 0xffff = regular FPU data only */ | ||
47 | |||
48 | /* FXSR FPU environment */ | ||
49 | unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ | ||
50 | unsigned long mxcsr; | ||
51 | unsigned long reserved; | ||
52 | struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ | ||
53 | struct _xmmreg _xmm[8]; | ||
54 | unsigned long padding[56]; | ||
55 | }; | ||
56 | |||
57 | #define X86_FXSR_MAGIC 0x0000 | ||
58 | |||
59 | struct sigcontext { | ||
60 | unsigned short gs, __gsh; | ||
61 | unsigned short fs, __fsh; | ||
62 | unsigned short es, __esh; | ||
63 | unsigned short ds, __dsh; | ||
64 | unsigned long edi; | ||
65 | unsigned long esi; | ||
66 | unsigned long ebp; | ||
67 | unsigned long esp; | ||
68 | unsigned long ebx; | ||
69 | unsigned long edx; | ||
70 | unsigned long ecx; | ||
71 | unsigned long eax; | ||
72 | unsigned long trapno; | ||
73 | unsigned long err; | ||
74 | unsigned long eip; | ||
75 | unsigned short cs, __csh; | ||
76 | unsigned long eflags; | ||
77 | unsigned long esp_at_signal; | ||
78 | unsigned short ss, __ssh; | ||
79 | struct _fpstate __user * fpstate; | ||
80 | unsigned long oldmask; | ||
81 | unsigned long cr2; | ||
82 | }; | ||
83 | |||
84 | |||
85 | #endif | ||
diff --git a/include/asm-x86/sigcontext_64.h b/include/asm-x86/sigcontext_64.h new file mode 100644 index 000000000000..b4e40236666c --- /dev/null +++ b/include/asm-x86/sigcontext_64.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef _ASM_X86_64_SIGCONTEXT_H | ||
2 | #define _ASM_X86_64_SIGCONTEXT_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | /* FXSAVE frame */ | ||
8 | /* Note: reserved1/2 may someday contain valuable data. Always save/restore | ||
9 | them when you change signal frames. */ | ||
10 | struct _fpstate { | ||
11 | __u16 cwd; | ||
12 | __u16 swd; | ||
13 | __u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ | ||
14 | __u16 fop; | ||
15 | __u64 rip; | ||
16 | __u64 rdp; | ||
17 | __u32 mxcsr; | ||
18 | __u32 mxcsr_mask; | ||
19 | __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ | ||
20 | __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ | ||
21 | __u32 reserved2[24]; | ||
22 | }; | ||
23 | |||
24 | struct sigcontext { | ||
25 | unsigned long r8; | ||
26 | unsigned long r9; | ||
27 | unsigned long r10; | ||
28 | unsigned long r11; | ||
29 | unsigned long r12; | ||
30 | unsigned long r13; | ||
31 | unsigned long r14; | ||
32 | unsigned long r15; | ||
33 | unsigned long rdi; | ||
34 | unsigned long rsi; | ||
35 | unsigned long rbp; | ||
36 | unsigned long rbx; | ||
37 | unsigned long rdx; | ||
38 | unsigned long rax; | ||
39 | unsigned long rcx; | ||
40 | unsigned long rsp; | ||
41 | unsigned long rip; | ||
42 | unsigned long eflags; /* RFLAGS */ | ||
43 | unsigned short cs; | ||
44 | unsigned short gs; | ||
45 | unsigned short fs; | ||
46 | unsigned short __pad0; | ||
47 | unsigned long err; | ||
48 | unsigned long trapno; | ||
49 | unsigned long oldmask; | ||
50 | unsigned long cr2; | ||
51 | struct _fpstate __user *fpstate; /* zero when no FPU context */ | ||
52 | unsigned long reserved1[8]; | ||
53 | }; | ||
54 | |||
55 | #endif | ||
diff --git a/include/asm-x86/siginfo.h b/include/asm-x86/siginfo.h new file mode 100644 index 000000000000..0b8e4bb47d25 --- /dev/null +++ b/include/asm-x86/siginfo.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "siginfo_32.h" | ||
4 | # else | ||
5 | # include "siginfo_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "siginfo_32.h" | ||
10 | # else | ||
11 | # include "siginfo_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/siginfo_32.h b/include/asm-x86/siginfo_32.h new file mode 100644 index 000000000000..fe18f98fccfa --- /dev/null +++ b/include/asm-x86/siginfo_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _I386_SIGINFO_H | ||
2 | #define _I386_SIGINFO_H | ||
3 | |||
4 | #include <asm-generic/siginfo.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/siginfo_64.h b/include/asm-x86/siginfo_64.h new file mode 100644 index 000000000000..d09a1e6e7246 --- /dev/null +++ b/include/asm-x86/siginfo_64.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _X8664_SIGINFO_H | ||
2 | #define _X8664_SIGINFO_H | ||
3 | |||
4 | #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) | ||
5 | |||
6 | #include <asm-generic/siginfo.h> | ||
7 | |||
8 | #endif | ||
diff --git a/include/asm-x86/signal.h b/include/asm-x86/signal.h new file mode 100644 index 000000000000..bf5a63f457da --- /dev/null +++ b/include/asm-x86/signal.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "signal_32.h" | ||
4 | # else | ||
5 | # include "signal_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "signal_32.h" | ||
10 | # else | ||
11 | # include "signal_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/signal_32.h b/include/asm-x86/signal_32.h new file mode 100644 index 000000000000..c3e8adec5918 --- /dev/null +++ b/include/asm-x86/signal_32.h | |||
@@ -0,0 +1,232 @@ | |||
1 | #ifndef _ASMi386_SIGNAL_H | ||
2 | #define _ASMi386_SIGNAL_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/time.h> | ||
6 | #include <linux/compiler.h> | ||
7 | |||
8 | /* Avoid too many header ordering problems. */ | ||
9 | struct siginfo; | ||
10 | |||
11 | #ifdef __KERNEL__ | ||
12 | |||
13 | #include <linux/linkage.h> | ||
14 | |||
15 | /* Most things should be clean enough to redefine this at will, if care | ||
16 | is taken to make libc match. */ | ||
17 | |||
18 | #define _NSIG 64 | ||
19 | #define _NSIG_BPW 32 | ||
20 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) | ||
21 | |||
22 | typedef unsigned long old_sigset_t; /* at least 32 bits */ | ||
23 | |||
24 | typedef struct { | ||
25 | unsigned long sig[_NSIG_WORDS]; | ||
26 | } sigset_t; | ||
27 | |||
28 | #else | ||
29 | /* Here we must cater to libcs that poke about in kernel headers. */ | ||
30 | |||
31 | #define NSIG 32 | ||
32 | typedef unsigned long sigset_t; | ||
33 | |||
34 | #endif /* __KERNEL__ */ | ||
35 | |||
36 | #define SIGHUP 1 | ||
37 | #define SIGINT 2 | ||
38 | #define SIGQUIT 3 | ||
39 | #define SIGILL 4 | ||
40 | #define SIGTRAP 5 | ||
41 | #define SIGABRT 6 | ||
42 | #define SIGIOT 6 | ||
43 | #define SIGBUS 7 | ||
44 | #define SIGFPE 8 | ||
45 | #define SIGKILL 9 | ||
46 | #define SIGUSR1 10 | ||
47 | #define SIGSEGV 11 | ||
48 | #define SIGUSR2 12 | ||
49 | #define SIGPIPE 13 | ||
50 | #define SIGALRM 14 | ||
51 | #define SIGTERM 15 | ||
52 | #define SIGSTKFLT 16 | ||
53 | #define SIGCHLD 17 | ||
54 | #define SIGCONT 18 | ||
55 | #define SIGSTOP 19 | ||
56 | #define SIGTSTP 20 | ||
57 | #define SIGTTIN 21 | ||
58 | #define SIGTTOU 22 | ||
59 | #define SIGURG 23 | ||
60 | #define SIGXCPU 24 | ||
61 | #define SIGXFSZ 25 | ||
62 | #define SIGVTALRM 26 | ||
63 | #define SIGPROF 27 | ||
64 | #define SIGWINCH 28 | ||
65 | #define SIGIO 29 | ||
66 | #define SIGPOLL SIGIO | ||
67 | /* | ||
68 | #define SIGLOST 29 | ||
69 | */ | ||
70 | #define SIGPWR 30 | ||
71 | #define SIGSYS 31 | ||
72 | #define SIGUNUSED 31 | ||
73 | |||
74 | /* These should not be considered constants from userland. */ | ||
75 | #define SIGRTMIN 32 | ||
76 | #define SIGRTMAX _NSIG | ||
77 | |||
78 | /* | ||
79 | * SA_FLAGS values: | ||
80 | * | ||
81 | * SA_ONSTACK indicates that a registered stack_t will be used. | ||
82 | * SA_RESTART flag to get restarting signals (which were the default long ago) | ||
83 | * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. | ||
84 | * SA_RESETHAND clears the handler when the signal is delivered. | ||
85 | * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. | ||
86 | * SA_NODEFER prevents the current signal from being masked in the handler. | ||
87 | * | ||
88 | * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single | ||
89 | * Unix names RESETHAND and NODEFER respectively. | ||
90 | */ | ||
91 | #define SA_NOCLDSTOP 0x00000001u | ||
92 | #define SA_NOCLDWAIT 0x00000002u | ||
93 | #define SA_SIGINFO 0x00000004u | ||
94 | #define SA_ONSTACK 0x08000000u | ||
95 | #define SA_RESTART 0x10000000u | ||
96 | #define SA_NODEFER 0x40000000u | ||
97 | #define SA_RESETHAND 0x80000000u | ||
98 | |||
99 | #define SA_NOMASK SA_NODEFER | ||
100 | #define SA_ONESHOT SA_RESETHAND | ||
101 | |||
102 | #define SA_RESTORER 0x04000000 | ||
103 | |||
104 | /* | ||
105 | * sigaltstack controls | ||
106 | */ | ||
107 | #define SS_ONSTACK 1 | ||
108 | #define SS_DISABLE 2 | ||
109 | |||
110 | #define MINSIGSTKSZ 2048 | ||
111 | #define SIGSTKSZ 8192 | ||
112 | |||
113 | #include <asm-generic/signal.h> | ||
114 | |||
115 | #ifdef __KERNEL__ | ||
116 | struct old_sigaction { | ||
117 | __sighandler_t sa_handler; | ||
118 | old_sigset_t sa_mask; | ||
119 | unsigned long sa_flags; | ||
120 | __sigrestore_t sa_restorer; | ||
121 | }; | ||
122 | |||
123 | struct sigaction { | ||
124 | __sighandler_t sa_handler; | ||
125 | unsigned long sa_flags; | ||
126 | __sigrestore_t sa_restorer; | ||
127 | sigset_t sa_mask; /* mask last for extensibility */ | ||
128 | }; | ||
129 | |||
130 | struct k_sigaction { | ||
131 | struct sigaction sa; | ||
132 | }; | ||
133 | #else | ||
134 | /* Here we must cater to libcs that poke about in kernel headers. */ | ||
135 | |||
136 | struct sigaction { | ||
137 | union { | ||
138 | __sighandler_t _sa_handler; | ||
139 | void (*_sa_sigaction)(int, struct siginfo *, void *); | ||
140 | } _u; | ||
141 | sigset_t sa_mask; | ||
142 | unsigned long sa_flags; | ||
143 | void (*sa_restorer)(void); | ||
144 | }; | ||
145 | |||
146 | #define sa_handler _u._sa_handler | ||
147 | #define sa_sigaction _u._sa_sigaction | ||
148 | |||
149 | #endif /* __KERNEL__ */ | ||
150 | |||
151 | typedef struct sigaltstack { | ||
152 | void __user *ss_sp; | ||
153 | int ss_flags; | ||
154 | size_t ss_size; | ||
155 | } stack_t; | ||
156 | |||
157 | #ifdef __KERNEL__ | ||
158 | #include <asm/sigcontext.h> | ||
159 | |||
160 | #define __HAVE_ARCH_SIG_BITOPS | ||
161 | |||
162 | #define sigaddset(set,sig) \ | ||
163 | (__builtin_constant_p(sig) ? \ | ||
164 | __const_sigaddset((set),(sig)) : \ | ||
165 | __gen_sigaddset((set),(sig))) | ||
166 | |||
167 | static __inline__ void __gen_sigaddset(sigset_t *set, int _sig) | ||
168 | { | ||
169 | __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); | ||
170 | } | ||
171 | |||
172 | static __inline__ void __const_sigaddset(sigset_t *set, int _sig) | ||
173 | { | ||
174 | unsigned long sig = _sig - 1; | ||
175 | set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); | ||
176 | } | ||
177 | |||
178 | #define sigdelset(set,sig) \ | ||
179 | (__builtin_constant_p(sig) ? \ | ||
180 | __const_sigdelset((set),(sig)) : \ | ||
181 | __gen_sigdelset((set),(sig))) | ||
182 | |||
183 | |||
184 | static __inline__ void __gen_sigdelset(sigset_t *set, int _sig) | ||
185 | { | ||
186 | __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); | ||
187 | } | ||
188 | |||
189 | static __inline__ void __const_sigdelset(sigset_t *set, int _sig) | ||
190 | { | ||
191 | unsigned long sig = _sig - 1; | ||
192 | set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); | ||
193 | } | ||
194 | |||
195 | static __inline__ int __const_sigismember(sigset_t *set, int _sig) | ||
196 | { | ||
197 | unsigned long sig = _sig - 1; | ||
198 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); | ||
199 | } | ||
200 | |||
201 | static __inline__ int __gen_sigismember(sigset_t *set, int _sig) | ||
202 | { | ||
203 | int ret; | ||
204 | __asm__("btl %2,%1\n\tsbbl %0,%0" | ||
205 | : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | #define sigismember(set,sig) \ | ||
210 | (__builtin_constant_p(sig) ? \ | ||
211 | __const_sigismember((set),(sig)) : \ | ||
212 | __gen_sigismember((set),(sig))) | ||
213 | |||
214 | static __inline__ int sigfindinword(unsigned long word) | ||
215 | { | ||
216 | __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); | ||
217 | return word; | ||
218 | } | ||
219 | |||
220 | struct pt_regs; | ||
221 | |||
222 | #define ptrace_signal_deliver(regs, cookie) \ | ||
223 | do { \ | ||
224 | if (current->ptrace & PT_DTRACE) { \ | ||
225 | current->ptrace &= ~PT_DTRACE; \ | ||
226 | (regs)->eflags &= ~TF_MASK; \ | ||
227 | } \ | ||
228 | } while (0) | ||
229 | |||
230 | #endif /* __KERNEL__ */ | ||
231 | |||
232 | #endif | ||
diff --git a/include/asm-x86/signal_64.h b/include/asm-x86/signal_64.h new file mode 100644 index 000000000000..4581f978b299 --- /dev/null +++ b/include/asm-x86/signal_64.h | |||
@@ -0,0 +1,181 @@ | |||
1 | #ifndef _ASMx8664_SIGNAL_H | ||
2 | #define _ASMx8664_SIGNAL_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | #include <linux/types.h> | ||
6 | #include <linux/time.h> | ||
7 | |||
8 | /* Avoid too many header ordering problems. */ | ||
9 | struct siginfo; | ||
10 | |||
11 | #ifdef __KERNEL__ | ||
12 | #include <linux/linkage.h> | ||
13 | /* Most things should be clean enough to redefine this at will, if care | ||
14 | is taken to make libc match. */ | ||
15 | |||
16 | #define _NSIG 64 | ||
17 | #define _NSIG_BPW 64 | ||
18 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) | ||
19 | |||
20 | typedef unsigned long old_sigset_t; /* at least 32 bits */ | ||
21 | |||
22 | typedef struct { | ||
23 | unsigned long sig[_NSIG_WORDS]; | ||
24 | } sigset_t; | ||
25 | |||
26 | |||
27 | #else | ||
28 | /* Here we must cater to libcs that poke about in kernel headers. */ | ||
29 | |||
30 | #define NSIG 32 | ||
31 | typedef unsigned long sigset_t; | ||
32 | |||
33 | #endif /* __KERNEL__ */ | ||
34 | #endif | ||
35 | |||
36 | #define SIGHUP 1 | ||
37 | #define SIGINT 2 | ||
38 | #define SIGQUIT 3 | ||
39 | #define SIGILL 4 | ||
40 | #define SIGTRAP 5 | ||
41 | #define SIGABRT 6 | ||
42 | #define SIGIOT 6 | ||
43 | #define SIGBUS 7 | ||
44 | #define SIGFPE 8 | ||
45 | #define SIGKILL 9 | ||
46 | #define SIGUSR1 10 | ||
47 | #define SIGSEGV 11 | ||
48 | #define SIGUSR2 12 | ||
49 | #define SIGPIPE 13 | ||
50 | #define SIGALRM 14 | ||
51 | #define SIGTERM 15 | ||
52 | #define SIGSTKFLT 16 | ||
53 | #define SIGCHLD 17 | ||
54 | #define SIGCONT 18 | ||
55 | #define SIGSTOP 19 | ||
56 | #define SIGTSTP 20 | ||
57 | #define SIGTTIN 21 | ||
58 | #define SIGTTOU 22 | ||
59 | #define SIGURG 23 | ||
60 | #define SIGXCPU 24 | ||
61 | #define SIGXFSZ 25 | ||
62 | #define SIGVTALRM 26 | ||
63 | #define SIGPROF 27 | ||
64 | #define SIGWINCH 28 | ||
65 | #define SIGIO 29 | ||
66 | #define SIGPOLL SIGIO | ||
67 | /* | ||
68 | #define SIGLOST 29 | ||
69 | */ | ||
70 | #define SIGPWR 30 | ||
71 | #define SIGSYS 31 | ||
72 | #define SIGUNUSED 31 | ||
73 | |||
74 | /* These should not be considered constants from userland. */ | ||
75 | #define SIGRTMIN 32 | ||
76 | #define SIGRTMAX _NSIG | ||
77 | |||
78 | /* | ||
79 | * SA_FLAGS values: | ||
80 | * | ||
81 | * SA_ONSTACK indicates that a registered stack_t will be used. | ||
82 | * SA_RESTART flag to get restarting signals (which were the default long ago) | ||
83 | * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. | ||
84 | * SA_RESETHAND clears the handler when the signal is delivered. | ||
85 | * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. | ||
86 | * SA_NODEFER prevents the current signal from being masked in the handler. | ||
87 | * | ||
88 | * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single | ||
89 | * Unix names RESETHAND and NODEFER respectively. | ||
90 | */ | ||
91 | #define SA_NOCLDSTOP 0x00000001 | ||
92 | #define SA_NOCLDWAIT 0x00000002 | ||
93 | #define SA_SIGINFO 0x00000004 | ||
94 | #define SA_ONSTACK 0x08000000 | ||
95 | #define SA_RESTART 0x10000000 | ||
96 | #define SA_NODEFER 0x40000000 | ||
97 | #define SA_RESETHAND 0x80000000 | ||
98 | |||
99 | #define SA_NOMASK SA_NODEFER | ||
100 | #define SA_ONESHOT SA_RESETHAND | ||
101 | |||
102 | #define SA_RESTORER 0x04000000 | ||
103 | |||
104 | /* | ||
105 | * sigaltstack controls | ||
106 | */ | ||
107 | #define SS_ONSTACK 1 | ||
108 | #define SS_DISABLE 2 | ||
109 | |||
110 | #define MINSIGSTKSZ 2048 | ||
111 | #define SIGSTKSZ 8192 | ||
112 | |||
113 | #include <asm-generic/signal.h> | ||
114 | |||
115 | #ifndef __ASSEMBLY__ | ||
116 | |||
117 | struct sigaction { | ||
118 | __sighandler_t sa_handler; | ||
119 | unsigned long sa_flags; | ||
120 | __sigrestore_t sa_restorer; | ||
121 | sigset_t sa_mask; /* mask last for extensibility */ | ||
122 | }; | ||
123 | |||
124 | struct k_sigaction { | ||
125 | struct sigaction sa; | ||
126 | }; | ||
127 | |||
128 | typedef struct sigaltstack { | ||
129 | void __user *ss_sp; | ||
130 | int ss_flags; | ||
131 | size_t ss_size; | ||
132 | } stack_t; | ||
133 | |||
134 | #ifdef __KERNEL__ | ||
135 | #include <asm/sigcontext.h> | ||
136 | |||
137 | #undef __HAVE_ARCH_SIG_BITOPS | ||
138 | #if 0 | ||
139 | |||
140 | static inline void sigaddset(sigset_t *set, int _sig) | ||
141 | { | ||
142 | __asm__("btsq %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); | ||
143 | } | ||
144 | |||
145 | static inline void sigdelset(sigset_t *set, int _sig) | ||
146 | { | ||
147 | __asm__("btrq %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); | ||
148 | } | ||
149 | |||
150 | static inline int __const_sigismember(sigset_t *set, int _sig) | ||
151 | { | ||
152 | unsigned long sig = _sig - 1; | ||
153 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig & ~(_NSIG_BPW-1))); | ||
154 | } | ||
155 | |||
156 | static inline int __gen_sigismember(sigset_t *set, int _sig) | ||
157 | { | ||
158 | int ret; | ||
159 | __asm__("btq %2,%1\n\tsbbq %0,%0" | ||
160 | : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); | ||
161 | return ret; | ||
162 | } | ||
163 | |||
164 | #define sigismember(set,sig) \ | ||
165 | (__builtin_constant_p(sig) ? \ | ||
166 | __const_sigismember((set),(sig)) : \ | ||
167 | __gen_sigismember((set),(sig))) | ||
168 | |||
169 | static inline int sigfindinword(unsigned long word) | ||
170 | { | ||
171 | __asm__("bsfq %1,%0" : "=r"(word) : "rm"(word) : "cc"); | ||
172 | return word; | ||
173 | } | ||
174 | #endif | ||
175 | #endif | ||
176 | |||
177 | #define ptrace_signal_deliver(regs, cookie) do { } while (0) | ||
178 | |||
179 | #endif /* __KERNEL__ */ | ||
180 | |||
181 | #endif | ||
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h new file mode 100644 index 000000000000..f2e8319a6b0b --- /dev/null +++ b/include/asm-x86/smp.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "smp_32.h" | ||
3 | #else | ||
4 | # include "smp_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/smp_32.h b/include/asm-x86/smp_32.h new file mode 100644 index 000000000000..1f73bde165b1 --- /dev/null +++ b/include/asm-x86/smp_32.h | |||
@@ -0,0 +1,182 @@ | |||
1 | #ifndef __ASM_SMP_H | ||
2 | #define __ASM_SMP_H | ||
3 | |||
4 | /* | ||
5 | * We need the APIC definitions automatically as part of 'smp.h' | ||
6 | */ | ||
7 | #ifndef __ASSEMBLY__ | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/threads.h> | ||
10 | #include <linux/cpumask.h> | ||
11 | #endif | ||
12 | |||
13 | #if defined(CONFIG_X86_LOCAL_APIC) && !defined(__ASSEMBLY__) | ||
14 | #include <asm/bitops.h> | ||
15 | #include <asm/mpspec.h> | ||
16 | #include <asm/apic.h> | ||
17 | #ifdef CONFIG_X86_IO_APIC | ||
18 | #include <asm/io_apic.h> | ||
19 | #endif | ||
20 | #endif | ||
21 | |||
22 | #define BAD_APICID 0xFFu | ||
23 | #ifdef CONFIG_SMP | ||
24 | #ifndef __ASSEMBLY__ | ||
25 | |||
26 | /* | ||
27 | * Private routines/data | ||
28 | */ | ||
29 | |||
30 | extern void smp_alloc_memory(void); | ||
31 | extern int pic_mode; | ||
32 | extern int smp_num_siblings; | ||
33 | extern cpumask_t cpu_sibling_map[]; | ||
34 | extern cpumask_t cpu_core_map[]; | ||
35 | |||
36 | extern void (*mtrr_hook) (void); | ||
37 | extern void zap_low_mappings (void); | ||
38 | extern void lock_ipi_call_lock(void); | ||
39 | extern void unlock_ipi_call_lock(void); | ||
40 | |||
41 | #define MAX_APICID 256 | ||
42 | extern u8 x86_cpu_to_apicid[]; | ||
43 | |||
44 | #define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu] | ||
45 | |||
46 | extern void set_cpu_sibling_map(int cpu); | ||
47 | |||
48 | #ifdef CONFIG_HOTPLUG_CPU | ||
49 | extern void cpu_exit_clear(void); | ||
50 | extern void cpu_uninit(void); | ||
51 | extern void remove_siblinginfo(int cpu); | ||
52 | #endif | ||
53 | |||
54 | struct smp_ops | ||
55 | { | ||
56 | void (*smp_prepare_boot_cpu)(void); | ||
57 | void (*smp_prepare_cpus)(unsigned max_cpus); | ||
58 | int (*cpu_up)(unsigned cpu); | ||
59 | void (*smp_cpus_done)(unsigned max_cpus); | ||
60 | |||
61 | void (*smp_send_stop)(void); | ||
62 | void (*smp_send_reschedule)(int cpu); | ||
63 | int (*smp_call_function_mask)(cpumask_t mask, | ||
64 | void (*func)(void *info), void *info, | ||
65 | int wait); | ||
66 | }; | ||
67 | |||
68 | extern struct smp_ops smp_ops; | ||
69 | |||
70 | static inline void smp_prepare_boot_cpu(void) | ||
71 | { | ||
72 | smp_ops.smp_prepare_boot_cpu(); | ||
73 | } | ||
74 | static inline void smp_prepare_cpus(unsigned int max_cpus) | ||
75 | { | ||
76 | smp_ops.smp_prepare_cpus(max_cpus); | ||
77 | } | ||
78 | static inline int __cpu_up(unsigned int cpu) | ||
79 | { | ||
80 | return smp_ops.cpu_up(cpu); | ||
81 | } | ||
82 | static inline void smp_cpus_done(unsigned int max_cpus) | ||
83 | { | ||
84 | smp_ops.smp_cpus_done(max_cpus); | ||
85 | } | ||
86 | |||
87 | static inline void smp_send_stop(void) | ||
88 | { | ||
89 | smp_ops.smp_send_stop(); | ||
90 | } | ||
91 | static inline void smp_send_reschedule(int cpu) | ||
92 | { | ||
93 | smp_ops.smp_send_reschedule(cpu); | ||
94 | } | ||
95 | static inline int smp_call_function_mask(cpumask_t mask, | ||
96 | void (*func) (void *info), void *info, | ||
97 | int wait) | ||
98 | { | ||
99 | return smp_ops.smp_call_function_mask(mask, func, info, wait); | ||
100 | } | ||
101 | |||
102 | void native_smp_prepare_boot_cpu(void); | ||
103 | void native_smp_prepare_cpus(unsigned int max_cpus); | ||
104 | int native_cpu_up(unsigned int cpunum); | ||
105 | void native_smp_cpus_done(unsigned int max_cpus); | ||
106 | |||
107 | #ifndef CONFIG_PARAVIRT | ||
108 | #define startup_ipi_hook(phys_apicid, start_eip, start_esp) \ | ||
109 | do { } while (0) | ||
110 | #endif | ||
111 | |||
112 | /* | ||
113 | * This function is needed by all SMP systems. It must _always_ be valid | ||
114 | * from the initial startup. We map APIC_BASE very early in page_setup(), | ||
115 | * so this is correct in the x86 case. | ||
116 | */ | ||
117 | DECLARE_PER_CPU(int, cpu_number); | ||
118 | #define raw_smp_processor_id() (x86_read_percpu(cpu_number)) | ||
119 | |||
120 | extern cpumask_t cpu_callout_map; | ||
121 | extern cpumask_t cpu_callin_map; | ||
122 | extern cpumask_t cpu_possible_map; | ||
123 | |||
124 | /* We don't mark CPUs online until __cpu_up(), so we need another measure */ | ||
125 | static inline int num_booting_cpus(void) | ||
126 | { | ||
127 | return cpus_weight(cpu_callout_map); | ||
128 | } | ||
129 | |||
130 | extern int safe_smp_processor_id(void); | ||
131 | extern int __cpu_disable(void); | ||
132 | extern void __cpu_die(unsigned int cpu); | ||
133 | extern unsigned int num_processors; | ||
134 | |||
135 | void __cpuinit smp_store_cpu_info(int id); | ||
136 | |||
137 | #endif /* !__ASSEMBLY__ */ | ||
138 | |||
139 | #else /* CONFIG_SMP */ | ||
140 | |||
141 | #define safe_smp_processor_id() 0 | ||
142 | #define cpu_physical_id(cpu) boot_cpu_physical_apicid | ||
143 | |||
144 | #define NO_PROC_ID 0xFF /* No processor magic marker */ | ||
145 | |||
146 | #endif /* CONFIG_SMP */ | ||
147 | |||
148 | #ifndef __ASSEMBLY__ | ||
149 | |||
150 | #ifdef CONFIG_X86_LOCAL_APIC | ||
151 | |||
152 | #ifdef APIC_DEFINITION | ||
153 | extern int hard_smp_processor_id(void); | ||
154 | #else | ||
155 | #include <mach_apicdef.h> | ||
156 | static inline int hard_smp_processor_id(void) | ||
157 | { | ||
158 | /* we don't want to mark this access volatile - bad code generation */ | ||
159 | return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID)); | ||
160 | } | ||
161 | #endif /* APIC_DEFINITION */ | ||
162 | |||
163 | #else /* CONFIG_X86_LOCAL_APIC */ | ||
164 | |||
165 | #ifndef CONFIG_SMP | ||
166 | #define hard_smp_processor_id() 0 | ||
167 | #endif | ||
168 | |||
169 | #endif /* CONFIG_X86_LOCAL_APIC */ | ||
170 | |||
171 | extern u8 apicid_2_node[]; | ||
172 | |||
173 | #ifdef CONFIG_X86_LOCAL_APIC | ||
174 | static __inline int logical_smp_processor_id(void) | ||
175 | { | ||
176 | /* we don't want to mark this access volatile - bad code generation */ | ||
177 | return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR)); | ||
178 | } | ||
179 | #endif | ||
180 | #endif | ||
181 | |||
182 | #endif | ||
diff --git a/include/asm-x86/smp_64.h b/include/asm-x86/smp_64.h new file mode 100644 index 000000000000..3f303d2365ed --- /dev/null +++ b/include/asm-x86/smp_64.h | |||
@@ -0,0 +1,117 @@ | |||
1 | #ifndef __ASM_SMP_H | ||
2 | #define __ASM_SMP_H | ||
3 | |||
4 | /* | ||
5 | * We need the APIC definitions automatically as part of 'smp.h' | ||
6 | */ | ||
7 | #include <linux/threads.h> | ||
8 | #include <linux/cpumask.h> | ||
9 | #include <linux/bitops.h> | ||
10 | #include <linux/init.h> | ||
11 | extern int disable_apic; | ||
12 | |||
13 | #include <asm/mpspec.h> | ||
14 | #include <asm/apic.h> | ||
15 | #include <asm/io_apic.h> | ||
16 | #include <asm/thread_info.h> | ||
17 | |||
18 | #ifdef CONFIG_SMP | ||
19 | |||
20 | #include <asm/pda.h> | ||
21 | |||
22 | struct pt_regs; | ||
23 | |||
24 | extern cpumask_t cpu_present_mask; | ||
25 | extern cpumask_t cpu_possible_map; | ||
26 | extern cpumask_t cpu_online_map; | ||
27 | extern cpumask_t cpu_callout_map; | ||
28 | extern cpumask_t cpu_initialized; | ||
29 | |||
30 | /* | ||
31 | * Private routines/data | ||
32 | */ | ||
33 | |||
34 | extern void smp_alloc_memory(void); | ||
35 | extern volatile unsigned long smp_invalidate_needed; | ||
36 | extern void lock_ipi_call_lock(void); | ||
37 | extern void unlock_ipi_call_lock(void); | ||
38 | extern int smp_num_siblings; | ||
39 | extern void smp_send_reschedule(int cpu); | ||
40 | |||
41 | extern cpumask_t cpu_sibling_map[NR_CPUS]; | ||
42 | extern cpumask_t cpu_core_map[NR_CPUS]; | ||
43 | extern u8 cpu_llc_id[NR_CPUS]; | ||
44 | |||
45 | #define SMP_TRAMPOLINE_BASE 0x6000 | ||
46 | |||
47 | /* | ||
48 | * On x86 all CPUs are mapped 1:1 to the APIC space. | ||
49 | * This simplifies scheduling and IPI sending and | ||
50 | * compresses data structures. | ||
51 | */ | ||
52 | |||
53 | static inline int num_booting_cpus(void) | ||
54 | { | ||
55 | return cpus_weight(cpu_callout_map); | ||
56 | } | ||
57 | |||
58 | #define raw_smp_processor_id() read_pda(cpunumber) | ||
59 | |||
60 | extern int __cpu_disable(void); | ||
61 | extern void __cpu_die(unsigned int cpu); | ||
62 | extern void prefill_possible_map(void); | ||
63 | extern unsigned num_processors; | ||
64 | extern unsigned __cpuinitdata disabled_cpus; | ||
65 | |||
66 | #define NO_PROC_ID 0xFF /* No processor magic marker */ | ||
67 | |||
68 | #endif /* CONFIG_SMP */ | ||
69 | |||
70 | static inline int hard_smp_processor_id(void) | ||
71 | { | ||
72 | /* we don't want to mark this access volatile - bad code generation */ | ||
73 | return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID)); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * Some lowlevel functions might want to know about | ||
78 | * the real APIC ID <-> CPU # mapping. | ||
79 | */ | ||
80 | extern u8 x86_cpu_to_apicid[NR_CPUS]; /* physical ID */ | ||
81 | extern u8 x86_cpu_to_log_apicid[NR_CPUS]; | ||
82 | extern u8 bios_cpu_apicid[]; | ||
83 | |||
84 | static inline int cpu_present_to_apicid(int mps_cpu) | ||
85 | { | ||
86 | if (mps_cpu < NR_CPUS) | ||
87 | return (int)bios_cpu_apicid[mps_cpu]; | ||
88 | else | ||
89 | return BAD_APICID; | ||
90 | } | ||
91 | |||
92 | #ifndef CONFIG_SMP | ||
93 | #define stack_smp_processor_id() 0 | ||
94 | #define cpu_logical_map(x) (x) | ||
95 | #else | ||
96 | #include <asm/thread_info.h> | ||
97 | #define stack_smp_processor_id() \ | ||
98 | ({ \ | ||
99 | struct thread_info *ti; \ | ||
100 | __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ | ||
101 | ti->cpu; \ | ||
102 | }) | ||
103 | #endif | ||
104 | |||
105 | static __inline int logical_smp_processor_id(void) | ||
106 | { | ||
107 | /* we don't want to mark this access volatile - bad code generation */ | ||
108 | return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR)); | ||
109 | } | ||
110 | |||
111 | #ifdef CONFIG_SMP | ||
112 | #define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu] | ||
113 | #else | ||
114 | #define cpu_physical_id(cpu) boot_cpu_id | ||
115 | #endif /* !CONFIG_SMP */ | ||
116 | #endif | ||
117 | |||
diff --git a/include/asm-x86/socket.h b/include/asm-x86/socket.h new file mode 100644 index 000000000000..99ca648b94c5 --- /dev/null +++ b/include/asm-x86/socket.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef _ASM_SOCKET_H | ||
2 | #define _ASM_SOCKET_H | ||
3 | |||
4 | #include <asm/sockios.h> | ||
5 | |||
6 | /* For setsockopt(2) */ | ||
7 | #define SOL_SOCKET 1 | ||
8 | |||
9 | #define SO_DEBUG 1 | ||
10 | #define SO_REUSEADDR 2 | ||
11 | #define SO_TYPE 3 | ||
12 | #define SO_ERROR 4 | ||
13 | #define SO_DONTROUTE 5 | ||
14 | #define SO_BROADCAST 6 | ||
15 | #define SO_SNDBUF 7 | ||
16 | #define SO_RCVBUF 8 | ||
17 | #define SO_SNDBUFFORCE 32 | ||
18 | #define SO_RCVBUFFORCE 33 | ||
19 | #define SO_KEEPALIVE 9 | ||
20 | #define SO_OOBINLINE 10 | ||
21 | #define SO_NO_CHECK 11 | ||
22 | #define SO_PRIORITY 12 | ||
23 | #define SO_LINGER 13 | ||
24 | #define SO_BSDCOMPAT 14 | ||
25 | /* To add :#define SO_REUSEPORT 15 */ | ||
26 | #define SO_PASSCRED 16 | ||
27 | #define SO_PEERCRED 17 | ||
28 | #define SO_RCVLOWAT 18 | ||
29 | #define SO_SNDLOWAT 19 | ||
30 | #define SO_RCVTIMEO 20 | ||
31 | #define SO_SNDTIMEO 21 | ||
32 | |||
33 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | ||
34 | #define SO_SECURITY_AUTHENTICATION 22 | ||
35 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 | ||
36 | #define SO_SECURITY_ENCRYPTION_NETWORK 24 | ||
37 | |||
38 | #define SO_BINDTODEVICE 25 | ||
39 | |||
40 | /* Socket filtering */ | ||
41 | #define SO_ATTACH_FILTER 26 | ||
42 | #define SO_DETACH_FILTER 27 | ||
43 | |||
44 | #define SO_PEERNAME 28 | ||
45 | #define SO_TIMESTAMP 29 | ||
46 | #define SCM_TIMESTAMP SO_TIMESTAMP | ||
47 | |||
48 | #define SO_ACCEPTCONN 30 | ||
49 | |||
50 | #define SO_PEERSEC 31 | ||
51 | #define SO_PASSSEC 34 | ||
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
54 | |||
55 | #endif /* _ASM_SOCKET_H */ | ||
diff --git a/include/asm-x86/sockios.h b/include/asm-x86/sockios.h new file mode 100644 index 000000000000..5a134fc70b9c --- /dev/null +++ b/include/asm-x86/sockios.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "sockios_32.h" | ||
4 | # else | ||
5 | # include "sockios_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "sockios_32.h" | ||
10 | # else | ||
11 | # include "sockios_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/sockios_32.h b/include/asm-x86/sockios_32.h new file mode 100644 index 000000000000..ff528c7d255c --- /dev/null +++ b/include/asm-x86/sockios_32.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ARCH_I386_SOCKIOS__ | ||
2 | #define __ARCH_I386_SOCKIOS__ | ||
3 | |||
4 | /* Socket-level I/O control calls. */ | ||
5 | #define FIOSETOWN 0x8901 | ||
6 | #define SIOCSPGRP 0x8902 | ||
7 | #define FIOGETOWN 0x8903 | ||
8 | #define SIOCGPGRP 0x8904 | ||
9 | #define SIOCATMARK 0x8905 | ||
10 | #define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ | ||
11 | #define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/sockios_64.h b/include/asm-x86/sockios_64.h new file mode 100644 index 000000000000..d726ba2513e3 --- /dev/null +++ b/include/asm-x86/sockios_64.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ARCH_X8664_SOCKIOS__ | ||
2 | #define __ARCH_X8664_SOCKIOS__ | ||
3 | |||
4 | /* Socket-level I/O control calls. */ | ||
5 | #define FIOSETOWN 0x8901 | ||
6 | #define SIOCSPGRP 0x8902 | ||
7 | #define FIOGETOWN 0x8903 | ||
8 | #define SIOCGPGRP 0x8904 | ||
9 | #define SIOCATMARK 0x8905 | ||
10 | #define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ | ||
11 | #define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/sparsemem.h b/include/asm-x86/sparsemem.h new file mode 100644 index 000000000000..3f203b1d9ee8 --- /dev/null +++ b/include/asm-x86/sparsemem.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "sparsemem_32.h" | ||
3 | #else | ||
4 | # include "sparsemem_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/sparsemem_32.h b/include/asm-x86/sparsemem_32.h new file mode 100644 index 000000000000..cfeed990585f --- /dev/null +++ b/include/asm-x86/sparsemem_32.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _I386_SPARSEMEM_H | ||
2 | #define _I386_SPARSEMEM_H | ||
3 | #ifdef CONFIG_SPARSEMEM | ||
4 | |||
5 | /* | ||
6 | * generic non-linear memory support: | ||
7 | * | ||
8 | * 1) we will not split memory into more chunks than will fit into the | ||
9 | * flags field of the struct page | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * SECTION_SIZE_BITS 2^N: how big each section will be | ||
14 | * MAX_PHYSADDR_BITS 2^N: how much physical address space we have | ||
15 | * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space | ||
16 | */ | ||
17 | #ifdef CONFIG_X86_PAE | ||
18 | #define SECTION_SIZE_BITS 30 | ||
19 | #define MAX_PHYSADDR_BITS 36 | ||
20 | #define MAX_PHYSMEM_BITS 36 | ||
21 | #else | ||
22 | #define SECTION_SIZE_BITS 26 | ||
23 | #define MAX_PHYSADDR_BITS 32 | ||
24 | #define MAX_PHYSMEM_BITS 32 | ||
25 | #endif | ||
26 | |||
27 | /* XXX: FIXME -- wli */ | ||
28 | #define kern_addr_valid(kaddr) (0) | ||
29 | |||
30 | #endif /* CONFIG_SPARSEMEM */ | ||
31 | #endif /* _I386_SPARSEMEM_H */ | ||
diff --git a/include/asm-x86/sparsemem_64.h b/include/asm-x86/sparsemem_64.h new file mode 100644 index 000000000000..dabb16714a71 --- /dev/null +++ b/include/asm-x86/sparsemem_64.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef _ASM_X86_64_SPARSEMEM_H | ||
2 | #define _ASM_X86_64_SPARSEMEM_H 1 | ||
3 | |||
4 | #ifdef CONFIG_SPARSEMEM | ||
5 | |||
6 | /* | ||
7 | * generic non-linear memory support: | ||
8 | * | ||
9 | * 1) we will not split memory into more chunks than will fit into the flags | ||
10 | * field of the struct page | ||
11 | * | ||
12 | * SECTION_SIZE_BITS 2^n: size of each section | ||
13 | * MAX_PHYSADDR_BITS 2^n: max size of physical address space | ||
14 | * MAX_PHYSMEM_BITS 2^n: how much memory we can have in that space | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */ | ||
19 | #define MAX_PHYSADDR_BITS 40 | ||
20 | #define MAX_PHYSMEM_BITS 40 | ||
21 | |||
22 | extern int early_pfn_to_nid(unsigned long pfn); | ||
23 | |||
24 | #endif /* CONFIG_SPARSEMEM */ | ||
25 | |||
26 | #endif /* _ASM_X86_64_SPARSEMEM_H */ | ||
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h new file mode 100644 index 000000000000..d74d85e71dcb --- /dev/null +++ b/include/asm-x86/spinlock.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "spinlock_32.h" | ||
3 | #else | ||
4 | # include "spinlock_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/spinlock_32.h b/include/asm-x86/spinlock_32.h new file mode 100644 index 000000000000..d3bcebed60ca --- /dev/null +++ b/include/asm-x86/spinlock_32.h | |||
@@ -0,0 +1,221 @@ | |||
1 | #ifndef __ASM_SPINLOCK_H | ||
2 | #define __ASM_SPINLOCK_H | ||
3 | |||
4 | #include <asm/atomic.h> | ||
5 | #include <asm/rwlock.h> | ||
6 | #include <asm/page.h> | ||
7 | #include <asm/processor.h> | ||
8 | #include <linux/compiler.h> | ||
9 | |||
10 | #ifdef CONFIG_PARAVIRT | ||
11 | #include <asm/paravirt.h> | ||
12 | #else | ||
13 | #define CLI_STRING "cli" | ||
14 | #define STI_STRING "sti" | ||
15 | #define CLI_STI_CLOBBERS | ||
16 | #define CLI_STI_INPUT_ARGS | ||
17 | #endif /* CONFIG_PARAVIRT */ | ||
18 | |||
19 | /* | ||
20 | * Your basic SMP spinlocks, allowing only a single CPU anywhere | ||
21 | * | ||
22 | * Simple spin lock operations. There are two variants, one clears IRQ's | ||
23 | * on the local processor, one does not. | ||
24 | * | ||
25 | * We make no fairness assumptions. They have a cost. | ||
26 | * | ||
27 | * (the type definitions are in asm/spinlock_types.h) | ||
28 | */ | ||
29 | |||
30 | static inline int __raw_spin_is_locked(raw_spinlock_t *x) | ||
31 | { | ||
32 | return *(volatile signed char *)(&(x)->slock) <= 0; | ||
33 | } | ||
34 | |||
35 | static inline void __raw_spin_lock(raw_spinlock_t *lock) | ||
36 | { | ||
37 | asm volatile("\n1:\t" | ||
38 | LOCK_PREFIX " ; decb %0\n\t" | ||
39 | "jns 3f\n" | ||
40 | "2:\t" | ||
41 | "rep;nop\n\t" | ||
42 | "cmpb $0,%0\n\t" | ||
43 | "jle 2b\n\t" | ||
44 | "jmp 1b\n" | ||
45 | "3:\n\t" | ||
46 | : "+m" (lock->slock) : : "memory"); | ||
47 | } | ||
48 | |||
49 | /* | ||
50 | * It is easier for the lock validator if interrupts are not re-enabled | ||
51 | * in the middle of a lock-acquire. This is a performance feature anyway | ||
52 | * so we turn it off: | ||
53 | * | ||
54 | * NOTE: there's an irqs-on section here, which normally would have to be | ||
55 | * irq-traced, but on CONFIG_TRACE_IRQFLAGS we never use this variant. | ||
56 | */ | ||
57 | #ifndef CONFIG_PROVE_LOCKING | ||
58 | static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) | ||
59 | { | ||
60 | asm volatile( | ||
61 | "\n1:\t" | ||
62 | LOCK_PREFIX " ; decb %[slock]\n\t" | ||
63 | "jns 5f\n" | ||
64 | "2:\t" | ||
65 | "testl $0x200, %[flags]\n\t" | ||
66 | "jz 4f\n\t" | ||
67 | STI_STRING "\n" | ||
68 | "3:\t" | ||
69 | "rep;nop\n\t" | ||
70 | "cmpb $0, %[slock]\n\t" | ||
71 | "jle 3b\n\t" | ||
72 | CLI_STRING "\n\t" | ||
73 | "jmp 1b\n" | ||
74 | "4:\t" | ||
75 | "rep;nop\n\t" | ||
76 | "cmpb $0, %[slock]\n\t" | ||
77 | "jg 1b\n\t" | ||
78 | "jmp 4b\n" | ||
79 | "5:\n\t" | ||
80 | : [slock] "+m" (lock->slock) | ||
81 | : [flags] "r" (flags) | ||
82 | CLI_STI_INPUT_ARGS | ||
83 | : "memory" CLI_STI_CLOBBERS); | ||
84 | } | ||
85 | #endif | ||
86 | |||
87 | static inline int __raw_spin_trylock(raw_spinlock_t *lock) | ||
88 | { | ||
89 | char oldval; | ||
90 | asm volatile( | ||
91 | "xchgb %b0,%1" | ||
92 | :"=q" (oldval), "+m" (lock->slock) | ||
93 | :"0" (0) : "memory"); | ||
94 | return oldval > 0; | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * __raw_spin_unlock based on writing $1 to the low byte. | ||
99 | * This method works. Despite all the confusion. | ||
100 | * (except on PPro SMP or if we are using OOSTORE, so we use xchgb there) | ||
101 | * (PPro errata 66, 92) | ||
102 | */ | ||
103 | |||
104 | #if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE) | ||
105 | |||
106 | static inline void __raw_spin_unlock(raw_spinlock_t *lock) | ||
107 | { | ||
108 | asm volatile("movb $1,%0" : "+m" (lock->slock) :: "memory"); | ||
109 | } | ||
110 | |||
111 | #else | ||
112 | |||
113 | static inline void __raw_spin_unlock(raw_spinlock_t *lock) | ||
114 | { | ||
115 | char oldval = 1; | ||
116 | |||
117 | asm volatile("xchgb %b0, %1" | ||
118 | : "=q" (oldval), "+m" (lock->slock) | ||
119 | : "0" (oldval) : "memory"); | ||
120 | } | ||
121 | |||
122 | #endif | ||
123 | |||
124 | static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock) | ||
125 | { | ||
126 | while (__raw_spin_is_locked(lock)) | ||
127 | cpu_relax(); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Read-write spinlocks, allowing multiple readers | ||
132 | * but only one writer. | ||
133 | * | ||
134 | * NOTE! it is quite common to have readers in interrupts | ||
135 | * but no interrupt writers. For those circumstances we | ||
136 | * can "mix" irq-safe locks - any writer needs to get a | ||
137 | * irq-safe write-lock, but readers can get non-irqsafe | ||
138 | * read-locks. | ||
139 | * | ||
140 | * On x86, we implement read-write locks as a 32-bit counter | ||
141 | * with the high bit (sign) being the "contended" bit. | ||
142 | * | ||
143 | * The inline assembly is non-obvious. Think about it. | ||
144 | * | ||
145 | * Changed to use the same technique as rw semaphores. See | ||
146 | * semaphore.h for details. -ben | ||
147 | * | ||
148 | * the helpers are in arch/i386/kernel/semaphore.c | ||
149 | */ | ||
150 | |||
151 | /** | ||
152 | * read_can_lock - would read_trylock() succeed? | ||
153 | * @lock: the rwlock in question. | ||
154 | */ | ||
155 | static inline int __raw_read_can_lock(raw_rwlock_t *x) | ||
156 | { | ||
157 | return (int)(x)->lock > 0; | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * write_can_lock - would write_trylock() succeed? | ||
162 | * @lock: the rwlock in question. | ||
163 | */ | ||
164 | static inline int __raw_write_can_lock(raw_rwlock_t *x) | ||
165 | { | ||
166 | return (x)->lock == RW_LOCK_BIAS; | ||
167 | } | ||
168 | |||
169 | static inline void __raw_read_lock(raw_rwlock_t *rw) | ||
170 | { | ||
171 | asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t" | ||
172 | "jns 1f\n" | ||
173 | "call __read_lock_failed\n\t" | ||
174 | "1:\n" | ||
175 | ::"a" (rw) : "memory"); | ||
176 | } | ||
177 | |||
178 | static inline void __raw_write_lock(raw_rwlock_t *rw) | ||
179 | { | ||
180 | asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" | ||
181 | "jz 1f\n" | ||
182 | "call __write_lock_failed\n\t" | ||
183 | "1:\n" | ||
184 | ::"a" (rw) : "memory"); | ||
185 | } | ||
186 | |||
187 | static inline int __raw_read_trylock(raw_rwlock_t *lock) | ||
188 | { | ||
189 | atomic_t *count = (atomic_t *)lock; | ||
190 | atomic_dec(count); | ||
191 | if (atomic_read(count) >= 0) | ||
192 | return 1; | ||
193 | atomic_inc(count); | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static inline int __raw_write_trylock(raw_rwlock_t *lock) | ||
198 | { | ||
199 | atomic_t *count = (atomic_t *)lock; | ||
200 | if (atomic_sub_and_test(RW_LOCK_BIAS, count)) | ||
201 | return 1; | ||
202 | atomic_add(RW_LOCK_BIAS, count); | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static inline void __raw_read_unlock(raw_rwlock_t *rw) | ||
207 | { | ||
208 | asm volatile(LOCK_PREFIX "incl %0" :"+m" (rw->lock) : : "memory"); | ||
209 | } | ||
210 | |||
211 | static inline void __raw_write_unlock(raw_rwlock_t *rw) | ||
212 | { | ||
213 | asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0" | ||
214 | : "+m" (rw->lock) : : "memory"); | ||
215 | } | ||
216 | |||
217 | #define _raw_spin_relax(lock) cpu_relax() | ||
218 | #define _raw_read_relax(lock) cpu_relax() | ||
219 | #define _raw_write_relax(lock) cpu_relax() | ||
220 | |||
221 | #endif /* __ASM_SPINLOCK_H */ | ||
diff --git a/include/asm-x86/spinlock_64.h b/include/asm-x86/spinlock_64.h new file mode 100644 index 000000000000..88bf981e73cf --- /dev/null +++ b/include/asm-x86/spinlock_64.h | |||
@@ -0,0 +1,167 @@ | |||
1 | #ifndef __ASM_SPINLOCK_H | ||
2 | #define __ASM_SPINLOCK_H | ||
3 | |||
4 | #include <asm/atomic.h> | ||
5 | #include <asm/rwlock.h> | ||
6 | #include <asm/page.h> | ||
7 | #include <asm/processor.h> | ||
8 | |||
9 | /* | ||
10 | * Your basic SMP spinlocks, allowing only a single CPU anywhere | ||
11 | * | ||
12 | * Simple spin lock operations. There are two variants, one clears IRQ's | ||
13 | * on the local processor, one does not. | ||
14 | * | ||
15 | * We make no fairness assumptions. They have a cost. | ||
16 | * | ||
17 | * (the type definitions are in asm/spinlock_types.h) | ||
18 | */ | ||
19 | |||
20 | static inline int __raw_spin_is_locked(raw_spinlock_t *lock) | ||
21 | { | ||
22 | return *(volatile signed int *)(&(lock)->slock) <= 0; | ||
23 | } | ||
24 | |||
25 | static inline void __raw_spin_lock(raw_spinlock_t *lock) | ||
26 | { | ||
27 | asm volatile( | ||
28 | "\n1:\t" | ||
29 | LOCK_PREFIX " ; decl %0\n\t" | ||
30 | "jns 2f\n" | ||
31 | "3:\n" | ||
32 | "rep;nop\n\t" | ||
33 | "cmpl $0,%0\n\t" | ||
34 | "jle 3b\n\t" | ||
35 | "jmp 1b\n" | ||
36 | "2:\t" : "=m" (lock->slock) : : "memory"); | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Same as __raw_spin_lock, but reenable interrupts during spinning. | ||
41 | */ | ||
42 | #ifndef CONFIG_PROVE_LOCKING | ||
43 | static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) | ||
44 | { | ||
45 | asm volatile( | ||
46 | "\n1:\t" | ||
47 | LOCK_PREFIX " ; decl %0\n\t" | ||
48 | "jns 5f\n" | ||
49 | "testl $0x200, %1\n\t" /* interrupts were disabled? */ | ||
50 | "jz 4f\n\t" | ||
51 | "sti\n" | ||
52 | "3:\t" | ||
53 | "rep;nop\n\t" | ||
54 | "cmpl $0, %0\n\t" | ||
55 | "jle 3b\n\t" | ||
56 | "cli\n\t" | ||
57 | "jmp 1b\n" | ||
58 | "4:\t" | ||
59 | "rep;nop\n\t" | ||
60 | "cmpl $0, %0\n\t" | ||
61 | "jg 1b\n\t" | ||
62 | "jmp 4b\n" | ||
63 | "5:\n\t" | ||
64 | : "+m" (lock->slock) : "r" ((unsigned)flags) : "memory"); | ||
65 | } | ||
66 | #endif | ||
67 | |||
68 | static inline int __raw_spin_trylock(raw_spinlock_t *lock) | ||
69 | { | ||
70 | int oldval; | ||
71 | |||
72 | asm volatile( | ||
73 | "xchgl %0,%1" | ||
74 | :"=q" (oldval), "=m" (lock->slock) | ||
75 | :"0" (0) : "memory"); | ||
76 | |||
77 | return oldval > 0; | ||
78 | } | ||
79 | |||
80 | static inline void __raw_spin_unlock(raw_spinlock_t *lock) | ||
81 | { | ||
82 | asm volatile("movl $1,%0" :"=m" (lock->slock) :: "memory"); | ||
83 | } | ||
84 | |||
85 | static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock) | ||
86 | { | ||
87 | while (__raw_spin_is_locked(lock)) | ||
88 | cpu_relax(); | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * Read-write spinlocks, allowing multiple readers | ||
93 | * but only one writer. | ||
94 | * | ||
95 | * NOTE! it is quite common to have readers in interrupts | ||
96 | * but no interrupt writers. For those circumstances we | ||
97 | * can "mix" irq-safe locks - any writer needs to get a | ||
98 | * irq-safe write-lock, but readers can get non-irqsafe | ||
99 | * read-locks. | ||
100 | * | ||
101 | * On x86, we implement read-write locks as a 32-bit counter | ||
102 | * with the high bit (sign) being the "contended" bit. | ||
103 | */ | ||
104 | |||
105 | static inline int __raw_read_can_lock(raw_rwlock_t *lock) | ||
106 | { | ||
107 | return (int)(lock)->lock > 0; | ||
108 | } | ||
109 | |||
110 | static inline int __raw_write_can_lock(raw_rwlock_t *lock) | ||
111 | { | ||
112 | return (lock)->lock == RW_LOCK_BIAS; | ||
113 | } | ||
114 | |||
115 | static inline void __raw_read_lock(raw_rwlock_t *rw) | ||
116 | { | ||
117 | asm volatile(LOCK_PREFIX "subl $1,(%0)\n\t" | ||
118 | "jns 1f\n" | ||
119 | "call __read_lock_failed\n" | ||
120 | "1:\n" | ||
121 | ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory"); | ||
122 | } | ||
123 | |||
124 | static inline void __raw_write_lock(raw_rwlock_t *rw) | ||
125 | { | ||
126 | asm volatile(LOCK_PREFIX "subl %1,(%0)\n\t" | ||
127 | "jz 1f\n" | ||
128 | "\tcall __write_lock_failed\n\t" | ||
129 | "1:\n" | ||
130 | ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory"); | ||
131 | } | ||
132 | |||
133 | static inline int __raw_read_trylock(raw_rwlock_t *lock) | ||
134 | { | ||
135 | atomic_t *count = (atomic_t *)lock; | ||
136 | atomic_dec(count); | ||
137 | if (atomic_read(count) >= 0) | ||
138 | return 1; | ||
139 | atomic_inc(count); | ||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static inline int __raw_write_trylock(raw_rwlock_t *lock) | ||
144 | { | ||
145 | atomic_t *count = (atomic_t *)lock; | ||
146 | if (atomic_sub_and_test(RW_LOCK_BIAS, count)) | ||
147 | return 1; | ||
148 | atomic_add(RW_LOCK_BIAS, count); | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static inline void __raw_read_unlock(raw_rwlock_t *rw) | ||
153 | { | ||
154 | asm volatile(LOCK_PREFIX " ; incl %0" :"=m" (rw->lock) : : "memory"); | ||
155 | } | ||
156 | |||
157 | static inline void __raw_write_unlock(raw_rwlock_t *rw) | ||
158 | { | ||
159 | asm volatile(LOCK_PREFIX " ; addl $" RW_LOCK_BIAS_STR ",%0" | ||
160 | : "=m" (rw->lock) : : "memory"); | ||
161 | } | ||
162 | |||
163 | #define _raw_spin_relax(lock) cpu_relax() | ||
164 | #define _raw_read_relax(lock) cpu_relax() | ||
165 | #define _raw_write_relax(lock) cpu_relax() | ||
166 | |||
167 | #endif /* __ASM_SPINLOCK_H */ | ||
diff --git a/include/asm-x86/spinlock_types.h b/include/asm-x86/spinlock_types.h new file mode 100644 index 000000000000..4da9345c1500 --- /dev/null +++ b/include/asm-x86/spinlock_types.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef __ASM_SPINLOCK_TYPES_H | ||
2 | #define __ASM_SPINLOCK_TYPES_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | typedef struct { | ||
9 | unsigned int slock; | ||
10 | } raw_spinlock_t; | ||
11 | |||
12 | #define __RAW_SPIN_LOCK_UNLOCKED { 1 } | ||
13 | |||
14 | typedef struct { | ||
15 | unsigned int lock; | ||
16 | } raw_rwlock_t; | ||
17 | |||
18 | #define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-x86/srat.h b/include/asm-x86/srat.h new file mode 100644 index 000000000000..165ab4bdc02b --- /dev/null +++ b/include/asm-x86/srat.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Some of the code in this file has been gleaned from the 64 bit | ||
3 | * discontigmem support code base. | ||
4 | * | ||
5 | * Copyright (C) 2002, IBM Corp. | ||
6 | * | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to Pat Gaughen <gone@us.ibm.com> | ||
25 | */ | ||
26 | |||
27 | #ifndef _ASM_SRAT_H_ | ||
28 | #define _ASM_SRAT_H_ | ||
29 | |||
30 | #ifndef CONFIG_ACPI_SRAT | ||
31 | #error CONFIG_ACPI_SRAT not defined, and srat.h header has been included | ||
32 | #endif | ||
33 | |||
34 | extern int get_memcfg_from_srat(void); | ||
35 | extern unsigned long *get_zholes_size(int); | ||
36 | |||
37 | #endif /* _ASM_SRAT_H_ */ | ||
diff --git a/include/asm-x86/stacktrace.h b/include/asm-x86/stacktrace.h new file mode 100644 index 000000000000..6f0b54594307 --- /dev/null +++ b/include/asm-x86/stacktrace.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_STACKTRACE_H | ||
2 | #define _ASM_STACKTRACE_H 1 | ||
3 | |||
4 | extern int kstack_depth_to_print; | ||
5 | |||
6 | /* Generic stack tracer with callbacks */ | ||
7 | |||
8 | struct stacktrace_ops { | ||
9 | void (*warning)(void *data, char *msg); | ||
10 | /* msg must contain %s for the symbol */ | ||
11 | void (*warning_symbol)(void *data, char *msg, unsigned long symbol); | ||
12 | void (*address)(void *data, unsigned long address); | ||
13 | /* On negative return stop dumping */ | ||
14 | int (*stack)(void *data, char *name); | ||
15 | }; | ||
16 | |||
17 | void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack, | ||
18 | struct stacktrace_ops *ops, void *data); | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-x86/stat.h b/include/asm-x86/stat.h new file mode 100644 index 000000000000..3ff6b50ef833 --- /dev/null +++ b/include/asm-x86/stat.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "stat_32.h" | ||
4 | # else | ||
5 | # include "stat_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "stat_32.h" | ||
10 | # else | ||
11 | # include "stat_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/stat_32.h b/include/asm-x86/stat_32.h new file mode 100644 index 000000000000..67eae78323ba --- /dev/null +++ b/include/asm-x86/stat_32.h | |||
@@ -0,0 +1,77 @@ | |||
1 | #ifndef _I386_STAT_H | ||
2 | #define _I386_STAT_H | ||
3 | |||
4 | struct __old_kernel_stat { | ||
5 | unsigned short st_dev; | ||
6 | unsigned short st_ino; | ||
7 | unsigned short st_mode; | ||
8 | unsigned short st_nlink; | ||
9 | unsigned short st_uid; | ||
10 | unsigned short st_gid; | ||
11 | unsigned short st_rdev; | ||
12 | unsigned long st_size; | ||
13 | unsigned long st_atime; | ||
14 | unsigned long st_mtime; | ||
15 | unsigned long st_ctime; | ||
16 | }; | ||
17 | |||
18 | struct stat { | ||
19 | unsigned long st_dev; | ||
20 | unsigned long st_ino; | ||
21 | unsigned short st_mode; | ||
22 | unsigned short st_nlink; | ||
23 | unsigned short st_uid; | ||
24 | unsigned short st_gid; | ||
25 | unsigned long st_rdev; | ||
26 | unsigned long st_size; | ||
27 | unsigned long st_blksize; | ||
28 | unsigned long st_blocks; | ||
29 | unsigned long st_atime; | ||
30 | unsigned long st_atime_nsec; | ||
31 | unsigned long st_mtime; | ||
32 | unsigned long st_mtime_nsec; | ||
33 | unsigned long st_ctime; | ||
34 | unsigned long st_ctime_nsec; | ||
35 | unsigned long __unused4; | ||
36 | unsigned long __unused5; | ||
37 | }; | ||
38 | |||
39 | /* This matches struct stat64 in glibc2.1, hence the absolutely | ||
40 | * insane amounts of padding around dev_t's. | ||
41 | */ | ||
42 | struct stat64 { | ||
43 | unsigned long long st_dev; | ||
44 | unsigned char __pad0[4]; | ||
45 | |||
46 | #define STAT64_HAS_BROKEN_ST_INO 1 | ||
47 | unsigned long __st_ino; | ||
48 | |||
49 | unsigned int st_mode; | ||
50 | unsigned int st_nlink; | ||
51 | |||
52 | unsigned long st_uid; | ||
53 | unsigned long st_gid; | ||
54 | |||
55 | unsigned long long st_rdev; | ||
56 | unsigned char __pad3[4]; | ||
57 | |||
58 | long long st_size; | ||
59 | unsigned long st_blksize; | ||
60 | |||
61 | unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ | ||
62 | |||
63 | unsigned long st_atime; | ||
64 | unsigned long st_atime_nsec; | ||
65 | |||
66 | unsigned long st_mtime; | ||
67 | unsigned int st_mtime_nsec; | ||
68 | |||
69 | unsigned long st_ctime; | ||
70 | unsigned long st_ctime_nsec; | ||
71 | |||
72 | unsigned long long st_ino; | ||
73 | }; | ||
74 | |||
75 | #define STAT_HAVE_NSEC 1 | ||
76 | |||
77 | #endif | ||
diff --git a/include/asm-x86/stat_64.h b/include/asm-x86/stat_64.h new file mode 100644 index 000000000000..fd9f00d560f8 --- /dev/null +++ b/include/asm-x86/stat_64.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _ASM_X86_64_STAT_H | ||
2 | #define _ASM_X86_64_STAT_H | ||
3 | |||
4 | #define STAT_HAVE_NSEC 1 | ||
5 | |||
6 | struct stat { | ||
7 | unsigned long st_dev; | ||
8 | unsigned long st_ino; | ||
9 | unsigned long st_nlink; | ||
10 | |||
11 | unsigned int st_mode; | ||
12 | unsigned int st_uid; | ||
13 | unsigned int st_gid; | ||
14 | unsigned int __pad0; | ||
15 | unsigned long st_rdev; | ||
16 | long st_size; | ||
17 | long st_blksize; | ||
18 | long st_blocks; /* Number 512-byte blocks allocated. */ | ||
19 | |||
20 | unsigned long st_atime; | ||
21 | unsigned long st_atime_nsec; | ||
22 | unsigned long st_mtime; | ||
23 | unsigned long st_mtime_nsec; | ||
24 | unsigned long st_ctime; | ||
25 | unsigned long st_ctime_nsec; | ||
26 | long __unused[3]; | ||
27 | }; | ||
28 | |||
29 | /* For 32bit emulation */ | ||
30 | struct __old_kernel_stat { | ||
31 | unsigned short st_dev; | ||
32 | unsigned short st_ino; | ||
33 | unsigned short st_mode; | ||
34 | unsigned short st_nlink; | ||
35 | unsigned short st_uid; | ||
36 | unsigned short st_gid; | ||
37 | unsigned short st_rdev; | ||
38 | unsigned int st_size; | ||
39 | unsigned int st_atime; | ||
40 | unsigned int st_mtime; | ||
41 | unsigned int st_ctime; | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/include/asm-x86/statfs.h b/include/asm-x86/statfs.h new file mode 100644 index 000000000000..327fb5d7a148 --- /dev/null +++ b/include/asm-x86/statfs.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "statfs_32.h" | ||
4 | # else | ||
5 | # include "statfs_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "statfs_32.h" | ||
10 | # else | ||
11 | # include "statfs_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/statfs_32.h b/include/asm-x86/statfs_32.h new file mode 100644 index 000000000000..24972c175132 --- /dev/null +++ b/include/asm-x86/statfs_32.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _I386_STATFS_H | ||
2 | #define _I386_STATFS_H | ||
3 | |||
4 | #include <asm-generic/statfs.h> | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-x86/statfs_64.h b/include/asm-x86/statfs_64.h new file mode 100644 index 000000000000..b3f4718af30b --- /dev/null +++ b/include/asm-x86/statfs_64.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef _X86_64_STATFS_H | ||
2 | #define _X86_64_STATFS_H | ||
3 | |||
4 | #ifndef __KERNEL_STRICT_NAMES | ||
5 | |||
6 | #include <linux/types.h> | ||
7 | |||
8 | typedef __kernel_fsid_t fsid_t; | ||
9 | |||
10 | #endif | ||
11 | |||
12 | /* | ||
13 | * This is ugly -- we're already 64-bit clean, so just duplicate the | ||
14 | * definitions. | ||
15 | */ | ||
16 | struct statfs { | ||
17 | long f_type; | ||
18 | long f_bsize; | ||
19 | long f_blocks; | ||
20 | long f_bfree; | ||
21 | long f_bavail; | ||
22 | long f_files; | ||
23 | long f_ffree; | ||
24 | __kernel_fsid_t f_fsid; | ||
25 | long f_namelen; | ||
26 | long f_frsize; | ||
27 | long f_spare[5]; | ||
28 | }; | ||
29 | |||
30 | struct statfs64 { | ||
31 | long f_type; | ||
32 | long f_bsize; | ||
33 | long f_blocks; | ||
34 | long f_bfree; | ||
35 | long f_bavail; | ||
36 | long f_files; | ||
37 | long f_ffree; | ||
38 | __kernel_fsid_t f_fsid; | ||
39 | long f_namelen; | ||
40 | long f_frsize; | ||
41 | long f_spare[5]; | ||
42 | }; | ||
43 | |||
44 | struct compat_statfs64 { | ||
45 | __u32 f_type; | ||
46 | __u32 f_bsize; | ||
47 | __u64 f_blocks; | ||
48 | __u64 f_bfree; | ||
49 | __u64 f_bavail; | ||
50 | __u64 f_files; | ||
51 | __u64 f_ffree; | ||
52 | __kernel_fsid_t f_fsid; | ||
53 | __u32 f_namelen; | ||
54 | __u32 f_frsize; | ||
55 | __u32 f_spare[5]; | ||
56 | } __attribute__((packed)); | ||
57 | |||
58 | #endif | ||
diff --git a/include/asm-x86/string.h b/include/asm-x86/string.h new file mode 100644 index 000000000000..6dfd6d9373a0 --- /dev/null +++ b/include/asm-x86/string.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "string_32.h" | ||
3 | #else | ||
4 | # include "string_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/string_32.h b/include/asm-x86/string_32.h new file mode 100644 index 000000000000..a9b64453bdf5 --- /dev/null +++ b/include/asm-x86/string_32.h | |||
@@ -0,0 +1,276 @@ | |||
1 | #ifndef _I386_STRING_H_ | ||
2 | #define _I386_STRING_H_ | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | /* Let gcc decide wether to inline or use the out of line functions */ | ||
7 | |||
8 | #define __HAVE_ARCH_STRCPY | ||
9 | extern char *strcpy(char *dest, const char *src); | ||
10 | |||
11 | #define __HAVE_ARCH_STRNCPY | ||
12 | extern char *strncpy(char *dest, const char *src, size_t count); | ||
13 | |||
14 | #define __HAVE_ARCH_STRCAT | ||
15 | extern char *strcat(char *dest, const char *src); | ||
16 | |||
17 | #define __HAVE_ARCH_STRNCAT | ||
18 | extern char *strncat(char *dest, const char *src, size_t count); | ||
19 | |||
20 | #define __HAVE_ARCH_STRCMP | ||
21 | extern int strcmp(const char *cs, const char *ct); | ||
22 | |||
23 | #define __HAVE_ARCH_STRNCMP | ||
24 | extern int strncmp(const char *cs, const char *ct, size_t count); | ||
25 | |||
26 | #define __HAVE_ARCH_STRCHR | ||
27 | extern char *strchr(const char *s, int c); | ||
28 | |||
29 | #define __HAVE_ARCH_STRRCHR | ||
30 | extern char *strrchr(const char *s, int c); | ||
31 | |||
32 | #define __HAVE_ARCH_STRLEN | ||
33 | extern size_t strlen(const char *s); | ||
34 | |||
35 | static __always_inline void * __memcpy(void * to, const void * from, size_t n) | ||
36 | { | ||
37 | int d0, d1, d2; | ||
38 | __asm__ __volatile__( | ||
39 | "rep ; movsl\n\t" | ||
40 | "movl %4,%%ecx\n\t" | ||
41 | "andl $3,%%ecx\n\t" | ||
42 | "jz 1f\n\t" | ||
43 | "rep ; movsb\n\t" | ||
44 | "1:" | ||
45 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
46 | : "0" (n/4), "g" (n), "1" ((long) to), "2" ((long) from) | ||
47 | : "memory"); | ||
48 | return (to); | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * This looks ugly, but the compiler can optimize it totally, | ||
53 | * as the count is constant. | ||
54 | */ | ||
55 | static __always_inline void * __constant_memcpy(void * to, const void * from, size_t n) | ||
56 | { | ||
57 | long esi, edi; | ||
58 | if (!n) return to; | ||
59 | #if 1 /* want to do small copies with non-string ops? */ | ||
60 | switch (n) { | ||
61 | case 1: *(char*)to = *(char*)from; return to; | ||
62 | case 2: *(short*)to = *(short*)from; return to; | ||
63 | case 4: *(int*)to = *(int*)from; return to; | ||
64 | #if 1 /* including those doable with two moves? */ | ||
65 | case 3: *(short*)to = *(short*)from; | ||
66 | *((char*)to+2) = *((char*)from+2); return to; | ||
67 | case 5: *(int*)to = *(int*)from; | ||
68 | *((char*)to+4) = *((char*)from+4); return to; | ||
69 | case 6: *(int*)to = *(int*)from; | ||
70 | *((short*)to+2) = *((short*)from+2); return to; | ||
71 | case 8: *(int*)to = *(int*)from; | ||
72 | *((int*)to+1) = *((int*)from+1); return to; | ||
73 | #endif | ||
74 | } | ||
75 | #endif | ||
76 | esi = (long) from; | ||
77 | edi = (long) to; | ||
78 | if (n >= 5*4) { | ||
79 | /* large block: use rep prefix */ | ||
80 | int ecx; | ||
81 | __asm__ __volatile__( | ||
82 | "rep ; movsl" | ||
83 | : "=&c" (ecx), "=&D" (edi), "=&S" (esi) | ||
84 | : "0" (n/4), "1" (edi),"2" (esi) | ||
85 | : "memory" | ||
86 | ); | ||
87 | } else { | ||
88 | /* small block: don't clobber ecx + smaller code */ | ||
89 | if (n >= 4*4) __asm__ __volatile__("movsl" | ||
90 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
91 | if (n >= 3*4) __asm__ __volatile__("movsl" | ||
92 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
93 | if (n >= 2*4) __asm__ __volatile__("movsl" | ||
94 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
95 | if (n >= 1*4) __asm__ __volatile__("movsl" | ||
96 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
97 | } | ||
98 | switch (n % 4) { | ||
99 | /* tail */ | ||
100 | case 0: return to; | ||
101 | case 1: __asm__ __volatile__("movsb" | ||
102 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
103 | return to; | ||
104 | case 2: __asm__ __volatile__("movsw" | ||
105 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
106 | return to; | ||
107 | default: __asm__ __volatile__("movsw\n\tmovsb" | ||
108 | :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory"); | ||
109 | return to; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | #define __HAVE_ARCH_MEMCPY | ||
114 | |||
115 | #ifdef CONFIG_X86_USE_3DNOW | ||
116 | |||
117 | #include <asm/mmx.h> | ||
118 | |||
119 | /* | ||
120 | * This CPU favours 3DNow strongly (eg AMD Athlon) | ||
121 | */ | ||
122 | |||
123 | static inline void * __constant_memcpy3d(void * to, const void * from, size_t len) | ||
124 | { | ||
125 | if (len < 512) | ||
126 | return __constant_memcpy(to, from, len); | ||
127 | return _mmx_memcpy(to, from, len); | ||
128 | } | ||
129 | |||
130 | static __inline__ void *__memcpy3d(void *to, const void *from, size_t len) | ||
131 | { | ||
132 | if (len < 512) | ||
133 | return __memcpy(to, from, len); | ||
134 | return _mmx_memcpy(to, from, len); | ||
135 | } | ||
136 | |||
137 | #define memcpy(t, f, n) \ | ||
138 | (__builtin_constant_p(n) ? \ | ||
139 | __constant_memcpy3d((t),(f),(n)) : \ | ||
140 | __memcpy3d((t),(f),(n))) | ||
141 | |||
142 | #else | ||
143 | |||
144 | /* | ||
145 | * No 3D Now! | ||
146 | */ | ||
147 | |||
148 | #define memcpy(t, f, n) \ | ||
149 | (__builtin_constant_p(n) ? \ | ||
150 | __constant_memcpy((t),(f),(n)) : \ | ||
151 | __memcpy((t),(f),(n))) | ||
152 | |||
153 | #endif | ||
154 | |||
155 | #define __HAVE_ARCH_MEMMOVE | ||
156 | void *memmove(void * dest,const void * src, size_t n); | ||
157 | |||
158 | #define memcmp __builtin_memcmp | ||
159 | |||
160 | #define __HAVE_ARCH_MEMCHR | ||
161 | extern void *memchr(const void * cs,int c,size_t count); | ||
162 | |||
163 | static inline void * __memset_generic(void * s, char c,size_t count) | ||
164 | { | ||
165 | int d0, d1; | ||
166 | __asm__ __volatile__( | ||
167 | "rep\n\t" | ||
168 | "stosb" | ||
169 | : "=&c" (d0), "=&D" (d1) | ||
170 | :"a" (c),"1" (s),"0" (count) | ||
171 | :"memory"); | ||
172 | return s; | ||
173 | } | ||
174 | |||
175 | /* we might want to write optimized versions of these later */ | ||
176 | #define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count)) | ||
177 | |||
178 | /* | ||
179 | * memset(x,0,y) is a reasonably common thing to do, so we want to fill | ||
180 | * things 32 bits at a time even when we don't know the size of the | ||
181 | * area at compile-time.. | ||
182 | */ | ||
183 | static __always_inline void * __constant_c_memset(void * s, unsigned long c, size_t count) | ||
184 | { | ||
185 | int d0, d1; | ||
186 | __asm__ __volatile__( | ||
187 | "rep ; stosl\n\t" | ||
188 | "testb $2,%b3\n\t" | ||
189 | "je 1f\n\t" | ||
190 | "stosw\n" | ||
191 | "1:\ttestb $1,%b3\n\t" | ||
192 | "je 2f\n\t" | ||
193 | "stosb\n" | ||
194 | "2:" | ||
195 | :"=&c" (d0), "=&D" (d1) | ||
196 | :"a" (c), "q" (count), "0" (count/4), "1" ((long) s) | ||
197 | :"memory"); | ||
198 | return (s); | ||
199 | } | ||
200 | |||
201 | /* Added by Gertjan van Wingerde to make minix and sysv module work */ | ||
202 | #define __HAVE_ARCH_STRNLEN | ||
203 | extern size_t strnlen(const char * s, size_t count); | ||
204 | /* end of additional stuff */ | ||
205 | |||
206 | #define __HAVE_ARCH_STRSTR | ||
207 | extern char *strstr(const char *cs, const char *ct); | ||
208 | |||
209 | /* | ||
210 | * This looks horribly ugly, but the compiler can optimize it totally, | ||
211 | * as we by now know that both pattern and count is constant.. | ||
212 | */ | ||
213 | static __always_inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) | ||
214 | { | ||
215 | switch (count) { | ||
216 | case 0: | ||
217 | return s; | ||
218 | case 1: | ||
219 | *(unsigned char *)s = pattern; | ||
220 | return s; | ||
221 | case 2: | ||
222 | *(unsigned short *)s = pattern; | ||
223 | return s; | ||
224 | case 3: | ||
225 | *(unsigned short *)s = pattern; | ||
226 | *(2+(unsigned char *)s) = pattern; | ||
227 | return s; | ||
228 | case 4: | ||
229 | *(unsigned long *)s = pattern; | ||
230 | return s; | ||
231 | } | ||
232 | #define COMMON(x) \ | ||
233 | __asm__ __volatile__( \ | ||
234 | "rep ; stosl" \ | ||
235 | x \ | ||
236 | : "=&c" (d0), "=&D" (d1) \ | ||
237 | : "a" (pattern),"0" (count/4),"1" ((long) s) \ | ||
238 | : "memory") | ||
239 | { | ||
240 | int d0, d1; | ||
241 | switch (count % 4) { | ||
242 | case 0: COMMON(""); return s; | ||
243 | case 1: COMMON("\n\tstosb"); return s; | ||
244 | case 2: COMMON("\n\tstosw"); return s; | ||
245 | default: COMMON("\n\tstosw\n\tstosb"); return s; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | #undef COMMON | ||
250 | } | ||
251 | |||
252 | #define __constant_c_x_memset(s, c, count) \ | ||
253 | (__builtin_constant_p(count) ? \ | ||
254 | __constant_c_and_count_memset((s),(c),(count)) : \ | ||
255 | __constant_c_memset((s),(c),(count))) | ||
256 | |||
257 | #define __memset(s, c, count) \ | ||
258 | (__builtin_constant_p(count) ? \ | ||
259 | __constant_count_memset((s),(c),(count)) : \ | ||
260 | __memset_generic((s),(c),(count))) | ||
261 | |||
262 | #define __HAVE_ARCH_MEMSET | ||
263 | #define memset(s, c, count) \ | ||
264 | (__builtin_constant_p(c) ? \ | ||
265 | __constant_c_x_memset((s),(0x01010101UL*(unsigned char)(c)),(count)) : \ | ||
266 | __memset((s),(c),(count))) | ||
267 | |||
268 | /* | ||
269 | * find the first occurrence of byte 'c', or 1 past the area if none | ||
270 | */ | ||
271 | #define __HAVE_ARCH_MEMSCAN | ||
272 | extern void *memscan(void * addr, int c, size_t size); | ||
273 | |||
274 | #endif /* __KERNEL__ */ | ||
275 | |||
276 | #endif | ||
diff --git a/include/asm-x86/string_64.h b/include/asm-x86/string_64.h new file mode 100644 index 000000000000..e583da7918fb --- /dev/null +++ b/include/asm-x86/string_64.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef _X86_64_STRING_H_ | ||
2 | #define _X86_64_STRING_H_ | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | /* Written 2002 by Andi Kleen */ | ||
7 | |||
8 | /* Only used for special circumstances. Stolen from i386/string.h */ | ||
9 | static __always_inline void * | ||
10 | __inline_memcpy(void * to, const void * from, size_t n) | ||
11 | { | ||
12 | unsigned long d0, d1, d2; | ||
13 | __asm__ __volatile__( | ||
14 | "rep ; movsl\n\t" | ||
15 | "testb $2,%b4\n\t" | ||
16 | "je 1f\n\t" | ||
17 | "movsw\n" | ||
18 | "1:\ttestb $1,%b4\n\t" | ||
19 | "je 2f\n\t" | ||
20 | "movsb\n" | ||
21 | "2:" | ||
22 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) | ||
23 | :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) | ||
24 | : "memory"); | ||
25 | return (to); | ||
26 | } | ||
27 | |||
28 | /* Even with __builtin_ the compiler may decide to use the out of line | ||
29 | function. */ | ||
30 | |||
31 | #define __HAVE_ARCH_MEMCPY 1 | ||
32 | #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 | ||
33 | extern void *memcpy(void *to, const void *from, size_t len); | ||
34 | #else | ||
35 | extern void *__memcpy(void *to, const void *from, size_t len); | ||
36 | #define memcpy(dst,src,len) \ | ||
37 | ({ size_t __len = (len); \ | ||
38 | void *__ret; \ | ||
39 | if (__builtin_constant_p(len) && __len >= 64) \ | ||
40 | __ret = __memcpy((dst),(src),__len); \ | ||
41 | else \ | ||
42 | __ret = __builtin_memcpy((dst),(src),__len); \ | ||
43 | __ret; }) | ||
44 | #endif | ||
45 | |||
46 | #define __HAVE_ARCH_MEMSET | ||
47 | void *memset(void *s, int c, size_t n); | ||
48 | |||
49 | #define __HAVE_ARCH_MEMMOVE | ||
50 | void * memmove(void * dest,const void *src,size_t count); | ||
51 | |||
52 | int memcmp(const void * cs,const void * ct,size_t count); | ||
53 | size_t strlen(const char * s); | ||
54 | char *strcpy(char * dest,const char *src); | ||
55 | char *strcat(char * dest, const char * src); | ||
56 | int strcmp(const char * cs,const char * ct); | ||
57 | |||
58 | #endif /* __KERNEL__ */ | ||
59 | |||
60 | #endif | ||
diff --git a/include/asm-x86/suspend.h b/include/asm-x86/suspend.h new file mode 100644 index 000000000000..9bd521fe4570 --- /dev/null +++ b/include/asm-x86/suspend.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "suspend_32.h" | ||
3 | #else | ||
4 | # include "suspend_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/suspend_32.h b/include/asm-x86/suspend_32.h new file mode 100644 index 000000000000..a2520732ffd6 --- /dev/null +++ b/include/asm-x86/suspend_32.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright 2001-2002 Pavel Machek <pavel@suse.cz> | ||
3 | * Based on code | ||
4 | * Copyright 2001 Patrick Mochel <mochel@osdl.org> | ||
5 | */ | ||
6 | #include <asm/desc.h> | ||
7 | #include <asm/i387.h> | ||
8 | |||
9 | static inline int arch_prepare_suspend(void) { return 0; } | ||
10 | |||
11 | /* image of the saved processor state */ | ||
12 | struct saved_context { | ||
13 | u16 es, fs, gs, ss; | ||
14 | unsigned long cr0, cr2, cr3, cr4; | ||
15 | struct Xgt_desc_struct gdt; | ||
16 | struct Xgt_desc_struct idt; | ||
17 | u16 ldt; | ||
18 | u16 tss; | ||
19 | unsigned long tr; | ||
20 | unsigned long safety; | ||
21 | unsigned long return_address; | ||
22 | } __attribute__((packed)); | ||
23 | |||
24 | #ifdef CONFIG_ACPI | ||
25 | extern unsigned long saved_eip; | ||
26 | extern unsigned long saved_esp; | ||
27 | extern unsigned long saved_ebp; | ||
28 | extern unsigned long saved_ebx; | ||
29 | extern unsigned long saved_esi; | ||
30 | extern unsigned long saved_edi; | ||
31 | |||
32 | static inline void acpi_save_register_state(unsigned long return_point) | ||
33 | { | ||
34 | saved_eip = return_point; | ||
35 | asm volatile ("movl %%esp,%0" : "=m" (saved_esp)); | ||
36 | asm volatile ("movl %%ebp,%0" : "=m" (saved_ebp)); | ||
37 | asm volatile ("movl %%ebx,%0" : "=m" (saved_ebx)); | ||
38 | asm volatile ("movl %%edi,%0" : "=m" (saved_edi)); | ||
39 | asm volatile ("movl %%esi,%0" : "=m" (saved_esi)); | ||
40 | } | ||
41 | |||
42 | #define acpi_restore_register_state() do {} while (0) | ||
43 | |||
44 | /* routines for saving/restoring kernel state */ | ||
45 | extern int acpi_save_state_mem(void); | ||
46 | #endif | ||
diff --git a/include/asm-x86/suspend_64.h b/include/asm-x86/suspend_64.h new file mode 100644 index 000000000000..b897e8cb55fb --- /dev/null +++ b/include/asm-x86/suspend_64.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright 2001-2003 Pavel Machek <pavel@suse.cz> | ||
3 | * Based on code | ||
4 | * Copyright 2001 Patrick Mochel <mochel@osdl.org> | ||
5 | */ | ||
6 | #include <asm/desc.h> | ||
7 | #include <asm/i387.h> | ||
8 | |||
9 | static inline int | ||
10 | arch_prepare_suspend(void) | ||
11 | { | ||
12 | return 0; | ||
13 | } | ||
14 | |||
15 | /* Image of the saved processor state. If you touch this, fix acpi_wakeup.S. */ | ||
16 | struct saved_context { | ||
17 | u16 ds, es, fs, gs, ss; | ||
18 | unsigned long gs_base, gs_kernel_base, fs_base; | ||
19 | unsigned long cr0, cr2, cr3, cr4, cr8; | ||
20 | unsigned long efer; | ||
21 | u16 gdt_pad; | ||
22 | u16 gdt_limit; | ||
23 | unsigned long gdt_base; | ||
24 | u16 idt_pad; | ||
25 | u16 idt_limit; | ||
26 | unsigned long idt_base; | ||
27 | u16 ldt; | ||
28 | u16 tss; | ||
29 | unsigned long tr; | ||
30 | unsigned long safety; | ||
31 | unsigned long return_address; | ||
32 | unsigned long eflags; | ||
33 | } __attribute__((packed)); | ||
34 | |||
35 | /* We'll access these from assembly, so we'd better have them outside struct */ | ||
36 | extern unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx; | ||
37 | extern unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi; | ||
38 | extern unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11; | ||
39 | extern unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15; | ||
40 | extern unsigned long saved_context_eflags; | ||
41 | |||
42 | #define loaddebug(thread,register) \ | ||
43 | set_debugreg((thread)->debugreg##register, register) | ||
44 | |||
45 | extern void fix_processor_context(void); | ||
46 | |||
47 | extern unsigned long saved_rip; | ||
48 | extern unsigned long saved_rsp; | ||
49 | extern unsigned long saved_rbp; | ||
50 | extern unsigned long saved_rbx; | ||
51 | extern unsigned long saved_rsi; | ||
52 | extern unsigned long saved_rdi; | ||
53 | |||
54 | /* routines for saving/restoring kernel state */ | ||
55 | extern int acpi_save_state_mem(void); | ||
diff --git a/include/asm-x86/swiotlb.h b/include/asm-x86/swiotlb.h new file mode 100644 index 000000000000..f9c589539a82 --- /dev/null +++ b/include/asm-x86/swiotlb.h | |||
@@ -0,0 +1,56 @@ | |||
1 | #ifndef _ASM_SWIOTLB_H | ||
2 | #define _ASM_SWIOTLB_H 1 | ||
3 | |||
4 | #include <asm/dma-mapping.h> | ||
5 | |||
6 | /* SWIOTLB interface */ | ||
7 | |||
8 | extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, | ||
9 | size_t size, int dir); | ||
10 | extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size, | ||
11 | dma_addr_t *dma_handle, gfp_t flags); | ||
12 | extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, | ||
13 | size_t size, int dir); | ||
14 | extern void swiotlb_sync_single_for_cpu(struct device *hwdev, | ||
15 | dma_addr_t dev_addr, | ||
16 | size_t size, int dir); | ||
17 | extern void swiotlb_sync_single_for_device(struct device *hwdev, | ||
18 | dma_addr_t dev_addr, | ||
19 | size_t size, int dir); | ||
20 | extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev, | ||
21 | dma_addr_t dev_addr, | ||
22 | unsigned long offset, | ||
23 | size_t size, int dir); | ||
24 | extern void swiotlb_sync_single_range_for_device(struct device *hwdev, | ||
25 | dma_addr_t dev_addr, | ||
26 | unsigned long offset, | ||
27 | size_t size, int dir); | ||
28 | extern void swiotlb_sync_sg_for_cpu(struct device *hwdev, | ||
29 | struct scatterlist *sg, int nelems, | ||
30 | int dir); | ||
31 | extern void swiotlb_sync_sg_for_device(struct device *hwdev, | ||
32 | struct scatterlist *sg, int nelems, | ||
33 | int dir); | ||
34 | extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, | ||
35 | int nents, int direction); | ||
36 | extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, | ||
37 | int nents, int direction); | ||
38 | extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr); | ||
39 | extern void swiotlb_free_coherent (struct device *hwdev, size_t size, | ||
40 | void *vaddr, dma_addr_t dma_handle); | ||
41 | extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); | ||
42 | extern void swiotlb_init(void); | ||
43 | |||
44 | extern int swiotlb_force; | ||
45 | |||
46 | #ifdef CONFIG_SWIOTLB | ||
47 | extern int swiotlb; | ||
48 | #else | ||
49 | #define swiotlb 0 | ||
50 | #endif | ||
51 | |||
52 | extern void pci_swiotlb_init(void); | ||
53 | |||
54 | static inline void dma_mark_clean(void *addr, size_t size) {} | ||
55 | |||
56 | #endif /* _ASM_SWIOTLB_H */ | ||
diff --git a/include/asm-x86/sync_bitops.h b/include/asm-x86/sync_bitops.h new file mode 100644 index 000000000000..cbce08a2d135 --- /dev/null +++ b/include/asm-x86/sync_bitops.h | |||
@@ -0,0 +1,156 @@ | |||
1 | #ifndef _I386_SYNC_BITOPS_H | ||
2 | #define _I386_SYNC_BITOPS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 1992, Linus Torvalds. | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * These have to be done with inline assembly: that way the bit-setting | ||
10 | * is guaranteed to be atomic. All bit operations return 0 if the bit | ||
11 | * was cleared before the operation and != 0 if it was not. | ||
12 | * | ||
13 | * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). | ||
14 | */ | ||
15 | |||
16 | #define ADDR (*(volatile long *) addr) | ||
17 | |||
18 | /** | ||
19 | * sync_set_bit - Atomically set a bit in memory | ||
20 | * @nr: the bit to set | ||
21 | * @addr: the address to start counting from | ||
22 | * | ||
23 | * This function is atomic and may not be reordered. See __set_bit() | ||
24 | * if you do not require the atomic guarantees. | ||
25 | * | ||
26 | * Note: there are no guarantees that this function will not be reordered | ||
27 | * on non-x86 architectures, so if you are writing portable code, | ||
28 | * make sure not to rely on its reordering guarantees. | ||
29 | * | ||
30 | * Note that @nr may be almost arbitrarily large; this function is not | ||
31 | * restricted to acting on a single-word quantity. | ||
32 | */ | ||
33 | static inline void sync_set_bit(int nr, volatile unsigned long * addr) | ||
34 | { | ||
35 | __asm__ __volatile__("lock; btsl %1,%0" | ||
36 | :"+m" (ADDR) | ||
37 | :"Ir" (nr) | ||
38 | : "memory"); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * sync_clear_bit - Clears a bit in memory | ||
43 | * @nr: Bit to clear | ||
44 | * @addr: Address to start counting from | ||
45 | * | ||
46 | * sync_clear_bit() is atomic and may not be reordered. However, it does | ||
47 | * not contain a memory barrier, so if it is used for locking purposes, | ||
48 | * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() | ||
49 | * in order to ensure changes are visible on other processors. | ||
50 | */ | ||
51 | static inline void sync_clear_bit(int nr, volatile unsigned long * addr) | ||
52 | { | ||
53 | __asm__ __volatile__("lock; btrl %1,%0" | ||
54 | :"+m" (ADDR) | ||
55 | :"Ir" (nr) | ||
56 | : "memory"); | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * sync_change_bit - Toggle a bit in memory | ||
61 | * @nr: Bit to change | ||
62 | * @addr: Address to start counting from | ||
63 | * | ||
64 | * change_bit() is atomic and may not be reordered. It may be | ||
65 | * reordered on other architectures than x86. | ||
66 | * Note that @nr may be almost arbitrarily large; this function is not | ||
67 | * restricted to acting on a single-word quantity. | ||
68 | */ | ||
69 | static inline void sync_change_bit(int nr, volatile unsigned long * addr) | ||
70 | { | ||
71 | __asm__ __volatile__("lock; btcl %1,%0" | ||
72 | :"+m" (ADDR) | ||
73 | :"Ir" (nr) | ||
74 | : "memory"); | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * sync_test_and_set_bit - Set a bit and return its old value | ||
79 | * @nr: Bit to set | ||
80 | * @addr: Address to count from | ||
81 | * | ||
82 | * This operation is atomic and cannot be reordered. | ||
83 | * It may be reordered on other architectures than x86. | ||
84 | * It also implies a memory barrier. | ||
85 | */ | ||
86 | static inline int sync_test_and_set_bit(int nr, volatile unsigned long * addr) | ||
87 | { | ||
88 | int oldbit; | ||
89 | |||
90 | __asm__ __volatile__("lock; btsl %2,%1\n\tsbbl %0,%0" | ||
91 | :"=r" (oldbit),"+m" (ADDR) | ||
92 | :"Ir" (nr) : "memory"); | ||
93 | return oldbit; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * sync_test_and_clear_bit - Clear a bit and return its old value | ||
98 | * @nr: Bit to clear | ||
99 | * @addr: Address to count from | ||
100 | * | ||
101 | * This operation is atomic and cannot be reordered. | ||
102 | * It can be reorderdered on other architectures other than x86. | ||
103 | * It also implies a memory barrier. | ||
104 | */ | ||
105 | static inline int sync_test_and_clear_bit(int nr, volatile unsigned long * addr) | ||
106 | { | ||
107 | int oldbit; | ||
108 | |||
109 | __asm__ __volatile__("lock; btrl %2,%1\n\tsbbl %0,%0" | ||
110 | :"=r" (oldbit),"+m" (ADDR) | ||
111 | :"Ir" (nr) : "memory"); | ||
112 | return oldbit; | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * sync_test_and_change_bit - Change a bit and return its old value | ||
117 | * @nr: Bit to change | ||
118 | * @addr: Address to count from | ||
119 | * | ||
120 | * This operation is atomic and cannot be reordered. | ||
121 | * It also implies a memory barrier. | ||
122 | */ | ||
123 | static inline int sync_test_and_change_bit(int nr, volatile unsigned long* addr) | ||
124 | { | ||
125 | int oldbit; | ||
126 | |||
127 | __asm__ __volatile__("lock; btcl %2,%1\n\tsbbl %0,%0" | ||
128 | :"=r" (oldbit),"+m" (ADDR) | ||
129 | :"Ir" (nr) : "memory"); | ||
130 | return oldbit; | ||
131 | } | ||
132 | |||
133 | static __always_inline int sync_constant_test_bit(int nr, const volatile unsigned long *addr) | ||
134 | { | ||
135 | return ((1UL << (nr & 31)) & | ||
136 | (((const volatile unsigned int *)addr)[nr >> 5])) != 0; | ||
137 | } | ||
138 | |||
139 | static inline int sync_var_test_bit(int nr, const volatile unsigned long * addr) | ||
140 | { | ||
141 | int oldbit; | ||
142 | |||
143 | __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0" | ||
144 | :"=r" (oldbit) | ||
145 | :"m" (ADDR),"Ir" (nr)); | ||
146 | return oldbit; | ||
147 | } | ||
148 | |||
149 | #define sync_test_bit(nr,addr) \ | ||
150 | (__builtin_constant_p(nr) ? \ | ||
151 | sync_constant_test_bit((nr),(addr)) : \ | ||
152 | sync_var_test_bit((nr),(addr))) | ||
153 | |||
154 | #undef ADDR | ||
155 | |||
156 | #endif /* _I386_SYNC_BITOPS_H */ | ||
diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h new file mode 100644 index 000000000000..692562b48f2a --- /dev/null +++ b/include/asm-x86/system.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "system_32.h" | ||
3 | #else | ||
4 | # include "system_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/system_32.h b/include/asm-x86/system_32.h new file mode 100644 index 000000000000..d69ba937e092 --- /dev/null +++ b/include/asm-x86/system_32.h | |||
@@ -0,0 +1,313 @@ | |||
1 | #ifndef __ASM_SYSTEM_H | ||
2 | #define __ASM_SYSTEM_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <asm/segment.h> | ||
6 | #include <asm/cpufeature.h> | ||
7 | #include <asm/cmpxchg.h> | ||
8 | |||
9 | #ifdef __KERNEL__ | ||
10 | |||
11 | struct task_struct; /* one of the stranger aspects of C forward declarations.. */ | ||
12 | extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); | ||
13 | |||
14 | /* | ||
15 | * Saving eflags is important. It switches not only IOPL between tasks, | ||
16 | * it also protects other tasks from NT leaking through sysenter etc. | ||
17 | */ | ||
18 | #define switch_to(prev,next,last) do { \ | ||
19 | unsigned long esi,edi; \ | ||
20 | asm volatile("pushfl\n\t" /* Save flags */ \ | ||
21 | "pushl %%ebp\n\t" \ | ||
22 | "movl %%esp,%0\n\t" /* save ESP */ \ | ||
23 | "movl %5,%%esp\n\t" /* restore ESP */ \ | ||
24 | "movl $1f,%1\n\t" /* save EIP */ \ | ||
25 | "pushl %6\n\t" /* restore EIP */ \ | ||
26 | "jmp __switch_to\n" \ | ||
27 | "1:\t" \ | ||
28 | "popl %%ebp\n\t" \ | ||
29 | "popfl" \ | ||
30 | :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \ | ||
31 | "=a" (last),"=S" (esi),"=D" (edi) \ | ||
32 | :"m" (next->thread.esp),"m" (next->thread.eip), \ | ||
33 | "2" (prev), "d" (next)); \ | ||
34 | } while (0) | ||
35 | |||
36 | #define _set_base(addr,base) do { unsigned long __pr; \ | ||
37 | __asm__ __volatile__ ("movw %%dx,%1\n\t" \ | ||
38 | "rorl $16,%%edx\n\t" \ | ||
39 | "movb %%dl,%2\n\t" \ | ||
40 | "movb %%dh,%3" \ | ||
41 | :"=&d" (__pr) \ | ||
42 | :"m" (*((addr)+2)), \ | ||
43 | "m" (*((addr)+4)), \ | ||
44 | "m" (*((addr)+7)), \ | ||
45 | "0" (base) \ | ||
46 | ); } while(0) | ||
47 | |||
48 | #define _set_limit(addr,limit) do { unsigned long __lr; \ | ||
49 | __asm__ __volatile__ ("movw %%dx,%1\n\t" \ | ||
50 | "rorl $16,%%edx\n\t" \ | ||
51 | "movb %2,%%dh\n\t" \ | ||
52 | "andb $0xf0,%%dh\n\t" \ | ||
53 | "orb %%dh,%%dl\n\t" \ | ||
54 | "movb %%dl,%2" \ | ||
55 | :"=&d" (__lr) \ | ||
56 | :"m" (*(addr)), \ | ||
57 | "m" (*((addr)+6)), \ | ||
58 | "0" (limit) \ | ||
59 | ); } while(0) | ||
60 | |||
61 | #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) ) | ||
62 | #define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1) ) | ||
63 | |||
64 | /* | ||
65 | * Load a segment. Fall back on loading the zero | ||
66 | * segment if something goes wrong.. | ||
67 | */ | ||
68 | #define loadsegment(seg,value) \ | ||
69 | asm volatile("\n" \ | ||
70 | "1:\t" \ | ||
71 | "mov %0,%%" #seg "\n" \ | ||
72 | "2:\n" \ | ||
73 | ".section .fixup,\"ax\"\n" \ | ||
74 | "3:\t" \ | ||
75 | "pushl $0\n\t" \ | ||
76 | "popl %%" #seg "\n\t" \ | ||
77 | "jmp 2b\n" \ | ||
78 | ".previous\n" \ | ||
79 | ".section __ex_table,\"a\"\n\t" \ | ||
80 | ".align 4\n\t" \ | ||
81 | ".long 1b,3b\n" \ | ||
82 | ".previous" \ | ||
83 | : :"rm" (value)) | ||
84 | |||
85 | /* | ||
86 | * Save a segment register away | ||
87 | */ | ||
88 | #define savesegment(seg, value) \ | ||
89 | asm volatile("mov %%" #seg ",%0":"=rm" (value)) | ||
90 | |||
91 | |||
92 | static inline void native_clts(void) | ||
93 | { | ||
94 | asm volatile ("clts"); | ||
95 | } | ||
96 | |||
97 | static inline unsigned long native_read_cr0(void) | ||
98 | { | ||
99 | unsigned long val; | ||
100 | asm volatile("movl %%cr0,%0\n\t" :"=r" (val)); | ||
101 | return val; | ||
102 | } | ||
103 | |||
104 | static inline void native_write_cr0(unsigned long val) | ||
105 | { | ||
106 | asm volatile("movl %0,%%cr0": :"r" (val)); | ||
107 | } | ||
108 | |||
109 | static inline unsigned long native_read_cr2(void) | ||
110 | { | ||
111 | unsigned long val; | ||
112 | asm volatile("movl %%cr2,%0\n\t" :"=r" (val)); | ||
113 | return val; | ||
114 | } | ||
115 | |||
116 | static inline void native_write_cr2(unsigned long val) | ||
117 | { | ||
118 | asm volatile("movl %0,%%cr2": :"r" (val)); | ||
119 | } | ||
120 | |||
121 | static inline unsigned long native_read_cr3(void) | ||
122 | { | ||
123 | unsigned long val; | ||
124 | asm volatile("movl %%cr3,%0\n\t" :"=r" (val)); | ||
125 | return val; | ||
126 | } | ||
127 | |||
128 | static inline void native_write_cr3(unsigned long val) | ||
129 | { | ||
130 | asm volatile("movl %0,%%cr3": :"r" (val)); | ||
131 | } | ||
132 | |||
133 | static inline unsigned long native_read_cr4(void) | ||
134 | { | ||
135 | unsigned long val; | ||
136 | asm volatile("movl %%cr4,%0\n\t" :"=r" (val)); | ||
137 | return val; | ||
138 | } | ||
139 | |||
140 | static inline unsigned long native_read_cr4_safe(void) | ||
141 | { | ||
142 | unsigned long val; | ||
143 | /* This could fault if %cr4 does not exist */ | ||
144 | asm("1: movl %%cr4, %0 \n" | ||
145 | "2: \n" | ||
146 | ".section __ex_table,\"a\" \n" | ||
147 | ".long 1b,2b \n" | ||
148 | ".previous \n" | ||
149 | : "=r" (val): "0" (0)); | ||
150 | return val; | ||
151 | } | ||
152 | |||
153 | static inline void native_write_cr4(unsigned long val) | ||
154 | { | ||
155 | asm volatile("movl %0,%%cr4": :"r" (val)); | ||
156 | } | ||
157 | |||
158 | static inline void native_wbinvd(void) | ||
159 | { | ||
160 | asm volatile("wbinvd": : :"memory"); | ||
161 | } | ||
162 | |||
163 | |||
164 | #ifdef CONFIG_PARAVIRT | ||
165 | #include <asm/paravirt.h> | ||
166 | #else | ||
167 | #define read_cr0() (native_read_cr0()) | ||
168 | #define write_cr0(x) (native_write_cr0(x)) | ||
169 | #define read_cr2() (native_read_cr2()) | ||
170 | #define write_cr2(x) (native_write_cr2(x)) | ||
171 | #define read_cr3() (native_read_cr3()) | ||
172 | #define write_cr3(x) (native_write_cr3(x)) | ||
173 | #define read_cr4() (native_read_cr4()) | ||
174 | #define read_cr4_safe() (native_read_cr4_safe()) | ||
175 | #define write_cr4(x) (native_write_cr4(x)) | ||
176 | #define wbinvd() (native_wbinvd()) | ||
177 | |||
178 | /* Clear the 'TS' bit */ | ||
179 | #define clts() (native_clts()) | ||
180 | |||
181 | #endif/* CONFIG_PARAVIRT */ | ||
182 | |||
183 | /* Set the 'TS' bit */ | ||
184 | #define stts() write_cr0(8 | read_cr0()) | ||
185 | |||
186 | #endif /* __KERNEL__ */ | ||
187 | |||
188 | static inline unsigned long get_limit(unsigned long segment) | ||
189 | { | ||
190 | unsigned long __limit; | ||
191 | __asm__("lsll %1,%0" | ||
192 | :"=r" (__limit):"r" (segment)); | ||
193 | return __limit+1; | ||
194 | } | ||
195 | |||
196 | #define nop() __asm__ __volatile__ ("nop") | ||
197 | |||
198 | /* | ||
199 | * Force strict CPU ordering. | ||
200 | * And yes, this is required on UP too when we're talking | ||
201 | * to devices. | ||
202 | * | ||
203 | * For now, "wmb()" doesn't actually do anything, as all | ||
204 | * Intel CPU's follow what Intel calls a *Processor Order*, | ||
205 | * in which all writes are seen in the program order even | ||
206 | * outside the CPU. | ||
207 | * | ||
208 | * I expect future Intel CPU's to have a weaker ordering, | ||
209 | * but I'd also expect them to finally get their act together | ||
210 | * and add some real memory barriers if so. | ||
211 | * | ||
212 | * Some non intel clones support out of order store. wmb() ceases to be a | ||
213 | * nop for these. | ||
214 | */ | ||
215 | |||
216 | |||
217 | #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) | ||
218 | #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) | ||
219 | |||
220 | /** | ||
221 | * read_barrier_depends - Flush all pending reads that subsequents reads | ||
222 | * depend on. | ||
223 | * | ||
224 | * No data-dependent reads from memory-like regions are ever reordered | ||
225 | * over this barrier. All reads preceding this primitive are guaranteed | ||
226 | * to access memory (but not necessarily other CPUs' caches) before any | ||
227 | * reads following this primitive that depend on the data return by | ||
228 | * any of the preceding reads. This primitive is much lighter weight than | ||
229 | * rmb() on most CPUs, and is never heavier weight than is | ||
230 | * rmb(). | ||
231 | * | ||
232 | * These ordering constraints are respected by both the local CPU | ||
233 | * and the compiler. | ||
234 | * | ||
235 | * Ordering is not guaranteed by anything other than these primitives, | ||
236 | * not even by data dependencies. See the documentation for | ||
237 | * memory_barrier() for examples and URLs to more information. | ||
238 | * | ||
239 | * For example, the following code would force ordering (the initial | ||
240 | * value of "a" is zero, "b" is one, and "p" is "&a"): | ||
241 | * | ||
242 | * <programlisting> | ||
243 | * CPU 0 CPU 1 | ||
244 | * | ||
245 | * b = 2; | ||
246 | * memory_barrier(); | ||
247 | * p = &b; q = p; | ||
248 | * read_barrier_depends(); | ||
249 | * d = *q; | ||
250 | * </programlisting> | ||
251 | * | ||
252 | * because the read of "*q" depends on the read of "p" and these | ||
253 | * two reads are separated by a read_barrier_depends(). However, | ||
254 | * the following code, with the same initial values for "a" and "b": | ||
255 | * | ||
256 | * <programlisting> | ||
257 | * CPU 0 CPU 1 | ||
258 | * | ||
259 | * a = 2; | ||
260 | * memory_barrier(); | ||
261 | * b = 3; y = b; | ||
262 | * read_barrier_depends(); | ||
263 | * x = a; | ||
264 | * </programlisting> | ||
265 | * | ||
266 | * does not enforce ordering, since there is no data dependency between | ||
267 | * the read of "a" and the read of "b". Therefore, on some CPUs, such | ||
268 | * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() | ||
269 | * in cases like this where there are no data dependencies. | ||
270 | **/ | ||
271 | |||
272 | #define read_barrier_depends() do { } while(0) | ||
273 | |||
274 | #ifdef CONFIG_X86_OOSTORE | ||
275 | /* Actually there are no OOO store capable CPUs for now that do SSE, | ||
276 | but make it already an possibility. */ | ||
277 | #define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) | ||
278 | #else | ||
279 | #define wmb() __asm__ __volatile__ ("": : :"memory") | ||
280 | #endif | ||
281 | |||
282 | #ifdef CONFIG_SMP | ||
283 | #define smp_mb() mb() | ||
284 | #define smp_rmb() rmb() | ||
285 | #define smp_wmb() wmb() | ||
286 | #define smp_read_barrier_depends() read_barrier_depends() | ||
287 | #define set_mb(var, value) do { (void) xchg(&var, value); } while (0) | ||
288 | #else | ||
289 | #define smp_mb() barrier() | ||
290 | #define smp_rmb() barrier() | ||
291 | #define smp_wmb() barrier() | ||
292 | #define smp_read_barrier_depends() do { } while(0) | ||
293 | #define set_mb(var, value) do { var = value; barrier(); } while (0) | ||
294 | #endif | ||
295 | |||
296 | #include <linux/irqflags.h> | ||
297 | |||
298 | /* | ||
299 | * disable hlt during certain critical i/o operations | ||
300 | */ | ||
301 | #define HAVE_DISABLE_HLT | ||
302 | void disable_hlt(void); | ||
303 | void enable_hlt(void); | ||
304 | |||
305 | extern int es7000_plat; | ||
306 | void cpu_idle_wait(void); | ||
307 | |||
308 | extern unsigned long arch_align_stack(unsigned long sp); | ||
309 | extern void free_init_pages(char *what, unsigned long begin, unsigned long end); | ||
310 | |||
311 | void default_idle(void); | ||
312 | |||
313 | #endif | ||
diff --git a/include/asm-x86/system_64.h b/include/asm-x86/system_64.h new file mode 100644 index 000000000000..02175aa1d16a --- /dev/null +++ b/include/asm-x86/system_64.h | |||
@@ -0,0 +1,180 @@ | |||
1 | #ifndef __ASM_SYSTEM_H | ||
2 | #define __ASM_SYSTEM_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <asm/segment.h> | ||
6 | #include <asm/cmpxchg.h> | ||
7 | |||
8 | #ifdef __KERNEL__ | ||
9 | |||
10 | #define __STR(x) #x | ||
11 | #define STR(x) __STR(x) | ||
12 | |||
13 | #define __SAVE(reg,offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t" | ||
14 | #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t" | ||
15 | |||
16 | /* frame pointer must be last for get_wchan */ | ||
17 | #define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t" | ||
18 | #define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t" | ||
19 | |||
20 | #define __EXTRA_CLOBBER \ | ||
21 | ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15" | ||
22 | |||
23 | /* Save restore flags to clear handle leaking NT */ | ||
24 | #define switch_to(prev,next,last) \ | ||
25 | asm volatile(SAVE_CONTEXT \ | ||
26 | "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ | ||
27 | "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \ | ||
28 | "call __switch_to\n\t" \ | ||
29 | ".globl thread_return\n" \ | ||
30 | "thread_return:\n\t" \ | ||
31 | "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \ | ||
32 | "movq %P[thread_info](%%rsi),%%r8\n\t" \ | ||
33 | LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \ | ||
34 | "movq %%rax,%%rdi\n\t" \ | ||
35 | "jc ret_from_fork\n\t" \ | ||
36 | RESTORE_CONTEXT \ | ||
37 | : "=a" (last) \ | ||
38 | : [next] "S" (next), [prev] "D" (prev), \ | ||
39 | [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \ | ||
40 | [ti_flags] "i" (offsetof(struct thread_info, flags)),\ | ||
41 | [tif_fork] "i" (TIF_FORK), \ | ||
42 | [thread_info] "i" (offsetof(struct task_struct, stack)), \ | ||
43 | [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \ | ||
44 | : "memory", "cc" __EXTRA_CLOBBER) | ||
45 | |||
46 | extern void load_gs_index(unsigned); | ||
47 | |||
48 | /* | ||
49 | * Load a segment. Fall back on loading the zero | ||
50 | * segment if something goes wrong.. | ||
51 | */ | ||
52 | #define loadsegment(seg,value) \ | ||
53 | asm volatile("\n" \ | ||
54 | "1:\t" \ | ||
55 | "movl %k0,%%" #seg "\n" \ | ||
56 | "2:\n" \ | ||
57 | ".section .fixup,\"ax\"\n" \ | ||
58 | "3:\t" \ | ||
59 | "movl %1,%%" #seg "\n\t" \ | ||
60 | "jmp 2b\n" \ | ||
61 | ".previous\n" \ | ||
62 | ".section __ex_table,\"a\"\n\t" \ | ||
63 | ".align 8\n\t" \ | ||
64 | ".quad 1b,3b\n" \ | ||
65 | ".previous" \ | ||
66 | : :"r" (value), "r" (0)) | ||
67 | |||
68 | /* | ||
69 | * Clear and set 'TS' bit respectively | ||
70 | */ | ||
71 | #define clts() __asm__ __volatile__ ("clts") | ||
72 | |||
73 | static inline unsigned long read_cr0(void) | ||
74 | { | ||
75 | unsigned long cr0; | ||
76 | asm volatile("movq %%cr0,%0" : "=r" (cr0)); | ||
77 | return cr0; | ||
78 | } | ||
79 | |||
80 | static inline void write_cr0(unsigned long val) | ||
81 | { | ||
82 | asm volatile("movq %0,%%cr0" :: "r" (val)); | ||
83 | } | ||
84 | |||
85 | static inline unsigned long read_cr2(void) | ||
86 | { | ||
87 | unsigned long cr2; | ||
88 | asm("movq %%cr2,%0" : "=r" (cr2)); | ||
89 | return cr2; | ||
90 | } | ||
91 | |||
92 | static inline void write_cr2(unsigned long val) | ||
93 | { | ||
94 | asm volatile("movq %0,%%cr2" :: "r" (val)); | ||
95 | } | ||
96 | |||
97 | static inline unsigned long read_cr3(void) | ||
98 | { | ||
99 | unsigned long cr3; | ||
100 | asm("movq %%cr3,%0" : "=r" (cr3)); | ||
101 | return cr3; | ||
102 | } | ||
103 | |||
104 | static inline void write_cr3(unsigned long val) | ||
105 | { | ||
106 | asm volatile("movq %0,%%cr3" :: "r" (val) : "memory"); | ||
107 | } | ||
108 | |||
109 | static inline unsigned long read_cr4(void) | ||
110 | { | ||
111 | unsigned long cr4; | ||
112 | asm("movq %%cr4,%0" : "=r" (cr4)); | ||
113 | return cr4; | ||
114 | } | ||
115 | |||
116 | static inline void write_cr4(unsigned long val) | ||
117 | { | ||
118 | asm volatile("movq %0,%%cr4" :: "r" (val) : "memory"); | ||
119 | } | ||
120 | |||
121 | static inline unsigned long read_cr8(void) | ||
122 | { | ||
123 | unsigned long cr8; | ||
124 | asm("movq %%cr8,%0" : "=r" (cr8)); | ||
125 | return cr8; | ||
126 | } | ||
127 | |||
128 | static inline void write_cr8(unsigned long val) | ||
129 | { | ||
130 | asm volatile("movq %0,%%cr8" :: "r" (val) : "memory"); | ||
131 | } | ||
132 | |||
133 | #define stts() write_cr0(8 | read_cr0()) | ||
134 | |||
135 | #define wbinvd() \ | ||
136 | __asm__ __volatile__ ("wbinvd": : :"memory") | ||
137 | |||
138 | #endif /* __KERNEL__ */ | ||
139 | |||
140 | #define nop() __asm__ __volatile__ ("nop") | ||
141 | |||
142 | #ifdef CONFIG_SMP | ||
143 | #define smp_mb() mb() | ||
144 | #define smp_rmb() rmb() | ||
145 | #define smp_wmb() wmb() | ||
146 | #define smp_read_barrier_depends() do {} while(0) | ||
147 | #else | ||
148 | #define smp_mb() barrier() | ||
149 | #define smp_rmb() barrier() | ||
150 | #define smp_wmb() barrier() | ||
151 | #define smp_read_barrier_depends() do {} while(0) | ||
152 | #endif | ||
153 | |||
154 | |||
155 | /* | ||
156 | * Force strict CPU ordering. | ||
157 | * And yes, this is required on UP too when we're talking | ||
158 | * to devices. | ||
159 | */ | ||
160 | #define mb() asm volatile("mfence":::"memory") | ||
161 | #define rmb() asm volatile("lfence":::"memory") | ||
162 | |||
163 | #ifdef CONFIG_UNORDERED_IO | ||
164 | #define wmb() asm volatile("sfence" ::: "memory") | ||
165 | #else | ||
166 | #define wmb() asm volatile("" ::: "memory") | ||
167 | #endif | ||
168 | #define read_barrier_depends() do {} while(0) | ||
169 | #define set_mb(var, value) do { (void) xchg(&var, value); } while (0) | ||
170 | |||
171 | #define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0) | ||
172 | |||
173 | #include <linux/irqflags.h> | ||
174 | |||
175 | void cpu_idle_wait(void); | ||
176 | |||
177 | extern unsigned long arch_align_stack(unsigned long sp); | ||
178 | extern void free_init_pages(char *what, unsigned long begin, unsigned long end); | ||
179 | |||
180 | #endif | ||
diff --git a/include/asm-x86/tce.h b/include/asm-x86/tce.h new file mode 100644 index 000000000000..cd955d3d112f --- /dev/null +++ b/include/asm-x86/tce.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * This file is derived from asm-powerpc/tce.h. | ||
3 | * | ||
4 | * Copyright (C) IBM Corporation, 2006 | ||
5 | * | ||
6 | * Author: Muli Ben-Yehuda <muli@il.ibm.com> | ||
7 | * Author: Jon Mason <jdmason@us.ibm.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #ifndef _ASM_X86_64_TCE_H | ||
25 | #define _ASM_X86_64_TCE_H | ||
26 | |||
27 | extern unsigned int specified_table_size; | ||
28 | struct iommu_table; | ||
29 | |||
30 | #define TCE_ENTRY_SIZE 8 /* in bytes */ | ||
31 | |||
32 | #define TCE_READ_SHIFT 0 | ||
33 | #define TCE_WRITE_SHIFT 1 | ||
34 | #define TCE_HUBID_SHIFT 2 /* unused */ | ||
35 | #define TCE_RSVD_SHIFT 8 /* unused */ | ||
36 | #define TCE_RPN_SHIFT 12 | ||
37 | #define TCE_UNUSED_SHIFT 48 /* unused */ | ||
38 | |||
39 | #define TCE_RPN_MASK 0x0000fffffffff000ULL | ||
40 | |||
41 | extern void tce_build(struct iommu_table *tbl, unsigned long index, | ||
42 | unsigned int npages, unsigned long uaddr, int direction); | ||
43 | extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages); | ||
44 | extern void * __init alloc_tce_table(void); | ||
45 | extern void __init free_tce_table(void *tbl); | ||
46 | extern int __init build_tce_table(struct pci_dev *dev, void __iomem *bbar); | ||
47 | |||
48 | #endif /* _ASM_X86_64_TCE_H */ | ||
diff --git a/include/asm-x86/termbits.h b/include/asm-x86/termbits.h new file mode 100644 index 000000000000..69f3080e2a1d --- /dev/null +++ b/include/asm-x86/termbits.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "termbits_32.h" | ||
4 | # else | ||
5 | # include "termbits_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "termbits_32.h" | ||
10 | # else | ||
11 | # include "termbits_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/termbits_32.h b/include/asm-x86/termbits_32.h new file mode 100644 index 000000000000..a21700352e7b --- /dev/null +++ b/include/asm-x86/termbits_32.h | |||
@@ -0,0 +1,198 @@ | |||
1 | #ifndef __ARCH_I386_TERMBITS_H__ | ||
2 | #define __ARCH_I386_TERMBITS_H__ | ||
3 | |||
4 | #include <linux/posix_types.h> | ||
5 | |||
6 | typedef unsigned char cc_t; | ||
7 | typedef unsigned int speed_t; | ||
8 | typedef unsigned int tcflag_t; | ||
9 | |||
10 | #define NCCS 19 | ||
11 | struct termios { | ||
12 | tcflag_t c_iflag; /* input mode flags */ | ||
13 | tcflag_t c_oflag; /* output mode flags */ | ||
14 | tcflag_t c_cflag; /* control mode flags */ | ||
15 | tcflag_t c_lflag; /* local mode flags */ | ||
16 | cc_t c_line; /* line discipline */ | ||
17 | cc_t c_cc[NCCS]; /* control characters */ | ||
18 | }; | ||
19 | |||
20 | struct termios2 { | ||
21 | tcflag_t c_iflag; /* input mode flags */ | ||
22 | tcflag_t c_oflag; /* output mode flags */ | ||
23 | tcflag_t c_cflag; /* control mode flags */ | ||
24 | tcflag_t c_lflag; /* local mode flags */ | ||
25 | cc_t c_line; /* line discipline */ | ||
26 | cc_t c_cc[NCCS]; /* control characters */ | ||
27 | speed_t c_ispeed; /* input speed */ | ||
28 | speed_t c_ospeed; /* output speed */ | ||
29 | }; | ||
30 | |||
31 | struct ktermios { | ||
32 | tcflag_t c_iflag; /* input mode flags */ | ||
33 | tcflag_t c_oflag; /* output mode flags */ | ||
34 | tcflag_t c_cflag; /* control mode flags */ | ||
35 | tcflag_t c_lflag; /* local mode flags */ | ||
36 | cc_t c_line; /* line discipline */ | ||
37 | cc_t c_cc[NCCS]; /* control characters */ | ||
38 | speed_t c_ispeed; /* input speed */ | ||
39 | speed_t c_ospeed; /* output speed */ | ||
40 | }; | ||
41 | |||
42 | /* c_cc characters */ | ||
43 | #define VINTR 0 | ||
44 | #define VQUIT 1 | ||
45 | #define VERASE 2 | ||
46 | #define VKILL 3 | ||
47 | #define VEOF 4 | ||
48 | #define VTIME 5 | ||
49 | #define VMIN 6 | ||
50 | #define VSWTC 7 | ||
51 | #define VSTART 8 | ||
52 | #define VSTOP 9 | ||
53 | #define VSUSP 10 | ||
54 | #define VEOL 11 | ||
55 | #define VREPRINT 12 | ||
56 | #define VDISCARD 13 | ||
57 | #define VWERASE 14 | ||
58 | #define VLNEXT 15 | ||
59 | #define VEOL2 16 | ||
60 | |||
61 | /* c_iflag bits */ | ||
62 | #define IGNBRK 0000001 | ||
63 | #define BRKINT 0000002 | ||
64 | #define IGNPAR 0000004 | ||
65 | #define PARMRK 0000010 | ||
66 | #define INPCK 0000020 | ||
67 | #define ISTRIP 0000040 | ||
68 | #define INLCR 0000100 | ||
69 | #define IGNCR 0000200 | ||
70 | #define ICRNL 0000400 | ||
71 | #define IUCLC 0001000 | ||
72 | #define IXON 0002000 | ||
73 | #define IXANY 0004000 | ||
74 | #define IXOFF 0010000 | ||
75 | #define IMAXBEL 0020000 | ||
76 | #define IUTF8 0040000 | ||
77 | |||
78 | /* c_oflag bits */ | ||
79 | #define OPOST 0000001 | ||
80 | #define OLCUC 0000002 | ||
81 | #define ONLCR 0000004 | ||
82 | #define OCRNL 0000010 | ||
83 | #define ONOCR 0000020 | ||
84 | #define ONLRET 0000040 | ||
85 | #define OFILL 0000100 | ||
86 | #define OFDEL 0000200 | ||
87 | #define NLDLY 0000400 | ||
88 | #define NL0 0000000 | ||
89 | #define NL1 0000400 | ||
90 | #define CRDLY 0003000 | ||
91 | #define CR0 0000000 | ||
92 | #define CR1 0001000 | ||
93 | #define CR2 0002000 | ||
94 | #define CR3 0003000 | ||
95 | #define TABDLY 0014000 | ||
96 | #define TAB0 0000000 | ||
97 | #define TAB1 0004000 | ||
98 | #define TAB2 0010000 | ||
99 | #define TAB3 0014000 | ||
100 | #define XTABS 0014000 | ||
101 | #define BSDLY 0020000 | ||
102 | #define BS0 0000000 | ||
103 | #define BS1 0020000 | ||
104 | #define VTDLY 0040000 | ||
105 | #define VT0 0000000 | ||
106 | #define VT1 0040000 | ||
107 | #define FFDLY 0100000 | ||
108 | #define FF0 0000000 | ||
109 | #define FF1 0100000 | ||
110 | |||
111 | /* c_cflag bit meaning */ | ||
112 | #define CBAUD 0010017 | ||
113 | #define B0 0000000 /* hang up */ | ||
114 | #define B50 0000001 | ||
115 | #define B75 0000002 | ||
116 | #define B110 0000003 | ||
117 | #define B134 0000004 | ||
118 | #define B150 0000005 | ||
119 | #define B200 0000006 | ||
120 | #define B300 0000007 | ||
121 | #define B600 0000010 | ||
122 | #define B1200 0000011 | ||
123 | #define B1800 0000012 | ||
124 | #define B2400 0000013 | ||
125 | #define B4800 0000014 | ||
126 | #define B9600 0000015 | ||
127 | #define B19200 0000016 | ||
128 | #define B38400 0000017 | ||
129 | #define EXTA B19200 | ||
130 | #define EXTB B38400 | ||
131 | #define CSIZE 0000060 | ||
132 | #define CS5 0000000 | ||
133 | #define CS6 0000020 | ||
134 | #define CS7 0000040 | ||
135 | #define CS8 0000060 | ||
136 | #define CSTOPB 0000100 | ||
137 | #define CREAD 0000200 | ||
138 | #define PARENB 0000400 | ||
139 | #define PARODD 0001000 | ||
140 | #define HUPCL 0002000 | ||
141 | #define CLOCAL 0004000 | ||
142 | #define CBAUDEX 0010000 | ||
143 | #define BOTHER 0010000 | ||
144 | #define B57600 0010001 | ||
145 | #define B115200 0010002 | ||
146 | #define B230400 0010003 | ||
147 | #define B460800 0010004 | ||
148 | #define B500000 0010005 | ||
149 | #define B576000 0010006 | ||
150 | #define B921600 0010007 | ||
151 | #define B1000000 0010010 | ||
152 | #define B1152000 0010011 | ||
153 | #define B1500000 0010012 | ||
154 | #define B2000000 0010013 | ||
155 | #define B2500000 0010014 | ||
156 | #define B3000000 0010015 | ||
157 | #define B3500000 0010016 | ||
158 | #define B4000000 0010017 | ||
159 | #define CIBAUD 002003600000 | ||
160 | #define CMSPAR 010000000000 /* mark or space (stick) parity */ | ||
161 | #define CRTSCTS 020000000000 /* flow control */ | ||
162 | |||
163 | #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ | ||
164 | |||
165 | /* c_lflag bits */ | ||
166 | #define ISIG 0000001 | ||
167 | #define ICANON 0000002 | ||
168 | #define XCASE 0000004 | ||
169 | #define ECHO 0000010 | ||
170 | #define ECHOE 0000020 | ||
171 | #define ECHOK 0000040 | ||
172 | #define ECHONL 0000100 | ||
173 | #define NOFLSH 0000200 | ||
174 | #define TOSTOP 0000400 | ||
175 | #define ECHOCTL 0001000 | ||
176 | #define ECHOPRT 0002000 | ||
177 | #define ECHOKE 0004000 | ||
178 | #define FLUSHO 0010000 | ||
179 | #define PENDIN 0040000 | ||
180 | #define IEXTEN 0100000 | ||
181 | |||
182 | /* tcflow() and TCXONC use these */ | ||
183 | #define TCOOFF 0 | ||
184 | #define TCOON 1 | ||
185 | #define TCIOFF 2 | ||
186 | #define TCION 3 | ||
187 | |||
188 | /* tcflush() and TCFLSH use these */ | ||
189 | #define TCIFLUSH 0 | ||
190 | #define TCOFLUSH 1 | ||
191 | #define TCIOFLUSH 2 | ||
192 | |||
193 | /* tcsetattr uses these */ | ||
194 | #define TCSANOW 0 | ||
195 | #define TCSADRAIN 1 | ||
196 | #define TCSAFLUSH 2 | ||
197 | |||
198 | #endif | ||
diff --git a/include/asm-x86/termbits_64.h b/include/asm-x86/termbits_64.h new file mode 100644 index 000000000000..7405756dd41b --- /dev/null +++ b/include/asm-x86/termbits_64.h | |||
@@ -0,0 +1,198 @@ | |||
1 | #ifndef __ARCH_X8664_TERMBITS_H__ | ||
2 | #define __ARCH_X8664_TERMBITS_H__ | ||
3 | |||
4 | #include <linux/posix_types.h> | ||
5 | |||
6 | typedef unsigned char cc_t; | ||
7 | typedef unsigned int speed_t; | ||
8 | typedef unsigned int tcflag_t; | ||
9 | |||
10 | #define NCCS 19 | ||
11 | struct termios { | ||
12 | tcflag_t c_iflag; /* input mode flags */ | ||
13 | tcflag_t c_oflag; /* output mode flags */ | ||
14 | tcflag_t c_cflag; /* control mode flags */ | ||
15 | tcflag_t c_lflag; /* local mode flags */ | ||
16 | cc_t c_line; /* line discipline */ | ||
17 | cc_t c_cc[NCCS]; /* control characters */ | ||
18 | }; | ||
19 | |||
20 | struct termios2 { | ||
21 | tcflag_t c_iflag; /* input mode flags */ | ||
22 | tcflag_t c_oflag; /* output mode flags */ | ||
23 | tcflag_t c_cflag; /* control mode flags */ | ||
24 | tcflag_t c_lflag; /* local mode flags */ | ||
25 | cc_t c_line; /* line discipline */ | ||
26 | cc_t c_cc[NCCS]; /* control characters */ | ||
27 | speed_t c_ispeed; /* input speed */ | ||
28 | speed_t c_ospeed; /* output speed */ | ||
29 | }; | ||
30 | |||
31 | struct ktermios { | ||
32 | tcflag_t c_iflag; /* input mode flags */ | ||
33 | tcflag_t c_oflag; /* output mode flags */ | ||
34 | tcflag_t c_cflag; /* control mode flags */ | ||
35 | tcflag_t c_lflag; /* local mode flags */ | ||
36 | cc_t c_line; /* line discipline */ | ||
37 | cc_t c_cc[NCCS]; /* control characters */ | ||
38 | speed_t c_ispeed; /* input speed */ | ||
39 | speed_t c_ospeed; /* output speed */ | ||
40 | }; | ||
41 | |||
42 | /* c_cc characters */ | ||
43 | #define VINTR 0 | ||
44 | #define VQUIT 1 | ||
45 | #define VERASE 2 | ||
46 | #define VKILL 3 | ||
47 | #define VEOF 4 | ||
48 | #define VTIME 5 | ||
49 | #define VMIN 6 | ||
50 | #define VSWTC 7 | ||
51 | #define VSTART 8 | ||
52 | #define VSTOP 9 | ||
53 | #define VSUSP 10 | ||
54 | #define VEOL 11 | ||
55 | #define VREPRINT 12 | ||
56 | #define VDISCARD 13 | ||
57 | #define VWERASE 14 | ||
58 | #define VLNEXT 15 | ||
59 | #define VEOL2 16 | ||
60 | |||
61 | /* c_iflag bits */ | ||
62 | #define IGNBRK 0000001 | ||
63 | #define BRKINT 0000002 | ||
64 | #define IGNPAR 0000004 | ||
65 | #define PARMRK 0000010 | ||
66 | #define INPCK 0000020 | ||
67 | #define ISTRIP 0000040 | ||
68 | #define INLCR 0000100 | ||
69 | #define IGNCR 0000200 | ||
70 | #define ICRNL 0000400 | ||
71 | #define IUCLC 0001000 | ||
72 | #define IXON 0002000 | ||
73 | #define IXANY 0004000 | ||
74 | #define IXOFF 0010000 | ||
75 | #define IMAXBEL 0020000 | ||
76 | #define IUTF8 0040000 | ||
77 | |||
78 | /* c_oflag bits */ | ||
79 | #define OPOST 0000001 | ||
80 | #define OLCUC 0000002 | ||
81 | #define ONLCR 0000004 | ||
82 | #define OCRNL 0000010 | ||
83 | #define ONOCR 0000020 | ||
84 | #define ONLRET 0000040 | ||
85 | #define OFILL 0000100 | ||
86 | #define OFDEL 0000200 | ||
87 | #define NLDLY 0000400 | ||
88 | #define NL0 0000000 | ||
89 | #define NL1 0000400 | ||
90 | #define CRDLY 0003000 | ||
91 | #define CR0 0000000 | ||
92 | #define CR1 0001000 | ||
93 | #define CR2 0002000 | ||
94 | #define CR3 0003000 | ||
95 | #define TABDLY 0014000 | ||
96 | #define TAB0 0000000 | ||
97 | #define TAB1 0004000 | ||
98 | #define TAB2 0010000 | ||
99 | #define TAB3 0014000 | ||
100 | #define XTABS 0014000 | ||
101 | #define BSDLY 0020000 | ||
102 | #define BS0 0000000 | ||
103 | #define BS1 0020000 | ||
104 | #define VTDLY 0040000 | ||
105 | #define VT0 0000000 | ||
106 | #define VT1 0040000 | ||
107 | #define FFDLY 0100000 | ||
108 | #define FF0 0000000 | ||
109 | #define FF1 0100000 | ||
110 | |||
111 | /* c_cflag bit meaning */ | ||
112 | #define CBAUD 0010017 | ||
113 | #define B0 0000000 /* hang up */ | ||
114 | #define B50 0000001 | ||
115 | #define B75 0000002 | ||
116 | #define B110 0000003 | ||
117 | #define B134 0000004 | ||
118 | #define B150 0000005 | ||
119 | #define B200 0000006 | ||
120 | #define B300 0000007 | ||
121 | #define B600 0000010 | ||
122 | #define B1200 0000011 | ||
123 | #define B1800 0000012 | ||
124 | #define B2400 0000013 | ||
125 | #define B4800 0000014 | ||
126 | #define B9600 0000015 | ||
127 | #define B19200 0000016 | ||
128 | #define B38400 0000017 | ||
129 | #define EXTA B19200 | ||
130 | #define EXTB B38400 | ||
131 | #define CSIZE 0000060 | ||
132 | #define CS5 0000000 | ||
133 | #define CS6 0000020 | ||
134 | #define CS7 0000040 | ||
135 | #define CS8 0000060 | ||
136 | #define CSTOPB 0000100 | ||
137 | #define CREAD 0000200 | ||
138 | #define PARENB 0000400 | ||
139 | #define PARODD 0001000 | ||
140 | #define HUPCL 0002000 | ||
141 | #define CLOCAL 0004000 | ||
142 | #define CBAUDEX 0010000 | ||
143 | #define BOTHER 0010000 /* non standard rate */ | ||
144 | #define B57600 0010001 | ||
145 | #define B115200 0010002 | ||
146 | #define B230400 0010003 | ||
147 | #define B460800 0010004 | ||
148 | #define B500000 0010005 | ||
149 | #define B576000 0010006 | ||
150 | #define B921600 0010007 | ||
151 | #define B1000000 0010010 | ||
152 | #define B1152000 0010011 | ||
153 | #define B1500000 0010012 | ||
154 | #define B2000000 0010013 | ||
155 | #define B2500000 0010014 | ||
156 | #define B3000000 0010015 | ||
157 | #define B3500000 0010016 | ||
158 | #define B4000000 0010017 | ||
159 | #define CIBAUD 002003600000 /* input baud rate */ | ||
160 | #define CMSPAR 010000000000 /* mark or space (stick) parity */ | ||
161 | #define CRTSCTS 020000000000 /* flow control */ | ||
162 | |||
163 | #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ | ||
164 | |||
165 | /* c_lflag bits */ | ||
166 | #define ISIG 0000001 | ||
167 | #define ICANON 0000002 | ||
168 | #define XCASE 0000004 | ||
169 | #define ECHO 0000010 | ||
170 | #define ECHOE 0000020 | ||
171 | #define ECHOK 0000040 | ||
172 | #define ECHONL 0000100 | ||
173 | #define NOFLSH 0000200 | ||
174 | #define TOSTOP 0000400 | ||
175 | #define ECHOCTL 0001000 | ||
176 | #define ECHOPRT 0002000 | ||
177 | #define ECHOKE 0004000 | ||
178 | #define FLUSHO 0010000 | ||
179 | #define PENDIN 0040000 | ||
180 | #define IEXTEN 0100000 | ||
181 | |||
182 | /* tcflow() and TCXONC use these */ | ||
183 | #define TCOOFF 0 | ||
184 | #define TCOON 1 | ||
185 | #define TCIOFF 2 | ||
186 | #define TCION 3 | ||
187 | |||
188 | /* tcflush() and TCFLSH use these */ | ||
189 | #define TCIFLUSH 0 | ||
190 | #define TCOFLUSH 1 | ||
191 | #define TCIOFLUSH 2 | ||
192 | |||
193 | /* tcsetattr uses these */ | ||
194 | #define TCSANOW 0 | ||
195 | #define TCSADRAIN 1 | ||
196 | #define TCSAFLUSH 2 | ||
197 | |||
198 | #endif | ||
diff --git a/include/asm-x86/termios.h b/include/asm-x86/termios.h new file mode 100644 index 000000000000..a4f4ae20a591 --- /dev/null +++ b/include/asm-x86/termios.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "termios_32.h" | ||
4 | # else | ||
5 | # include "termios_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "termios_32.h" | ||
10 | # else | ||
11 | # include "termios_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/termios_32.h b/include/asm-x86/termios_32.h new file mode 100644 index 000000000000..6fdb2c841b73 --- /dev/null +++ b/include/asm-x86/termios_32.h | |||
@@ -0,0 +1,90 @@ | |||
1 | #ifndef _I386_TERMIOS_H | ||
2 | #define _I386_TERMIOS_H | ||
3 | |||
4 | #include <asm/termbits.h> | ||
5 | #include <asm/ioctls.h> | ||
6 | |||
7 | struct winsize { | ||
8 | unsigned short ws_row; | ||
9 | unsigned short ws_col; | ||
10 | unsigned short ws_xpixel; | ||
11 | unsigned short ws_ypixel; | ||
12 | }; | ||
13 | |||
14 | #define NCC 8 | ||
15 | struct termio { | ||
16 | unsigned short c_iflag; /* input mode flags */ | ||
17 | unsigned short c_oflag; /* output mode flags */ | ||
18 | unsigned short c_cflag; /* control mode flags */ | ||
19 | unsigned short c_lflag; /* local mode flags */ | ||
20 | unsigned char c_line; /* line discipline */ | ||
21 | unsigned char c_cc[NCC]; /* control characters */ | ||
22 | }; | ||
23 | |||
24 | /* modem lines */ | ||
25 | #define TIOCM_LE 0x001 | ||
26 | #define TIOCM_DTR 0x002 | ||
27 | #define TIOCM_RTS 0x004 | ||
28 | #define TIOCM_ST 0x008 | ||
29 | #define TIOCM_SR 0x010 | ||
30 | #define TIOCM_CTS 0x020 | ||
31 | #define TIOCM_CAR 0x040 | ||
32 | #define TIOCM_RNG 0x080 | ||
33 | #define TIOCM_DSR 0x100 | ||
34 | #define TIOCM_CD TIOCM_CAR | ||
35 | #define TIOCM_RI TIOCM_RNG | ||
36 | #define TIOCM_OUT1 0x2000 | ||
37 | #define TIOCM_OUT2 0x4000 | ||
38 | #define TIOCM_LOOP 0x8000 | ||
39 | |||
40 | /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ | ||
41 | |||
42 | #ifdef __KERNEL__ | ||
43 | |||
44 | /* intr=^C quit=^\ erase=del kill=^U | ||
45 | eof=^D vtime=\0 vmin=\1 sxtc=\0 | ||
46 | start=^Q stop=^S susp=^Z eol=\0 | ||
47 | reprint=^R discard=^U werase=^W lnext=^V | ||
48 | eol2=\0 | ||
49 | */ | ||
50 | #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" | ||
51 | |||
52 | /* | ||
53 | * Translate a "termio" structure into a "termios". Ugh. | ||
54 | */ | ||
55 | #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ | ||
56 | unsigned short __tmp; \ | ||
57 | get_user(__tmp,&(termio)->x); \ | ||
58 | *(unsigned short *) &(termios)->x = __tmp; \ | ||
59 | } | ||
60 | |||
61 | #define user_termio_to_kernel_termios(termios, termio) \ | ||
62 | ({ \ | ||
63 | SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ | ||
64 | SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ | ||
65 | SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ | ||
66 | SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ | ||
67 | copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ | ||
68 | }) | ||
69 | |||
70 | /* | ||
71 | * Translate a "termios" structure into a "termio". Ugh. | ||
72 | */ | ||
73 | #define kernel_termios_to_user_termio(termio, termios) \ | ||
74 | ({ \ | ||
75 | put_user((termios)->c_iflag, &(termio)->c_iflag); \ | ||
76 | put_user((termios)->c_oflag, &(termio)->c_oflag); \ | ||
77 | put_user((termios)->c_cflag, &(termio)->c_cflag); \ | ||
78 | put_user((termios)->c_lflag, &(termio)->c_lflag); \ | ||
79 | put_user((termios)->c_line, &(termio)->c_line); \ | ||
80 | copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | ||
81 | }) | ||
82 | |||
83 | #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2)) | ||
84 | #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2)) | ||
85 | #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) | ||
86 | #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) | ||
87 | |||
88 | #endif /* __KERNEL__ */ | ||
89 | |||
90 | #endif /* _I386_TERMIOS_H */ | ||
diff --git a/include/asm-x86/termios_64.h b/include/asm-x86/termios_64.h new file mode 100644 index 000000000000..35ee59b78329 --- /dev/null +++ b/include/asm-x86/termios_64.h | |||
@@ -0,0 +1,90 @@ | |||
1 | #ifndef _X8664_TERMIOS_H | ||
2 | #define _X8664_TERMIOS_H | ||
3 | |||
4 | #include <asm/termbits.h> | ||
5 | #include <asm/ioctls.h> | ||
6 | |||
7 | struct winsize { | ||
8 | unsigned short ws_row; | ||
9 | unsigned short ws_col; | ||
10 | unsigned short ws_xpixel; | ||
11 | unsigned short ws_ypixel; | ||
12 | }; | ||
13 | |||
14 | #define NCC 8 | ||
15 | struct termio { | ||
16 | unsigned short c_iflag; /* input mode flags */ | ||
17 | unsigned short c_oflag; /* output mode flags */ | ||
18 | unsigned short c_cflag; /* control mode flags */ | ||
19 | unsigned short c_lflag; /* local mode flags */ | ||
20 | unsigned char c_line; /* line discipline */ | ||
21 | unsigned char c_cc[NCC]; /* control characters */ | ||
22 | }; | ||
23 | |||
24 | /* modem lines */ | ||
25 | #define TIOCM_LE 0x001 | ||
26 | #define TIOCM_DTR 0x002 | ||
27 | #define TIOCM_RTS 0x004 | ||
28 | #define TIOCM_ST 0x008 | ||
29 | #define TIOCM_SR 0x010 | ||
30 | #define TIOCM_CTS 0x020 | ||
31 | #define TIOCM_CAR 0x040 | ||
32 | #define TIOCM_RNG 0x080 | ||
33 | #define TIOCM_DSR 0x100 | ||
34 | #define TIOCM_CD TIOCM_CAR | ||
35 | #define TIOCM_RI TIOCM_RNG | ||
36 | #define TIOCM_OUT1 0x2000 | ||
37 | #define TIOCM_OUT2 0x4000 | ||
38 | #define TIOCM_LOOP 0x8000 | ||
39 | |||
40 | /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ | ||
41 | |||
42 | #ifdef __KERNEL__ | ||
43 | |||
44 | /* intr=^C quit=^\ erase=del kill=^U | ||
45 | eof=^D vtime=\0 vmin=\1 sxtc=\0 | ||
46 | start=^Q stop=^S susp=^Z eol=\0 | ||
47 | reprint=^R discard=^U werase=^W lnext=^V | ||
48 | eol2=\0 | ||
49 | */ | ||
50 | #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" | ||
51 | |||
52 | /* | ||
53 | * Translate a "termio" structure into a "termios". Ugh. | ||
54 | */ | ||
55 | #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ | ||
56 | unsigned short __tmp; \ | ||
57 | get_user(__tmp,&(termio)->x); \ | ||
58 | *(unsigned short *) &(termios)->x = __tmp; \ | ||
59 | } | ||
60 | |||
61 | #define user_termio_to_kernel_termios(termios, termio) \ | ||
62 | ({ \ | ||
63 | SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ | ||
64 | SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ | ||
65 | SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ | ||
66 | SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ | ||
67 | copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ | ||
68 | }) | ||
69 | |||
70 | /* | ||
71 | * Translate a "termios" structure into a "termio". Ugh. | ||
72 | */ | ||
73 | #define kernel_termios_to_user_termio(termio, termios) \ | ||
74 | ({ \ | ||
75 | put_user((termios)->c_iflag, &(termio)->c_iflag); \ | ||
76 | put_user((termios)->c_oflag, &(termio)->c_oflag); \ | ||
77 | put_user((termios)->c_cflag, &(termio)->c_cflag); \ | ||
78 | put_user((termios)->c_lflag, &(termio)->c_lflag); \ | ||
79 | put_user((termios)->c_line, &(termio)->c_line); \ | ||
80 | copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | ||
81 | }) | ||
82 | |||
83 | #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2)) | ||
84 | #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2)) | ||
85 | #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) | ||
86 | #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) | ||
87 | |||
88 | #endif /* __KERNEL__ */ | ||
89 | |||
90 | #endif /* _X8664_TERMIOS_H */ | ||
diff --git a/include/asm-x86/therm_throt.h b/include/asm-x86/therm_throt.h new file mode 100644 index 000000000000..399bf6026b16 --- /dev/null +++ b/include/asm-x86/therm_throt.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __ASM_I386_THERM_THROT_H__ | ||
2 | #define __ASM_I386_THERM_THROT_H__ 1 | ||
3 | |||
4 | #include <asm/atomic.h> | ||
5 | |||
6 | extern atomic_t therm_throt_en; | ||
7 | int therm_throt_process(int curr); | ||
8 | |||
9 | #endif /* __ASM_I386_THERM_THROT_H__ */ | ||
diff --git a/include/asm-x86/thread_info.h b/include/asm-x86/thread_info.h new file mode 100644 index 000000000000..d5fd12f2abdb --- /dev/null +++ b/include/asm-x86/thread_info.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "thread_info_32.h" | ||
3 | #else | ||
4 | # include "thread_info_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/thread_info_32.h b/include/asm-x86/thread_info_32.h new file mode 100644 index 000000000000..22a8cbcd35e2 --- /dev/null +++ b/include/asm-x86/thread_info_32.h | |||
@@ -0,0 +1,180 @@ | |||
1 | /* thread_info.h: i386 low-level thread information | ||
2 | * | ||
3 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | ||
4 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | ||
5 | */ | ||
6 | |||
7 | #ifndef _ASM_THREAD_INFO_H | ||
8 | #define _ASM_THREAD_INFO_H | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | #include <linux/compiler.h> | ||
13 | #include <asm/page.h> | ||
14 | |||
15 | #ifndef __ASSEMBLY__ | ||
16 | #include <asm/processor.h> | ||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * low level task data that entry.S needs immediate access to | ||
21 | * - this struct should fit entirely inside of one cache line | ||
22 | * - this struct shares the supervisor stack pages | ||
23 | * - if the contents of this structure are changed, the assembly constants must also be changed | ||
24 | */ | ||
25 | #ifndef __ASSEMBLY__ | ||
26 | |||
27 | struct thread_info { | ||
28 | struct task_struct *task; /* main task structure */ | ||
29 | struct exec_domain *exec_domain; /* execution domain */ | ||
30 | unsigned long flags; /* low level flags */ | ||
31 | unsigned long status; /* thread-synchronous flags */ | ||
32 | __u32 cpu; /* current CPU */ | ||
33 | int preempt_count; /* 0 => preemptable, <0 => BUG */ | ||
34 | |||
35 | |||
36 | mm_segment_t addr_limit; /* thread address space: | ||
37 | 0-0xBFFFFFFF for user-thead | ||
38 | 0-0xFFFFFFFF for kernel-thread | ||
39 | */ | ||
40 | void *sysenter_return; | ||
41 | struct restart_block restart_block; | ||
42 | |||
43 | unsigned long previous_esp; /* ESP of the previous stack in case | ||
44 | of nested (IRQ) stacks | ||
45 | */ | ||
46 | __u8 supervisor_stack[0]; | ||
47 | }; | ||
48 | |||
49 | #else /* !__ASSEMBLY__ */ | ||
50 | |||
51 | #include <asm/asm-offsets.h> | ||
52 | |||
53 | #endif | ||
54 | |||
55 | #define PREEMPT_ACTIVE 0x10000000 | ||
56 | #ifdef CONFIG_4KSTACKS | ||
57 | #define THREAD_SIZE (4096) | ||
58 | #else | ||
59 | #define THREAD_SIZE (8192) | ||
60 | #endif | ||
61 | |||
62 | #define STACK_WARN (THREAD_SIZE/8) | ||
63 | /* | ||
64 | * macros/functions for gaining access to the thread information structure | ||
65 | * | ||
66 | * preempt_count needs to be 1 initially, until the scheduler is functional. | ||
67 | */ | ||
68 | #ifndef __ASSEMBLY__ | ||
69 | |||
70 | #define INIT_THREAD_INFO(tsk) \ | ||
71 | { \ | ||
72 | .task = &tsk, \ | ||
73 | .exec_domain = &default_exec_domain, \ | ||
74 | .flags = 0, \ | ||
75 | .cpu = 0, \ | ||
76 | .preempt_count = 1, \ | ||
77 | .addr_limit = KERNEL_DS, \ | ||
78 | .restart_block = { \ | ||
79 | .fn = do_no_restart_syscall, \ | ||
80 | }, \ | ||
81 | } | ||
82 | |||
83 | #define init_thread_info (init_thread_union.thread_info) | ||
84 | #define init_stack (init_thread_union.stack) | ||
85 | |||
86 | |||
87 | /* how to get the current stack pointer from C */ | ||
88 | register unsigned long current_stack_pointer asm("esp") __attribute_used__; | ||
89 | |||
90 | /* how to get the thread information struct from C */ | ||
91 | static inline struct thread_info *current_thread_info(void) | ||
92 | { | ||
93 | return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1)); | ||
94 | } | ||
95 | |||
96 | /* thread information allocation */ | ||
97 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
98 | #define alloc_thread_info(tsk) ((struct thread_info *) \ | ||
99 | __get_free_pages(GFP_KERNEL| __GFP_ZERO, get_order(THREAD_SIZE))) | ||
100 | #else | ||
101 | #define alloc_thread_info(tsk) ((struct thread_info *) \ | ||
102 | __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE))) | ||
103 | #endif | ||
104 | |||
105 | #define free_thread_info(info) free_pages((unsigned long)(info), get_order(THREAD_SIZE)) | ||
106 | |||
107 | #else /* !__ASSEMBLY__ */ | ||
108 | |||
109 | /* how to get the thread information struct from ASM */ | ||
110 | #define GET_THREAD_INFO(reg) \ | ||
111 | movl $-THREAD_SIZE, reg; \ | ||
112 | andl %esp, reg | ||
113 | |||
114 | /* use this one if reg already contains %esp */ | ||
115 | #define GET_THREAD_INFO_WITH_ESP(reg) \ | ||
116 | andl $-THREAD_SIZE, reg | ||
117 | |||
118 | #endif | ||
119 | |||
120 | /* | ||
121 | * thread information flags | ||
122 | * - these are process state flags that various assembly files may need to access | ||
123 | * - pending work-to-be-done flags are in LSW | ||
124 | * - other flags in MSW | ||
125 | */ | ||
126 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | ||
127 | #define TIF_SIGPENDING 1 /* signal pending */ | ||
128 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ | ||
129 | #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ | ||
130 | #define TIF_IRET 4 /* return with iret */ | ||
131 | #define TIF_SYSCALL_EMU 5 /* syscall emulation active */ | ||
132 | #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ | ||
133 | #define TIF_SECCOMP 7 /* secure computing */ | ||
134 | #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */ | ||
135 | #define TIF_MEMDIE 16 | ||
136 | #define TIF_DEBUG 17 /* uses debug registers */ | ||
137 | #define TIF_IO_BITMAP 18 /* uses I/O bitmap */ | ||
138 | #define TIF_FREEZE 19 /* is freezing for suspend */ | ||
139 | #define TIF_NOTSC 20 /* TSC is not accessible in userland */ | ||
140 | |||
141 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | ||
142 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) | ||
143 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | ||
144 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | ||
145 | #define _TIF_IRET (1<<TIF_IRET) | ||
146 | #define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU) | ||
147 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | ||
148 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | ||
149 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) | ||
150 | #define _TIF_DEBUG (1<<TIF_DEBUG) | ||
151 | #define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) | ||
152 | #define _TIF_FREEZE (1<<TIF_FREEZE) | ||
153 | #define _TIF_NOTSC (1<<TIF_NOTSC) | ||
154 | |||
155 | /* work to do on interrupt/exception return */ | ||
156 | #define _TIF_WORK_MASK \ | ||
157 | (0x0000FFFF & ~(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ | ||
158 | _TIF_SECCOMP | _TIF_SYSCALL_EMU)) | ||
159 | /* work to do on any return to u-space */ | ||
160 | #define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) | ||
161 | |||
162 | /* flags to check in __switch_to() */ | ||
163 | #define _TIF_WORK_CTXSW_NEXT (_TIF_IO_BITMAP | _TIF_NOTSC | _TIF_DEBUG) | ||
164 | #define _TIF_WORK_CTXSW_PREV (_TIF_IO_BITMAP | _TIF_NOTSC) | ||
165 | |||
166 | /* | ||
167 | * Thread-synchronous status. | ||
168 | * | ||
169 | * This is different from the flags in that nobody else | ||
170 | * ever touches our thread-synchronous status, so we don't | ||
171 | * have to worry about atomic accesses. | ||
172 | */ | ||
173 | #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ | ||
174 | #define TS_POLLING 0x0002 /* True if in idle loop and not sleeping */ | ||
175 | |||
176 | #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) | ||
177 | |||
178 | #endif /* __KERNEL__ */ | ||
179 | |||
180 | #endif /* _ASM_THREAD_INFO_H */ | ||
diff --git a/include/asm-x86/thread_info_64.h b/include/asm-x86/thread_info_64.h new file mode 100644 index 000000000000..beae2bfb62ca --- /dev/null +++ b/include/asm-x86/thread_info_64.h | |||
@@ -0,0 +1,169 @@ | |||
1 | /* thread_info.h: x86_64 low-level thread information | ||
2 | * | ||
3 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | ||
4 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | ||
5 | */ | ||
6 | |||
7 | #ifndef _ASM_THREAD_INFO_H | ||
8 | #define _ASM_THREAD_INFO_H | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | #include <asm/page.h> | ||
13 | #include <asm/types.h> | ||
14 | #include <asm/pda.h> | ||
15 | |||
16 | /* | ||
17 | * low level task data that entry.S needs immediate access to | ||
18 | * - this struct should fit entirely inside of one cache line | ||
19 | * - this struct shares the supervisor stack pages | ||
20 | */ | ||
21 | #ifndef __ASSEMBLY__ | ||
22 | struct task_struct; | ||
23 | struct exec_domain; | ||
24 | #include <asm/mmsegment.h> | ||
25 | |||
26 | struct thread_info { | ||
27 | struct task_struct *task; /* main task structure */ | ||
28 | struct exec_domain *exec_domain; /* execution domain */ | ||
29 | __u32 flags; /* low level flags */ | ||
30 | __u32 status; /* thread synchronous flags */ | ||
31 | __u32 cpu; /* current CPU */ | ||
32 | int preempt_count; /* 0 => preemptable, <0 => BUG */ | ||
33 | |||
34 | mm_segment_t addr_limit; | ||
35 | struct restart_block restart_block; | ||
36 | }; | ||
37 | #endif | ||
38 | |||
39 | /* | ||
40 | * macros/functions for gaining access to the thread information structure | ||
41 | * preempt_count needs to be 1 initially, until the scheduler is functional. | ||
42 | */ | ||
43 | #ifndef __ASSEMBLY__ | ||
44 | #define INIT_THREAD_INFO(tsk) \ | ||
45 | { \ | ||
46 | .task = &tsk, \ | ||
47 | .exec_domain = &default_exec_domain, \ | ||
48 | .flags = 0, \ | ||
49 | .cpu = 0, \ | ||
50 | .preempt_count = 1, \ | ||
51 | .addr_limit = KERNEL_DS, \ | ||
52 | .restart_block = { \ | ||
53 | .fn = do_no_restart_syscall, \ | ||
54 | }, \ | ||
55 | } | ||
56 | |||
57 | #define init_thread_info (init_thread_union.thread_info) | ||
58 | #define init_stack (init_thread_union.stack) | ||
59 | |||
60 | static inline struct thread_info *current_thread_info(void) | ||
61 | { | ||
62 | struct thread_info *ti; | ||
63 | ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET - THREAD_SIZE); | ||
64 | return ti; | ||
65 | } | ||
66 | |||
67 | /* do not use in interrupt context */ | ||
68 | static inline struct thread_info *stack_thread_info(void) | ||
69 | { | ||
70 | struct thread_info *ti; | ||
71 | __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1))); | ||
72 | return ti; | ||
73 | } | ||
74 | |||
75 | /* thread information allocation */ | ||
76 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
77 | #define alloc_thread_info(tsk) \ | ||
78 | ({ \ | ||
79 | struct thread_info *ret; \ | ||
80 | \ | ||
81 | ret = ((struct thread_info *) __get_free_pages(GFP_KERNEL,THREAD_ORDER)); \ | ||
82 | if (ret) \ | ||
83 | memset(ret, 0, THREAD_SIZE); \ | ||
84 | ret; \ | ||
85 | }) | ||
86 | #else | ||
87 | #define alloc_thread_info(tsk) \ | ||
88 | ((struct thread_info *) __get_free_pages(GFP_KERNEL,THREAD_ORDER)) | ||
89 | #endif | ||
90 | |||
91 | #define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER) | ||
92 | |||
93 | #else /* !__ASSEMBLY__ */ | ||
94 | |||
95 | /* how to get the thread information struct from ASM */ | ||
96 | #define GET_THREAD_INFO(reg) \ | ||
97 | movq %gs:pda_kernelstack,reg ; \ | ||
98 | subq $(THREAD_SIZE-PDA_STACKOFFSET),reg | ||
99 | |||
100 | #endif | ||
101 | |||
102 | /* | ||
103 | * thread information flags | ||
104 | * - these are process state flags that various assembly files may need to access | ||
105 | * - pending work-to-be-done flags are in LSW | ||
106 | * - other flags in MSW | ||
107 | * Warning: layout of LSW is hardcoded in entry.S | ||
108 | */ | ||
109 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | ||
110 | #define TIF_SIGPENDING 2 /* signal pending */ | ||
111 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | ||
112 | #define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/ | ||
113 | #define TIF_IRET 5 /* force IRET */ | ||
114 | #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ | ||
115 | #define TIF_SECCOMP 8 /* secure computing */ | ||
116 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */ | ||
117 | #define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */ | ||
118 | /* 16 free */ | ||
119 | #define TIF_IA32 17 /* 32bit process */ | ||
120 | #define TIF_FORK 18 /* ret_from_fork */ | ||
121 | #define TIF_ABI_PENDING 19 | ||
122 | #define TIF_MEMDIE 20 | ||
123 | #define TIF_DEBUG 21 /* uses debug registers */ | ||
124 | #define TIF_IO_BITMAP 22 /* uses I/O bitmap */ | ||
125 | #define TIF_FREEZE 23 /* is freezing for suspend */ | ||
126 | |||
127 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | ||
128 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) | ||
129 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | ||
130 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | ||
131 | #define _TIF_IRET (1<<TIF_IRET) | ||
132 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | ||
133 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | ||
134 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) | ||
135 | #define _TIF_MCE_NOTIFY (1<<TIF_MCE_NOTIFY) | ||
136 | #define _TIF_IA32 (1<<TIF_IA32) | ||
137 | #define _TIF_FORK (1<<TIF_FORK) | ||
138 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) | ||
139 | #define _TIF_DEBUG (1<<TIF_DEBUG) | ||
140 | #define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) | ||
141 | #define _TIF_FREEZE (1<<TIF_FREEZE) | ||
142 | |||
143 | /* work to do on interrupt/exception return */ | ||
144 | #define _TIF_WORK_MASK \ | ||
145 | (0x0000FFFF & ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP|_TIF_SECCOMP)) | ||
146 | /* work to do on any return to user space */ | ||
147 | #define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) | ||
148 | |||
149 | /* flags to check in __switch_to() */ | ||
150 | #define _TIF_WORK_CTXSW (_TIF_DEBUG|_TIF_IO_BITMAP) | ||
151 | |||
152 | #define PREEMPT_ACTIVE 0x10000000 | ||
153 | |||
154 | /* | ||
155 | * Thread-synchronous status. | ||
156 | * | ||
157 | * This is different from the flags in that nobody else | ||
158 | * ever touches our thread-synchronous status, so we don't | ||
159 | * have to worry about atomic accesses. | ||
160 | */ | ||
161 | #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ | ||
162 | #define TS_COMPAT 0x0002 /* 32bit syscall active */ | ||
163 | #define TS_POLLING 0x0004 /* true if in idle loop and not sleeping */ | ||
164 | |||
165 | #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) | ||
166 | |||
167 | #endif /* __KERNEL__ */ | ||
168 | |||
169 | #endif /* _ASM_THREAD_INFO_H */ | ||
diff --git a/include/asm-x86/time.h b/include/asm-x86/time.h new file mode 100644 index 000000000000..eac011366dc2 --- /dev/null +++ b/include/asm-x86/time.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _ASMi386_TIME_H | ||
2 | #define _ASMi386_TIME_H | ||
3 | |||
4 | #include <linux/efi.h> | ||
5 | #include "mach_time.h" | ||
6 | |||
7 | static inline unsigned long native_get_wallclock(void) | ||
8 | { | ||
9 | unsigned long retval; | ||
10 | |||
11 | if (efi_enabled) | ||
12 | retval = efi_get_time(); | ||
13 | else | ||
14 | retval = mach_get_cmos_time(); | ||
15 | |||
16 | return retval; | ||
17 | } | ||
18 | |||
19 | static inline int native_set_wallclock(unsigned long nowtime) | ||
20 | { | ||
21 | int retval; | ||
22 | |||
23 | if (efi_enabled) | ||
24 | retval = efi_set_rtc_mmss(nowtime); | ||
25 | else | ||
26 | retval = mach_set_rtc_mmss(nowtime); | ||
27 | |||
28 | return retval; | ||
29 | } | ||
30 | |||
31 | extern void (*late_time_init)(void); | ||
32 | extern void hpet_time_init(void); | ||
33 | |||
34 | #ifdef CONFIG_PARAVIRT | ||
35 | #include <asm/paravirt.h> | ||
36 | #else /* !CONFIG_PARAVIRT */ | ||
37 | |||
38 | #define get_wallclock() native_get_wallclock() | ||
39 | #define set_wallclock(x) native_set_wallclock(x) | ||
40 | #define choose_time_init() hpet_time_init | ||
41 | |||
42 | #endif /* CONFIG_PARAVIRT */ | ||
43 | |||
44 | #endif | ||
diff --git a/include/asm-x86/timer.h b/include/asm-x86/timer.h new file mode 100644 index 000000000000..0db7e994fb8b --- /dev/null +++ b/include/asm-x86/timer.h | |||
@@ -0,0 +1,50 @@ | |||
1 | #ifndef _ASMi386_TIMER_H | ||
2 | #define _ASMi386_TIMER_H | ||
3 | #include <linux/init.h> | ||
4 | #include <linux/pm.h> | ||
5 | |||
6 | #define TICK_SIZE (tick_nsec / 1000) | ||
7 | |||
8 | unsigned long long native_sched_clock(void); | ||
9 | unsigned long native_calculate_cpu_khz(void); | ||
10 | |||
11 | extern int timer_ack; | ||
12 | extern int no_timer_check; | ||
13 | extern int recalibrate_cpu_khz(void); | ||
14 | |||
15 | #ifndef CONFIG_PARAVIRT | ||
16 | #define calculate_cpu_khz() native_calculate_cpu_khz() | ||
17 | #endif | ||
18 | |||
19 | /* Accellerators for sched_clock() | ||
20 | * convert from cycles(64bits) => nanoseconds (64bits) | ||
21 | * basic equation: | ||
22 | * ns = cycles / (freq / ns_per_sec) | ||
23 | * ns = cycles * (ns_per_sec / freq) | ||
24 | * ns = cycles * (10^9 / (cpu_khz * 10^3)) | ||
25 | * ns = cycles * (10^6 / cpu_khz) | ||
26 | * | ||
27 | * Then we use scaling math (suggested by george@mvista.com) to get: | ||
28 | * ns = cycles * (10^6 * SC / cpu_khz) / SC | ||
29 | * ns = cycles * cyc2ns_scale / SC | ||
30 | * | ||
31 | * And since SC is a constant power of two, we can convert the div | ||
32 | * into a shift. | ||
33 | * | ||
34 | * We can use khz divisor instead of mhz to keep a better percision, since | ||
35 | * cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits. | ||
36 | * (mathieu.desnoyers@polymtl.ca) | ||
37 | * | ||
38 | * -johnstul@us.ibm.com "math is hard, lets go shopping!" | ||
39 | */ | ||
40 | extern unsigned long cyc2ns_scale __read_mostly; | ||
41 | |||
42 | #define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ | ||
43 | |||
44 | static inline unsigned long long cycles_2_ns(unsigned long long cyc) | ||
45 | { | ||
46 | return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR; | ||
47 | } | ||
48 | |||
49 | |||
50 | #endif | ||
diff --git a/include/asm-x86/timex.h b/include/asm-x86/timex.h new file mode 100644 index 000000000000..d01c18cfccef --- /dev/null +++ b/include/asm-x86/timex.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "timex_32.h" | ||
3 | #else | ||
4 | # include "timex_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/timex_32.h b/include/asm-x86/timex_32.h new file mode 100644 index 000000000000..3666044409f0 --- /dev/null +++ b/include/asm-x86/timex_32.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/timex.h | ||
3 | * | ||
4 | * i386 architecture timex specifications | ||
5 | */ | ||
6 | #ifndef _ASMi386_TIMEX_H | ||
7 | #define _ASMi386_TIMEX_H | ||
8 | |||
9 | #include <asm/processor.h> | ||
10 | #include <asm/tsc.h> | ||
11 | |||
12 | #ifdef CONFIG_X86_ELAN | ||
13 | # define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */ | ||
14 | #else | ||
15 | # define CLOCK_TICK_RATE 1193182 /* Underlying HZ */ | ||
16 | #endif | ||
17 | |||
18 | |||
19 | extern int read_current_timer(unsigned long *timer_value); | ||
20 | #define ARCH_HAS_READ_CURRENT_TIMER 1 | ||
21 | |||
22 | #endif | ||
diff --git a/include/asm-x86/timex_64.h b/include/asm-x86/timex_64.h new file mode 100644 index 000000000000..6ed21f44d308 --- /dev/null +++ b/include/asm-x86/timex_64.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * linux/include/asm-x86_64/timex.h | ||
3 | * | ||
4 | * x86-64 architecture timex specifications | ||
5 | */ | ||
6 | #ifndef _ASMx8664_TIMEX_H | ||
7 | #define _ASMx8664_TIMEX_H | ||
8 | |||
9 | #include <asm/8253pit.h> | ||
10 | #include <asm/msr.h> | ||
11 | #include <asm/vsyscall.h> | ||
12 | #include <asm/system.h> | ||
13 | #include <asm/processor.h> | ||
14 | #include <asm/tsc.h> | ||
15 | #include <linux/compiler.h> | ||
16 | |||
17 | #define CLOCK_TICK_RATE PIT_TICK_RATE /* Underlying HZ */ | ||
18 | |||
19 | extern int read_current_timer(unsigned long *timer_value); | ||
20 | #define ARCH_HAS_READ_CURRENT_TIMER 1 | ||
21 | |||
22 | #define USEC_PER_TICK (USEC_PER_SEC / HZ) | ||
23 | #define NSEC_PER_TICK (NSEC_PER_SEC / HZ) | ||
24 | #define FSEC_PER_TICK (FSEC_PER_SEC / HZ) | ||
25 | |||
26 | #define NS_SCALE 10 /* 2^10, carefully chosen */ | ||
27 | #define US_SCALE 32 /* 2^32, arbitralrily chosen */ | ||
28 | |||
29 | extern void mark_tsc_unstable(char *msg); | ||
30 | extern void set_cyc2ns_scale(unsigned long khz); | ||
31 | #endif | ||
diff --git a/include/asm-x86/tlb.h b/include/asm-x86/tlb.h new file mode 100644 index 000000000000..7d55c3762b43 --- /dev/null +++ b/include/asm-x86/tlb.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "tlb_32.h" | ||
3 | #else | ||
4 | # include "tlb_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/tlb_32.h b/include/asm-x86/tlb_32.h new file mode 100644 index 000000000000..c006c5c92bea --- /dev/null +++ b/include/asm-x86/tlb_32.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _I386_TLB_H | ||
2 | #define _I386_TLB_H | ||
3 | |||
4 | /* | ||
5 | * x86 doesn't need any special per-pte or | ||
6 | * per-vma handling.. | ||
7 | */ | ||
8 | #define tlb_start_vma(tlb, vma) do { } while (0) | ||
9 | #define tlb_end_vma(tlb, vma) do { } while (0) | ||
10 | #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) | ||
11 | |||
12 | /* | ||
13 | * .. because we flush the whole mm when it | ||
14 | * fills up. | ||
15 | */ | ||
16 | #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) | ||
17 | |||
18 | #include <asm-generic/tlb.h> | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-x86/tlb_64.h b/include/asm-x86/tlb_64.h new file mode 100644 index 000000000000..cd4c3c590a0e --- /dev/null +++ b/include/asm-x86/tlb_64.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef TLB_H | ||
2 | #define TLB_H 1 | ||
3 | |||
4 | |||
5 | #define tlb_start_vma(tlb, vma) do { } while (0) | ||
6 | #define tlb_end_vma(tlb, vma) do { } while (0) | ||
7 | #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) | ||
8 | |||
9 | #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) | ||
10 | |||
11 | #include <asm-generic/tlb.h> | ||
12 | |||
13 | #endif | ||
diff --git a/include/asm-x86/tlbflush.h b/include/asm-x86/tlbflush.h new file mode 100644 index 000000000000..9af4cc83a1af --- /dev/null +++ b/include/asm-x86/tlbflush.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "tlbflush_32.h" | ||
3 | #else | ||
4 | # include "tlbflush_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/tlbflush_32.h b/include/asm-x86/tlbflush_32.h new file mode 100644 index 000000000000..a50fa6741486 --- /dev/null +++ b/include/asm-x86/tlbflush_32.h | |||
@@ -0,0 +1,175 @@ | |||
1 | #ifndef _I386_TLBFLUSH_H | ||
2 | #define _I386_TLBFLUSH_H | ||
3 | |||
4 | #include <linux/mm.h> | ||
5 | #include <asm/processor.h> | ||
6 | |||
7 | #ifdef CONFIG_PARAVIRT | ||
8 | #include <asm/paravirt.h> | ||
9 | #else | ||
10 | #define __flush_tlb() __native_flush_tlb() | ||
11 | #define __flush_tlb_global() __native_flush_tlb_global() | ||
12 | #define __flush_tlb_single(addr) __native_flush_tlb_single(addr) | ||
13 | #endif | ||
14 | |||
15 | #define __native_flush_tlb() \ | ||
16 | do { \ | ||
17 | unsigned int tmpreg; \ | ||
18 | \ | ||
19 | __asm__ __volatile__( \ | ||
20 | "movl %%cr3, %0; \n" \ | ||
21 | "movl %0, %%cr3; # flush TLB \n" \ | ||
22 | : "=r" (tmpreg) \ | ||
23 | :: "memory"); \ | ||
24 | } while (0) | ||
25 | |||
26 | /* | ||
27 | * Global pages have to be flushed a bit differently. Not a real | ||
28 | * performance problem because this does not happen often. | ||
29 | */ | ||
30 | #define __native_flush_tlb_global() \ | ||
31 | do { \ | ||
32 | unsigned int tmpreg, cr4, cr4_orig; \ | ||
33 | \ | ||
34 | __asm__ __volatile__( \ | ||
35 | "movl %%cr4, %2; # turn off PGE \n" \ | ||
36 | "movl %2, %1; \n" \ | ||
37 | "andl %3, %1; \n" \ | ||
38 | "movl %1, %%cr4; \n" \ | ||
39 | "movl %%cr3, %0; \n" \ | ||
40 | "movl %0, %%cr3; # flush TLB \n" \ | ||
41 | "movl %2, %%cr4; # turn PGE back on \n" \ | ||
42 | : "=&r" (tmpreg), "=&r" (cr4), "=&r" (cr4_orig) \ | ||
43 | : "i" (~X86_CR4_PGE) \ | ||
44 | : "memory"); \ | ||
45 | } while (0) | ||
46 | |||
47 | #define __native_flush_tlb_single(addr) \ | ||
48 | __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory") | ||
49 | |||
50 | # define __flush_tlb_all() \ | ||
51 | do { \ | ||
52 | if (cpu_has_pge) \ | ||
53 | __flush_tlb_global(); \ | ||
54 | else \ | ||
55 | __flush_tlb(); \ | ||
56 | } while (0) | ||
57 | |||
58 | #define cpu_has_invlpg (boot_cpu_data.x86 > 3) | ||
59 | |||
60 | #ifdef CONFIG_X86_INVLPG | ||
61 | # define __flush_tlb_one(addr) __flush_tlb_single(addr) | ||
62 | #else | ||
63 | # define __flush_tlb_one(addr) \ | ||
64 | do { \ | ||
65 | if (cpu_has_invlpg) \ | ||
66 | __flush_tlb_single(addr); \ | ||
67 | else \ | ||
68 | __flush_tlb(); \ | ||
69 | } while (0) | ||
70 | #endif | ||
71 | |||
72 | /* | ||
73 | * TLB flushing: | ||
74 | * | ||
75 | * - flush_tlb() flushes the current mm struct TLBs | ||
76 | * - flush_tlb_all() flushes all processes TLBs | ||
77 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's | ||
78 | * - flush_tlb_page(vma, vmaddr) flushes one page | ||
79 | * - flush_tlb_range(vma, start, end) flushes a range of pages | ||
80 | * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages | ||
81 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables | ||
82 | * - flush_tlb_others(cpumask, mm, va) flushes a TLBs on other cpus | ||
83 | * | ||
84 | * ..but the i386 has somewhat limited tlb flushing capabilities, | ||
85 | * and page-granular flushes are available only on i486 and up. | ||
86 | */ | ||
87 | |||
88 | #define TLB_FLUSH_ALL 0xffffffff | ||
89 | |||
90 | |||
91 | #ifndef CONFIG_SMP | ||
92 | |||
93 | #include <linux/sched.h> | ||
94 | |||
95 | #define flush_tlb() __flush_tlb() | ||
96 | #define flush_tlb_all() __flush_tlb_all() | ||
97 | #define local_flush_tlb() __flush_tlb() | ||
98 | |||
99 | static inline void flush_tlb_mm(struct mm_struct *mm) | ||
100 | { | ||
101 | if (mm == current->active_mm) | ||
102 | __flush_tlb(); | ||
103 | } | ||
104 | |||
105 | static inline void flush_tlb_page(struct vm_area_struct *vma, | ||
106 | unsigned long addr) | ||
107 | { | ||
108 | if (vma->vm_mm == current->active_mm) | ||
109 | __flush_tlb_one(addr); | ||
110 | } | ||
111 | |||
112 | static inline void flush_tlb_range(struct vm_area_struct *vma, | ||
113 | unsigned long start, unsigned long end) | ||
114 | { | ||
115 | if (vma->vm_mm == current->active_mm) | ||
116 | __flush_tlb(); | ||
117 | } | ||
118 | |||
119 | static inline void native_flush_tlb_others(const cpumask_t *cpumask, | ||
120 | struct mm_struct *mm, unsigned long va) | ||
121 | { | ||
122 | } | ||
123 | |||
124 | #else /* SMP */ | ||
125 | |||
126 | #include <asm/smp.h> | ||
127 | |||
128 | #define local_flush_tlb() \ | ||
129 | __flush_tlb() | ||
130 | |||
131 | extern void flush_tlb_all(void); | ||
132 | extern void flush_tlb_current_task(void); | ||
133 | extern void flush_tlb_mm(struct mm_struct *); | ||
134 | extern void flush_tlb_page(struct vm_area_struct *, unsigned long); | ||
135 | |||
136 | #define flush_tlb() flush_tlb_current_task() | ||
137 | |||
138 | static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end) | ||
139 | { | ||
140 | flush_tlb_mm(vma->vm_mm); | ||
141 | } | ||
142 | |||
143 | void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm, | ||
144 | unsigned long va); | ||
145 | |||
146 | #define TLBSTATE_OK 1 | ||
147 | #define TLBSTATE_LAZY 2 | ||
148 | |||
149 | struct tlb_state | ||
150 | { | ||
151 | struct mm_struct *active_mm; | ||
152 | int state; | ||
153 | char __cacheline_padding[L1_CACHE_BYTES-8]; | ||
154 | }; | ||
155 | DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate); | ||
156 | #endif /* SMP */ | ||
157 | |||
158 | #ifndef CONFIG_PARAVIRT | ||
159 | #define flush_tlb_others(mask, mm, va) \ | ||
160 | native_flush_tlb_others(&mask, mm, va) | ||
161 | #endif | ||
162 | |||
163 | static inline void flush_tlb_kernel_range(unsigned long start, | ||
164 | unsigned long end) | ||
165 | { | ||
166 | flush_tlb_all(); | ||
167 | } | ||
168 | |||
169 | static inline void flush_tlb_pgtables(struct mm_struct *mm, | ||
170 | unsigned long start, unsigned long end) | ||
171 | { | ||
172 | /* i386 does not keep any page table caches in TLB */ | ||
173 | } | ||
174 | |||
175 | #endif /* _I386_TLBFLUSH_H */ | ||
diff --git a/include/asm-x86/tlbflush_64.h b/include/asm-x86/tlbflush_64.h new file mode 100644 index 000000000000..888eb4abdd07 --- /dev/null +++ b/include/asm-x86/tlbflush_64.h | |||
@@ -0,0 +1,109 @@ | |||
1 | #ifndef _X8664_TLBFLUSH_H | ||
2 | #define _X8664_TLBFLUSH_H | ||
3 | |||
4 | #include <linux/mm.h> | ||
5 | #include <linux/sched.h> | ||
6 | #include <asm/processor.h> | ||
7 | #include <asm/system.h> | ||
8 | |||
9 | static inline void __flush_tlb(void) | ||
10 | { | ||
11 | write_cr3(read_cr3()); | ||
12 | } | ||
13 | |||
14 | static inline void __flush_tlb_all(void) | ||
15 | { | ||
16 | unsigned long cr4 = read_cr4(); | ||
17 | write_cr4(cr4 & ~X86_CR4_PGE); /* clear PGE */ | ||
18 | write_cr4(cr4); /* write old PGE again and flush TLBs */ | ||
19 | } | ||
20 | |||
21 | #define __flush_tlb_one(addr) \ | ||
22 | __asm__ __volatile__("invlpg (%0)" :: "r" (addr) : "memory") | ||
23 | |||
24 | |||
25 | /* | ||
26 | * TLB flushing: | ||
27 | * | ||
28 | * - flush_tlb() flushes the current mm struct TLBs | ||
29 | * - flush_tlb_all() flushes all processes TLBs | ||
30 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's | ||
31 | * - flush_tlb_page(vma, vmaddr) flushes one page | ||
32 | * - flush_tlb_range(vma, start, end) flushes a range of pages | ||
33 | * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages | ||
34 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables | ||
35 | * | ||
36 | * x86-64 can only flush individual pages or full VMs. For a range flush | ||
37 | * we always do the full VM. Might be worth trying if for a small | ||
38 | * range a few INVLPGs in a row are a win. | ||
39 | */ | ||
40 | |||
41 | #ifndef CONFIG_SMP | ||
42 | |||
43 | #define flush_tlb() __flush_tlb() | ||
44 | #define flush_tlb_all() __flush_tlb_all() | ||
45 | #define local_flush_tlb() __flush_tlb() | ||
46 | |||
47 | static inline void flush_tlb_mm(struct mm_struct *mm) | ||
48 | { | ||
49 | if (mm == current->active_mm) | ||
50 | __flush_tlb(); | ||
51 | } | ||
52 | |||
53 | static inline void flush_tlb_page(struct vm_area_struct *vma, | ||
54 | unsigned long addr) | ||
55 | { | ||
56 | if (vma->vm_mm == current->active_mm) | ||
57 | __flush_tlb_one(addr); | ||
58 | } | ||
59 | |||
60 | static inline void flush_tlb_range(struct vm_area_struct *vma, | ||
61 | unsigned long start, unsigned long end) | ||
62 | { | ||
63 | if (vma->vm_mm == current->active_mm) | ||
64 | __flush_tlb(); | ||
65 | } | ||
66 | |||
67 | #else | ||
68 | |||
69 | #include <asm/smp.h> | ||
70 | |||
71 | #define local_flush_tlb() \ | ||
72 | __flush_tlb() | ||
73 | |||
74 | extern void flush_tlb_all(void); | ||
75 | extern void flush_tlb_current_task(void); | ||
76 | extern void flush_tlb_mm(struct mm_struct *); | ||
77 | extern void flush_tlb_page(struct vm_area_struct *, unsigned long); | ||
78 | |||
79 | #define flush_tlb() flush_tlb_current_task() | ||
80 | |||
81 | static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end) | ||
82 | { | ||
83 | flush_tlb_mm(vma->vm_mm); | ||
84 | } | ||
85 | |||
86 | #define TLBSTATE_OK 1 | ||
87 | #define TLBSTATE_LAZY 2 | ||
88 | |||
89 | /* Roughly an IPI every 20MB with 4k pages for freeing page table | ||
90 | ranges. Cost is about 42k of memory for each CPU. */ | ||
91 | #define ARCH_FREE_PTE_NR 5350 | ||
92 | |||
93 | #endif | ||
94 | |||
95 | static inline void flush_tlb_kernel_range(unsigned long start, | ||
96 | unsigned long end) | ||
97 | { | ||
98 | flush_tlb_all(); | ||
99 | } | ||
100 | |||
101 | static inline void flush_tlb_pgtables(struct mm_struct *mm, | ||
102 | unsigned long start, unsigned long end) | ||
103 | { | ||
104 | /* x86_64 does not keep any page table caches in a software TLB. | ||
105 | The CPUs do in their hardware TLBs, but they are handled | ||
106 | by the normal TLB flushing algorithms. */ | ||
107 | } | ||
108 | |||
109 | #endif /* _X8664_TLBFLUSH_H */ | ||
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h new file mode 100644 index 000000000000..b10fde9798ea --- /dev/null +++ b/include/asm-x86/topology.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "topology_32.h" | ||
3 | #else | ||
4 | # include "topology_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/topology_32.h b/include/asm-x86/topology_32.h new file mode 100644 index 000000000000..19b2dafd0c81 --- /dev/null +++ b/include/asm-x86/topology_32.h | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/topology.h | ||
3 | * | ||
4 | * Written by: Matthew Dobson, IBM Corporation | ||
5 | * | ||
6 | * Copyright (C) 2002, IBM Corp. | ||
7 | * | ||
8 | * All rights reserved. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <colpatch@us.ibm.com> | ||
26 | */ | ||
27 | #ifndef _ASM_I386_TOPOLOGY_H | ||
28 | #define _ASM_I386_TOPOLOGY_H | ||
29 | |||
30 | #ifdef CONFIG_X86_HT | ||
31 | #define topology_physical_package_id(cpu) (cpu_data[cpu].phys_proc_id) | ||
32 | #define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id) | ||
33 | #define topology_core_siblings(cpu) (cpu_core_map[cpu]) | ||
34 | #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) | ||
35 | #endif | ||
36 | |||
37 | #ifdef CONFIG_NUMA | ||
38 | |||
39 | #include <asm/mpspec.h> | ||
40 | |||
41 | #include <linux/cpumask.h> | ||
42 | |||
43 | /* Mappings between logical cpu number and node number */ | ||
44 | extern cpumask_t node_2_cpu_mask[]; | ||
45 | extern int cpu_2_node[]; | ||
46 | |||
47 | /* Returns the number of the node containing CPU 'cpu' */ | ||
48 | static inline int cpu_to_node(int cpu) | ||
49 | { | ||
50 | return cpu_2_node[cpu]; | ||
51 | } | ||
52 | |||
53 | /* Returns the number of the node containing Node 'node'. This architecture is flat, | ||
54 | so it is a pretty simple function! */ | ||
55 | #define parent_node(node) (node) | ||
56 | |||
57 | /* Returns a bitmask of CPUs on Node 'node'. */ | ||
58 | static inline cpumask_t node_to_cpumask(int node) | ||
59 | { | ||
60 | return node_2_cpu_mask[node]; | ||
61 | } | ||
62 | |||
63 | /* Returns the number of the first CPU on Node 'node'. */ | ||
64 | static inline int node_to_first_cpu(int node) | ||
65 | { | ||
66 | cpumask_t mask = node_to_cpumask(node); | ||
67 | return first_cpu(mask); | ||
68 | } | ||
69 | |||
70 | #define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node | ||
71 | #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)) | ||
72 | |||
73 | /* sched_domains SD_NODE_INIT for NUMAQ machines */ | ||
74 | #define SD_NODE_INIT (struct sched_domain) { \ | ||
75 | .span = CPU_MASK_NONE, \ | ||
76 | .parent = NULL, \ | ||
77 | .child = NULL, \ | ||
78 | .groups = NULL, \ | ||
79 | .min_interval = 8, \ | ||
80 | .max_interval = 32, \ | ||
81 | .busy_factor = 32, \ | ||
82 | .imbalance_pct = 125, \ | ||
83 | .cache_nice_tries = 1, \ | ||
84 | .busy_idx = 3, \ | ||
85 | .idle_idx = 1, \ | ||
86 | .newidle_idx = 2, \ | ||
87 | .wake_idx = 1, \ | ||
88 | .flags = SD_LOAD_BALANCE \ | ||
89 | | SD_BALANCE_EXEC \ | ||
90 | | SD_BALANCE_FORK \ | ||
91 | | SD_SERIALIZE \ | ||
92 | | SD_WAKE_BALANCE, \ | ||
93 | .last_balance = jiffies, \ | ||
94 | .balance_interval = 1, \ | ||
95 | .nr_balance_failed = 0, \ | ||
96 | } | ||
97 | |||
98 | extern unsigned long node_start_pfn[]; | ||
99 | extern unsigned long node_end_pfn[]; | ||
100 | extern unsigned long node_remap_size[]; | ||
101 | |||
102 | #define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid]) | ||
103 | |||
104 | #else /* !CONFIG_NUMA */ | ||
105 | /* | ||
106 | * Other i386 platforms should define their own version of the | ||
107 | * above macros here. | ||
108 | */ | ||
109 | |||
110 | #include <asm-generic/topology.h> | ||
111 | |||
112 | #endif /* CONFIG_NUMA */ | ||
113 | |||
114 | extern cpumask_t cpu_coregroup_map(int cpu); | ||
115 | |||
116 | #ifdef CONFIG_SMP | ||
117 | #define mc_capable() (boot_cpu_data.x86_max_cores > 1) | ||
118 | #define smt_capable() (smp_num_siblings > 1) | ||
119 | #endif | ||
120 | |||
121 | #endif /* _ASM_I386_TOPOLOGY_H */ | ||
diff --git a/include/asm-x86/topology_64.h b/include/asm-x86/topology_64.h new file mode 100644 index 000000000000..36e52fba7960 --- /dev/null +++ b/include/asm-x86/topology_64.h | |||
@@ -0,0 +1,71 @@ | |||
1 | #ifndef _ASM_X86_64_TOPOLOGY_H | ||
2 | #define _ASM_X86_64_TOPOLOGY_H | ||
3 | |||
4 | |||
5 | #ifdef CONFIG_NUMA | ||
6 | |||
7 | #include <asm/mpspec.h> | ||
8 | #include <asm/bitops.h> | ||
9 | |||
10 | extern cpumask_t cpu_online_map; | ||
11 | |||
12 | extern unsigned char cpu_to_node[]; | ||
13 | extern cpumask_t node_to_cpumask[]; | ||
14 | |||
15 | #ifdef CONFIG_ACPI_NUMA | ||
16 | extern int __node_distance(int, int); | ||
17 | #define node_distance(a,b) __node_distance(a,b) | ||
18 | /* #else fallback version */ | ||
19 | #endif | ||
20 | |||
21 | #define cpu_to_node(cpu) (cpu_to_node[cpu]) | ||
22 | #define parent_node(node) (node) | ||
23 | #define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node])) | ||
24 | #define node_to_cpumask(node) (node_to_cpumask[node]) | ||
25 | #define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node | ||
26 | #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)); | ||
27 | |||
28 | #define numa_node_id() read_pda(nodenumber) | ||
29 | |||
30 | /* sched_domains SD_NODE_INIT for x86_64 machines */ | ||
31 | #define SD_NODE_INIT (struct sched_domain) { \ | ||
32 | .span = CPU_MASK_NONE, \ | ||
33 | .parent = NULL, \ | ||
34 | .child = NULL, \ | ||
35 | .groups = NULL, \ | ||
36 | .min_interval = 8, \ | ||
37 | .max_interval = 32, \ | ||
38 | .busy_factor = 32, \ | ||
39 | .imbalance_pct = 125, \ | ||
40 | .cache_nice_tries = 2, \ | ||
41 | .busy_idx = 3, \ | ||
42 | .idle_idx = 2, \ | ||
43 | .newidle_idx = 0, \ | ||
44 | .wake_idx = 1, \ | ||
45 | .forkexec_idx = 1, \ | ||
46 | .flags = SD_LOAD_BALANCE \ | ||
47 | | SD_BALANCE_FORK \ | ||
48 | | SD_BALANCE_EXEC \ | ||
49 | | SD_SERIALIZE \ | ||
50 | | SD_WAKE_BALANCE, \ | ||
51 | .last_balance = jiffies, \ | ||
52 | .balance_interval = 1, \ | ||
53 | .nr_balance_failed = 0, \ | ||
54 | } | ||
55 | |||
56 | #endif | ||
57 | |||
58 | #ifdef CONFIG_SMP | ||
59 | #define topology_physical_package_id(cpu) (cpu_data[cpu].phys_proc_id) | ||
60 | #define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id) | ||
61 | #define topology_core_siblings(cpu) (cpu_core_map[cpu]) | ||
62 | #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) | ||
63 | #define mc_capable() (boot_cpu_data.x86_max_cores > 1) | ||
64 | #define smt_capable() (smp_num_siblings > 1) | ||
65 | #endif | ||
66 | |||
67 | #include <asm-generic/topology.h> | ||
68 | |||
69 | extern cpumask_t cpu_coregroup_map(int cpu); | ||
70 | |||
71 | #endif | ||
diff --git a/include/asm-x86/tsc.h b/include/asm-x86/tsc.h new file mode 100644 index 000000000000..a4d806610b7f --- /dev/null +++ b/include/asm-x86/tsc.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * linux/include/asm-i386/tsc.h | ||
3 | * | ||
4 | * i386 TSC related functions | ||
5 | */ | ||
6 | #ifndef _ASM_i386_TSC_H | ||
7 | #define _ASM_i386_TSC_H | ||
8 | |||
9 | #include <asm/processor.h> | ||
10 | |||
11 | /* | ||
12 | * Standard way to access the cycle counter. | ||
13 | */ | ||
14 | typedef unsigned long long cycles_t; | ||
15 | |||
16 | extern unsigned int cpu_khz; | ||
17 | extern unsigned int tsc_khz; | ||
18 | |||
19 | static inline cycles_t get_cycles(void) | ||
20 | { | ||
21 | unsigned long long ret = 0; | ||
22 | |||
23 | #ifndef CONFIG_X86_TSC | ||
24 | if (!cpu_has_tsc) | ||
25 | return 0; | ||
26 | #endif | ||
27 | |||
28 | #if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC) | ||
29 | rdtscll(ret); | ||
30 | #endif | ||
31 | return ret; | ||
32 | } | ||
33 | |||
34 | /* Like get_cycles, but make sure the CPU is synchronized. */ | ||
35 | static __always_inline cycles_t get_cycles_sync(void) | ||
36 | { | ||
37 | unsigned long long ret; | ||
38 | unsigned eax, edx; | ||
39 | |||
40 | /* | ||
41 | * Use RDTSCP if possible; it is guaranteed to be synchronous | ||
42 | * and doesn't cause a VMEXIT on Hypervisors | ||
43 | */ | ||
44 | alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP, | ||
45 | ASM_OUTPUT2("=a" (eax), "=d" (edx)), | ||
46 | "a" (0U), "d" (0U) : "ecx", "memory"); | ||
47 | ret = (((unsigned long long)edx) << 32) | ((unsigned long long)eax); | ||
48 | if (ret) | ||
49 | return ret; | ||
50 | |||
51 | /* | ||
52 | * Don't do an additional sync on CPUs where we know | ||
53 | * RDTSC is already synchronous: | ||
54 | */ | ||
55 | alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC, | ||
56 | "=a" (eax), "0" (1) : "ebx","ecx","edx","memory"); | ||
57 | rdtscll(ret); | ||
58 | |||
59 | return ret; | ||
60 | } | ||
61 | |||
62 | extern void tsc_init(void); | ||
63 | extern void mark_tsc_unstable(char *reason); | ||
64 | extern int unsynchronized_tsc(void); | ||
65 | extern void init_tsc_clocksource(void); | ||
66 | int check_tsc_unstable(void); | ||
67 | |||
68 | /* | ||
69 | * Boot-time check whether the TSCs are synchronized across | ||
70 | * all CPUs/cores: | ||
71 | */ | ||
72 | extern void check_tsc_sync_source(int cpu); | ||
73 | extern void check_tsc_sync_target(void); | ||
74 | |||
75 | #endif | ||
diff --git a/include/asm-x86/types.h b/include/asm-x86/types.h new file mode 100644 index 000000000000..a777a9b83974 --- /dev/null +++ b/include/asm-x86/types.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "types_32.h" | ||
4 | # else | ||
5 | # include "types_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "types_32.h" | ||
10 | # else | ||
11 | # include "types_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/types_32.h b/include/asm-x86/types_32.h new file mode 100644 index 000000000000..ad0a55bd782f --- /dev/null +++ b/include/asm-x86/types_32.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _I386_TYPES_H | ||
2 | #define _I386_TYPES_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | |||
6 | typedef unsigned short umode_t; | ||
7 | |||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
23 | typedef __signed__ long long __s64; | ||
24 | typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | |||
27 | #endif /* __ASSEMBLY__ */ | ||
28 | |||
29 | /* | ||
30 | * These aren't exported outside the kernel to avoid name space clashes | ||
31 | */ | ||
32 | #ifdef __KERNEL__ | ||
33 | |||
34 | #define BITS_PER_LONG 32 | ||
35 | |||
36 | #ifndef __ASSEMBLY__ | ||
37 | |||
38 | |||
39 | typedef signed char s8; | ||
40 | typedef unsigned char u8; | ||
41 | |||
42 | typedef signed short s16; | ||
43 | typedef unsigned short u16; | ||
44 | |||
45 | typedef signed int s32; | ||
46 | typedef unsigned int u32; | ||
47 | |||
48 | typedef signed long long s64; | ||
49 | typedef unsigned long long u64; | ||
50 | |||
51 | /* DMA addresses come in generic and 64-bit flavours. */ | ||
52 | |||
53 | #ifdef CONFIG_HIGHMEM64G | ||
54 | typedef u64 dma_addr_t; | ||
55 | #else | ||
56 | typedef u32 dma_addr_t; | ||
57 | #endif | ||
58 | typedef u64 dma64_addr_t; | ||
59 | |||
60 | #endif /* __ASSEMBLY__ */ | ||
61 | |||
62 | #endif /* __KERNEL__ */ | ||
63 | |||
64 | #endif | ||
diff --git a/include/asm-x86/types_64.h b/include/asm-x86/types_64.h new file mode 100644 index 000000000000..2d4491aae281 --- /dev/null +++ b/include/asm-x86/types_64.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef _X86_64_TYPES_H | ||
2 | #define _X86_64_TYPES_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | |||
6 | typedef unsigned short umode_t; | ||
7 | |||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | typedef __signed__ long long __s64; | ||
23 | typedef unsigned long long __u64; | ||
24 | |||
25 | #endif /* __ASSEMBLY__ */ | ||
26 | |||
27 | /* | ||
28 | * These aren't exported outside the kernel to avoid name space clashes | ||
29 | */ | ||
30 | #ifdef __KERNEL__ | ||
31 | |||
32 | #define BITS_PER_LONG 64 | ||
33 | |||
34 | #ifndef __ASSEMBLY__ | ||
35 | |||
36 | typedef signed char s8; | ||
37 | typedef unsigned char u8; | ||
38 | |||
39 | typedef signed short s16; | ||
40 | typedef unsigned short u16; | ||
41 | |||
42 | typedef signed int s32; | ||
43 | typedef unsigned int u32; | ||
44 | |||
45 | typedef signed long long s64; | ||
46 | typedef unsigned long long u64; | ||
47 | |||
48 | typedef u64 dma64_addr_t; | ||
49 | typedef u64 dma_addr_t; | ||
50 | |||
51 | #endif /* __ASSEMBLY__ */ | ||
52 | |||
53 | #endif /* __KERNEL__ */ | ||
54 | |||
55 | #endif | ||
diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h new file mode 100644 index 000000000000..9fefd2947e78 --- /dev/null +++ b/include/asm-x86/uaccess.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "uaccess_32.h" | ||
3 | #else | ||
4 | # include "uaccess_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h new file mode 100644 index 000000000000..d2a4f7be9c2c --- /dev/null +++ b/include/asm-x86/uaccess_32.h | |||
@@ -0,0 +1,590 @@ | |||
1 | #ifndef __i386_UACCESS_H | ||
2 | #define __i386_UACCESS_H | ||
3 | |||
4 | /* | ||
5 | * User space memory access functions | ||
6 | */ | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/thread_info.h> | ||
9 | #include <linux/prefetch.h> | ||
10 | #include <linux/string.h> | ||
11 | #include <asm/page.h> | ||
12 | |||
13 | #define VERIFY_READ 0 | ||
14 | #define VERIFY_WRITE 1 | ||
15 | |||
16 | /* | ||
17 | * The fs value determines whether argument validity checking should be | ||
18 | * performed or not. If get_fs() == USER_DS, checking is performed, with | ||
19 | * get_fs() == KERNEL_DS, checking is bypassed. | ||
20 | * | ||
21 | * For historical reasons, these macros are grossly misnamed. | ||
22 | */ | ||
23 | |||
24 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | ||
25 | |||
26 | |||
27 | #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL) | ||
28 | #define USER_DS MAKE_MM_SEG(PAGE_OFFSET) | ||
29 | |||
30 | #define get_ds() (KERNEL_DS) | ||
31 | #define get_fs() (current_thread_info()->addr_limit) | ||
32 | #define set_fs(x) (current_thread_info()->addr_limit = (x)) | ||
33 | |||
34 | #define segment_eq(a,b) ((a).seg == (b).seg) | ||
35 | |||
36 | /* | ||
37 | * movsl can be slow when source and dest are not both 8-byte aligned | ||
38 | */ | ||
39 | #ifdef CONFIG_X86_INTEL_USERCOPY | ||
40 | extern struct movsl_mask { | ||
41 | int mask; | ||
42 | } ____cacheline_aligned_in_smp movsl_mask; | ||
43 | #endif | ||
44 | |||
45 | #define __addr_ok(addr) ((unsigned long __force)(addr) < (current_thread_info()->addr_limit.seg)) | ||
46 | |||
47 | /* | ||
48 | * Test whether a block of memory is a valid user space address. | ||
49 | * Returns 0 if the range is valid, nonzero otherwise. | ||
50 | * | ||
51 | * This is equivalent to the following test: | ||
52 | * (u33)addr + (u33)size >= (u33)current->addr_limit.seg | ||
53 | * | ||
54 | * This needs 33-bit arithmetic. We have a carry... | ||
55 | */ | ||
56 | #define __range_ok(addr,size) ({ \ | ||
57 | unsigned long flag,roksum; \ | ||
58 | __chk_user_ptr(addr); \ | ||
59 | asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \ | ||
60 | :"=&r" (flag), "=r" (roksum) \ | ||
61 | :"1" (addr),"g" ((int)(size)),"rm" (current_thread_info()->addr_limit.seg)); \ | ||
62 | flag; }) | ||
63 | |||
64 | /** | ||
65 | * access_ok: - Checks if a user space pointer is valid | ||
66 | * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that | ||
67 | * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe | ||
68 | * to write to a block, it is always safe to read from it. | ||
69 | * @addr: User space pointer to start of block to check | ||
70 | * @size: Size of block to check | ||
71 | * | ||
72 | * Context: User context only. This function may sleep. | ||
73 | * | ||
74 | * Checks if a pointer to a block of memory in user space is valid. | ||
75 | * | ||
76 | * Returns true (nonzero) if the memory block may be valid, false (zero) | ||
77 | * if it is definitely invalid. | ||
78 | * | ||
79 | * Note that, depending on architecture, this function probably just | ||
80 | * checks that the pointer is in the user space range - after calling | ||
81 | * this function, memory access functions may still return -EFAULT. | ||
82 | */ | ||
83 | #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) | ||
84 | |||
85 | /* | ||
86 | * The exception table consists of pairs of addresses: the first is the | ||
87 | * address of an instruction that is allowed to fault, and the second is | ||
88 | * the address at which the program should continue. No registers are | ||
89 | * modified, so it is entirely up to the continuation code to figure out | ||
90 | * what to do. | ||
91 | * | ||
92 | * All the routines below use bits of fixup code that are out of line | ||
93 | * with the main instruction path. This means when everything is well, | ||
94 | * we don't even have to jump over them. Further, they do not intrude | ||
95 | * on our cache or tlb entries. | ||
96 | */ | ||
97 | |||
98 | struct exception_table_entry | ||
99 | { | ||
100 | unsigned long insn, fixup; | ||
101 | }; | ||
102 | |||
103 | extern int fixup_exception(struct pt_regs *regs); | ||
104 | |||
105 | /* | ||
106 | * These are the main single-value transfer routines. They automatically | ||
107 | * use the right size if we just have the right pointer type. | ||
108 | * | ||
109 | * This gets kind of ugly. We want to return _two_ values in "get_user()" | ||
110 | * and yet we don't want to do any pointers, because that is too much | ||
111 | * of a performance impact. Thus we have a few rather ugly macros here, | ||
112 | * and hide all the ugliness from the user. | ||
113 | * | ||
114 | * The "__xxx" versions of the user access functions are versions that | ||
115 | * do not verify the address space, that must have been done previously | ||
116 | * with a separate "access_ok()" call (this is used when we do multiple | ||
117 | * accesses to the same area of user memory). | ||
118 | */ | ||
119 | |||
120 | extern void __get_user_1(void); | ||
121 | extern void __get_user_2(void); | ||
122 | extern void __get_user_4(void); | ||
123 | |||
124 | #define __get_user_x(size,ret,x,ptr) \ | ||
125 | __asm__ __volatile__("call __get_user_" #size \ | ||
126 | :"=a" (ret),"=d" (x) \ | ||
127 | :"0" (ptr)) | ||
128 | |||
129 | |||
130 | /* Careful: we have to cast the result to the type of the pointer for sign reasons */ | ||
131 | /** | ||
132 | * get_user: - Get a simple variable from user space. | ||
133 | * @x: Variable to store result. | ||
134 | * @ptr: Source address, in user space. | ||
135 | * | ||
136 | * Context: User context only. This function may sleep. | ||
137 | * | ||
138 | * This macro copies a single simple variable from user space to kernel | ||
139 | * space. It supports simple types like char and int, but not larger | ||
140 | * data types like structures or arrays. | ||
141 | * | ||
142 | * @ptr must have pointer-to-simple-variable type, and the result of | ||
143 | * dereferencing @ptr must be assignable to @x without a cast. | ||
144 | * | ||
145 | * Returns zero on success, or -EFAULT on error. | ||
146 | * On error, the variable @x is set to zero. | ||
147 | */ | ||
148 | #define get_user(x,ptr) \ | ||
149 | ({ int __ret_gu; \ | ||
150 | unsigned long __val_gu; \ | ||
151 | __chk_user_ptr(ptr); \ | ||
152 | switch(sizeof (*(ptr))) { \ | ||
153 | case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \ | ||
154 | case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \ | ||
155 | case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \ | ||
156 | default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \ | ||
157 | } \ | ||
158 | (x) = (__typeof__(*(ptr)))__val_gu; \ | ||
159 | __ret_gu; \ | ||
160 | }) | ||
161 | |||
162 | extern void __put_user_bad(void); | ||
163 | |||
164 | /* | ||
165 | * Strange magic calling convention: pointer in %ecx, | ||
166 | * value in %eax(:%edx), return value in %eax, no clobbers. | ||
167 | */ | ||
168 | extern void __put_user_1(void); | ||
169 | extern void __put_user_2(void); | ||
170 | extern void __put_user_4(void); | ||
171 | extern void __put_user_8(void); | ||
172 | |||
173 | #define __put_user_1(x, ptr) __asm__ __volatile__("call __put_user_1":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) | ||
174 | #define __put_user_2(x, ptr) __asm__ __volatile__("call __put_user_2":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) | ||
175 | #define __put_user_4(x, ptr) __asm__ __volatile__("call __put_user_4":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) | ||
176 | #define __put_user_8(x, ptr) __asm__ __volatile__("call __put_user_8":"=a" (__ret_pu):"A" ((typeof(*(ptr)))(x)), "c" (ptr)) | ||
177 | #define __put_user_X(x, ptr) __asm__ __volatile__("call __put_user_X":"=a" (__ret_pu):"c" (ptr)) | ||
178 | |||
179 | /** | ||
180 | * put_user: - Write a simple value into user space. | ||
181 | * @x: Value to copy to user space. | ||
182 | * @ptr: Destination address, in user space. | ||
183 | * | ||
184 | * Context: User context only. This function may sleep. | ||
185 | * | ||
186 | * This macro copies a single simple value from kernel space to user | ||
187 | * space. It supports simple types like char and int, but not larger | ||
188 | * data types like structures or arrays. | ||
189 | * | ||
190 | * @ptr must have pointer-to-simple-variable type, and @x must be assignable | ||
191 | * to the result of dereferencing @ptr. | ||
192 | * | ||
193 | * Returns zero on success, or -EFAULT on error. | ||
194 | */ | ||
195 | #ifdef CONFIG_X86_WP_WORKS_OK | ||
196 | |||
197 | #define put_user(x,ptr) \ | ||
198 | ({ int __ret_pu; \ | ||
199 | __typeof__(*(ptr)) __pu_val; \ | ||
200 | __chk_user_ptr(ptr); \ | ||
201 | __pu_val = x; \ | ||
202 | switch(sizeof(*(ptr))) { \ | ||
203 | case 1: __put_user_1(__pu_val, ptr); break; \ | ||
204 | case 2: __put_user_2(__pu_val, ptr); break; \ | ||
205 | case 4: __put_user_4(__pu_val, ptr); break; \ | ||
206 | case 8: __put_user_8(__pu_val, ptr); break; \ | ||
207 | default:__put_user_X(__pu_val, ptr); break; \ | ||
208 | } \ | ||
209 | __ret_pu; \ | ||
210 | }) | ||
211 | |||
212 | #else | ||
213 | #define put_user(x,ptr) \ | ||
214 | ({ \ | ||
215 | int __ret_pu; \ | ||
216 | __typeof__(*(ptr)) __pus_tmp = x; \ | ||
217 | __ret_pu=0; \ | ||
218 | if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, \ | ||
219 | sizeof(*(ptr))) != 0)) \ | ||
220 | __ret_pu=-EFAULT; \ | ||
221 | __ret_pu; \ | ||
222 | }) | ||
223 | |||
224 | |||
225 | #endif | ||
226 | |||
227 | /** | ||
228 | * __get_user: - Get a simple variable from user space, with less checking. | ||
229 | * @x: Variable to store result. | ||
230 | * @ptr: Source address, in user space. | ||
231 | * | ||
232 | * Context: User context only. This function may sleep. | ||
233 | * | ||
234 | * This macro copies a single simple variable from user space to kernel | ||
235 | * space. It supports simple types like char and int, but not larger | ||
236 | * data types like structures or arrays. | ||
237 | * | ||
238 | * @ptr must have pointer-to-simple-variable type, and the result of | ||
239 | * dereferencing @ptr must be assignable to @x without a cast. | ||
240 | * | ||
241 | * Caller must check the pointer with access_ok() before calling this | ||
242 | * function. | ||
243 | * | ||
244 | * Returns zero on success, or -EFAULT on error. | ||
245 | * On error, the variable @x is set to zero. | ||
246 | */ | ||
247 | #define __get_user(x,ptr) \ | ||
248 | __get_user_nocheck((x),(ptr),sizeof(*(ptr))) | ||
249 | |||
250 | |||
251 | /** | ||
252 | * __put_user: - Write a simple value into user space, with less checking. | ||
253 | * @x: Value to copy to user space. | ||
254 | * @ptr: Destination address, in user space. | ||
255 | * | ||
256 | * Context: User context only. This function may sleep. | ||
257 | * | ||
258 | * This macro copies a single simple value from kernel space to user | ||
259 | * space. It supports simple types like char and int, but not larger | ||
260 | * data types like structures or arrays. | ||
261 | * | ||
262 | * @ptr must have pointer-to-simple-variable type, and @x must be assignable | ||
263 | * to the result of dereferencing @ptr. | ||
264 | * | ||
265 | * Caller must check the pointer with access_ok() before calling this | ||
266 | * function. | ||
267 | * | ||
268 | * Returns zero on success, or -EFAULT on error. | ||
269 | */ | ||
270 | #define __put_user(x,ptr) \ | ||
271 | __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) | ||
272 | |||
273 | #define __put_user_nocheck(x,ptr,size) \ | ||
274 | ({ \ | ||
275 | long __pu_err; \ | ||
276 | __put_user_size((x),(ptr),(size),__pu_err,-EFAULT); \ | ||
277 | __pu_err; \ | ||
278 | }) | ||
279 | |||
280 | |||
281 | #define __put_user_u64(x, addr, err) \ | ||
282 | __asm__ __volatile__( \ | ||
283 | "1: movl %%eax,0(%2)\n" \ | ||
284 | "2: movl %%edx,4(%2)\n" \ | ||
285 | "3:\n" \ | ||
286 | ".section .fixup,\"ax\"\n" \ | ||
287 | "4: movl %3,%0\n" \ | ||
288 | " jmp 3b\n" \ | ||
289 | ".previous\n" \ | ||
290 | ".section __ex_table,\"a\"\n" \ | ||
291 | " .align 4\n" \ | ||
292 | " .long 1b,4b\n" \ | ||
293 | " .long 2b,4b\n" \ | ||
294 | ".previous" \ | ||
295 | : "=r"(err) \ | ||
296 | : "A" (x), "r" (addr), "i"(-EFAULT), "0"(err)) | ||
297 | |||
298 | #ifdef CONFIG_X86_WP_WORKS_OK | ||
299 | |||
300 | #define __put_user_size(x,ptr,size,retval,errret) \ | ||
301 | do { \ | ||
302 | retval = 0; \ | ||
303 | __chk_user_ptr(ptr); \ | ||
304 | switch (size) { \ | ||
305 | case 1: __put_user_asm(x,ptr,retval,"b","b","iq",errret);break; \ | ||
306 | case 2: __put_user_asm(x,ptr,retval,"w","w","ir",errret);break; \ | ||
307 | case 4: __put_user_asm(x,ptr,retval,"l","","ir",errret); break; \ | ||
308 | case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\ | ||
309 | default: __put_user_bad(); \ | ||
310 | } \ | ||
311 | } while (0) | ||
312 | |||
313 | #else | ||
314 | |||
315 | #define __put_user_size(x,ptr,size,retval,errret) \ | ||
316 | do { \ | ||
317 | __typeof__(*(ptr)) __pus_tmp = x; \ | ||
318 | retval = 0; \ | ||
319 | \ | ||
320 | if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, size) != 0)) \ | ||
321 | retval = errret; \ | ||
322 | } while (0) | ||
323 | |||
324 | #endif | ||
325 | struct __large_struct { unsigned long buf[100]; }; | ||
326 | #define __m(x) (*(struct __large_struct __user *)(x)) | ||
327 | |||
328 | /* | ||
329 | * Tell gcc we read from memory instead of writing: this is because | ||
330 | * we do not write to any memory gcc knows about, so there are no | ||
331 | * aliasing issues. | ||
332 | */ | ||
333 | #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \ | ||
334 | __asm__ __volatile__( \ | ||
335 | "1: mov"itype" %"rtype"1,%2\n" \ | ||
336 | "2:\n" \ | ||
337 | ".section .fixup,\"ax\"\n" \ | ||
338 | "3: movl %3,%0\n" \ | ||
339 | " jmp 2b\n" \ | ||
340 | ".previous\n" \ | ||
341 | ".section __ex_table,\"a\"\n" \ | ||
342 | " .align 4\n" \ | ||
343 | " .long 1b,3b\n" \ | ||
344 | ".previous" \ | ||
345 | : "=r"(err) \ | ||
346 | : ltype (x), "m"(__m(addr)), "i"(errret), "0"(err)) | ||
347 | |||
348 | |||
349 | #define __get_user_nocheck(x,ptr,size) \ | ||
350 | ({ \ | ||
351 | long __gu_err; \ | ||
352 | unsigned long __gu_val; \ | ||
353 | __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ | ||
354 | (x) = (__typeof__(*(ptr)))__gu_val; \ | ||
355 | __gu_err; \ | ||
356 | }) | ||
357 | |||
358 | extern long __get_user_bad(void); | ||
359 | |||
360 | #define __get_user_size(x,ptr,size,retval,errret) \ | ||
361 | do { \ | ||
362 | retval = 0; \ | ||
363 | __chk_user_ptr(ptr); \ | ||
364 | switch (size) { \ | ||
365 | case 1: __get_user_asm(x,ptr,retval,"b","b","=q",errret);break; \ | ||
366 | case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; \ | ||
367 | case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break; \ | ||
368 | default: (x) = __get_user_bad(); \ | ||
369 | } \ | ||
370 | } while (0) | ||
371 | |||
372 | #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \ | ||
373 | __asm__ __volatile__( \ | ||
374 | "1: mov"itype" %2,%"rtype"1\n" \ | ||
375 | "2:\n" \ | ||
376 | ".section .fixup,\"ax\"\n" \ | ||
377 | "3: movl %3,%0\n" \ | ||
378 | " xor"itype" %"rtype"1,%"rtype"1\n" \ | ||
379 | " jmp 2b\n" \ | ||
380 | ".previous\n" \ | ||
381 | ".section __ex_table,\"a\"\n" \ | ||
382 | " .align 4\n" \ | ||
383 | " .long 1b,3b\n" \ | ||
384 | ".previous" \ | ||
385 | : "=r"(err), ltype (x) \ | ||
386 | : "m"(__m(addr)), "i"(errret), "0"(err)) | ||
387 | |||
388 | |||
389 | unsigned long __must_check __copy_to_user_ll(void __user *to, | ||
390 | const void *from, unsigned long n); | ||
391 | unsigned long __must_check __copy_from_user_ll(void *to, | ||
392 | const void __user *from, unsigned long n); | ||
393 | unsigned long __must_check __copy_from_user_ll_nozero(void *to, | ||
394 | const void __user *from, unsigned long n); | ||
395 | unsigned long __must_check __copy_from_user_ll_nocache(void *to, | ||
396 | const void __user *from, unsigned long n); | ||
397 | unsigned long __must_check __copy_from_user_ll_nocache_nozero(void *to, | ||
398 | const void __user *from, unsigned long n); | ||
399 | |||
400 | /** | ||
401 | * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking. | ||
402 | * @to: Destination address, in user space. | ||
403 | * @from: Source address, in kernel space. | ||
404 | * @n: Number of bytes to copy. | ||
405 | * | ||
406 | * Context: User context only. | ||
407 | * | ||
408 | * Copy data from kernel space to user space. Caller must check | ||
409 | * the specified block with access_ok() before calling this function. | ||
410 | * The caller should also make sure he pins the user space address | ||
411 | * so that the we don't result in page fault and sleep. | ||
412 | * | ||
413 | * Here we special-case 1, 2 and 4-byte copy_*_user invocations. On a fault | ||
414 | * we return the initial request size (1, 2 or 4), as copy_*_user should do. | ||
415 | * If a store crosses a page boundary and gets a fault, the x86 will not write | ||
416 | * anything, so this is accurate. | ||
417 | */ | ||
418 | |||
419 | static __always_inline unsigned long __must_check | ||
420 | __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) | ||
421 | { | ||
422 | if (__builtin_constant_p(n)) { | ||
423 | unsigned long ret; | ||
424 | |||
425 | switch (n) { | ||
426 | case 1: | ||
427 | __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1); | ||
428 | return ret; | ||
429 | case 2: | ||
430 | __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2); | ||
431 | return ret; | ||
432 | case 4: | ||
433 | __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4); | ||
434 | return ret; | ||
435 | } | ||
436 | } | ||
437 | return __copy_to_user_ll(to, from, n); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * __copy_to_user: - Copy a block of data into user space, with less checking. | ||
442 | * @to: Destination address, in user space. | ||
443 | * @from: Source address, in kernel space. | ||
444 | * @n: Number of bytes to copy. | ||
445 | * | ||
446 | * Context: User context only. This function may sleep. | ||
447 | * | ||
448 | * Copy data from kernel space to user space. Caller must check | ||
449 | * the specified block with access_ok() before calling this function. | ||
450 | * | ||
451 | * Returns number of bytes that could not be copied. | ||
452 | * On success, this will be zero. | ||
453 | */ | ||
454 | static __always_inline unsigned long __must_check | ||
455 | __copy_to_user(void __user *to, const void *from, unsigned long n) | ||
456 | { | ||
457 | might_sleep(); | ||
458 | return __copy_to_user_inatomic(to, from, n); | ||
459 | } | ||
460 | |||
461 | static __always_inline unsigned long | ||
462 | __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) | ||
463 | { | ||
464 | /* Avoid zeroing the tail if the copy fails.. | ||
465 | * If 'n' is constant and 1, 2, or 4, we do still zero on a failure, | ||
466 | * but as the zeroing behaviour is only significant when n is not | ||
467 | * constant, that shouldn't be a problem. | ||
468 | */ | ||
469 | if (__builtin_constant_p(n)) { | ||
470 | unsigned long ret; | ||
471 | |||
472 | switch (n) { | ||
473 | case 1: | ||
474 | __get_user_size(*(u8 *)to, from, 1, ret, 1); | ||
475 | return ret; | ||
476 | case 2: | ||
477 | __get_user_size(*(u16 *)to, from, 2, ret, 2); | ||
478 | return ret; | ||
479 | case 4: | ||
480 | __get_user_size(*(u32 *)to, from, 4, ret, 4); | ||
481 | return ret; | ||
482 | } | ||
483 | } | ||
484 | return __copy_from_user_ll_nozero(to, from, n); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * __copy_from_user: - Copy a block of data from user space, with less checking. | ||
489 | * @to: Destination address, in kernel space. | ||
490 | * @from: Source address, in user space. | ||
491 | * @n: Number of bytes to copy. | ||
492 | * | ||
493 | * Context: User context only. This function may sleep. | ||
494 | * | ||
495 | * Copy data from user space to kernel space. Caller must check | ||
496 | * the specified block with access_ok() before calling this function. | ||
497 | * | ||
498 | * Returns number of bytes that could not be copied. | ||
499 | * On success, this will be zero. | ||
500 | * | ||
501 | * If some data could not be copied, this function will pad the copied | ||
502 | * data to the requested size using zero bytes. | ||
503 | * | ||
504 | * An alternate version - __copy_from_user_inatomic() - may be called from | ||
505 | * atomic context and will fail rather than sleep. In this case the | ||
506 | * uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h | ||
507 | * for explanation of why this is needed. | ||
508 | */ | ||
509 | static __always_inline unsigned long | ||
510 | __copy_from_user(void *to, const void __user *from, unsigned long n) | ||
511 | { | ||
512 | might_sleep(); | ||
513 | if (__builtin_constant_p(n)) { | ||
514 | unsigned long ret; | ||
515 | |||
516 | switch (n) { | ||
517 | case 1: | ||
518 | __get_user_size(*(u8 *)to, from, 1, ret, 1); | ||
519 | return ret; | ||
520 | case 2: | ||
521 | __get_user_size(*(u16 *)to, from, 2, ret, 2); | ||
522 | return ret; | ||
523 | case 4: | ||
524 | __get_user_size(*(u32 *)to, from, 4, ret, 4); | ||
525 | return ret; | ||
526 | } | ||
527 | } | ||
528 | return __copy_from_user_ll(to, from, n); | ||
529 | } | ||
530 | |||
531 | #define ARCH_HAS_NOCACHE_UACCESS | ||
532 | |||
533 | static __always_inline unsigned long __copy_from_user_nocache(void *to, | ||
534 | const void __user *from, unsigned long n) | ||
535 | { | ||
536 | might_sleep(); | ||
537 | if (__builtin_constant_p(n)) { | ||
538 | unsigned long ret; | ||
539 | |||
540 | switch (n) { | ||
541 | case 1: | ||
542 | __get_user_size(*(u8 *)to, from, 1, ret, 1); | ||
543 | return ret; | ||
544 | case 2: | ||
545 | __get_user_size(*(u16 *)to, from, 2, ret, 2); | ||
546 | return ret; | ||
547 | case 4: | ||
548 | __get_user_size(*(u32 *)to, from, 4, ret, 4); | ||
549 | return ret; | ||
550 | } | ||
551 | } | ||
552 | return __copy_from_user_ll_nocache(to, from, n); | ||
553 | } | ||
554 | |||
555 | static __always_inline unsigned long | ||
556 | __copy_from_user_inatomic_nocache(void *to, const void __user *from, unsigned long n) | ||
557 | { | ||
558 | return __copy_from_user_ll_nocache_nozero(to, from, n); | ||
559 | } | ||
560 | |||
561 | unsigned long __must_check copy_to_user(void __user *to, | ||
562 | const void *from, unsigned long n); | ||
563 | unsigned long __must_check copy_from_user(void *to, | ||
564 | const void __user *from, unsigned long n); | ||
565 | long __must_check strncpy_from_user(char *dst, const char __user *src, | ||
566 | long count); | ||
567 | long __must_check __strncpy_from_user(char *dst, | ||
568 | const char __user *src, long count); | ||
569 | |||
570 | /** | ||
571 | * strlen_user: - Get the size of a string in user space. | ||
572 | * @str: The string to measure. | ||
573 | * | ||
574 | * Context: User context only. This function may sleep. | ||
575 | * | ||
576 | * Get the size of a NUL-terminated string in user space. | ||
577 | * | ||
578 | * Returns the size of the string INCLUDING the terminating NUL. | ||
579 | * On exception, returns 0. | ||
580 | * | ||
581 | * If there is a limit on the length of a valid string, you may wish to | ||
582 | * consider using strnlen_user() instead. | ||
583 | */ | ||
584 | #define strlen_user(str) strnlen_user(str, LONG_MAX) | ||
585 | |||
586 | long strnlen_user(const char __user *str, long n); | ||
587 | unsigned long __must_check clear_user(void __user *mem, unsigned long len); | ||
588 | unsigned long __must_check __clear_user(void __user *mem, unsigned long len); | ||
589 | |||
590 | #endif /* __i386_UACCESS_H */ | ||
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h new file mode 100644 index 000000000000..f4ce8768ad44 --- /dev/null +++ b/include/asm-x86/uaccess_64.h | |||
@@ -0,0 +1,384 @@ | |||
1 | #ifndef __X86_64_UACCESS_H | ||
2 | #define __X86_64_UACCESS_H | ||
3 | |||
4 | /* | ||
5 | * User space memory access functions | ||
6 | */ | ||
7 | #include <linux/compiler.h> | ||
8 | #include <linux/errno.h> | ||
9 | #include <linux/prefetch.h> | ||
10 | #include <asm/page.h> | ||
11 | |||
12 | #define VERIFY_READ 0 | ||
13 | #define VERIFY_WRITE 1 | ||
14 | |||
15 | /* | ||
16 | * The fs value determines whether argument validity checking should be | ||
17 | * performed or not. If get_fs() == USER_DS, checking is performed, with | ||
18 | * get_fs() == KERNEL_DS, checking is bypassed. | ||
19 | * | ||
20 | * For historical reasons, these macros are grossly misnamed. | ||
21 | */ | ||
22 | |||
23 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | ||
24 | |||
25 | #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFFFFFFFFFUL) | ||
26 | #define USER_DS MAKE_MM_SEG(PAGE_OFFSET) | ||
27 | |||
28 | #define get_ds() (KERNEL_DS) | ||
29 | #define get_fs() (current_thread_info()->addr_limit) | ||
30 | #define set_fs(x) (current_thread_info()->addr_limit = (x)) | ||
31 | |||
32 | #define segment_eq(a,b) ((a).seg == (b).seg) | ||
33 | |||
34 | #define __addr_ok(addr) (!((unsigned long)(addr) & (current_thread_info()->addr_limit.seg))) | ||
35 | |||
36 | /* | ||
37 | * Uhhuh, this needs 65-bit arithmetic. We have a carry.. | ||
38 | */ | ||
39 | #define __range_not_ok(addr,size) ({ \ | ||
40 | unsigned long flag,roksum; \ | ||
41 | __chk_user_ptr(addr); \ | ||
42 | asm("# range_ok\n\r" \ | ||
43 | "addq %3,%1 ; sbbq %0,%0 ; cmpq %1,%4 ; sbbq $0,%0" \ | ||
44 | :"=&r" (flag), "=r" (roksum) \ | ||
45 | :"1" (addr),"g" ((long)(size)),"g" (current_thread_info()->addr_limit.seg)); \ | ||
46 | flag; }) | ||
47 | |||
48 | #define access_ok(type, addr, size) (__range_not_ok(addr,size) == 0) | ||
49 | |||
50 | /* | ||
51 | * The exception table consists of pairs of addresses: the first is the | ||
52 | * address of an instruction that is allowed to fault, and the second is | ||
53 | * the address at which the program should continue. No registers are | ||
54 | * modified, so it is entirely up to the continuation code to figure out | ||
55 | * what to do. | ||
56 | * | ||
57 | * All the routines below use bits of fixup code that are out of line | ||
58 | * with the main instruction path. This means when everything is well, | ||
59 | * we don't even have to jump over them. Further, they do not intrude | ||
60 | * on our cache or tlb entries. | ||
61 | */ | ||
62 | |||
63 | struct exception_table_entry | ||
64 | { | ||
65 | unsigned long insn, fixup; | ||
66 | }; | ||
67 | |||
68 | #define ARCH_HAS_SEARCH_EXTABLE | ||
69 | |||
70 | /* | ||
71 | * These are the main single-value transfer routines. They automatically | ||
72 | * use the right size if we just have the right pointer type. | ||
73 | * | ||
74 | * This gets kind of ugly. We want to return _two_ values in "get_user()" | ||
75 | * and yet we don't want to do any pointers, because that is too much | ||
76 | * of a performance impact. Thus we have a few rather ugly macros here, | ||
77 | * and hide all the ugliness from the user. | ||
78 | * | ||
79 | * The "__xxx" versions of the user access functions are versions that | ||
80 | * do not verify the address space, that must have been done previously | ||
81 | * with a separate "access_ok()" call (this is used when we do multiple | ||
82 | * accesses to the same area of user memory). | ||
83 | */ | ||
84 | |||
85 | #define __get_user_x(size,ret,x,ptr) \ | ||
86 | asm volatile("call __get_user_" #size \ | ||
87 | :"=a" (ret),"=d" (x) \ | ||
88 | :"c" (ptr) \ | ||
89 | :"r8") | ||
90 | |||
91 | /* Careful: we have to cast the result to the type of the pointer for sign reasons */ | ||
92 | #define get_user(x,ptr) \ | ||
93 | ({ unsigned long __val_gu; \ | ||
94 | int __ret_gu; \ | ||
95 | __chk_user_ptr(ptr); \ | ||
96 | switch(sizeof (*(ptr))) { \ | ||
97 | case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \ | ||
98 | case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \ | ||
99 | case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \ | ||
100 | case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \ | ||
101 | default: __get_user_bad(); break; \ | ||
102 | } \ | ||
103 | (x) = (__force typeof(*(ptr)))__val_gu; \ | ||
104 | __ret_gu; \ | ||
105 | }) | ||
106 | |||
107 | extern void __put_user_1(void); | ||
108 | extern void __put_user_2(void); | ||
109 | extern void __put_user_4(void); | ||
110 | extern void __put_user_8(void); | ||
111 | extern void __put_user_bad(void); | ||
112 | |||
113 | #define __put_user_x(size,ret,x,ptr) \ | ||
114 | asm volatile("call __put_user_" #size \ | ||
115 | :"=a" (ret) \ | ||
116 | :"c" (ptr),"d" (x) \ | ||
117 | :"r8") | ||
118 | |||
119 | #define put_user(x,ptr) \ | ||
120 | __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) | ||
121 | |||
122 | #define __get_user(x,ptr) \ | ||
123 | __get_user_nocheck((x),(ptr),sizeof(*(ptr))) | ||
124 | #define __put_user(x,ptr) \ | ||
125 | __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) | ||
126 | |||
127 | #define __get_user_unaligned __get_user | ||
128 | #define __put_user_unaligned __put_user | ||
129 | |||
130 | #define __put_user_nocheck(x,ptr,size) \ | ||
131 | ({ \ | ||
132 | int __pu_err; \ | ||
133 | __put_user_size((x),(ptr),(size),__pu_err); \ | ||
134 | __pu_err; \ | ||
135 | }) | ||
136 | |||
137 | |||
138 | #define __put_user_check(x,ptr,size) \ | ||
139 | ({ \ | ||
140 | int __pu_err; \ | ||
141 | typeof(*(ptr)) __user *__pu_addr = (ptr); \ | ||
142 | switch (size) { \ | ||
143 | case 1: __put_user_x(1,__pu_err,x,__pu_addr); break; \ | ||
144 | case 2: __put_user_x(2,__pu_err,x,__pu_addr); break; \ | ||
145 | case 4: __put_user_x(4,__pu_err,x,__pu_addr); break; \ | ||
146 | case 8: __put_user_x(8,__pu_err,x,__pu_addr); break; \ | ||
147 | default: __put_user_bad(); \ | ||
148 | } \ | ||
149 | __pu_err; \ | ||
150 | }) | ||
151 | |||
152 | #define __put_user_size(x,ptr,size,retval) \ | ||
153 | do { \ | ||
154 | retval = 0; \ | ||
155 | __chk_user_ptr(ptr); \ | ||
156 | switch (size) { \ | ||
157 | case 1: __put_user_asm(x,ptr,retval,"b","b","iq",-EFAULT); break;\ | ||
158 | case 2: __put_user_asm(x,ptr,retval,"w","w","ir",-EFAULT); break;\ | ||
159 | case 4: __put_user_asm(x,ptr,retval,"l","k","ir",-EFAULT); break;\ | ||
160 | case 8: __put_user_asm(x,ptr,retval,"q","","Zr",-EFAULT); break;\ | ||
161 | default: __put_user_bad(); \ | ||
162 | } \ | ||
163 | } while (0) | ||
164 | |||
165 | /* FIXME: this hack is definitely wrong -AK */ | ||
166 | struct __large_struct { unsigned long buf[100]; }; | ||
167 | #define __m(x) (*(struct __large_struct __user *)(x)) | ||
168 | |||
169 | /* | ||
170 | * Tell gcc we read from memory instead of writing: this is because | ||
171 | * we do not write to any memory gcc knows about, so there are no | ||
172 | * aliasing issues. | ||
173 | */ | ||
174 | #define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \ | ||
175 | asm volatile( \ | ||
176 | "1: mov"itype" %"rtype"1,%2\n" \ | ||
177 | "2:\n" \ | ||
178 | ".section .fixup,\"ax\"\n" \ | ||
179 | "3: mov %3,%0\n" \ | ||
180 | " jmp 2b\n" \ | ||
181 | ".previous\n" \ | ||
182 | ".section __ex_table,\"a\"\n" \ | ||
183 | " .align 8\n" \ | ||
184 | " .quad 1b,3b\n" \ | ||
185 | ".previous" \ | ||
186 | : "=r"(err) \ | ||
187 | : ltype (x), "m"(__m(addr)), "i"(errno), "0"(err)) | ||
188 | |||
189 | |||
190 | #define __get_user_nocheck(x,ptr,size) \ | ||
191 | ({ \ | ||
192 | int __gu_err; \ | ||
193 | unsigned long __gu_val; \ | ||
194 | __get_user_size(__gu_val,(ptr),(size),__gu_err); \ | ||
195 | (x) = (__force typeof(*(ptr)))__gu_val; \ | ||
196 | __gu_err; \ | ||
197 | }) | ||
198 | |||
199 | extern int __get_user_1(void); | ||
200 | extern int __get_user_2(void); | ||
201 | extern int __get_user_4(void); | ||
202 | extern int __get_user_8(void); | ||
203 | extern int __get_user_bad(void); | ||
204 | |||
205 | #define __get_user_size(x,ptr,size,retval) \ | ||
206 | do { \ | ||
207 | retval = 0; \ | ||
208 | __chk_user_ptr(ptr); \ | ||
209 | switch (size) { \ | ||
210 | case 1: __get_user_asm(x,ptr,retval,"b","b","=q",-EFAULT); break;\ | ||
211 | case 2: __get_user_asm(x,ptr,retval,"w","w","=r",-EFAULT); break;\ | ||
212 | case 4: __get_user_asm(x,ptr,retval,"l","k","=r",-EFAULT); break;\ | ||
213 | case 8: __get_user_asm(x,ptr,retval,"q","","=r",-EFAULT); break;\ | ||
214 | default: (x) = __get_user_bad(); \ | ||
215 | } \ | ||
216 | } while (0) | ||
217 | |||
218 | #define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \ | ||
219 | asm volatile( \ | ||
220 | "1: mov"itype" %2,%"rtype"1\n" \ | ||
221 | "2:\n" \ | ||
222 | ".section .fixup,\"ax\"\n" \ | ||
223 | "3: mov %3,%0\n" \ | ||
224 | " xor"itype" %"rtype"1,%"rtype"1\n" \ | ||
225 | " jmp 2b\n" \ | ||
226 | ".previous\n" \ | ||
227 | ".section __ex_table,\"a\"\n" \ | ||
228 | " .align 8\n" \ | ||
229 | " .quad 1b,3b\n" \ | ||
230 | ".previous" \ | ||
231 | : "=r"(err), ltype (x) \ | ||
232 | : "m"(__m(addr)), "i"(errno), "0"(err)) | ||
233 | |||
234 | /* | ||
235 | * Copy To/From Userspace | ||
236 | */ | ||
237 | |||
238 | /* Handles exceptions in both to and from, but doesn't do access_ok */ | ||
239 | __must_check unsigned long | ||
240 | copy_user_generic(void *to, const void *from, unsigned len); | ||
241 | |||
242 | __must_check unsigned long | ||
243 | copy_to_user(void __user *to, const void *from, unsigned len); | ||
244 | __must_check unsigned long | ||
245 | copy_from_user(void *to, const void __user *from, unsigned len); | ||
246 | __must_check unsigned long | ||
247 | copy_in_user(void __user *to, const void __user *from, unsigned len); | ||
248 | |||
249 | static __always_inline __must_check | ||
250 | int __copy_from_user(void *dst, const void __user *src, unsigned size) | ||
251 | { | ||
252 | int ret = 0; | ||
253 | if (!__builtin_constant_p(size)) | ||
254 | return copy_user_generic(dst,(__force void *)src,size); | ||
255 | switch (size) { | ||
256 | case 1:__get_user_asm(*(u8*)dst,(u8 __user *)src,ret,"b","b","=q",1); | ||
257 | return ret; | ||
258 | case 2:__get_user_asm(*(u16*)dst,(u16 __user *)src,ret,"w","w","=r",2); | ||
259 | return ret; | ||
260 | case 4:__get_user_asm(*(u32*)dst,(u32 __user *)src,ret,"l","k","=r",4); | ||
261 | return ret; | ||
262 | case 8:__get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",8); | ||
263 | return ret; | ||
264 | case 10: | ||
265 | __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16); | ||
266 | if (unlikely(ret)) return ret; | ||
267 | __get_user_asm(*(u16*)(8+(char*)dst),(u16 __user *)(8+(char __user *)src),ret,"w","w","=r",2); | ||
268 | return ret; | ||
269 | case 16: | ||
270 | __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16); | ||
271 | if (unlikely(ret)) return ret; | ||
272 | __get_user_asm(*(u64*)(8+(char*)dst),(u64 __user *)(8+(char __user *)src),ret,"q","","=r",8); | ||
273 | return ret; | ||
274 | default: | ||
275 | return copy_user_generic(dst,(__force void *)src,size); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | static __always_inline __must_check | ||
280 | int __copy_to_user(void __user *dst, const void *src, unsigned size) | ||
281 | { | ||
282 | int ret = 0; | ||
283 | if (!__builtin_constant_p(size)) | ||
284 | return copy_user_generic((__force void *)dst,src,size); | ||
285 | switch (size) { | ||
286 | case 1:__put_user_asm(*(u8*)src,(u8 __user *)dst,ret,"b","b","iq",1); | ||
287 | return ret; | ||
288 | case 2:__put_user_asm(*(u16*)src,(u16 __user *)dst,ret,"w","w","ir",2); | ||
289 | return ret; | ||
290 | case 4:__put_user_asm(*(u32*)src,(u32 __user *)dst,ret,"l","k","ir",4); | ||
291 | return ret; | ||
292 | case 8:__put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",8); | ||
293 | return ret; | ||
294 | case 10: | ||
295 | __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",10); | ||
296 | if (unlikely(ret)) return ret; | ||
297 | asm("":::"memory"); | ||
298 | __put_user_asm(4[(u16*)src],4+(u16 __user *)dst,ret,"w","w","ir",2); | ||
299 | return ret; | ||
300 | case 16: | ||
301 | __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",16); | ||
302 | if (unlikely(ret)) return ret; | ||
303 | asm("":::"memory"); | ||
304 | __put_user_asm(1[(u64*)src],1+(u64 __user *)dst,ret,"q","","ir",8); | ||
305 | return ret; | ||
306 | default: | ||
307 | return copy_user_generic((__force void *)dst,src,size); | ||
308 | } | ||
309 | } | ||
310 | |||
311 | static __always_inline __must_check | ||
312 | int __copy_in_user(void __user *dst, const void __user *src, unsigned size) | ||
313 | { | ||
314 | int ret = 0; | ||
315 | if (!__builtin_constant_p(size)) | ||
316 | return copy_user_generic((__force void *)dst,(__force void *)src,size); | ||
317 | switch (size) { | ||
318 | case 1: { | ||
319 | u8 tmp; | ||
320 | __get_user_asm(tmp,(u8 __user *)src,ret,"b","b","=q",1); | ||
321 | if (likely(!ret)) | ||
322 | __put_user_asm(tmp,(u8 __user *)dst,ret,"b","b","iq",1); | ||
323 | return ret; | ||
324 | } | ||
325 | case 2: { | ||
326 | u16 tmp; | ||
327 | __get_user_asm(tmp,(u16 __user *)src,ret,"w","w","=r",2); | ||
328 | if (likely(!ret)) | ||
329 | __put_user_asm(tmp,(u16 __user *)dst,ret,"w","w","ir",2); | ||
330 | return ret; | ||
331 | } | ||
332 | |||
333 | case 4: { | ||
334 | u32 tmp; | ||
335 | __get_user_asm(tmp,(u32 __user *)src,ret,"l","k","=r",4); | ||
336 | if (likely(!ret)) | ||
337 | __put_user_asm(tmp,(u32 __user *)dst,ret,"l","k","ir",4); | ||
338 | return ret; | ||
339 | } | ||
340 | case 8: { | ||
341 | u64 tmp; | ||
342 | __get_user_asm(tmp,(u64 __user *)src,ret,"q","","=r",8); | ||
343 | if (likely(!ret)) | ||
344 | __put_user_asm(tmp,(u64 __user *)dst,ret,"q","","ir",8); | ||
345 | return ret; | ||
346 | } | ||
347 | default: | ||
348 | return copy_user_generic((__force void *)dst,(__force void *)src,size); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | __must_check long | ||
353 | strncpy_from_user(char *dst, const char __user *src, long count); | ||
354 | __must_check long | ||
355 | __strncpy_from_user(char *dst, const char __user *src, long count); | ||
356 | __must_check long strnlen_user(const char __user *str, long n); | ||
357 | __must_check long __strnlen_user(const char __user *str, long n); | ||
358 | __must_check long strlen_user(const char __user *str); | ||
359 | __must_check unsigned long clear_user(void __user *mem, unsigned long len); | ||
360 | __must_check unsigned long __clear_user(void __user *mem, unsigned long len); | ||
361 | |||
362 | __must_check long __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size); | ||
363 | |||
364 | static __must_check __always_inline int | ||
365 | __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) | ||
366 | { | ||
367 | return copy_user_generic((__force void *)dst, src, size); | ||
368 | } | ||
369 | |||
370 | #define ARCH_HAS_NOCACHE_UACCESS 1 | ||
371 | extern long __copy_user_nocache(void *dst, const void __user *src, unsigned size, int zerorest); | ||
372 | |||
373 | static inline int __copy_from_user_nocache(void *dst, const void __user *src, unsigned size) | ||
374 | { | ||
375 | might_sleep(); | ||
376 | return __copy_user_nocache(dst, src, size, 1); | ||
377 | } | ||
378 | |||
379 | static inline int __copy_from_user_inatomic_nocache(void *dst, const void __user *src, unsigned size) | ||
380 | { | ||
381 | return __copy_user_nocache(dst, src, size, 0); | ||
382 | } | ||
383 | |||
384 | #endif /* __X86_64_UACCESS_H */ | ||
diff --git a/include/asm-x86/ucontext.h b/include/asm-x86/ucontext.h new file mode 100644 index 000000000000..175c8cb59731 --- /dev/null +++ b/include/asm-x86/ucontext.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "ucontext_32.h" | ||
4 | # else | ||
5 | # include "ucontext_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "ucontext_32.h" | ||
10 | # else | ||
11 | # include "ucontext_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/ucontext_32.h b/include/asm-x86/ucontext_32.h new file mode 100644 index 000000000000..b0db36925f55 --- /dev/null +++ b/include/asm-x86/ucontext_32.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASMi386_UCONTEXT_H | ||
2 | #define _ASMi386_UCONTEXT_H | ||
3 | |||
4 | struct ucontext { | ||
5 | unsigned long uc_flags; | ||
6 | struct ucontext *uc_link; | ||
7 | stack_t uc_stack; | ||
8 | struct sigcontext uc_mcontext; | ||
9 | sigset_t uc_sigmask; /* mask last for extensibility */ | ||
10 | }; | ||
11 | |||
12 | #endif /* !_ASMi386_UCONTEXT_H */ | ||
diff --git a/include/asm-x86/ucontext_64.h b/include/asm-x86/ucontext_64.h new file mode 100644 index 000000000000..159a3da9e112 --- /dev/null +++ b/include/asm-x86/ucontext_64.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASMX8664_UCONTEXT_H | ||
2 | #define _ASMX8664_UCONTEXT_H | ||
3 | |||
4 | struct ucontext { | ||
5 | unsigned long uc_flags; | ||
6 | struct ucontext *uc_link; | ||
7 | stack_t uc_stack; | ||
8 | struct sigcontext uc_mcontext; | ||
9 | sigset_t uc_sigmask; /* mask last for extensibility */ | ||
10 | }; | ||
11 | |||
12 | #endif | ||
diff --git a/include/asm-x86/unaligned.h b/include/asm-x86/unaligned.h new file mode 100644 index 000000000000..68067150fbcb --- /dev/null +++ b/include/asm-x86/unaligned.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "unaligned_32.h" | ||
3 | #else | ||
4 | # include "unaligned_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/unaligned_32.h b/include/asm-x86/unaligned_32.h new file mode 100644 index 000000000000..7acd7957621e --- /dev/null +++ b/include/asm-x86/unaligned_32.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef __I386_UNALIGNED_H | ||
2 | #define __I386_UNALIGNED_H | ||
3 | |||
4 | /* | ||
5 | * The i386 can do unaligned accesses itself. | ||
6 | * | ||
7 | * The strange macros are there to make sure these can't | ||
8 | * be misused in a way that makes them not work on other | ||
9 | * architectures where unaligned accesses aren't as simple. | ||
10 | */ | ||
11 | |||
12 | /** | ||
13 | * get_unaligned - get value from possibly mis-aligned location | ||
14 | * @ptr: pointer to value | ||
15 | * | ||
16 | * This macro should be used for accessing values larger in size than | ||
17 | * single bytes at locations that are expected to be improperly aligned, | ||
18 | * e.g. retrieving a u16 value from a location not u16-aligned. | ||
19 | * | ||
20 | * Note that unaligned accesses can be very expensive on some architectures. | ||
21 | */ | ||
22 | #define get_unaligned(ptr) (*(ptr)) | ||
23 | |||
24 | /** | ||
25 | * put_unaligned - put value to a possibly mis-aligned location | ||
26 | * @val: value to place | ||
27 | * @ptr: pointer to location | ||
28 | * | ||
29 | * This macro should be used for placing values larger in size than | ||
30 | * single bytes at locations that are expected to be improperly aligned, | ||
31 | * e.g. writing a u16 value to a location not u16-aligned. | ||
32 | * | ||
33 | * Note that unaligned accesses can be very expensive on some architectures. | ||
34 | */ | ||
35 | #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) | ||
36 | |||
37 | #endif | ||
diff --git a/include/asm-x86/unaligned_64.h b/include/asm-x86/unaligned_64.h new file mode 100644 index 000000000000..d4bf78dc6f39 --- /dev/null +++ b/include/asm-x86/unaligned_64.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef __X8664_UNALIGNED_H | ||
2 | #define __X8664_UNALIGNED_H | ||
3 | |||
4 | /* | ||
5 | * The x86-64 can do unaligned accesses itself. | ||
6 | * | ||
7 | * The strange macros are there to make sure these can't | ||
8 | * be misused in a way that makes them not work on other | ||
9 | * architectures where unaligned accesses aren't as simple. | ||
10 | */ | ||
11 | |||
12 | /** | ||
13 | * get_unaligned - get value from possibly mis-aligned location | ||
14 | * @ptr: pointer to value | ||
15 | * | ||
16 | * This macro should be used for accessing values larger in size than | ||
17 | * single bytes at locations that are expected to be improperly aligned, | ||
18 | * e.g. retrieving a u16 value from a location not u16-aligned. | ||
19 | * | ||
20 | * Note that unaligned accesses can be very expensive on some architectures. | ||
21 | */ | ||
22 | #define get_unaligned(ptr) (*(ptr)) | ||
23 | |||
24 | /** | ||
25 | * put_unaligned - put value to a possibly mis-aligned location | ||
26 | * @val: value to place | ||
27 | * @ptr: pointer to location | ||
28 | * | ||
29 | * This macro should be used for placing values larger in size than | ||
30 | * single bytes at locations that are expected to be improperly aligned, | ||
31 | * e.g. writing a u16 value to a location not u16-aligned. | ||
32 | * | ||
33 | * Note that unaligned accesses can be very expensive on some architectures. | ||
34 | */ | ||
35 | #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) | ||
36 | |||
37 | #endif | ||
diff --git a/include/asm-x86/unistd.h b/include/asm-x86/unistd.h new file mode 100644 index 000000000000..2a58ed3e51d8 --- /dev/null +++ b/include/asm-x86/unistd.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "unistd_32.h" | ||
4 | # else | ||
5 | # include "unistd_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "unistd_32.h" | ||
10 | # else | ||
11 | # include "unistd_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/unistd_32.h b/include/asm-x86/unistd_32.h new file mode 100644 index 000000000000..9b15545eb9b5 --- /dev/null +++ b/include/asm-x86/unistd_32.h | |||
@@ -0,0 +1,373 @@ | |||
1 | #ifndef _ASM_I386_UNISTD_H_ | ||
2 | #define _ASM_I386_UNISTD_H_ | ||
3 | |||
4 | /* | ||
5 | * This file contains the system call numbers. | ||
6 | */ | ||
7 | |||
8 | #define __NR_restart_syscall 0 | ||
9 | #define __NR_exit 1 | ||
10 | #define __NR_fork 2 | ||
11 | #define __NR_read 3 | ||
12 | #define __NR_write 4 | ||
13 | #define __NR_open 5 | ||
14 | #define __NR_close 6 | ||
15 | #define __NR_waitpid 7 | ||
16 | #define __NR_creat 8 | ||
17 | #define __NR_link 9 | ||
18 | #define __NR_unlink 10 | ||
19 | #define __NR_execve 11 | ||
20 | #define __NR_chdir 12 | ||
21 | #define __NR_time 13 | ||
22 | #define __NR_mknod 14 | ||
23 | #define __NR_chmod 15 | ||
24 | #define __NR_lchown 16 | ||
25 | #define __NR_break 17 | ||
26 | #define __NR_oldstat 18 | ||
27 | #define __NR_lseek 19 | ||
28 | #define __NR_getpid 20 | ||
29 | #define __NR_mount 21 | ||
30 | #define __NR_umount 22 | ||
31 | #define __NR_setuid 23 | ||
32 | #define __NR_getuid 24 | ||
33 | #define __NR_stime 25 | ||
34 | #define __NR_ptrace 26 | ||
35 | #define __NR_alarm 27 | ||
36 | #define __NR_oldfstat 28 | ||
37 | #define __NR_pause 29 | ||
38 | #define __NR_utime 30 | ||
39 | #define __NR_stty 31 | ||
40 | #define __NR_gtty 32 | ||
41 | #define __NR_access 33 | ||
42 | #define __NR_nice 34 | ||
43 | #define __NR_ftime 35 | ||
44 | #define __NR_sync 36 | ||
45 | #define __NR_kill 37 | ||
46 | #define __NR_rename 38 | ||
47 | #define __NR_mkdir 39 | ||
48 | #define __NR_rmdir 40 | ||
49 | #define __NR_dup 41 | ||
50 | #define __NR_pipe 42 | ||
51 | #define __NR_times 43 | ||
52 | #define __NR_prof 44 | ||
53 | #define __NR_brk 45 | ||
54 | #define __NR_setgid 46 | ||
55 | #define __NR_getgid 47 | ||
56 | #define __NR_signal 48 | ||
57 | #define __NR_geteuid 49 | ||
58 | #define __NR_getegid 50 | ||
59 | #define __NR_acct 51 | ||
60 | #define __NR_umount2 52 | ||
61 | #define __NR_lock 53 | ||
62 | #define __NR_ioctl 54 | ||
63 | #define __NR_fcntl 55 | ||
64 | #define __NR_mpx 56 | ||
65 | #define __NR_setpgid 57 | ||
66 | #define __NR_ulimit 58 | ||
67 | #define __NR_oldolduname 59 | ||
68 | #define __NR_umask 60 | ||
69 | #define __NR_chroot 61 | ||
70 | #define __NR_ustat 62 | ||
71 | #define __NR_dup2 63 | ||
72 | #define __NR_getppid 64 | ||
73 | #define __NR_getpgrp 65 | ||
74 | #define __NR_setsid 66 | ||
75 | #define __NR_sigaction 67 | ||
76 | #define __NR_sgetmask 68 | ||
77 | #define __NR_ssetmask 69 | ||
78 | #define __NR_setreuid 70 | ||
79 | #define __NR_setregid 71 | ||
80 | #define __NR_sigsuspend 72 | ||
81 | #define __NR_sigpending 73 | ||
82 | #define __NR_sethostname 74 | ||
83 | #define __NR_setrlimit 75 | ||
84 | #define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ | ||
85 | #define __NR_getrusage 77 | ||
86 | #define __NR_gettimeofday 78 | ||
87 | #define __NR_settimeofday 79 | ||
88 | #define __NR_getgroups 80 | ||
89 | #define __NR_setgroups 81 | ||
90 | #define __NR_select 82 | ||
91 | #define __NR_symlink 83 | ||
92 | #define __NR_oldlstat 84 | ||
93 | #define __NR_readlink 85 | ||
94 | #define __NR_uselib 86 | ||
95 | #define __NR_swapon 87 | ||
96 | #define __NR_reboot 88 | ||
97 | #define __NR_readdir 89 | ||
98 | #define __NR_mmap 90 | ||
99 | #define __NR_munmap 91 | ||
100 | #define __NR_truncate 92 | ||
101 | #define __NR_ftruncate 93 | ||
102 | #define __NR_fchmod 94 | ||
103 | #define __NR_fchown 95 | ||
104 | #define __NR_getpriority 96 | ||
105 | #define __NR_setpriority 97 | ||
106 | #define __NR_profil 98 | ||
107 | #define __NR_statfs 99 | ||
108 | #define __NR_fstatfs 100 | ||
109 | #define __NR_ioperm 101 | ||
110 | #define __NR_socketcall 102 | ||
111 | #define __NR_syslog 103 | ||
112 | #define __NR_setitimer 104 | ||
113 | #define __NR_getitimer 105 | ||
114 | #define __NR_stat 106 | ||
115 | #define __NR_lstat 107 | ||
116 | #define __NR_fstat 108 | ||
117 | #define __NR_olduname 109 | ||
118 | #define __NR_iopl 110 | ||
119 | #define __NR_vhangup 111 | ||
120 | #define __NR_idle 112 | ||
121 | #define __NR_vm86old 113 | ||
122 | #define __NR_wait4 114 | ||
123 | #define __NR_swapoff 115 | ||
124 | #define __NR_sysinfo 116 | ||
125 | #define __NR_ipc 117 | ||
126 | #define __NR_fsync 118 | ||
127 | #define __NR_sigreturn 119 | ||
128 | #define __NR_clone 120 | ||
129 | #define __NR_setdomainname 121 | ||
130 | #define __NR_uname 122 | ||
131 | #define __NR_modify_ldt 123 | ||
132 | #define __NR_adjtimex 124 | ||
133 | #define __NR_mprotect 125 | ||
134 | #define __NR_sigprocmask 126 | ||
135 | #define __NR_create_module 127 | ||
136 | #define __NR_init_module 128 | ||
137 | #define __NR_delete_module 129 | ||
138 | #define __NR_get_kernel_syms 130 | ||
139 | #define __NR_quotactl 131 | ||
140 | #define __NR_getpgid 132 | ||
141 | #define __NR_fchdir 133 | ||
142 | #define __NR_bdflush 134 | ||
143 | #define __NR_sysfs 135 | ||
144 | #define __NR_personality 136 | ||
145 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
146 | #define __NR_setfsuid 138 | ||
147 | #define __NR_setfsgid 139 | ||
148 | #define __NR__llseek 140 | ||
149 | #define __NR_getdents 141 | ||
150 | #define __NR__newselect 142 | ||
151 | #define __NR_flock 143 | ||
152 | #define __NR_msync 144 | ||
153 | #define __NR_readv 145 | ||
154 | #define __NR_writev 146 | ||
155 | #define __NR_getsid 147 | ||
156 | #define __NR_fdatasync 148 | ||
157 | #define __NR__sysctl 149 | ||
158 | #define __NR_mlock 150 | ||
159 | #define __NR_munlock 151 | ||
160 | #define __NR_mlockall 152 | ||
161 | #define __NR_munlockall 153 | ||
162 | #define __NR_sched_setparam 154 | ||
163 | #define __NR_sched_getparam 155 | ||
164 | #define __NR_sched_setscheduler 156 | ||
165 | #define __NR_sched_getscheduler 157 | ||
166 | #define __NR_sched_yield 158 | ||
167 | #define __NR_sched_get_priority_max 159 | ||
168 | #define __NR_sched_get_priority_min 160 | ||
169 | #define __NR_sched_rr_get_interval 161 | ||
170 | #define __NR_nanosleep 162 | ||
171 | #define __NR_mremap 163 | ||
172 | #define __NR_setresuid 164 | ||
173 | #define __NR_getresuid 165 | ||
174 | #define __NR_vm86 166 | ||
175 | #define __NR_query_module 167 | ||
176 | #define __NR_poll 168 | ||
177 | #define __NR_nfsservctl 169 | ||
178 | #define __NR_setresgid 170 | ||
179 | #define __NR_getresgid 171 | ||
180 | #define __NR_prctl 172 | ||
181 | #define __NR_rt_sigreturn 173 | ||
182 | #define __NR_rt_sigaction 174 | ||
183 | #define __NR_rt_sigprocmask 175 | ||
184 | #define __NR_rt_sigpending 176 | ||
185 | #define __NR_rt_sigtimedwait 177 | ||
186 | #define __NR_rt_sigqueueinfo 178 | ||
187 | #define __NR_rt_sigsuspend 179 | ||
188 | #define __NR_pread64 180 | ||
189 | #define __NR_pwrite64 181 | ||
190 | #define __NR_chown 182 | ||
191 | #define __NR_getcwd 183 | ||
192 | #define __NR_capget 184 | ||
193 | #define __NR_capset 185 | ||
194 | #define __NR_sigaltstack 186 | ||
195 | #define __NR_sendfile 187 | ||
196 | #define __NR_getpmsg 188 /* some people actually want streams */ | ||
197 | #define __NR_putpmsg 189 /* some people actually want streams */ | ||
198 | #define __NR_vfork 190 | ||
199 | #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ | ||
200 | #define __NR_mmap2 192 | ||
201 | #define __NR_truncate64 193 | ||
202 | #define __NR_ftruncate64 194 | ||
203 | #define __NR_stat64 195 | ||
204 | #define __NR_lstat64 196 | ||
205 | #define __NR_fstat64 197 | ||
206 | #define __NR_lchown32 198 | ||
207 | #define __NR_getuid32 199 | ||
208 | #define __NR_getgid32 200 | ||
209 | #define __NR_geteuid32 201 | ||
210 | #define __NR_getegid32 202 | ||
211 | #define __NR_setreuid32 203 | ||
212 | #define __NR_setregid32 204 | ||
213 | #define __NR_getgroups32 205 | ||
214 | #define __NR_setgroups32 206 | ||
215 | #define __NR_fchown32 207 | ||
216 | #define __NR_setresuid32 208 | ||
217 | #define __NR_getresuid32 209 | ||
218 | #define __NR_setresgid32 210 | ||
219 | #define __NR_getresgid32 211 | ||
220 | #define __NR_chown32 212 | ||
221 | #define __NR_setuid32 213 | ||
222 | #define __NR_setgid32 214 | ||
223 | #define __NR_setfsuid32 215 | ||
224 | #define __NR_setfsgid32 216 | ||
225 | #define __NR_pivot_root 217 | ||
226 | #define __NR_mincore 218 | ||
227 | #define __NR_madvise 219 | ||
228 | #define __NR_madvise1 219 /* delete when C lib stub is removed */ | ||
229 | #define __NR_getdents64 220 | ||
230 | #define __NR_fcntl64 221 | ||
231 | /* 223 is unused */ | ||
232 | #define __NR_gettid 224 | ||
233 | #define __NR_readahead 225 | ||
234 | #define __NR_setxattr 226 | ||
235 | #define __NR_lsetxattr 227 | ||
236 | #define __NR_fsetxattr 228 | ||
237 | #define __NR_getxattr 229 | ||
238 | #define __NR_lgetxattr 230 | ||
239 | #define __NR_fgetxattr 231 | ||
240 | #define __NR_listxattr 232 | ||
241 | #define __NR_llistxattr 233 | ||
242 | #define __NR_flistxattr 234 | ||
243 | #define __NR_removexattr 235 | ||
244 | #define __NR_lremovexattr 236 | ||
245 | #define __NR_fremovexattr 237 | ||
246 | #define __NR_tkill 238 | ||
247 | #define __NR_sendfile64 239 | ||
248 | #define __NR_futex 240 | ||
249 | #define __NR_sched_setaffinity 241 | ||
250 | #define __NR_sched_getaffinity 242 | ||
251 | #define __NR_set_thread_area 243 | ||
252 | #define __NR_get_thread_area 244 | ||
253 | #define __NR_io_setup 245 | ||
254 | #define __NR_io_destroy 246 | ||
255 | #define __NR_io_getevents 247 | ||
256 | #define __NR_io_submit 248 | ||
257 | #define __NR_io_cancel 249 | ||
258 | #define __NR_fadvise64 250 | ||
259 | /* 251 is available for reuse (was briefly sys_set_zone_reclaim) */ | ||
260 | #define __NR_exit_group 252 | ||
261 | #define __NR_lookup_dcookie 253 | ||
262 | #define __NR_epoll_create 254 | ||
263 | #define __NR_epoll_ctl 255 | ||
264 | #define __NR_epoll_wait 256 | ||
265 | #define __NR_remap_file_pages 257 | ||
266 | #define __NR_set_tid_address 258 | ||
267 | #define __NR_timer_create 259 | ||
268 | #define __NR_timer_settime (__NR_timer_create+1) | ||
269 | #define __NR_timer_gettime (__NR_timer_create+2) | ||
270 | #define __NR_timer_getoverrun (__NR_timer_create+3) | ||
271 | #define __NR_timer_delete (__NR_timer_create+4) | ||
272 | #define __NR_clock_settime (__NR_timer_create+5) | ||
273 | #define __NR_clock_gettime (__NR_timer_create+6) | ||
274 | #define __NR_clock_getres (__NR_timer_create+7) | ||
275 | #define __NR_clock_nanosleep (__NR_timer_create+8) | ||
276 | #define __NR_statfs64 268 | ||
277 | #define __NR_fstatfs64 269 | ||
278 | #define __NR_tgkill 270 | ||
279 | #define __NR_utimes 271 | ||
280 | #define __NR_fadvise64_64 272 | ||
281 | #define __NR_vserver 273 | ||
282 | #define __NR_mbind 274 | ||
283 | #define __NR_get_mempolicy 275 | ||
284 | #define __NR_set_mempolicy 276 | ||
285 | #define __NR_mq_open 277 | ||
286 | #define __NR_mq_unlink (__NR_mq_open+1) | ||
287 | #define __NR_mq_timedsend (__NR_mq_open+2) | ||
288 | #define __NR_mq_timedreceive (__NR_mq_open+3) | ||
289 | #define __NR_mq_notify (__NR_mq_open+4) | ||
290 | #define __NR_mq_getsetattr (__NR_mq_open+5) | ||
291 | #define __NR_kexec_load 283 | ||
292 | #define __NR_waitid 284 | ||
293 | /* #define __NR_sys_setaltroot 285 */ | ||
294 | #define __NR_add_key 286 | ||
295 | #define __NR_request_key 287 | ||
296 | #define __NR_keyctl 288 | ||
297 | #define __NR_ioprio_set 289 | ||
298 | #define __NR_ioprio_get 290 | ||
299 | #define __NR_inotify_init 291 | ||
300 | #define __NR_inotify_add_watch 292 | ||
301 | #define __NR_inotify_rm_watch 293 | ||
302 | #define __NR_migrate_pages 294 | ||
303 | #define __NR_openat 295 | ||
304 | #define __NR_mkdirat 296 | ||
305 | #define __NR_mknodat 297 | ||
306 | #define __NR_fchownat 298 | ||
307 | #define __NR_futimesat 299 | ||
308 | #define __NR_fstatat64 300 | ||
309 | #define __NR_unlinkat 301 | ||
310 | #define __NR_renameat 302 | ||
311 | #define __NR_linkat 303 | ||
312 | #define __NR_symlinkat 304 | ||
313 | #define __NR_readlinkat 305 | ||
314 | #define __NR_fchmodat 306 | ||
315 | #define __NR_faccessat 307 | ||
316 | #define __NR_pselect6 308 | ||
317 | #define __NR_ppoll 309 | ||
318 | #define __NR_unshare 310 | ||
319 | #define __NR_set_robust_list 311 | ||
320 | #define __NR_get_robust_list 312 | ||
321 | #define __NR_splice 313 | ||
322 | #define __NR_sync_file_range 314 | ||
323 | #define __NR_tee 315 | ||
324 | #define __NR_vmsplice 316 | ||
325 | #define __NR_move_pages 317 | ||
326 | #define __NR_getcpu 318 | ||
327 | #define __NR_epoll_pwait 319 | ||
328 | #define __NR_utimensat 320 | ||
329 | #define __NR_signalfd 321 | ||
330 | #define __NR_timerfd 322 | ||
331 | #define __NR_eventfd 323 | ||
332 | #define __NR_fallocate 324 | ||
333 | |||
334 | #ifdef __KERNEL__ | ||
335 | |||
336 | #define NR_syscalls 325 | ||
337 | |||
338 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
339 | #define __ARCH_WANT_OLD_READDIR | ||
340 | #define __ARCH_WANT_OLD_STAT | ||
341 | #define __ARCH_WANT_STAT64 | ||
342 | #define __ARCH_WANT_SYS_ALARM | ||
343 | #define __ARCH_WANT_SYS_GETHOSTNAME | ||
344 | #define __ARCH_WANT_SYS_PAUSE | ||
345 | #define __ARCH_WANT_SYS_SGETMASK | ||
346 | #define __ARCH_WANT_SYS_SIGNAL | ||
347 | #define __ARCH_WANT_SYS_TIME | ||
348 | #define __ARCH_WANT_SYS_UTIME | ||
349 | #define __ARCH_WANT_SYS_WAITPID | ||
350 | #define __ARCH_WANT_SYS_SOCKETCALL | ||
351 | #define __ARCH_WANT_SYS_FADVISE64 | ||
352 | #define __ARCH_WANT_SYS_GETPGRP | ||
353 | #define __ARCH_WANT_SYS_LLSEEK | ||
354 | #define __ARCH_WANT_SYS_NICE | ||
355 | #define __ARCH_WANT_SYS_OLD_GETRLIMIT | ||
356 | #define __ARCH_WANT_SYS_OLDUMOUNT | ||
357 | #define __ARCH_WANT_SYS_SIGPENDING | ||
358 | #define __ARCH_WANT_SYS_SIGPROCMASK | ||
359 | #define __ARCH_WANT_SYS_RT_SIGACTION | ||
360 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | ||
361 | |||
362 | /* | ||
363 | * "Conditional" syscalls | ||
364 | * | ||
365 | * What we want is __attribute__((weak,alias("sys_ni_syscall"))), | ||
366 | * but it doesn't work on all toolchains, so we just do it by hand | ||
367 | */ | ||
368 | #ifndef cond_syscall | ||
369 | #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") | ||
370 | #endif | ||
371 | |||
372 | #endif /* __KERNEL__ */ | ||
373 | #endif /* _ASM_I386_UNISTD_H_ */ | ||
diff --git a/include/asm-x86/unistd_64.h b/include/asm-x86/unistd_64.h new file mode 100644 index 000000000000..fc4e73f5f1fa --- /dev/null +++ b/include/asm-x86/unistd_64.h | |||
@@ -0,0 +1,687 @@ | |||
1 | #ifndef _ASM_X86_64_UNISTD_H_ | ||
2 | #define _ASM_X86_64_UNISTD_H_ | ||
3 | |||
4 | #ifndef __SYSCALL | ||
5 | #define __SYSCALL(a,b) | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * This file contains the system call numbers. | ||
10 | * | ||
11 | * Note: holes are not allowed. | ||
12 | */ | ||
13 | |||
14 | /* at least 8 syscall per cacheline */ | ||
15 | #define __NR_read 0 | ||
16 | __SYSCALL(__NR_read, sys_read) | ||
17 | #define __NR_write 1 | ||
18 | __SYSCALL(__NR_write, sys_write) | ||
19 | #define __NR_open 2 | ||
20 | __SYSCALL(__NR_open, sys_open) | ||
21 | #define __NR_close 3 | ||
22 | __SYSCALL(__NR_close, sys_close) | ||
23 | #define __NR_stat 4 | ||
24 | __SYSCALL(__NR_stat, sys_newstat) | ||
25 | #define __NR_fstat 5 | ||
26 | __SYSCALL(__NR_fstat, sys_newfstat) | ||
27 | #define __NR_lstat 6 | ||
28 | __SYSCALL(__NR_lstat, sys_newlstat) | ||
29 | #define __NR_poll 7 | ||
30 | __SYSCALL(__NR_poll, sys_poll) | ||
31 | |||
32 | #define __NR_lseek 8 | ||
33 | __SYSCALL(__NR_lseek, sys_lseek) | ||
34 | #define __NR_mmap 9 | ||
35 | __SYSCALL(__NR_mmap, sys_mmap) | ||
36 | #define __NR_mprotect 10 | ||
37 | __SYSCALL(__NR_mprotect, sys_mprotect) | ||
38 | #define __NR_munmap 11 | ||
39 | __SYSCALL(__NR_munmap, sys_munmap) | ||
40 | #define __NR_brk 12 | ||
41 | __SYSCALL(__NR_brk, sys_brk) | ||
42 | #define __NR_rt_sigaction 13 | ||
43 | __SYSCALL(__NR_rt_sigaction, sys_rt_sigaction) | ||
44 | #define __NR_rt_sigprocmask 14 | ||
45 | __SYSCALL(__NR_rt_sigprocmask, sys_rt_sigprocmask) | ||
46 | #define __NR_rt_sigreturn 15 | ||
47 | __SYSCALL(__NR_rt_sigreturn, stub_rt_sigreturn) | ||
48 | |||
49 | #define __NR_ioctl 16 | ||
50 | __SYSCALL(__NR_ioctl, sys_ioctl) | ||
51 | #define __NR_pread64 17 | ||
52 | __SYSCALL(__NR_pread64, sys_pread64) | ||
53 | #define __NR_pwrite64 18 | ||
54 | __SYSCALL(__NR_pwrite64, sys_pwrite64) | ||
55 | #define __NR_readv 19 | ||
56 | __SYSCALL(__NR_readv, sys_readv) | ||
57 | #define __NR_writev 20 | ||
58 | __SYSCALL(__NR_writev, sys_writev) | ||
59 | #define __NR_access 21 | ||
60 | __SYSCALL(__NR_access, sys_access) | ||
61 | #define __NR_pipe 22 | ||
62 | __SYSCALL(__NR_pipe, sys_pipe) | ||
63 | #define __NR_select 23 | ||
64 | __SYSCALL(__NR_select, sys_select) | ||
65 | |||
66 | #define __NR_sched_yield 24 | ||
67 | __SYSCALL(__NR_sched_yield, sys_sched_yield) | ||
68 | #define __NR_mremap 25 | ||
69 | __SYSCALL(__NR_mremap, sys_mremap) | ||
70 | #define __NR_msync 26 | ||
71 | __SYSCALL(__NR_msync, sys_msync) | ||
72 | #define __NR_mincore 27 | ||
73 | __SYSCALL(__NR_mincore, sys_mincore) | ||
74 | #define __NR_madvise 28 | ||
75 | __SYSCALL(__NR_madvise, sys_madvise) | ||
76 | #define __NR_shmget 29 | ||
77 | __SYSCALL(__NR_shmget, sys_shmget) | ||
78 | #define __NR_shmat 30 | ||
79 | __SYSCALL(__NR_shmat, sys_shmat) | ||
80 | #define __NR_shmctl 31 | ||
81 | __SYSCALL(__NR_shmctl, sys_shmctl) | ||
82 | |||
83 | #define __NR_dup 32 | ||
84 | __SYSCALL(__NR_dup, sys_dup) | ||
85 | #define __NR_dup2 33 | ||
86 | __SYSCALL(__NR_dup2, sys_dup2) | ||
87 | #define __NR_pause 34 | ||
88 | __SYSCALL(__NR_pause, sys_pause) | ||
89 | #define __NR_nanosleep 35 | ||
90 | __SYSCALL(__NR_nanosleep, sys_nanosleep) | ||
91 | #define __NR_getitimer 36 | ||
92 | __SYSCALL(__NR_getitimer, sys_getitimer) | ||
93 | #define __NR_alarm 37 | ||
94 | __SYSCALL(__NR_alarm, sys_alarm) | ||
95 | #define __NR_setitimer 38 | ||
96 | __SYSCALL(__NR_setitimer, sys_setitimer) | ||
97 | #define __NR_getpid 39 | ||
98 | __SYSCALL(__NR_getpid, sys_getpid) | ||
99 | |||
100 | #define __NR_sendfile 40 | ||
101 | __SYSCALL(__NR_sendfile, sys_sendfile64) | ||
102 | #define __NR_socket 41 | ||
103 | __SYSCALL(__NR_socket, sys_socket) | ||
104 | #define __NR_connect 42 | ||
105 | __SYSCALL(__NR_connect, sys_connect) | ||
106 | #define __NR_accept 43 | ||
107 | __SYSCALL(__NR_accept, sys_accept) | ||
108 | #define __NR_sendto 44 | ||
109 | __SYSCALL(__NR_sendto, sys_sendto) | ||
110 | #define __NR_recvfrom 45 | ||
111 | __SYSCALL(__NR_recvfrom, sys_recvfrom) | ||
112 | #define __NR_sendmsg 46 | ||
113 | __SYSCALL(__NR_sendmsg, sys_sendmsg) | ||
114 | #define __NR_recvmsg 47 | ||
115 | __SYSCALL(__NR_recvmsg, sys_recvmsg) | ||
116 | |||
117 | #define __NR_shutdown 48 | ||
118 | __SYSCALL(__NR_shutdown, sys_shutdown) | ||
119 | #define __NR_bind 49 | ||
120 | __SYSCALL(__NR_bind, sys_bind) | ||
121 | #define __NR_listen 50 | ||
122 | __SYSCALL(__NR_listen, sys_listen) | ||
123 | #define __NR_getsockname 51 | ||
124 | __SYSCALL(__NR_getsockname, sys_getsockname) | ||
125 | #define __NR_getpeername 52 | ||
126 | __SYSCALL(__NR_getpeername, sys_getpeername) | ||
127 | #define __NR_socketpair 53 | ||
128 | __SYSCALL(__NR_socketpair, sys_socketpair) | ||
129 | #define __NR_setsockopt 54 | ||
130 | __SYSCALL(__NR_setsockopt, sys_setsockopt) | ||
131 | #define __NR_getsockopt 55 | ||
132 | __SYSCALL(__NR_getsockopt, sys_getsockopt) | ||
133 | |||
134 | #define __NR_clone 56 | ||
135 | __SYSCALL(__NR_clone, stub_clone) | ||
136 | #define __NR_fork 57 | ||
137 | __SYSCALL(__NR_fork, stub_fork) | ||
138 | #define __NR_vfork 58 | ||
139 | __SYSCALL(__NR_vfork, stub_vfork) | ||
140 | #define __NR_execve 59 | ||
141 | __SYSCALL(__NR_execve, stub_execve) | ||
142 | #define __NR_exit 60 | ||
143 | __SYSCALL(__NR_exit, sys_exit) | ||
144 | #define __NR_wait4 61 | ||
145 | __SYSCALL(__NR_wait4, sys_wait4) | ||
146 | #define __NR_kill 62 | ||
147 | __SYSCALL(__NR_kill, sys_kill) | ||
148 | #define __NR_uname 63 | ||
149 | __SYSCALL(__NR_uname, sys_uname) | ||
150 | |||
151 | #define __NR_semget 64 | ||
152 | __SYSCALL(__NR_semget, sys_semget) | ||
153 | #define __NR_semop 65 | ||
154 | __SYSCALL(__NR_semop, sys_semop) | ||
155 | #define __NR_semctl 66 | ||
156 | __SYSCALL(__NR_semctl, sys_semctl) | ||
157 | #define __NR_shmdt 67 | ||
158 | __SYSCALL(__NR_shmdt, sys_shmdt) | ||
159 | #define __NR_msgget 68 | ||
160 | __SYSCALL(__NR_msgget, sys_msgget) | ||
161 | #define __NR_msgsnd 69 | ||
162 | __SYSCALL(__NR_msgsnd, sys_msgsnd) | ||
163 | #define __NR_msgrcv 70 | ||
164 | __SYSCALL(__NR_msgrcv, sys_msgrcv) | ||
165 | #define __NR_msgctl 71 | ||
166 | __SYSCALL(__NR_msgctl, sys_msgctl) | ||
167 | |||
168 | #define __NR_fcntl 72 | ||
169 | __SYSCALL(__NR_fcntl, sys_fcntl) | ||
170 | #define __NR_flock 73 | ||
171 | __SYSCALL(__NR_flock, sys_flock) | ||
172 | #define __NR_fsync 74 | ||
173 | __SYSCALL(__NR_fsync, sys_fsync) | ||
174 | #define __NR_fdatasync 75 | ||
175 | __SYSCALL(__NR_fdatasync, sys_fdatasync) | ||
176 | #define __NR_truncate 76 | ||
177 | __SYSCALL(__NR_truncate, sys_truncate) | ||
178 | #define __NR_ftruncate 77 | ||
179 | __SYSCALL(__NR_ftruncate, sys_ftruncate) | ||
180 | #define __NR_getdents 78 | ||
181 | __SYSCALL(__NR_getdents, sys_getdents) | ||
182 | #define __NR_getcwd 79 | ||
183 | __SYSCALL(__NR_getcwd, sys_getcwd) | ||
184 | |||
185 | #define __NR_chdir 80 | ||
186 | __SYSCALL(__NR_chdir, sys_chdir) | ||
187 | #define __NR_fchdir 81 | ||
188 | __SYSCALL(__NR_fchdir, sys_fchdir) | ||
189 | #define __NR_rename 82 | ||
190 | __SYSCALL(__NR_rename, sys_rename) | ||
191 | #define __NR_mkdir 83 | ||
192 | __SYSCALL(__NR_mkdir, sys_mkdir) | ||
193 | #define __NR_rmdir 84 | ||
194 | __SYSCALL(__NR_rmdir, sys_rmdir) | ||
195 | #define __NR_creat 85 | ||
196 | __SYSCALL(__NR_creat, sys_creat) | ||
197 | #define __NR_link 86 | ||
198 | __SYSCALL(__NR_link, sys_link) | ||
199 | #define __NR_unlink 87 | ||
200 | __SYSCALL(__NR_unlink, sys_unlink) | ||
201 | |||
202 | #define __NR_symlink 88 | ||
203 | __SYSCALL(__NR_symlink, sys_symlink) | ||
204 | #define __NR_readlink 89 | ||
205 | __SYSCALL(__NR_readlink, sys_readlink) | ||
206 | #define __NR_chmod 90 | ||
207 | __SYSCALL(__NR_chmod, sys_chmod) | ||
208 | #define __NR_fchmod 91 | ||
209 | __SYSCALL(__NR_fchmod, sys_fchmod) | ||
210 | #define __NR_chown 92 | ||
211 | __SYSCALL(__NR_chown, sys_chown) | ||
212 | #define __NR_fchown 93 | ||
213 | __SYSCALL(__NR_fchown, sys_fchown) | ||
214 | #define __NR_lchown 94 | ||
215 | __SYSCALL(__NR_lchown, sys_lchown) | ||
216 | #define __NR_umask 95 | ||
217 | __SYSCALL(__NR_umask, sys_umask) | ||
218 | |||
219 | #define __NR_gettimeofday 96 | ||
220 | __SYSCALL(__NR_gettimeofday, sys_gettimeofday) | ||
221 | #define __NR_getrlimit 97 | ||
222 | __SYSCALL(__NR_getrlimit, sys_getrlimit) | ||
223 | #define __NR_getrusage 98 | ||
224 | __SYSCALL(__NR_getrusage, sys_getrusage) | ||
225 | #define __NR_sysinfo 99 | ||
226 | __SYSCALL(__NR_sysinfo, sys_sysinfo) | ||
227 | #define __NR_times 100 | ||
228 | __SYSCALL(__NR_times, sys_times) | ||
229 | #define __NR_ptrace 101 | ||
230 | __SYSCALL(__NR_ptrace, sys_ptrace) | ||
231 | #define __NR_getuid 102 | ||
232 | __SYSCALL(__NR_getuid, sys_getuid) | ||
233 | #define __NR_syslog 103 | ||
234 | __SYSCALL(__NR_syslog, sys_syslog) | ||
235 | |||
236 | /* at the very end the stuff that never runs during the benchmarks */ | ||
237 | #define __NR_getgid 104 | ||
238 | __SYSCALL(__NR_getgid, sys_getgid) | ||
239 | #define __NR_setuid 105 | ||
240 | __SYSCALL(__NR_setuid, sys_setuid) | ||
241 | #define __NR_setgid 106 | ||
242 | __SYSCALL(__NR_setgid, sys_setgid) | ||
243 | #define __NR_geteuid 107 | ||
244 | __SYSCALL(__NR_geteuid, sys_geteuid) | ||
245 | #define __NR_getegid 108 | ||
246 | __SYSCALL(__NR_getegid, sys_getegid) | ||
247 | #define __NR_setpgid 109 | ||
248 | __SYSCALL(__NR_setpgid, sys_setpgid) | ||
249 | #define __NR_getppid 110 | ||
250 | __SYSCALL(__NR_getppid, sys_getppid) | ||
251 | #define __NR_getpgrp 111 | ||
252 | __SYSCALL(__NR_getpgrp, sys_getpgrp) | ||
253 | |||
254 | #define __NR_setsid 112 | ||
255 | __SYSCALL(__NR_setsid, sys_setsid) | ||
256 | #define __NR_setreuid 113 | ||
257 | __SYSCALL(__NR_setreuid, sys_setreuid) | ||
258 | #define __NR_setregid 114 | ||
259 | __SYSCALL(__NR_setregid, sys_setregid) | ||
260 | #define __NR_getgroups 115 | ||
261 | __SYSCALL(__NR_getgroups, sys_getgroups) | ||
262 | #define __NR_setgroups 116 | ||
263 | __SYSCALL(__NR_setgroups, sys_setgroups) | ||
264 | #define __NR_setresuid 117 | ||
265 | __SYSCALL(__NR_setresuid, sys_setresuid) | ||
266 | #define __NR_getresuid 118 | ||
267 | __SYSCALL(__NR_getresuid, sys_getresuid) | ||
268 | #define __NR_setresgid 119 | ||
269 | __SYSCALL(__NR_setresgid, sys_setresgid) | ||
270 | |||
271 | #define __NR_getresgid 120 | ||
272 | __SYSCALL(__NR_getresgid, sys_getresgid) | ||
273 | #define __NR_getpgid 121 | ||
274 | __SYSCALL(__NR_getpgid, sys_getpgid) | ||
275 | #define __NR_setfsuid 122 | ||
276 | __SYSCALL(__NR_setfsuid, sys_setfsuid) | ||
277 | #define __NR_setfsgid 123 | ||
278 | __SYSCALL(__NR_setfsgid, sys_setfsgid) | ||
279 | #define __NR_getsid 124 | ||
280 | __SYSCALL(__NR_getsid, sys_getsid) | ||
281 | #define __NR_capget 125 | ||
282 | __SYSCALL(__NR_capget, sys_capget) | ||
283 | #define __NR_capset 126 | ||
284 | __SYSCALL(__NR_capset, sys_capset) | ||
285 | |||
286 | #define __NR_rt_sigpending 127 | ||
287 | __SYSCALL(__NR_rt_sigpending, sys_rt_sigpending) | ||
288 | #define __NR_rt_sigtimedwait 128 | ||
289 | __SYSCALL(__NR_rt_sigtimedwait, sys_rt_sigtimedwait) | ||
290 | #define __NR_rt_sigqueueinfo 129 | ||
291 | __SYSCALL(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo) | ||
292 | #define __NR_rt_sigsuspend 130 | ||
293 | __SYSCALL(__NR_rt_sigsuspend, stub_rt_sigsuspend) | ||
294 | #define __NR_sigaltstack 131 | ||
295 | __SYSCALL(__NR_sigaltstack, stub_sigaltstack) | ||
296 | #define __NR_utime 132 | ||
297 | __SYSCALL(__NR_utime, sys_utime) | ||
298 | #define __NR_mknod 133 | ||
299 | __SYSCALL(__NR_mknod, sys_mknod) | ||
300 | |||
301 | /* Only needed for a.out */ | ||
302 | #define __NR_uselib 134 | ||
303 | __SYSCALL(__NR_uselib, sys_ni_syscall) | ||
304 | #define __NR_personality 135 | ||
305 | __SYSCALL(__NR_personality, sys_personality) | ||
306 | |||
307 | #define __NR_ustat 136 | ||
308 | __SYSCALL(__NR_ustat, sys_ustat) | ||
309 | #define __NR_statfs 137 | ||
310 | __SYSCALL(__NR_statfs, sys_statfs) | ||
311 | #define __NR_fstatfs 138 | ||
312 | __SYSCALL(__NR_fstatfs, sys_fstatfs) | ||
313 | #define __NR_sysfs 139 | ||
314 | __SYSCALL(__NR_sysfs, sys_sysfs) | ||
315 | |||
316 | #define __NR_getpriority 140 | ||
317 | __SYSCALL(__NR_getpriority, sys_getpriority) | ||
318 | #define __NR_setpriority 141 | ||
319 | __SYSCALL(__NR_setpriority, sys_setpriority) | ||
320 | #define __NR_sched_setparam 142 | ||
321 | __SYSCALL(__NR_sched_setparam, sys_sched_setparam) | ||
322 | #define __NR_sched_getparam 143 | ||
323 | __SYSCALL(__NR_sched_getparam, sys_sched_getparam) | ||
324 | #define __NR_sched_setscheduler 144 | ||
325 | __SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler) | ||
326 | #define __NR_sched_getscheduler 145 | ||
327 | __SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler) | ||
328 | #define __NR_sched_get_priority_max 146 | ||
329 | __SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max) | ||
330 | #define __NR_sched_get_priority_min 147 | ||
331 | __SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min) | ||
332 | #define __NR_sched_rr_get_interval 148 | ||
333 | __SYSCALL(__NR_sched_rr_get_interval, sys_sched_rr_get_interval) | ||
334 | |||
335 | #define __NR_mlock 149 | ||
336 | __SYSCALL(__NR_mlock, sys_mlock) | ||
337 | #define __NR_munlock 150 | ||
338 | __SYSCALL(__NR_munlock, sys_munlock) | ||
339 | #define __NR_mlockall 151 | ||
340 | __SYSCALL(__NR_mlockall, sys_mlockall) | ||
341 | #define __NR_munlockall 152 | ||
342 | __SYSCALL(__NR_munlockall, sys_munlockall) | ||
343 | |||
344 | #define __NR_vhangup 153 | ||
345 | __SYSCALL(__NR_vhangup, sys_vhangup) | ||
346 | |||
347 | #define __NR_modify_ldt 154 | ||
348 | __SYSCALL(__NR_modify_ldt, sys_modify_ldt) | ||
349 | |||
350 | #define __NR_pivot_root 155 | ||
351 | __SYSCALL(__NR_pivot_root, sys_pivot_root) | ||
352 | |||
353 | #define __NR__sysctl 156 | ||
354 | __SYSCALL(__NR__sysctl, sys_sysctl) | ||
355 | |||
356 | #define __NR_prctl 157 | ||
357 | __SYSCALL(__NR_prctl, sys_prctl) | ||
358 | #define __NR_arch_prctl 158 | ||
359 | __SYSCALL(__NR_arch_prctl, sys_arch_prctl) | ||
360 | |||
361 | #define __NR_adjtimex 159 | ||
362 | __SYSCALL(__NR_adjtimex, sys_adjtimex) | ||
363 | |||
364 | #define __NR_setrlimit 160 | ||
365 | __SYSCALL(__NR_setrlimit, sys_setrlimit) | ||
366 | |||
367 | #define __NR_chroot 161 | ||
368 | __SYSCALL(__NR_chroot, sys_chroot) | ||
369 | |||
370 | #define __NR_sync 162 | ||
371 | __SYSCALL(__NR_sync, sys_sync) | ||
372 | |||
373 | #define __NR_acct 163 | ||
374 | __SYSCALL(__NR_acct, sys_acct) | ||
375 | |||
376 | #define __NR_settimeofday 164 | ||
377 | __SYSCALL(__NR_settimeofday, sys_settimeofday) | ||
378 | |||
379 | #define __NR_mount 165 | ||
380 | __SYSCALL(__NR_mount, sys_mount) | ||
381 | #define __NR_umount2 166 | ||
382 | __SYSCALL(__NR_umount2, sys_umount) | ||
383 | |||
384 | #define __NR_swapon 167 | ||
385 | __SYSCALL(__NR_swapon, sys_swapon) | ||
386 | #define __NR_swapoff 168 | ||
387 | __SYSCALL(__NR_swapoff, sys_swapoff) | ||
388 | |||
389 | #define __NR_reboot 169 | ||
390 | __SYSCALL(__NR_reboot, sys_reboot) | ||
391 | |||
392 | #define __NR_sethostname 170 | ||
393 | __SYSCALL(__NR_sethostname, sys_sethostname) | ||
394 | #define __NR_setdomainname 171 | ||
395 | __SYSCALL(__NR_setdomainname, sys_setdomainname) | ||
396 | |||
397 | #define __NR_iopl 172 | ||
398 | __SYSCALL(__NR_iopl, stub_iopl) | ||
399 | #define __NR_ioperm 173 | ||
400 | __SYSCALL(__NR_ioperm, sys_ioperm) | ||
401 | |||
402 | #define __NR_create_module 174 | ||
403 | __SYSCALL(__NR_create_module, sys_ni_syscall) | ||
404 | #define __NR_init_module 175 | ||
405 | __SYSCALL(__NR_init_module, sys_init_module) | ||
406 | #define __NR_delete_module 176 | ||
407 | __SYSCALL(__NR_delete_module, sys_delete_module) | ||
408 | #define __NR_get_kernel_syms 177 | ||
409 | __SYSCALL(__NR_get_kernel_syms, sys_ni_syscall) | ||
410 | #define __NR_query_module 178 | ||
411 | __SYSCALL(__NR_query_module, sys_ni_syscall) | ||
412 | |||
413 | #define __NR_quotactl 179 | ||
414 | __SYSCALL(__NR_quotactl, sys_quotactl) | ||
415 | |||
416 | #define __NR_nfsservctl 180 | ||
417 | __SYSCALL(__NR_nfsservctl, sys_nfsservctl) | ||
418 | |||
419 | #define __NR_getpmsg 181 /* reserved for LiS/STREAMS */ | ||
420 | __SYSCALL(__NR_getpmsg, sys_ni_syscall) | ||
421 | #define __NR_putpmsg 182 /* reserved for LiS/STREAMS */ | ||
422 | __SYSCALL(__NR_putpmsg, sys_ni_syscall) | ||
423 | |||
424 | #define __NR_afs_syscall 183 /* reserved for AFS */ | ||
425 | __SYSCALL(__NR_afs_syscall, sys_ni_syscall) | ||
426 | |||
427 | #define __NR_tuxcall 184 /* reserved for tux */ | ||
428 | __SYSCALL(__NR_tuxcall, sys_ni_syscall) | ||
429 | |||
430 | #define __NR_security 185 | ||
431 | __SYSCALL(__NR_security, sys_ni_syscall) | ||
432 | |||
433 | #define __NR_gettid 186 | ||
434 | __SYSCALL(__NR_gettid, sys_gettid) | ||
435 | |||
436 | #define __NR_readahead 187 | ||
437 | __SYSCALL(__NR_readahead, sys_readahead) | ||
438 | #define __NR_setxattr 188 | ||
439 | __SYSCALL(__NR_setxattr, sys_setxattr) | ||
440 | #define __NR_lsetxattr 189 | ||
441 | __SYSCALL(__NR_lsetxattr, sys_lsetxattr) | ||
442 | #define __NR_fsetxattr 190 | ||
443 | __SYSCALL(__NR_fsetxattr, sys_fsetxattr) | ||
444 | #define __NR_getxattr 191 | ||
445 | __SYSCALL(__NR_getxattr, sys_getxattr) | ||
446 | #define __NR_lgetxattr 192 | ||
447 | __SYSCALL(__NR_lgetxattr, sys_lgetxattr) | ||
448 | #define __NR_fgetxattr 193 | ||
449 | __SYSCALL(__NR_fgetxattr, sys_fgetxattr) | ||
450 | #define __NR_listxattr 194 | ||
451 | __SYSCALL(__NR_listxattr, sys_listxattr) | ||
452 | #define __NR_llistxattr 195 | ||
453 | __SYSCALL(__NR_llistxattr, sys_llistxattr) | ||
454 | #define __NR_flistxattr 196 | ||
455 | __SYSCALL(__NR_flistxattr, sys_flistxattr) | ||
456 | #define __NR_removexattr 197 | ||
457 | __SYSCALL(__NR_removexattr, sys_removexattr) | ||
458 | #define __NR_lremovexattr 198 | ||
459 | __SYSCALL(__NR_lremovexattr, sys_lremovexattr) | ||
460 | #define __NR_fremovexattr 199 | ||
461 | __SYSCALL(__NR_fremovexattr, sys_fremovexattr) | ||
462 | #define __NR_tkill 200 | ||
463 | __SYSCALL(__NR_tkill, sys_tkill) | ||
464 | #define __NR_time 201 | ||
465 | __SYSCALL(__NR_time, sys_time) | ||
466 | #define __NR_futex 202 | ||
467 | __SYSCALL(__NR_futex, sys_futex) | ||
468 | #define __NR_sched_setaffinity 203 | ||
469 | __SYSCALL(__NR_sched_setaffinity, sys_sched_setaffinity) | ||
470 | #define __NR_sched_getaffinity 204 | ||
471 | __SYSCALL(__NR_sched_getaffinity, sys_sched_getaffinity) | ||
472 | #define __NR_set_thread_area 205 | ||
473 | __SYSCALL(__NR_set_thread_area, sys_ni_syscall) /* use arch_prctl */ | ||
474 | #define __NR_io_setup 206 | ||
475 | __SYSCALL(__NR_io_setup, sys_io_setup) | ||
476 | #define __NR_io_destroy 207 | ||
477 | __SYSCALL(__NR_io_destroy, sys_io_destroy) | ||
478 | #define __NR_io_getevents 208 | ||
479 | __SYSCALL(__NR_io_getevents, sys_io_getevents) | ||
480 | #define __NR_io_submit 209 | ||
481 | __SYSCALL(__NR_io_submit, sys_io_submit) | ||
482 | #define __NR_io_cancel 210 | ||
483 | __SYSCALL(__NR_io_cancel, sys_io_cancel) | ||
484 | #define __NR_get_thread_area 211 | ||
485 | __SYSCALL(__NR_get_thread_area, sys_ni_syscall) /* use arch_prctl */ | ||
486 | #define __NR_lookup_dcookie 212 | ||
487 | __SYSCALL(__NR_lookup_dcookie, sys_lookup_dcookie) | ||
488 | #define __NR_epoll_create 213 | ||
489 | __SYSCALL(__NR_epoll_create, sys_epoll_create) | ||
490 | #define __NR_epoll_ctl_old 214 | ||
491 | __SYSCALL(__NR_epoll_ctl_old, sys_ni_syscall) | ||
492 | #define __NR_epoll_wait_old 215 | ||
493 | __SYSCALL(__NR_epoll_wait_old, sys_ni_syscall) | ||
494 | #define __NR_remap_file_pages 216 | ||
495 | __SYSCALL(__NR_remap_file_pages, sys_remap_file_pages) | ||
496 | #define __NR_getdents64 217 | ||
497 | __SYSCALL(__NR_getdents64, sys_getdents64) | ||
498 | #define __NR_set_tid_address 218 | ||
499 | __SYSCALL(__NR_set_tid_address, sys_set_tid_address) | ||
500 | #define __NR_restart_syscall 219 | ||
501 | __SYSCALL(__NR_restart_syscall, sys_restart_syscall) | ||
502 | #define __NR_semtimedop 220 | ||
503 | __SYSCALL(__NR_semtimedop, sys_semtimedop) | ||
504 | #define __NR_fadvise64 221 | ||
505 | __SYSCALL(__NR_fadvise64, sys_fadvise64) | ||
506 | #define __NR_timer_create 222 | ||
507 | __SYSCALL(__NR_timer_create, sys_timer_create) | ||
508 | #define __NR_timer_settime 223 | ||
509 | __SYSCALL(__NR_timer_settime, sys_timer_settime) | ||
510 | #define __NR_timer_gettime 224 | ||
511 | __SYSCALL(__NR_timer_gettime, sys_timer_gettime) | ||
512 | #define __NR_timer_getoverrun 225 | ||
513 | __SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun) | ||
514 | #define __NR_timer_delete 226 | ||
515 | __SYSCALL(__NR_timer_delete, sys_timer_delete) | ||
516 | #define __NR_clock_settime 227 | ||
517 | __SYSCALL(__NR_clock_settime, sys_clock_settime) | ||
518 | #define __NR_clock_gettime 228 | ||
519 | __SYSCALL(__NR_clock_gettime, sys_clock_gettime) | ||
520 | #define __NR_clock_getres 229 | ||
521 | __SYSCALL(__NR_clock_getres, sys_clock_getres) | ||
522 | #define __NR_clock_nanosleep 230 | ||
523 | __SYSCALL(__NR_clock_nanosleep, sys_clock_nanosleep) | ||
524 | #define __NR_exit_group 231 | ||
525 | __SYSCALL(__NR_exit_group, sys_exit_group) | ||
526 | #define __NR_epoll_wait 232 | ||
527 | __SYSCALL(__NR_epoll_wait, sys_epoll_wait) | ||
528 | #define __NR_epoll_ctl 233 | ||
529 | __SYSCALL(__NR_epoll_ctl, sys_epoll_ctl) | ||
530 | #define __NR_tgkill 234 | ||
531 | __SYSCALL(__NR_tgkill, sys_tgkill) | ||
532 | #define __NR_utimes 235 | ||
533 | __SYSCALL(__NR_utimes, sys_utimes) | ||
534 | #define __NR_vserver 236 | ||
535 | __SYSCALL(__NR_vserver, sys_ni_syscall) | ||
536 | #define __NR_mbind 237 | ||
537 | __SYSCALL(__NR_mbind, sys_mbind) | ||
538 | #define __NR_set_mempolicy 238 | ||
539 | __SYSCALL(__NR_set_mempolicy, sys_set_mempolicy) | ||
540 | #define __NR_get_mempolicy 239 | ||
541 | __SYSCALL(__NR_get_mempolicy, sys_get_mempolicy) | ||
542 | #define __NR_mq_open 240 | ||
543 | __SYSCALL(__NR_mq_open, sys_mq_open) | ||
544 | #define __NR_mq_unlink 241 | ||
545 | __SYSCALL(__NR_mq_unlink, sys_mq_unlink) | ||
546 | #define __NR_mq_timedsend 242 | ||
547 | __SYSCALL(__NR_mq_timedsend, sys_mq_timedsend) | ||
548 | #define __NR_mq_timedreceive 243 | ||
549 | __SYSCALL(__NR_mq_timedreceive, sys_mq_timedreceive) | ||
550 | #define __NR_mq_notify 244 | ||
551 | __SYSCALL(__NR_mq_notify, sys_mq_notify) | ||
552 | #define __NR_mq_getsetattr 245 | ||
553 | __SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr) | ||
554 | #define __NR_kexec_load 246 | ||
555 | __SYSCALL(__NR_kexec_load, sys_kexec_load) | ||
556 | #define __NR_waitid 247 | ||
557 | __SYSCALL(__NR_waitid, sys_waitid) | ||
558 | #define __NR_add_key 248 | ||
559 | __SYSCALL(__NR_add_key, sys_add_key) | ||
560 | #define __NR_request_key 249 | ||
561 | __SYSCALL(__NR_request_key, sys_request_key) | ||
562 | #define __NR_keyctl 250 | ||
563 | __SYSCALL(__NR_keyctl, sys_keyctl) | ||
564 | #define __NR_ioprio_set 251 | ||
565 | __SYSCALL(__NR_ioprio_set, sys_ioprio_set) | ||
566 | #define __NR_ioprio_get 252 | ||
567 | __SYSCALL(__NR_ioprio_get, sys_ioprio_get) | ||
568 | #define __NR_inotify_init 253 | ||
569 | __SYSCALL(__NR_inotify_init, sys_inotify_init) | ||
570 | #define __NR_inotify_add_watch 254 | ||
571 | __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch) | ||
572 | #define __NR_inotify_rm_watch 255 | ||
573 | __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch) | ||
574 | #define __NR_migrate_pages 256 | ||
575 | __SYSCALL(__NR_migrate_pages, sys_migrate_pages) | ||
576 | #define __NR_openat 257 | ||
577 | __SYSCALL(__NR_openat, sys_openat) | ||
578 | #define __NR_mkdirat 258 | ||
579 | __SYSCALL(__NR_mkdirat, sys_mkdirat) | ||
580 | #define __NR_mknodat 259 | ||
581 | __SYSCALL(__NR_mknodat, sys_mknodat) | ||
582 | #define __NR_fchownat 260 | ||
583 | __SYSCALL(__NR_fchownat, sys_fchownat) | ||
584 | #define __NR_futimesat 261 | ||
585 | __SYSCALL(__NR_futimesat, sys_futimesat) | ||
586 | #define __NR_newfstatat 262 | ||
587 | __SYSCALL(__NR_newfstatat, sys_newfstatat) | ||
588 | #define __NR_unlinkat 263 | ||
589 | __SYSCALL(__NR_unlinkat, sys_unlinkat) | ||
590 | #define __NR_renameat 264 | ||
591 | __SYSCALL(__NR_renameat, sys_renameat) | ||
592 | #define __NR_linkat 265 | ||
593 | __SYSCALL(__NR_linkat, sys_linkat) | ||
594 | #define __NR_symlinkat 266 | ||
595 | __SYSCALL(__NR_symlinkat, sys_symlinkat) | ||
596 | #define __NR_readlinkat 267 | ||
597 | __SYSCALL(__NR_readlinkat, sys_readlinkat) | ||
598 | #define __NR_fchmodat 268 | ||
599 | __SYSCALL(__NR_fchmodat, sys_fchmodat) | ||
600 | #define __NR_faccessat 269 | ||
601 | __SYSCALL(__NR_faccessat, sys_faccessat) | ||
602 | #define __NR_pselect6 270 | ||
603 | __SYSCALL(__NR_pselect6, sys_pselect6) | ||
604 | #define __NR_ppoll 271 | ||
605 | __SYSCALL(__NR_ppoll, sys_ppoll) | ||
606 | #define __NR_unshare 272 | ||
607 | __SYSCALL(__NR_unshare, sys_unshare) | ||
608 | #define __NR_set_robust_list 273 | ||
609 | __SYSCALL(__NR_set_robust_list, sys_set_robust_list) | ||
610 | #define __NR_get_robust_list 274 | ||
611 | __SYSCALL(__NR_get_robust_list, sys_get_robust_list) | ||
612 | #define __NR_splice 275 | ||
613 | __SYSCALL(__NR_splice, sys_splice) | ||
614 | #define __NR_tee 276 | ||
615 | __SYSCALL(__NR_tee, sys_tee) | ||
616 | #define __NR_sync_file_range 277 | ||
617 | __SYSCALL(__NR_sync_file_range, sys_sync_file_range) | ||
618 | #define __NR_vmsplice 278 | ||
619 | __SYSCALL(__NR_vmsplice, sys_vmsplice) | ||
620 | #define __NR_move_pages 279 | ||
621 | __SYSCALL(__NR_move_pages, sys_move_pages) | ||
622 | #define __NR_utimensat 280 | ||
623 | __SYSCALL(__NR_utimensat, sys_utimensat) | ||
624 | #define __IGNORE_getcpu /* implemented as a vsyscall */ | ||
625 | #define __NR_epoll_pwait 281 | ||
626 | __SYSCALL(__NR_epoll_pwait, sys_epoll_pwait) | ||
627 | #define __NR_signalfd 282 | ||
628 | __SYSCALL(__NR_signalfd, sys_signalfd) | ||
629 | #define __NR_timerfd 283 | ||
630 | __SYSCALL(__NR_timerfd, sys_timerfd) | ||
631 | #define __NR_eventfd 284 | ||
632 | __SYSCALL(__NR_eventfd, sys_eventfd) | ||
633 | #define __NR_fallocate 285 | ||
634 | __SYSCALL(__NR_fallocate, sys_fallocate) | ||
635 | |||
636 | #ifndef __NO_STUBS | ||
637 | #define __ARCH_WANT_OLD_READDIR | ||
638 | #define __ARCH_WANT_OLD_STAT | ||
639 | #define __ARCH_WANT_SYS_ALARM | ||
640 | #define __ARCH_WANT_SYS_GETHOSTNAME | ||
641 | #define __ARCH_WANT_SYS_PAUSE | ||
642 | #define __ARCH_WANT_SYS_SGETMASK | ||
643 | #define __ARCH_WANT_SYS_SIGNAL | ||
644 | #define __ARCH_WANT_SYS_UTIME | ||
645 | #define __ARCH_WANT_SYS_WAITPID | ||
646 | #define __ARCH_WANT_SYS_SOCKETCALL | ||
647 | #define __ARCH_WANT_SYS_FADVISE64 | ||
648 | #define __ARCH_WANT_SYS_GETPGRP | ||
649 | #define __ARCH_WANT_SYS_LLSEEK | ||
650 | #define __ARCH_WANT_SYS_NICE | ||
651 | #define __ARCH_WANT_SYS_OLD_GETRLIMIT | ||
652 | #define __ARCH_WANT_SYS_OLDUMOUNT | ||
653 | #define __ARCH_WANT_SYS_SIGPENDING | ||
654 | #define __ARCH_WANT_SYS_SIGPROCMASK | ||
655 | #define __ARCH_WANT_SYS_RT_SIGACTION | ||
656 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | ||
657 | #define __ARCH_WANT_SYS_TIME | ||
658 | #define __ARCH_WANT_COMPAT_SYS_TIME | ||
659 | |||
660 | #ifdef __KERNEL__ | ||
661 | #ifndef __ASSEMBLY__ | ||
662 | |||
663 | #include <linux/linkage.h> | ||
664 | #include <linux/compiler.h> | ||
665 | #include <linux/types.h> | ||
666 | #include <asm/ptrace.h> | ||
667 | |||
668 | asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs); | ||
669 | struct sigaction; | ||
670 | asmlinkage long sys_rt_sigaction(int sig, | ||
671 | const struct sigaction __user *act, | ||
672 | struct sigaction __user *oact, | ||
673 | size_t sigsetsize); | ||
674 | |||
675 | #endif /* __ASSEMBLY__ */ | ||
676 | #endif /* __KERNEL__ */ | ||
677 | #endif /* __NO_STUBS */ | ||
678 | |||
679 | /* | ||
680 | * "Conditional" syscalls | ||
681 | * | ||
682 | * What we want is __attribute__((weak,alias("sys_ni_syscall"))), | ||
683 | * but it doesn't work on all toolchains, so we just do it by hand | ||
684 | */ | ||
685 | #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") | ||
686 | |||
687 | #endif /* _ASM_X86_64_UNISTD_H_ */ | ||
diff --git a/include/asm-x86/unwind.h b/include/asm-x86/unwind.h new file mode 100644 index 000000000000..7e4d7ad55208 --- /dev/null +++ b/include/asm-x86/unwind.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "unwind_32.h" | ||
3 | #else | ||
4 | # include "unwind_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/unwind_32.h b/include/asm-x86/unwind_32.h new file mode 100644 index 000000000000..43c70c3de2f9 --- /dev/null +++ b/include/asm-x86/unwind_32.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _ASM_I386_UNWIND_H | ||
2 | #define _ASM_I386_UNWIND_H | ||
3 | |||
4 | #define UNW_PC(frame) ((void)(frame), 0) | ||
5 | #define UNW_SP(frame) ((void)(frame), 0) | ||
6 | #define UNW_FP(frame) ((void)(frame), 0) | ||
7 | |||
8 | static inline int arch_unw_user_mode(const void *info) | ||
9 | { | ||
10 | return 0; | ||
11 | } | ||
12 | |||
13 | #endif /* _ASM_I386_UNWIND_H */ | ||
diff --git a/include/asm-x86/unwind_64.h b/include/asm-x86/unwind_64.h new file mode 100644 index 000000000000..02710f6a4560 --- /dev/null +++ b/include/asm-x86/unwind_64.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASM_X86_64_UNWIND_H | ||
2 | #define _ASM_X86_64_UNWIND_H | ||
3 | |||
4 | #define UNW_PC(frame) ((void)(frame), 0UL) | ||
5 | #define UNW_SP(frame) ((void)(frame), 0UL) | ||
6 | |||
7 | static inline int arch_unw_user_mode(const void *info) | ||
8 | { | ||
9 | return 0; | ||
10 | } | ||
11 | |||
12 | #endif /* _ASM_X86_64_UNWIND_H */ | ||
diff --git a/include/asm-x86/user.h b/include/asm-x86/user.h new file mode 100644 index 000000000000..484715abe74a --- /dev/null +++ b/include/asm-x86/user.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | # ifdef CONFIG_X86_32 | ||
3 | # include "user_32.h" | ||
4 | # else | ||
5 | # include "user_64.h" | ||
6 | # endif | ||
7 | #else | ||
8 | # ifdef __i386__ | ||
9 | # include "user_32.h" | ||
10 | # else | ||
11 | # include "user_64.h" | ||
12 | # endif | ||
13 | #endif | ||
diff --git a/include/asm-x86/user32.h b/include/asm-x86/user32.h new file mode 100644 index 000000000000..f769872debea --- /dev/null +++ b/include/asm-x86/user32.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef USER32_H | ||
2 | #define USER32_H 1 | ||
3 | |||
4 | /* IA32 compatible user structures for ptrace. These should be used for 32bit coredumps too. */ | ||
5 | |||
6 | struct user_i387_ia32_struct { | ||
7 | u32 cwd; | ||
8 | u32 swd; | ||
9 | u32 twd; | ||
10 | u32 fip; | ||
11 | u32 fcs; | ||
12 | u32 foo; | ||
13 | u32 fos; | ||
14 | u32 st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ | ||
15 | }; | ||
16 | |||
17 | /* FSAVE frame with extensions */ | ||
18 | struct user32_fxsr_struct { | ||
19 | unsigned short cwd; | ||
20 | unsigned short swd; | ||
21 | unsigned short twd; /* not compatible to 64bit twd */ | ||
22 | unsigned short fop; | ||
23 | int fip; | ||
24 | int fcs; | ||
25 | int foo; | ||
26 | int fos; | ||
27 | int mxcsr; | ||
28 | int reserved; | ||
29 | int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ | ||
30 | int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ | ||
31 | int padding[56]; | ||
32 | }; | ||
33 | |||
34 | struct user_regs_struct32 { | ||
35 | __u32 ebx, ecx, edx, esi, edi, ebp, eax; | ||
36 | unsigned short ds, __ds, es, __es; | ||
37 | unsigned short fs, __fs, gs, __gs; | ||
38 | __u32 orig_eax, eip; | ||
39 | unsigned short cs, __cs; | ||
40 | __u32 eflags, esp; | ||
41 | unsigned short ss, __ss; | ||
42 | }; | ||
43 | |||
44 | struct user32 { | ||
45 | struct user_regs_struct32 regs; /* Where the registers are actually stored */ | ||
46 | int u_fpvalid; /* True if math co-processor being used. */ | ||
47 | /* for this mess. Not yet used. */ | ||
48 | struct user_i387_ia32_struct i387; /* Math Co-processor registers. */ | ||
49 | /* The rest of this junk is to help gdb figure out what goes where */ | ||
50 | __u32 u_tsize; /* Text segment size (pages). */ | ||
51 | __u32 u_dsize; /* Data segment size (pages). */ | ||
52 | __u32 u_ssize; /* Stack segment size (pages). */ | ||
53 | __u32 start_code; /* Starting virtual address of text. */ | ||
54 | __u32 start_stack; /* Starting virtual address of stack area. | ||
55 | This is actually the bottom of the stack, | ||
56 | the top of the stack is always found in the | ||
57 | esp register. */ | ||
58 | __u32 signal; /* Signal that caused the core dump. */ | ||
59 | int reserved; /* No __u32er used */ | ||
60 | __u32 u_ar0; /* Used by gdb to help find the values for */ | ||
61 | /* the registers. */ | ||
62 | __u32 u_fpstate; /* Math Co-processor pointer. */ | ||
63 | __u32 magic; /* To uniquely identify a core file */ | ||
64 | char u_comm[32]; /* User command that was responsible */ | ||
65 | int u_debugreg[8]; | ||
66 | }; | ||
67 | |||
68 | |||
69 | #endif | ||
diff --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h new file mode 100644 index 000000000000..0e85d2a5e33a --- /dev/null +++ b/include/asm-x86/user_32.h | |||
@@ -0,0 +1,121 @@ | |||
1 | #ifndef _I386_USER_H | ||
2 | #define _I386_USER_H | ||
3 | |||
4 | #include <asm/page.h> | ||
5 | /* Core file format: The core file is written in such a way that gdb | ||
6 | can understand it and provide useful information to the user (under | ||
7 | linux we use the 'trad-core' bfd). There are quite a number of | ||
8 | obstacles to being able to view the contents of the floating point | ||
9 | registers, and until these are solved you will not be able to view the | ||
10 | contents of them. Actually, you can read in the core file and look at | ||
11 | the contents of the user struct to find out what the floating point | ||
12 | registers contain. | ||
13 | The actual file contents are as follows: | ||
14 | UPAGE: 1 page consisting of a user struct that tells gdb what is present | ||
15 | in the file. Directly after this is a copy of the task_struct, which | ||
16 | is currently not used by gdb, but it may come in useful at some point. | ||
17 | All of the registers are stored as part of the upage. The upage should | ||
18 | always be only one page. | ||
19 | DATA: The data area is stored. We use current->end_text to | ||
20 | current->brk to pick up all of the user variables, plus any memory | ||
21 | that may have been malloced. No attempt is made to determine if a page | ||
22 | is demand-zero or if a page is totally unused, we just cover the entire | ||
23 | range. All of the addresses are rounded in such a way that an integral | ||
24 | number of pages is written. | ||
25 | STACK: We need the stack information in order to get a meaningful | ||
26 | backtrace. We need to write the data from (esp) to | ||
27 | current->start_stack, so we round each of these off in order to be able | ||
28 | to write an integer number of pages. | ||
29 | The minimum core file size is 3 pages, or 12288 bytes. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | * Pentium III FXSR, SSE support | ||
34 | * Gareth Hughes <gareth@valinux.com>, May 2000 | ||
35 | * | ||
36 | * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for | ||
37 | * interacting with the FXSR-format floating point environment. Floating | ||
38 | * point data can be accessed in the regular format in the usual manner, | ||
39 | * and both the standard and SIMD floating point data can be accessed via | ||
40 | * the new ptrace requests. In either case, changes to the FPU environment | ||
41 | * will be reflected in the task's state as expected. | ||
42 | */ | ||
43 | |||
44 | struct user_i387_struct { | ||
45 | long cwd; | ||
46 | long swd; | ||
47 | long twd; | ||
48 | long fip; | ||
49 | long fcs; | ||
50 | long foo; | ||
51 | long fos; | ||
52 | long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ | ||
53 | }; | ||
54 | |||
55 | struct user_fxsr_struct { | ||
56 | unsigned short cwd; | ||
57 | unsigned short swd; | ||
58 | unsigned short twd; | ||
59 | unsigned short fop; | ||
60 | long fip; | ||
61 | long fcs; | ||
62 | long foo; | ||
63 | long fos; | ||
64 | long mxcsr; | ||
65 | long reserved; | ||
66 | long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ | ||
67 | long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ | ||
68 | long padding[56]; | ||
69 | }; | ||
70 | |||
71 | /* | ||
72 | * This is the old layout of "struct pt_regs", and | ||
73 | * is still the layout used by user mode (the new | ||
74 | * pt_regs doesn't have all registers as the kernel | ||
75 | * doesn't use the extra segment registers) | ||
76 | */ | ||
77 | struct user_regs_struct { | ||
78 | long ebx, ecx, edx, esi, edi, ebp, eax; | ||
79 | unsigned short ds, __ds, es, __es; | ||
80 | unsigned short fs, __fs, gs, __gs; | ||
81 | long orig_eax, eip; | ||
82 | unsigned short cs, __cs; | ||
83 | long eflags, esp; | ||
84 | unsigned short ss, __ss; | ||
85 | }; | ||
86 | |||
87 | /* When the kernel dumps core, it starts by dumping the user struct - | ||
88 | this will be used by gdb to figure out where the data and stack segments | ||
89 | are within the file, and what virtual addresses to use. */ | ||
90 | struct user{ | ||
91 | /* We start with the registers, to mimic the way that "memory" is returned | ||
92 | from the ptrace(3,...) function. */ | ||
93 | struct user_regs_struct regs; /* Where the registers are actually stored */ | ||
94 | /* ptrace does not yet supply these. Someday.... */ | ||
95 | int u_fpvalid; /* True if math co-processor being used. */ | ||
96 | /* for this mess. Not yet used. */ | ||
97 | struct user_i387_struct i387; /* Math Co-processor registers. */ | ||
98 | /* The rest of this junk is to help gdb figure out what goes where */ | ||
99 | unsigned long int u_tsize; /* Text segment size (pages). */ | ||
100 | unsigned long int u_dsize; /* Data segment size (pages). */ | ||
101 | unsigned long int u_ssize; /* Stack segment size (pages). */ | ||
102 | unsigned long start_code; /* Starting virtual address of text. */ | ||
103 | unsigned long start_stack; /* Starting virtual address of stack area. | ||
104 | This is actually the bottom of the stack, | ||
105 | the top of the stack is always found in the | ||
106 | esp register. */ | ||
107 | long int signal; /* Signal that caused the core dump. */ | ||
108 | int reserved; /* No longer used */ | ||
109 | struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ | ||
110 | /* the registers. */ | ||
111 | struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ | ||
112 | unsigned long magic; /* To uniquely identify a core file */ | ||
113 | char u_comm[32]; /* User command that was responsible */ | ||
114 | int u_debugreg[8]; | ||
115 | }; | ||
116 | #define NBPG PAGE_SIZE | ||
117 | #define UPAGES 1 | ||
118 | #define HOST_TEXT_START_ADDR (u.start_code) | ||
119 | #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) | ||
120 | |||
121 | #endif /* _I386_USER_H */ | ||
diff --git a/include/asm-x86/user_64.h b/include/asm-x86/user_64.h new file mode 100644 index 000000000000..12785c649ac5 --- /dev/null +++ b/include/asm-x86/user_64.h | |||
@@ -0,0 +1,114 @@ | |||
1 | #ifndef _X86_64_USER_H | ||
2 | #define _X86_64_USER_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <asm/page.h> | ||
6 | /* Core file format: The core file is written in such a way that gdb | ||
7 | can understand it and provide useful information to the user. | ||
8 | There are quite a number of obstacles to being able to view the | ||
9 | contents of the floating point registers, and until these are | ||
10 | solved you will not be able to view the contents of them. | ||
11 | Actually, you can read in the core file and look at the contents of | ||
12 | the user struct to find out what the floating point registers | ||
13 | contain. | ||
14 | |||
15 | The actual file contents are as follows: | ||
16 | UPAGE: 1 page consisting of a user struct that tells gdb what is present | ||
17 | in the file. Directly after this is a copy of the task_struct, which | ||
18 | is currently not used by gdb, but it may come in useful at some point. | ||
19 | All of the registers are stored as part of the upage. The upage should | ||
20 | always be only one page. | ||
21 | DATA: The data area is stored. We use current->end_text to | ||
22 | current->brk to pick up all of the user variables, plus any memory | ||
23 | that may have been malloced. No attempt is made to determine if a page | ||
24 | is demand-zero or if a page is totally unused, we just cover the entire | ||
25 | range. All of the addresses are rounded in such a way that an integral | ||
26 | number of pages is written. | ||
27 | STACK: We need the stack information in order to get a meaningful | ||
28 | backtrace. We need to write the data from (esp) to | ||
29 | current->start_stack, so we round each of these off in order to be able | ||
30 | to write an integer number of pages. | ||
31 | The minimum core file size is 3 pages, or 12288 bytes. */ | ||
32 | |||
33 | /* | ||
34 | * Pentium III FXSR, SSE support | ||
35 | * Gareth Hughes <gareth@valinux.com>, May 2000 | ||
36 | * | ||
37 | * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for | ||
38 | * interacting with the FXSR-format floating point environment. Floating | ||
39 | * point data can be accessed in the regular format in the usual manner, | ||
40 | * and both the standard and SIMD floating point data can be accessed via | ||
41 | * the new ptrace requests. In either case, changes to the FPU environment | ||
42 | * will be reflected in the task's state as expected. | ||
43 | * | ||
44 | * x86-64 support by Andi Kleen. | ||
45 | */ | ||
46 | |||
47 | /* This matches the 64bit FXSAVE format as defined by AMD. It is the same | ||
48 | as the 32bit format defined by Intel, except that the selector:offset pairs for | ||
49 | data and eip are replaced with flat 64bit pointers. */ | ||
50 | struct user_i387_struct { | ||
51 | unsigned short cwd; | ||
52 | unsigned short swd; | ||
53 | unsigned short twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ | ||
54 | unsigned short fop; | ||
55 | __u64 rip; | ||
56 | __u64 rdp; | ||
57 | __u32 mxcsr; | ||
58 | __u32 mxcsr_mask; | ||
59 | __u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ | ||
60 | __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */ | ||
61 | __u32 padding[24]; | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * Segment register layout in coredumps. | ||
66 | */ | ||
67 | struct user_regs_struct { | ||
68 | unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10; | ||
69 | unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax; | ||
70 | unsigned long rip,cs,eflags; | ||
71 | unsigned long rsp,ss; | ||
72 | unsigned long fs_base, gs_base; | ||
73 | unsigned long ds,es,fs,gs; | ||
74 | }; | ||
75 | |||
76 | /* When the kernel dumps core, it starts by dumping the user struct - | ||
77 | this will be used by gdb to figure out where the data and stack segments | ||
78 | are within the file, and what virtual addresses to use. */ | ||
79 | struct user{ | ||
80 | /* We start with the registers, to mimic the way that "memory" is returned | ||
81 | from the ptrace(3,...) function. */ | ||
82 | struct user_regs_struct regs; /* Where the registers are actually stored */ | ||
83 | /* ptrace does not yet supply these. Someday.... */ | ||
84 | int u_fpvalid; /* True if math co-processor being used. */ | ||
85 | /* for this mess. Not yet used. */ | ||
86 | int pad0; | ||
87 | struct user_i387_struct i387; /* Math Co-processor registers. */ | ||
88 | /* The rest of this junk is to help gdb figure out what goes where */ | ||
89 | unsigned long int u_tsize; /* Text segment size (pages). */ | ||
90 | unsigned long int u_dsize; /* Data segment size (pages). */ | ||
91 | unsigned long int u_ssize; /* Stack segment size (pages). */ | ||
92 | unsigned long start_code; /* Starting virtual address of text. */ | ||
93 | unsigned long start_stack; /* Starting virtual address of stack area. | ||
94 | This is actually the bottom of the stack, | ||
95 | the top of the stack is always found in the | ||
96 | esp register. */ | ||
97 | long int signal; /* Signal that caused the core dump. */ | ||
98 | int reserved; /* No longer used */ | ||
99 | int pad1; | ||
100 | struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ | ||
101 | /* the registers. */ | ||
102 | struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ | ||
103 | unsigned long magic; /* To uniquely identify a core file */ | ||
104 | char u_comm[32]; /* User command that was responsible */ | ||
105 | unsigned long u_debugreg[8]; | ||
106 | unsigned long error_code; /* CPU error code or 0 */ | ||
107 | unsigned long fault_address; /* CR3 or 0 */ | ||
108 | }; | ||
109 | #define NBPG PAGE_SIZE | ||
110 | #define UPAGES 1 | ||
111 | #define HOST_TEXT_START_ADDR (u.start_code) | ||
112 | #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) | ||
113 | |||
114 | #endif /* _X86_64_USER_H */ | ||
diff --git a/include/asm-x86/vga.h b/include/asm-x86/vga.h new file mode 100644 index 000000000000..0ecf68ac03aa --- /dev/null +++ b/include/asm-x86/vga.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * Access to VGA videoram | ||
3 | * | ||
4 | * (c) 1998 Martin Mares <mj@ucw.cz> | ||
5 | */ | ||
6 | |||
7 | #ifndef _LINUX_ASM_VGA_H_ | ||
8 | #define _LINUX_ASM_VGA_H_ | ||
9 | |||
10 | /* | ||
11 | * On the PC, we can just recalculate addresses and then | ||
12 | * access the videoram directly without any black magic. | ||
13 | */ | ||
14 | |||
15 | #define VGA_MAP_MEM(x,s) (unsigned long)phys_to_virt(x) | ||
16 | |||
17 | #define vga_readb(x) (*(x)) | ||
18 | #define vga_writeb(x,y) (*(y) = (x)) | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-x86/vgtod.h b/include/asm-x86/vgtod.h new file mode 100644 index 000000000000..3301f0929342 --- /dev/null +++ b/include/asm-x86/vgtod.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef _ASM_VGTOD_H | ||
2 | #define _ASM_VGTOD_H 1 | ||
3 | |||
4 | #include <asm/vsyscall.h> | ||
5 | #include <linux/clocksource.h> | ||
6 | |||
7 | struct vsyscall_gtod_data { | ||
8 | seqlock_t lock; | ||
9 | |||
10 | /* open coded 'struct timespec' */ | ||
11 | time_t wall_time_sec; | ||
12 | u32 wall_time_nsec; | ||
13 | |||
14 | int sysctl_enabled; | ||
15 | struct timezone sys_tz; | ||
16 | struct { /* extract of a clocksource struct */ | ||
17 | cycle_t (*vread)(void); | ||
18 | cycle_t cycle_last; | ||
19 | cycle_t mask; | ||
20 | u32 mult; | ||
21 | u32 shift; | ||
22 | } clock; | ||
23 | struct timespec wall_to_monotonic; | ||
24 | }; | ||
25 | extern struct vsyscall_gtod_data __vsyscall_gtod_data | ||
26 | __section_vsyscall_gtod_data; | ||
27 | extern struct vsyscall_gtod_data vsyscall_gtod_data; | ||
28 | |||
29 | #endif | ||
diff --git a/include/asm-x86/vic.h b/include/asm-x86/vic.h new file mode 100644 index 000000000000..53100f353612 --- /dev/null +++ b/include/asm-x86/vic.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /* Copyright (C) 1999,2001 | ||
2 | * | ||
3 | * Author: J.E.J.Bottomley@HansenPartnership.com | ||
4 | * | ||
5 | * Standard include definitions for the NCR Voyager Interrupt Controller */ | ||
6 | |||
7 | /* The eight CPI vectors. To activate a CPI, you write a bit mask | ||
8 | * corresponding to the processor set to be interrupted into the | ||
9 | * relevant register. That set of CPUs will then be interrupted with | ||
10 | * the CPI */ | ||
11 | static const int VIC_CPI_Registers[] = | ||
12 | {0xFC00, 0xFC01, 0xFC08, 0xFC09, | ||
13 | 0xFC10, 0xFC11, 0xFC18, 0xFC19 }; | ||
14 | |||
15 | #define VIC_PROC_WHO_AM_I 0xfc29 | ||
16 | # define QUAD_IDENTIFIER 0xC0 | ||
17 | # define EIGHT_SLOT_IDENTIFIER 0xE0 | ||
18 | #define QIC_EXTENDED_PROCESSOR_SELECT 0xFC72 | ||
19 | #define VIC_CPI_BASE_REGISTER 0xFC41 | ||
20 | #define VIC_PROCESSOR_ID 0xFC21 | ||
21 | # define VIC_CPU_MASQUERADE_ENABLE 0x8 | ||
22 | |||
23 | #define VIC_CLAIM_REGISTER_0 0xFC38 | ||
24 | #define VIC_CLAIM_REGISTER_1 0xFC39 | ||
25 | #define VIC_REDIRECT_REGISTER_0 0xFC60 | ||
26 | #define VIC_REDIRECT_REGISTER_1 0xFC61 | ||
27 | #define VIC_PRIORITY_REGISTER 0xFC20 | ||
28 | |||
29 | #define VIC_PRIMARY_MC_BASE 0xFC48 | ||
30 | #define VIC_SECONDARY_MC_BASE 0xFC49 | ||
31 | |||
32 | #define QIC_PROCESSOR_ID 0xFC71 | ||
33 | # define QIC_CPUID_ENABLE 0x08 | ||
34 | |||
35 | #define QIC_VIC_CPI_BASE_REGISTER 0xFC79 | ||
36 | #define QIC_CPI_BASE_REGISTER 0xFC7A | ||
37 | |||
38 | #define QIC_MASK_REGISTER0 0xFC80 | ||
39 | /* NOTE: these are masked high, enabled low */ | ||
40 | # define QIC_PERF_TIMER 0x01 | ||
41 | # define QIC_LPE 0x02 | ||
42 | # define QIC_SYS_INT 0x04 | ||
43 | # define QIC_CMN_INT 0x08 | ||
44 | /* at the moment, just enable CMN_INT, disable SYS_INT */ | ||
45 | # define QIC_DEFAULT_MASK0 (~(QIC_CMN_INT /* | VIC_SYS_INT */)) | ||
46 | #define QIC_MASK_REGISTER1 0xFC81 | ||
47 | # define QIC_BOOT_CPI_MASK 0xFE | ||
48 | /* Enable CPI's 1-6 inclusive */ | ||
49 | # define QIC_CPI_ENABLE 0x81 | ||
50 | |||
51 | #define QIC_INTERRUPT_CLEAR0 0xFC8A | ||
52 | #define QIC_INTERRUPT_CLEAR1 0xFC8B | ||
53 | |||
54 | /* this is where we place the CPI vectors */ | ||
55 | #define VIC_DEFAULT_CPI_BASE 0xC0 | ||
56 | /* this is where we place the QIC CPI vectors */ | ||
57 | #define QIC_DEFAULT_CPI_BASE 0xD0 | ||
58 | |||
59 | #define VIC_BOOT_INTERRUPT_MASK 0xfe | ||
60 | |||
61 | extern void smp_vic_timer_interrupt(void); | ||
diff --git a/include/asm-x86/vm86.h b/include/asm-x86/vm86.h new file mode 100644 index 000000000000..a5edf517b992 --- /dev/null +++ b/include/asm-x86/vm86.h | |||
@@ -0,0 +1,215 @@ | |||
1 | #ifndef _LINUX_VM86_H | ||
2 | #define _LINUX_VM86_H | ||
3 | |||
4 | /* | ||
5 | * I'm guessing at the VIF/VIP flag usage, but hope that this is how | ||
6 | * the Pentium uses them. Linux will return from vm86 mode when both | ||
7 | * VIF and VIP is set. | ||
8 | * | ||
9 | * On a Pentium, we could probably optimize the virtual flags directly | ||
10 | * in the eflags register instead of doing it "by hand" in vflags... | ||
11 | * | ||
12 | * Linus | ||
13 | */ | ||
14 | |||
15 | #define TF_MASK 0x00000100 | ||
16 | #define IF_MASK 0x00000200 | ||
17 | #define IOPL_MASK 0x00003000 | ||
18 | #define NT_MASK 0x00004000 | ||
19 | #ifdef CONFIG_VM86 | ||
20 | #define VM_MASK 0x00020000 | ||
21 | #else | ||
22 | #define VM_MASK 0 /* ignored */ | ||
23 | #endif | ||
24 | #define AC_MASK 0x00040000 | ||
25 | #define VIF_MASK 0x00080000 /* virtual interrupt flag */ | ||
26 | #define VIP_MASK 0x00100000 /* virtual interrupt pending */ | ||
27 | #define ID_MASK 0x00200000 | ||
28 | |||
29 | #define BIOSSEG 0x0f000 | ||
30 | |||
31 | #define CPU_086 0 | ||
32 | #define CPU_186 1 | ||
33 | #define CPU_286 2 | ||
34 | #define CPU_386 3 | ||
35 | #define CPU_486 4 | ||
36 | #define CPU_586 5 | ||
37 | |||
38 | /* | ||
39 | * Return values for the 'vm86()' system call | ||
40 | */ | ||
41 | #define VM86_TYPE(retval) ((retval) & 0xff) | ||
42 | #define VM86_ARG(retval) ((retval) >> 8) | ||
43 | |||
44 | #define VM86_SIGNAL 0 /* return due to signal */ | ||
45 | #define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ | ||
46 | #define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ | ||
47 | #define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ | ||
48 | |||
49 | /* | ||
50 | * Additional return values when invoking new vm86() | ||
51 | */ | ||
52 | #define VM86_PICRETURN 4 /* return due to pending PIC request */ | ||
53 | #define VM86_TRAP 6 /* return due to DOS-debugger request */ | ||
54 | |||
55 | /* | ||
56 | * function codes when invoking new vm86() | ||
57 | */ | ||
58 | #define VM86_PLUS_INSTALL_CHECK 0 | ||
59 | #define VM86_ENTER 1 | ||
60 | #define VM86_ENTER_NO_BYPASS 2 | ||
61 | #define VM86_REQUEST_IRQ 3 | ||
62 | #define VM86_FREE_IRQ 4 | ||
63 | #define VM86_GET_IRQ_BITS 5 | ||
64 | #define VM86_GET_AND_RESET_IRQ 6 | ||
65 | |||
66 | /* | ||
67 | * This is the stack-layout seen by the user space program when we have | ||
68 | * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout | ||
69 | * is 'kernel_vm86_regs' (see below). | ||
70 | */ | ||
71 | |||
72 | struct vm86_regs { | ||
73 | /* | ||
74 | * normal regs, with special meaning for the segment descriptors.. | ||
75 | */ | ||
76 | long ebx; | ||
77 | long ecx; | ||
78 | long edx; | ||
79 | long esi; | ||
80 | long edi; | ||
81 | long ebp; | ||
82 | long eax; | ||
83 | long __null_ds; | ||
84 | long __null_es; | ||
85 | long __null_fs; | ||
86 | long __null_gs; | ||
87 | long orig_eax; | ||
88 | long eip; | ||
89 | unsigned short cs, __csh; | ||
90 | long eflags; | ||
91 | long esp; | ||
92 | unsigned short ss, __ssh; | ||
93 | /* | ||
94 | * these are specific to v86 mode: | ||
95 | */ | ||
96 | unsigned short es, __esh; | ||
97 | unsigned short ds, __dsh; | ||
98 | unsigned short fs, __fsh; | ||
99 | unsigned short gs, __gsh; | ||
100 | }; | ||
101 | |||
102 | struct revectored_struct { | ||
103 | unsigned long __map[8]; /* 256 bits */ | ||
104 | }; | ||
105 | |||
106 | struct vm86_struct { | ||
107 | struct vm86_regs regs; | ||
108 | unsigned long flags; | ||
109 | unsigned long screen_bitmap; | ||
110 | unsigned long cpu_type; | ||
111 | struct revectored_struct int_revectored; | ||
112 | struct revectored_struct int21_revectored; | ||
113 | }; | ||
114 | |||
115 | /* | ||
116 | * flags masks | ||
117 | */ | ||
118 | #define VM86_SCREEN_BITMAP 0x0001 | ||
119 | |||
120 | struct vm86plus_info_struct { | ||
121 | unsigned long force_return_for_pic:1; | ||
122 | unsigned long vm86dbg_active:1; /* for debugger */ | ||
123 | unsigned long vm86dbg_TFpendig:1; /* for debugger */ | ||
124 | unsigned long unused:28; | ||
125 | unsigned long is_vm86pus:1; /* for vm86 internal use */ | ||
126 | unsigned char vm86dbg_intxxtab[32]; /* for debugger */ | ||
127 | }; | ||
128 | |||
129 | struct vm86plus_struct { | ||
130 | struct vm86_regs regs; | ||
131 | unsigned long flags; | ||
132 | unsigned long screen_bitmap; | ||
133 | unsigned long cpu_type; | ||
134 | struct revectored_struct int_revectored; | ||
135 | struct revectored_struct int21_revectored; | ||
136 | struct vm86plus_info_struct vm86plus; | ||
137 | }; | ||
138 | |||
139 | #ifdef __KERNEL__ | ||
140 | /* | ||
141 | * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86 | ||
142 | * mode - the main change is that the old segment descriptors aren't | ||
143 | * useful any more and are forced to be zero by the kernel (and the | ||
144 | * hardware when a trap occurs), and the real segment descriptors are | ||
145 | * at the end of the structure. Look at ptrace.h to see the "normal" | ||
146 | * setup. For user space layout see 'struct vm86_regs' above. | ||
147 | */ | ||
148 | #include <asm/ptrace.h> | ||
149 | |||
150 | struct kernel_vm86_regs { | ||
151 | /* | ||
152 | * normal regs, with special meaning for the segment descriptors.. | ||
153 | */ | ||
154 | struct pt_regs pt; | ||
155 | /* | ||
156 | * these are specific to v86 mode: | ||
157 | */ | ||
158 | unsigned short es, __esh; | ||
159 | unsigned short ds, __dsh; | ||
160 | unsigned short fs, __fsh; | ||
161 | unsigned short gs, __gsh; | ||
162 | }; | ||
163 | |||
164 | struct kernel_vm86_struct { | ||
165 | struct kernel_vm86_regs regs; | ||
166 | /* | ||
167 | * the below part remains on the kernel stack while we are in VM86 mode. | ||
168 | * 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we | ||
169 | * get forced back from VM86, the CPU and "SAVE_ALL" will restore the above | ||
170 | * 'struct kernel_vm86_regs' with the then actual values. | ||
171 | * Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' | ||
172 | * in kernelspace, hence we need not reget the data from userspace. | ||
173 | */ | ||
174 | #define VM86_TSS_ESP0 flags | ||
175 | unsigned long flags; | ||
176 | unsigned long screen_bitmap; | ||
177 | unsigned long cpu_type; | ||
178 | struct revectored_struct int_revectored; | ||
179 | struct revectored_struct int21_revectored; | ||
180 | struct vm86plus_info_struct vm86plus; | ||
181 | struct pt_regs *regs32; /* here we save the pointer to the old regs */ | ||
182 | /* | ||
183 | * The below is not part of the structure, but the stack layout continues | ||
184 | * this way. In front of 'return-eip' may be some data, depending on | ||
185 | * compilation, so we don't rely on this and save the pointer to 'oldregs' | ||
186 | * in 'regs32' above. | ||
187 | * However, with GCC-2.7.2 and the current CFLAGS you see exactly this: | ||
188 | |||
189 | long return-eip; from call to vm86() | ||
190 | struct pt_regs oldregs; user space registers as saved by syscall | ||
191 | */ | ||
192 | }; | ||
193 | |||
194 | #ifdef CONFIG_VM86 | ||
195 | |||
196 | void handle_vm86_fault(struct kernel_vm86_regs *, long); | ||
197 | int handle_vm86_trap(struct kernel_vm86_regs *, long, int); | ||
198 | |||
199 | struct task_struct; | ||
200 | void release_vm86_irqs(struct task_struct *); | ||
201 | |||
202 | #else | ||
203 | |||
204 | #define handle_vm86_fault(a, b) | ||
205 | #define release_vm86_irqs(a) | ||
206 | |||
207 | static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) { | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | #endif /* CONFIG_VM86 */ | ||
212 | |||
213 | #endif /* __KERNEL__ */ | ||
214 | |||
215 | #endif | ||
diff --git a/include/asm-x86/vmi.h b/include/asm-x86/vmi.h new file mode 100644 index 000000000000..eb8bd892c01e --- /dev/null +++ b/include/asm-x86/vmi.h | |||
@@ -0,0 +1,263 @@ | |||
1 | /* | ||
2 | * VMI interface definition | ||
3 | * | ||
4 | * Copyright (C) 2005, VMware, Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
14 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
15 | * details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | * Maintained by: Zachary Amsden zach@vmware.com | ||
22 | * | ||
23 | */ | ||
24 | #include <linux/types.h> | ||
25 | |||
26 | /* | ||
27 | *--------------------------------------------------------------------- | ||
28 | * | ||
29 | * VMI Option ROM API | ||
30 | * | ||
31 | *--------------------------------------------------------------------- | ||
32 | */ | ||
33 | #define VMI_SIGNATURE 0x696d5663 /* "cVmi" */ | ||
34 | |||
35 | #define PCI_VENDOR_ID_VMWARE 0x15AD | ||
36 | #define PCI_DEVICE_ID_VMWARE_VMI 0x0801 | ||
37 | |||
38 | /* | ||
39 | * We use two version numbers for compatibility, with the major | ||
40 | * number signifying interface breakages, and the minor number | ||
41 | * interface extensions. | ||
42 | */ | ||
43 | #define VMI_API_REV_MAJOR 3 | ||
44 | #define VMI_API_REV_MINOR 0 | ||
45 | |||
46 | #define VMI_CALL_CPUID 0 | ||
47 | #define VMI_CALL_WRMSR 1 | ||
48 | #define VMI_CALL_RDMSR 2 | ||
49 | #define VMI_CALL_SetGDT 3 | ||
50 | #define VMI_CALL_SetLDT 4 | ||
51 | #define VMI_CALL_SetIDT 5 | ||
52 | #define VMI_CALL_SetTR 6 | ||
53 | #define VMI_CALL_GetGDT 7 | ||
54 | #define VMI_CALL_GetLDT 8 | ||
55 | #define VMI_CALL_GetIDT 9 | ||
56 | #define VMI_CALL_GetTR 10 | ||
57 | #define VMI_CALL_WriteGDTEntry 11 | ||
58 | #define VMI_CALL_WriteLDTEntry 12 | ||
59 | #define VMI_CALL_WriteIDTEntry 13 | ||
60 | #define VMI_CALL_UpdateKernelStack 14 | ||
61 | #define VMI_CALL_SetCR0 15 | ||
62 | #define VMI_CALL_SetCR2 16 | ||
63 | #define VMI_CALL_SetCR3 17 | ||
64 | #define VMI_CALL_SetCR4 18 | ||
65 | #define VMI_CALL_GetCR0 19 | ||
66 | #define VMI_CALL_GetCR2 20 | ||
67 | #define VMI_CALL_GetCR3 21 | ||
68 | #define VMI_CALL_GetCR4 22 | ||
69 | #define VMI_CALL_WBINVD 23 | ||
70 | #define VMI_CALL_SetDR 24 | ||
71 | #define VMI_CALL_GetDR 25 | ||
72 | #define VMI_CALL_RDPMC 26 | ||
73 | #define VMI_CALL_RDTSC 27 | ||
74 | #define VMI_CALL_CLTS 28 | ||
75 | #define VMI_CALL_EnableInterrupts 29 | ||
76 | #define VMI_CALL_DisableInterrupts 30 | ||
77 | #define VMI_CALL_GetInterruptMask 31 | ||
78 | #define VMI_CALL_SetInterruptMask 32 | ||
79 | #define VMI_CALL_IRET 33 | ||
80 | #define VMI_CALL_SYSEXIT 34 | ||
81 | #define VMI_CALL_Halt 35 | ||
82 | #define VMI_CALL_Reboot 36 | ||
83 | #define VMI_CALL_Shutdown 37 | ||
84 | #define VMI_CALL_SetPxE 38 | ||
85 | #define VMI_CALL_SetPxELong 39 | ||
86 | #define VMI_CALL_UpdatePxE 40 | ||
87 | #define VMI_CALL_UpdatePxELong 41 | ||
88 | #define VMI_CALL_MachineToPhysical 42 | ||
89 | #define VMI_CALL_PhysicalToMachine 43 | ||
90 | #define VMI_CALL_AllocatePage 44 | ||
91 | #define VMI_CALL_ReleasePage 45 | ||
92 | #define VMI_CALL_InvalPage 46 | ||
93 | #define VMI_CALL_FlushTLB 47 | ||
94 | #define VMI_CALL_SetLinearMapping 48 | ||
95 | |||
96 | #define VMI_CALL_SetIOPLMask 61 | ||
97 | #define VMI_CALL_SetInitialAPState 62 | ||
98 | #define VMI_CALL_APICWrite 63 | ||
99 | #define VMI_CALL_APICRead 64 | ||
100 | #define VMI_CALL_IODelay 65 | ||
101 | #define VMI_CALL_SetLazyMode 73 | ||
102 | |||
103 | /* | ||
104 | *--------------------------------------------------------------------- | ||
105 | * | ||
106 | * MMU operation flags | ||
107 | * | ||
108 | *--------------------------------------------------------------------- | ||
109 | */ | ||
110 | |||
111 | /* Flags used by VMI_{Allocate|Release}Page call */ | ||
112 | #define VMI_PAGE_PAE 0x10 /* Allocate PAE shadow */ | ||
113 | #define VMI_PAGE_CLONE 0x20 /* Clone from another shadow */ | ||
114 | #define VMI_PAGE_ZEROED 0x40 /* Page is pre-zeroed */ | ||
115 | |||
116 | |||
117 | /* Flags shared by Allocate|Release Page and PTE updates */ | ||
118 | #define VMI_PAGE_PT 0x01 | ||
119 | #define VMI_PAGE_PD 0x02 | ||
120 | #define VMI_PAGE_PDP 0x04 | ||
121 | #define VMI_PAGE_PML4 0x08 | ||
122 | |||
123 | #define VMI_PAGE_NORMAL 0x00 /* for debugging */ | ||
124 | |||
125 | /* Flags used by PTE updates */ | ||
126 | #define VMI_PAGE_CURRENT_AS 0x10 /* implies VMI_PAGE_VA_MASK is valid */ | ||
127 | #define VMI_PAGE_DEFER 0x20 /* may queue update until TLB inval */ | ||
128 | #define VMI_PAGE_VA_MASK 0xfffff000 | ||
129 | |||
130 | #ifdef CONFIG_X86_PAE | ||
131 | #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_PAE | VMI_PAGE_ZEROED) | ||
132 | #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_PAE | VMI_PAGE_ZEROED) | ||
133 | #else | ||
134 | #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_ZEROED) | ||
135 | #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_ZEROED) | ||
136 | #endif | ||
137 | |||
138 | /* Flags used by VMI_FlushTLB call */ | ||
139 | #define VMI_FLUSH_TLB 0x01 | ||
140 | #define VMI_FLUSH_GLOBAL 0x02 | ||
141 | |||
142 | /* | ||
143 | *--------------------------------------------------------------------- | ||
144 | * | ||
145 | * VMI relocation definitions for ROM call get_reloc | ||
146 | * | ||
147 | *--------------------------------------------------------------------- | ||
148 | */ | ||
149 | |||
150 | /* VMI Relocation types */ | ||
151 | #define VMI_RELOCATION_NONE 0 | ||
152 | #define VMI_RELOCATION_CALL_REL 1 | ||
153 | #define VMI_RELOCATION_JUMP_REL 2 | ||
154 | #define VMI_RELOCATION_NOP 3 | ||
155 | |||
156 | #ifndef __ASSEMBLY__ | ||
157 | struct vmi_relocation_info { | ||
158 | unsigned char *eip; | ||
159 | unsigned char type; | ||
160 | unsigned char reserved[3]; | ||
161 | }; | ||
162 | #endif | ||
163 | |||
164 | |||
165 | /* | ||
166 | *--------------------------------------------------------------------- | ||
167 | * | ||
168 | * Generic ROM structures and definitions | ||
169 | * | ||
170 | *--------------------------------------------------------------------- | ||
171 | */ | ||
172 | |||
173 | #ifndef __ASSEMBLY__ | ||
174 | |||
175 | struct vrom_header { | ||
176 | u16 rom_signature; // option ROM signature | ||
177 | u8 rom_length; // ROM length in 512 byte chunks | ||
178 | u8 rom_entry[4]; // 16-bit code entry point | ||
179 | u8 rom_pad0; // 4-byte align pad | ||
180 | u32 vrom_signature; // VROM identification signature | ||
181 | u8 api_version_min;// Minor version of API | ||
182 | u8 api_version_maj;// Major version of API | ||
183 | u8 jump_slots; // Number of jump slots | ||
184 | u8 reserved1; // Reserved for expansion | ||
185 | u32 virtual_top; // Hypervisor virtual address start | ||
186 | u16 reserved2; // Reserved for expansion | ||
187 | u16 license_offs; // Offset to License string | ||
188 | u16 pci_header_offs;// Offset to PCI OPROM header | ||
189 | u16 pnp_header_offs;// Offset to PnP OPROM header | ||
190 | u32 rom_pad3; // PnP reserverd / VMI reserved | ||
191 | u8 reserved[96]; // Reserved for headers | ||
192 | char vmi_init[8]; // VMI_Init jump point | ||
193 | char get_reloc[8]; // VMI_GetRelocationInfo jump point | ||
194 | } __attribute__((packed)); | ||
195 | |||
196 | struct pnp_header { | ||
197 | char sig[4]; | ||
198 | char rev; | ||
199 | char size; | ||
200 | short next; | ||
201 | short res; | ||
202 | long devID; | ||
203 | unsigned short manufacturer_offset; | ||
204 | unsigned short product_offset; | ||
205 | } __attribute__((packed)); | ||
206 | |||
207 | struct pci_header { | ||
208 | char sig[4]; | ||
209 | short vendorID; | ||
210 | short deviceID; | ||
211 | short vpdData; | ||
212 | short size; | ||
213 | char rev; | ||
214 | char class; | ||
215 | char subclass; | ||
216 | char interface; | ||
217 | short chunks; | ||
218 | char rom_version_min; | ||
219 | char rom_version_maj; | ||
220 | char codetype; | ||
221 | char lastRom; | ||
222 | short reserved; | ||
223 | } __attribute__((packed)); | ||
224 | |||
225 | /* Function prototypes for bootstrapping */ | ||
226 | extern void vmi_init(void); | ||
227 | extern void vmi_bringup(void); | ||
228 | extern void vmi_apply_boot_page_allocations(void); | ||
229 | |||
230 | /* State needed to start an application processor in an SMP system. */ | ||
231 | struct vmi_ap_state { | ||
232 | u32 cr0; | ||
233 | u32 cr2; | ||
234 | u32 cr3; | ||
235 | u32 cr4; | ||
236 | |||
237 | u64 efer; | ||
238 | |||
239 | u32 eip; | ||
240 | u32 eflags; | ||
241 | u32 eax; | ||
242 | u32 ebx; | ||
243 | u32 ecx; | ||
244 | u32 edx; | ||
245 | u32 esp; | ||
246 | u32 ebp; | ||
247 | u32 esi; | ||
248 | u32 edi; | ||
249 | u16 cs; | ||
250 | u16 ss; | ||
251 | u16 ds; | ||
252 | u16 es; | ||
253 | u16 fs; | ||
254 | u16 gs; | ||
255 | u16 ldtr; | ||
256 | |||
257 | u16 gdtr_limit; | ||
258 | u32 gdtr_base; | ||
259 | u32 idtr_base; | ||
260 | u16 idtr_limit; | ||
261 | }; | ||
262 | |||
263 | #endif | ||
diff --git a/include/asm-x86/vmi_time.h b/include/asm-x86/vmi_time.h new file mode 100644 index 000000000000..478188130328 --- /dev/null +++ b/include/asm-x86/vmi_time.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * VMI Time wrappers | ||
3 | * | ||
4 | * Copyright (C) 2006, VMware, Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
14 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
15 | * details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | * Send feedback to dhecht@vmware.com | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef __VMI_TIME_H | ||
26 | #define __VMI_TIME_H | ||
27 | |||
28 | /* | ||
29 | * Raw VMI call indices for timer functions | ||
30 | */ | ||
31 | #define VMI_CALL_GetCycleFrequency 66 | ||
32 | #define VMI_CALL_GetCycleCounter 67 | ||
33 | #define VMI_CALL_SetAlarm 68 | ||
34 | #define VMI_CALL_CancelAlarm 69 | ||
35 | #define VMI_CALL_GetWallclockTime 70 | ||
36 | #define VMI_CALL_WallclockUpdated 71 | ||
37 | |||
38 | /* Cached VMI timer operations */ | ||
39 | extern struct vmi_timer_ops { | ||
40 | u64 (*get_cycle_frequency)(void); | ||
41 | u64 (*get_cycle_counter)(int); | ||
42 | u64 (*get_wallclock)(void); | ||
43 | int (*wallclock_updated)(void); | ||
44 | void (*set_alarm)(u32 flags, u64 expiry, u64 period); | ||
45 | void (*cancel_alarm)(u32 flags); | ||
46 | } vmi_timer_ops; | ||
47 | |||
48 | /* Prototypes */ | ||
49 | extern void __init vmi_time_init(void); | ||
50 | extern unsigned long vmi_get_wallclock(void); | ||
51 | extern int vmi_set_wallclock(unsigned long now); | ||
52 | extern unsigned long long vmi_sched_clock(void); | ||
53 | extern unsigned long vmi_cpu_khz(void); | ||
54 | |||
55 | #ifdef CONFIG_X86_LOCAL_APIC | ||
56 | extern void __devinit vmi_time_bsp_init(void); | ||
57 | extern void __devinit vmi_time_ap_init(void); | ||
58 | #endif | ||
59 | |||
60 | /* | ||
61 | * When run under a hypervisor, a vcpu is always in one of three states: | ||
62 | * running, halted, or ready. The vcpu is in the 'running' state if it | ||
63 | * is executing. When the vcpu executes the halt interface, the vcpu | ||
64 | * enters the 'halted' state and remains halted until there is some work | ||
65 | * pending for the vcpu (e.g. an alarm expires, host I/O completes on | ||
66 | * behalf of virtual I/O). At this point, the vcpu enters the 'ready' | ||
67 | * state (waiting for the hypervisor to reschedule it). Finally, at any | ||
68 | * time when the vcpu is not in the 'running' state nor the 'halted' | ||
69 | * state, it is in the 'ready' state. | ||
70 | * | ||
71 | * Real time is advances while the vcpu is 'running', 'ready', or | ||
72 | * 'halted'. Stolen time is the time in which the vcpu is in the | ||
73 | * 'ready' state. Available time is the remaining time -- the vcpu is | ||
74 | * either 'running' or 'halted'. | ||
75 | * | ||
76 | * All three views of time are accessible through the VMI cycle | ||
77 | * counters. | ||
78 | */ | ||
79 | |||
80 | /* The cycle counters. */ | ||
81 | #define VMI_CYCLES_REAL 0 | ||
82 | #define VMI_CYCLES_AVAILABLE 1 | ||
83 | #define VMI_CYCLES_STOLEN 2 | ||
84 | |||
85 | /* The alarm interface 'flags' bits */ | ||
86 | #define VMI_ALARM_COUNTERS 2 | ||
87 | |||
88 | #define VMI_ALARM_COUNTER_MASK 0x000000ff | ||
89 | |||
90 | #define VMI_ALARM_WIRED_IRQ0 0x00000000 | ||
91 | #define VMI_ALARM_WIRED_LVTT 0x00010000 | ||
92 | |||
93 | #define VMI_ALARM_IS_ONESHOT 0x00000000 | ||
94 | #define VMI_ALARM_IS_PERIODIC 0x00000100 | ||
95 | |||
96 | #define CONFIG_VMI_ALARM_HZ 100 | ||
97 | |||
98 | #endif | ||
diff --git a/include/asm-x86/voyager.h b/include/asm-x86/voyager.h new file mode 100644 index 000000000000..91a9932937ab --- /dev/null +++ b/include/asm-x86/voyager.h | |||
@@ -0,0 +1,517 @@ | |||
1 | /* Copyright (C) 1999,2001 | ||
2 | * | ||
3 | * Author: J.E.J.Bottomley@HansenPartnership.com | ||
4 | * | ||
5 | * Standard include definitions for the NCR Voyager system */ | ||
6 | |||
7 | #undef VOYAGER_DEBUG | ||
8 | #undef VOYAGER_CAT_DEBUG | ||
9 | |||
10 | #ifdef VOYAGER_DEBUG | ||
11 | #define VDEBUG(x) printk x | ||
12 | #else | ||
13 | #define VDEBUG(x) | ||
14 | #endif | ||
15 | |||
16 | /* There are three levels of voyager machine: 3,4 and 5. The rule is | ||
17 | * if it's less than 3435 it's a Level 3 except for a 3360 which is | ||
18 | * a level 4. A 3435 or above is a Level 5 */ | ||
19 | #define VOYAGER_LEVEL5_AND_ABOVE 0x3435 | ||
20 | #define VOYAGER_LEVEL4 0x3360 | ||
21 | |||
22 | /* The L4 DINO ASIC */ | ||
23 | #define VOYAGER_DINO 0x43 | ||
24 | |||
25 | /* voyager ports in standard I/O space */ | ||
26 | #define VOYAGER_MC_SETUP 0x96 | ||
27 | |||
28 | |||
29 | #define VOYAGER_CAT_CONFIG_PORT 0x97 | ||
30 | # define VOYAGER_CAT_DESELECT 0xff | ||
31 | #define VOYAGER_SSPB_RELOCATION_PORT 0x98 | ||
32 | |||
33 | /* Valid CAT controller commands */ | ||
34 | /* start instruction register cycle */ | ||
35 | #define VOYAGER_CAT_IRCYC 0x01 | ||
36 | /* start data register cycle */ | ||
37 | #define VOYAGER_CAT_DRCYC 0x02 | ||
38 | /* move to execute state */ | ||
39 | #define VOYAGER_CAT_RUN 0x0F | ||
40 | /* end operation */ | ||
41 | #define VOYAGER_CAT_END 0x80 | ||
42 | /* hold in idle state */ | ||
43 | #define VOYAGER_CAT_HOLD 0x90 | ||
44 | /* single step an "intest" vector */ | ||
45 | #define VOYAGER_CAT_STEP 0xE0 | ||
46 | /* return cat controller to CLEMSON mode */ | ||
47 | #define VOYAGER_CAT_CLEMSON 0xFF | ||
48 | |||
49 | /* the default cat command header */ | ||
50 | #define VOYAGER_CAT_HEADER 0x7F | ||
51 | |||
52 | /* the range of possible CAT module ids in the system */ | ||
53 | #define VOYAGER_MIN_MODULE 0x10 | ||
54 | #define VOYAGER_MAX_MODULE 0x1f | ||
55 | |||
56 | /* The voyager registers per asic */ | ||
57 | #define VOYAGER_ASIC_ID_REG 0x00 | ||
58 | #define VOYAGER_ASIC_TYPE_REG 0x01 | ||
59 | /* the sub address registers can be made auto incrementing on reads */ | ||
60 | #define VOYAGER_AUTO_INC_REG 0x02 | ||
61 | # define VOYAGER_AUTO_INC 0x04 | ||
62 | # define VOYAGER_NO_AUTO_INC 0xfb | ||
63 | #define VOYAGER_SUBADDRDATA 0x03 | ||
64 | #define VOYAGER_SCANPATH 0x05 | ||
65 | # define VOYAGER_CONNECT_ASIC 0x01 | ||
66 | # define VOYAGER_DISCONNECT_ASIC 0xfe | ||
67 | #define VOYAGER_SUBADDRLO 0x06 | ||
68 | #define VOYAGER_SUBADDRHI 0x07 | ||
69 | #define VOYAGER_SUBMODSELECT 0x08 | ||
70 | #define VOYAGER_SUBMODPRESENT 0x09 | ||
71 | |||
72 | #define VOYAGER_SUBADDR_LO 0xff | ||
73 | #define VOYAGER_SUBADDR_HI 0xffff | ||
74 | |||
75 | /* the maximum size of a scan path -- used to form instructions */ | ||
76 | #define VOYAGER_MAX_SCAN_PATH 0x100 | ||
77 | /* the biggest possible register size (in bytes) */ | ||
78 | #define VOYAGER_MAX_REG_SIZE 4 | ||
79 | |||
80 | /* Total number of possible modules (including submodules) */ | ||
81 | #define VOYAGER_MAX_MODULES 16 | ||
82 | /* Largest number of asics per module */ | ||
83 | #define VOYAGER_MAX_ASICS_PER_MODULE 7 | ||
84 | |||
85 | /* the CAT asic of each module is always the first one */ | ||
86 | #define VOYAGER_CAT_ID 0 | ||
87 | #define VOYAGER_PSI 0x1a | ||
88 | |||
89 | /* voyager instruction operations and registers */ | ||
90 | #define VOYAGER_READ_CONFIG 0x1 | ||
91 | #define VOYAGER_WRITE_CONFIG 0x2 | ||
92 | #define VOYAGER_BYPASS 0xff | ||
93 | |||
94 | typedef struct voyager_asic | ||
95 | { | ||
96 | __u8 asic_addr; /* ASIC address; Level 4 */ | ||
97 | __u8 asic_type; /* ASIC type */ | ||
98 | __u8 asic_id; /* ASIC id */ | ||
99 | __u8 jtag_id[4]; /* JTAG id */ | ||
100 | __u8 asic_location; /* Location within scan path; start w/ 0 */ | ||
101 | __u8 bit_location; /* Location within bit stream; start w/ 0 */ | ||
102 | __u8 ireg_length; /* Instruction register length */ | ||
103 | __u16 subaddr; /* Amount of sub address space */ | ||
104 | struct voyager_asic *next; /* Next asic in linked list */ | ||
105 | } voyager_asic_t; | ||
106 | |||
107 | typedef struct voyager_module { | ||
108 | __u8 module_addr; /* Module address */ | ||
109 | __u8 scan_path_connected; /* Scan path connected */ | ||
110 | __u16 ee_size; /* Size of the EEPROM */ | ||
111 | __u16 num_asics; /* Number of Asics */ | ||
112 | __u16 inst_bits; /* Instruction bits in the scan path */ | ||
113 | __u16 largest_reg; /* Largest register in the scan path */ | ||
114 | __u16 smallest_reg; /* Smallest register in the scan path */ | ||
115 | voyager_asic_t *asic; /* First ASIC in scan path (CAT_I) */ | ||
116 | struct voyager_module *submodule; /* Submodule pointer */ | ||
117 | struct voyager_module *next; /* Next module in linked list */ | ||
118 | } voyager_module_t; | ||
119 | |||
120 | typedef struct voyager_eeprom_hdr { | ||
121 | __u8 module_id[4]; | ||
122 | __u8 version_id; | ||
123 | __u8 config_id; | ||
124 | __u16 boundry_id; /* boundary scan id */ | ||
125 | __u16 ee_size; /* size of EEPROM */ | ||
126 | __u8 assembly[11]; /* assembly # */ | ||
127 | __u8 assembly_rev; /* assembly rev */ | ||
128 | __u8 tracer[4]; /* tracer number */ | ||
129 | __u16 assembly_cksum; /* asm checksum */ | ||
130 | __u16 power_consump; /* pwr requirements */ | ||
131 | __u16 num_asics; /* number of asics */ | ||
132 | __u16 bist_time; /* min. bist time */ | ||
133 | __u16 err_log_offset; /* error log offset */ | ||
134 | __u16 scan_path_offset;/* scan path offset */ | ||
135 | __u16 cct_offset; | ||
136 | __u16 log_length; /* length of err log */ | ||
137 | __u16 xsum_end; /* offset to end of | ||
138 | checksum */ | ||
139 | __u8 reserved[4]; | ||
140 | __u8 sflag; /* starting sentinal */ | ||
141 | __u8 part_number[13]; /* prom part number */ | ||
142 | __u8 version[10]; /* version number */ | ||
143 | __u8 signature[8]; | ||
144 | __u16 eeprom_chksum; | ||
145 | __u32 data_stamp_offset; | ||
146 | __u8 eflag ; /* ending sentinal */ | ||
147 | } __attribute__((packed)) voyager_eprom_hdr_t; | ||
148 | |||
149 | |||
150 | |||
151 | #define VOYAGER_EPROM_SIZE_OFFSET ((__u16)(&(((voyager_eprom_hdr_t *)0)->ee_size))) | ||
152 | #define VOYAGER_XSUM_END_OFFSET 0x2a | ||
153 | |||
154 | /* the following three definitions are for internal table layouts | ||
155 | * in the module EPROMs. We really only care about the IDs and | ||
156 | * offsets */ | ||
157 | typedef struct voyager_sp_table { | ||
158 | __u8 asic_id; | ||
159 | __u8 bypass_flag; | ||
160 | __u16 asic_data_offset; | ||
161 | __u16 config_data_offset; | ||
162 | } __attribute__((packed)) voyager_sp_table_t; | ||
163 | |||
164 | typedef struct voyager_jtag_table { | ||
165 | __u8 icode[4]; | ||
166 | __u8 runbist[4]; | ||
167 | __u8 intest[4]; | ||
168 | __u8 samp_preld[4]; | ||
169 | __u8 ireg_len; | ||
170 | } __attribute__((packed)) voyager_jtt_t; | ||
171 | |||
172 | typedef struct voyager_asic_data_table { | ||
173 | __u8 jtag_id[4]; | ||
174 | __u16 length_bsr; | ||
175 | __u16 length_bist_reg; | ||
176 | __u32 bist_clk; | ||
177 | __u16 subaddr_bits; | ||
178 | __u16 seed_bits; | ||
179 | __u16 sig_bits; | ||
180 | __u16 jtag_offset; | ||
181 | } __attribute__((packed)) voyager_at_t; | ||
182 | |||
183 | /* Voyager Interrupt Controller (VIC) registers */ | ||
184 | |||
185 | /* Base to add to Cross Processor Interrupts (CPIs) when triggering | ||
186 | * the CPU IRQ line */ | ||
187 | /* register defines for the WCBICs (one per processor) */ | ||
188 | #define VOYAGER_WCBIC0 0x41 /* bus A node P1 processor 0 */ | ||
189 | #define VOYAGER_WCBIC1 0x49 /* bus A node P1 processor 1 */ | ||
190 | #define VOYAGER_WCBIC2 0x51 /* bus A node P2 processor 0 */ | ||
191 | #define VOYAGER_WCBIC3 0x59 /* bus A node P2 processor 1 */ | ||
192 | #define VOYAGER_WCBIC4 0x61 /* bus B node P1 processor 0 */ | ||
193 | #define VOYAGER_WCBIC5 0x69 /* bus B node P1 processor 1 */ | ||
194 | #define VOYAGER_WCBIC6 0x71 /* bus B node P2 processor 0 */ | ||
195 | #define VOYAGER_WCBIC7 0x79 /* bus B node P2 processor 1 */ | ||
196 | |||
197 | |||
198 | /* top of memory registers */ | ||
199 | #define VOYAGER_WCBIC_TOM_L 0x4 | ||
200 | #define VOYAGER_WCBIC_TOM_H 0x5 | ||
201 | |||
202 | /* register defines for Voyager Memory Contol (VMC) | ||
203 | * these are present on L4 machines only */ | ||
204 | #define VOYAGER_VMC1 0x81 | ||
205 | #define VOYAGER_VMC2 0x91 | ||
206 | #define VOYAGER_VMC3 0xa1 | ||
207 | #define VOYAGER_VMC4 0xb1 | ||
208 | |||
209 | /* VMC Ports */ | ||
210 | #define VOYAGER_VMC_MEMORY_SETUP 0x9 | ||
211 | # define VMC_Interleaving 0x01 | ||
212 | # define VMC_4Way 0x02 | ||
213 | # define VMC_EvenCacheLines 0x04 | ||
214 | # define VMC_HighLine 0x08 | ||
215 | # define VMC_Start0_Enable 0x20 | ||
216 | # define VMC_Start1_Enable 0x40 | ||
217 | # define VMC_Vremap 0x80 | ||
218 | #define VOYAGER_VMC_BANK_DENSITY 0xa | ||
219 | # define VMC_BANK_EMPTY 0 | ||
220 | # define VMC_BANK_4MB 1 | ||
221 | # define VMC_BANK_16MB 2 | ||
222 | # define VMC_BANK_64MB 3 | ||
223 | # define VMC_BANK0_MASK 0x03 | ||
224 | # define VMC_BANK1_MASK 0x0C | ||
225 | # define VMC_BANK2_MASK 0x30 | ||
226 | # define VMC_BANK3_MASK 0xC0 | ||
227 | |||
228 | /* Magellan Memory Controller (MMC) defines - present on L5 */ | ||
229 | #define VOYAGER_MMC_ASIC_ID 1 | ||
230 | /* the two memory modules corresponding to memory cards in the system */ | ||
231 | #define VOYAGER_MMC_MEMORY0_MODULE 0x14 | ||
232 | #define VOYAGER_MMC_MEMORY1_MODULE 0x15 | ||
233 | /* the Magellan Memory Address (MMA) defines */ | ||
234 | #define VOYAGER_MMA_ASIC_ID 2 | ||
235 | |||
236 | /* Submodule number for the Quad Baseboard */ | ||
237 | #define VOYAGER_QUAD_BASEBOARD 1 | ||
238 | |||
239 | /* ASIC defines for the Quad Baseboard */ | ||
240 | #define VOYAGER_QUAD_QDATA0 1 | ||
241 | #define VOYAGER_QUAD_QDATA1 2 | ||
242 | #define VOYAGER_QUAD_QABC 3 | ||
243 | |||
244 | /* Useful areas in extended CMOS */ | ||
245 | #define VOYAGER_PROCESSOR_PRESENT_MASK 0x88a | ||
246 | #define VOYAGER_MEMORY_CLICKMAP 0xa23 | ||
247 | #define VOYAGER_DUMP_LOCATION 0xb1a | ||
248 | |||
249 | /* SUS In Control bit - used to tell SUS that we don't need to be | ||
250 | * babysat anymore */ | ||
251 | #define VOYAGER_SUS_IN_CONTROL_PORT 0x3ff | ||
252 | # define VOYAGER_IN_CONTROL_FLAG 0x80 | ||
253 | |||
254 | /* Voyager PSI defines */ | ||
255 | #define VOYAGER_PSI_STATUS_REG 0x08 | ||
256 | # define PSI_DC_FAIL 0x01 | ||
257 | # define PSI_MON 0x02 | ||
258 | # define PSI_FAULT 0x04 | ||
259 | # define PSI_ALARM 0x08 | ||
260 | # define PSI_CURRENT 0x10 | ||
261 | # define PSI_DVM 0x20 | ||
262 | # define PSI_PSCFAULT 0x40 | ||
263 | # define PSI_STAT_CHG 0x80 | ||
264 | |||
265 | #define VOYAGER_PSI_SUPPLY_REG 0x8000 | ||
266 | /* read */ | ||
267 | # define PSI_FAIL_DC 0x01 | ||
268 | # define PSI_FAIL_AC 0x02 | ||
269 | # define PSI_MON_INT 0x04 | ||
270 | # define PSI_SWITCH_OFF 0x08 | ||
271 | # define PSI_HX_OFF 0x10 | ||
272 | # define PSI_SECURITY 0x20 | ||
273 | # define PSI_CMOS_BATT_LOW 0x40 | ||
274 | # define PSI_CMOS_BATT_FAIL 0x80 | ||
275 | /* write */ | ||
276 | # define PSI_CLR_SWITCH_OFF 0x13 | ||
277 | # define PSI_CLR_HX_OFF 0x14 | ||
278 | # define PSI_CLR_CMOS_BATT_FAIL 0x17 | ||
279 | |||
280 | #define VOYAGER_PSI_MASK 0x8001 | ||
281 | # define PSI_MASK_MASK 0x10 | ||
282 | |||
283 | #define VOYAGER_PSI_AC_FAIL_REG 0x8004 | ||
284 | #define AC_FAIL_STAT_CHANGE 0x80 | ||
285 | |||
286 | #define VOYAGER_PSI_GENERAL_REG 0x8007 | ||
287 | /* read */ | ||
288 | # define PSI_SWITCH_ON 0x01 | ||
289 | # define PSI_SWITCH_ENABLED 0x02 | ||
290 | # define PSI_ALARM_ENABLED 0x08 | ||
291 | # define PSI_SECURE_ENABLED 0x10 | ||
292 | # define PSI_COLD_RESET 0x20 | ||
293 | # define PSI_COLD_START 0x80 | ||
294 | /* write */ | ||
295 | # define PSI_POWER_DOWN 0x10 | ||
296 | # define PSI_SWITCH_DISABLE 0x01 | ||
297 | # define PSI_SWITCH_ENABLE 0x11 | ||
298 | # define PSI_CLEAR 0x12 | ||
299 | # define PSI_ALARM_DISABLE 0x03 | ||
300 | # define PSI_ALARM_ENABLE 0x13 | ||
301 | # define PSI_CLEAR_COLD_RESET 0x05 | ||
302 | # define PSI_SET_COLD_RESET 0x15 | ||
303 | # define PSI_CLEAR_COLD_START 0x07 | ||
304 | # define PSI_SET_COLD_START 0x17 | ||
305 | |||
306 | |||
307 | |||
308 | struct voyager_bios_info { | ||
309 | __u8 len; | ||
310 | __u8 major; | ||
311 | __u8 minor; | ||
312 | __u8 debug; | ||
313 | __u8 num_classes; | ||
314 | __u8 class_1; | ||
315 | __u8 class_2; | ||
316 | }; | ||
317 | |||
318 | /* The following structures and definitions are for the Kernel/SUS | ||
319 | * interface these are needed to find out how SUS initialised any Quad | ||
320 | * boards in the system */ | ||
321 | |||
322 | #define NUMBER_OF_MC_BUSSES 2 | ||
323 | #define SLOTS_PER_MC_BUS 8 | ||
324 | #define MAX_CPUS 16 /* 16 way CPU system */ | ||
325 | #define MAX_PROCESSOR_BOARDS 4 /* 4 processor slot system */ | ||
326 | #define MAX_CACHE_LEVELS 4 /* # of cache levels supported */ | ||
327 | #define MAX_SHARED_CPUS 4 /* # of CPUs that can share a LARC */ | ||
328 | #define NUMBER_OF_POS_REGS 8 | ||
329 | |||
330 | typedef struct { | ||
331 | __u8 MC_Slot; | ||
332 | __u8 POS_Values[NUMBER_OF_POS_REGS]; | ||
333 | } __attribute__((packed)) MC_SlotInformation_t; | ||
334 | |||
335 | struct QuadDescription { | ||
336 | __u8 Type; /* for type 0 (DYADIC or MONADIC) all fields | ||
337 | * will be zero except for slot */ | ||
338 | __u8 StructureVersion; | ||
339 | __u32 CPI_BaseAddress; | ||
340 | __u32 LARC_BankSize; | ||
341 | __u32 LocalMemoryStateBits; | ||
342 | __u8 Slot; /* Processor slots 1 - 4 */ | ||
343 | } __attribute__((packed)); | ||
344 | |||
345 | struct ProcBoardInfo { | ||
346 | __u8 Type; | ||
347 | __u8 StructureVersion; | ||
348 | __u8 NumberOfBoards; | ||
349 | struct QuadDescription QuadData[MAX_PROCESSOR_BOARDS]; | ||
350 | } __attribute__((packed)); | ||
351 | |||
352 | struct CacheDescription { | ||
353 | __u8 Level; | ||
354 | __u32 TotalSize; | ||
355 | __u16 LineSize; | ||
356 | __u8 Associativity; | ||
357 | __u8 CacheType; | ||
358 | __u8 WriteType; | ||
359 | __u8 Number_CPUs_SharedBy; | ||
360 | __u8 Shared_CPUs_Hardware_IDs[MAX_SHARED_CPUS]; | ||
361 | |||
362 | } __attribute__((packed)); | ||
363 | |||
364 | struct CPU_Description { | ||
365 | __u8 CPU_HardwareId; | ||
366 | char *FRU_String; | ||
367 | __u8 NumberOfCacheLevels; | ||
368 | struct CacheDescription CacheLevelData[MAX_CACHE_LEVELS]; | ||
369 | } __attribute__((packed)); | ||
370 | |||
371 | struct CPU_Info { | ||
372 | __u8 Type; | ||
373 | __u8 StructureVersion; | ||
374 | __u8 NumberOf_CPUs; | ||
375 | struct CPU_Description CPU_Data[MAX_CPUS]; | ||
376 | } __attribute__((packed)); | ||
377 | |||
378 | |||
379 | /* | ||
380 | * This structure will be used by SUS and the OS. | ||
381 | * The assumption about this structure is that no blank space is | ||
382 | * packed in it by our friend the compiler. | ||
383 | */ | ||
384 | typedef struct { | ||
385 | __u8 Mailbox_SUS; /* Written to by SUS to give commands/response to the OS */ | ||
386 | __u8 Mailbox_OS; /* Written to by the OS to give commands/response to SUS */ | ||
387 | __u8 SUS_MailboxVersion; /* Tells the OS which iteration of the interface SUS supports */ | ||
388 | __u8 OS_MailboxVersion; /* Tells SUS which iteration of the interface the OS supports */ | ||
389 | __u32 OS_Flags; /* Flags set by the OS as info for SUS */ | ||
390 | __u32 SUS_Flags; /* Flags set by SUS as info for the OS */ | ||
391 | __u32 WatchDogPeriod; /* Watchdog period (in seconds) which the DP uses to see if the OS is dead */ | ||
392 | __u32 WatchDogCount; /* Updated by the OS on every tic. */ | ||
393 | __u32 MemoryFor_SUS_ErrorLog; /* Flat 32 bit address which tells SUS where to stuff the SUS error log on a dump */ | ||
394 | MC_SlotInformation_t MC_SlotInfo[NUMBER_OF_MC_BUSSES*SLOTS_PER_MC_BUS]; /* Storage for MCA POS data */ | ||
395 | /* All new SECOND_PASS_INTERFACE fields added from this point */ | ||
396 | struct ProcBoardInfo *BoardData; | ||
397 | struct CPU_Info *CPU_Data; | ||
398 | /* All new fields must be added from this point */ | ||
399 | } Voyager_KernelSUS_Mbox_t; | ||
400 | |||
401 | /* structure for finding the right memory address to send a QIC CPI to */ | ||
402 | struct voyager_qic_cpi { | ||
403 | /* Each cache line (32 bytes) can trigger a cpi. The cpi | ||
404 | * read/write may occur anywhere in the cache line---pick the | ||
405 | * middle to be safe */ | ||
406 | struct { | ||
407 | __u32 pad1[3]; | ||
408 | __u32 cpi; | ||
409 | __u32 pad2[4]; | ||
410 | } qic_cpi[8]; | ||
411 | }; | ||
412 | |||
413 | struct voyager_status { | ||
414 | __u32 power_fail:1; | ||
415 | __u32 switch_off:1; | ||
416 | __u32 request_from_kernel:1; | ||
417 | }; | ||
418 | |||
419 | struct voyager_psi_regs { | ||
420 | __u8 cat_id; | ||
421 | __u8 cat_dev; | ||
422 | __u8 cat_control; | ||
423 | __u8 subaddr; | ||
424 | __u8 dummy4; | ||
425 | __u8 checkbit; | ||
426 | __u8 subaddr_low; | ||
427 | __u8 subaddr_high; | ||
428 | __u8 intstatus; | ||
429 | __u8 stat1; | ||
430 | __u8 stat3; | ||
431 | __u8 fault; | ||
432 | __u8 tms; | ||
433 | __u8 gen; | ||
434 | __u8 sysconf; | ||
435 | __u8 dummy15; | ||
436 | }; | ||
437 | |||
438 | struct voyager_psi_subregs { | ||
439 | __u8 supply; | ||
440 | __u8 mask; | ||
441 | __u8 present; | ||
442 | __u8 DCfail; | ||
443 | __u8 ACfail; | ||
444 | __u8 fail; | ||
445 | __u8 UPSfail; | ||
446 | __u8 genstatus; | ||
447 | }; | ||
448 | |||
449 | struct voyager_psi { | ||
450 | struct voyager_psi_regs regs; | ||
451 | struct voyager_psi_subregs subregs; | ||
452 | }; | ||
453 | |||
454 | struct voyager_SUS { | ||
455 | #define VOYAGER_DUMP_BUTTON_NMI 0x1 | ||
456 | #define VOYAGER_SUS_VALID 0x2 | ||
457 | #define VOYAGER_SYSINT_COMPLETE 0x3 | ||
458 | __u8 SUS_mbox; | ||
459 | #define VOYAGER_NO_COMMAND 0x0 | ||
460 | #define VOYAGER_IGNORE_DUMP 0x1 | ||
461 | #define VOYAGER_DO_DUMP 0x2 | ||
462 | #define VOYAGER_SYSINT_HANDSHAKE 0x3 | ||
463 | #define VOYAGER_DO_MEM_DUMP 0x4 | ||
464 | #define VOYAGER_SYSINT_WAS_RECOVERED 0x5 | ||
465 | __u8 kernel_mbox; | ||
466 | #define VOYAGER_MAILBOX_VERSION 0x10 | ||
467 | __u8 SUS_version; | ||
468 | __u8 kernel_version; | ||
469 | #define VOYAGER_OS_HAS_SYSINT 0x1 | ||
470 | #define VOYAGER_OS_IN_PROGRESS 0x2 | ||
471 | #define VOYAGER_UPDATING_WDPERIOD 0x4 | ||
472 | __u32 kernel_flags; | ||
473 | #define VOYAGER_SUS_BOOTING 0x1 | ||
474 | #define VOYAGER_SUS_IN_PROGRESS 0x2 | ||
475 | __u32 SUS_flags; | ||
476 | __u32 watchdog_period; | ||
477 | __u32 watchdog_count; | ||
478 | __u32 SUS_errorlog; | ||
479 | /* lots of system configuration stuff under here */ | ||
480 | }; | ||
481 | |||
482 | /* Variables exported by voyager_smp */ | ||
483 | extern __u32 voyager_extended_vic_processors; | ||
484 | extern __u32 voyager_allowed_boot_processors; | ||
485 | extern __u32 voyager_quad_processors; | ||
486 | extern struct voyager_qic_cpi *voyager_quad_cpi_addr[NR_CPUS]; | ||
487 | extern struct voyager_SUS *voyager_SUS; | ||
488 | |||
489 | /* variables exported always */ | ||
490 | extern struct task_struct *voyager_thread; | ||
491 | extern int voyager_level; | ||
492 | extern struct voyager_status voyager_status; | ||
493 | |||
494 | /* functions exported by the voyager and voyager_smp modules */ | ||
495 | extern int voyager_cat_readb(__u8 module, __u8 asic, int reg); | ||
496 | extern void voyager_cat_init(void); | ||
497 | extern void voyager_detect(struct voyager_bios_info *); | ||
498 | extern void voyager_trap_init(void); | ||
499 | extern void voyager_setup_irqs(void); | ||
500 | extern int voyager_memory_detect(int region, __u32 *addr, __u32 *length); | ||
501 | extern void voyager_smp_intr_init(void); | ||
502 | extern __u8 voyager_extended_cmos_read(__u16 cmos_address); | ||
503 | extern void voyager_smp_dump(void); | ||
504 | extern void voyager_timer_interrupt(void); | ||
505 | extern void smp_local_timer_interrupt(void); | ||
506 | extern void voyager_power_off(void); | ||
507 | extern void smp_voyager_power_off(void *dummy); | ||
508 | extern void voyager_restart(void); | ||
509 | extern void voyager_cat_power_off(void); | ||
510 | extern void voyager_cat_do_common_interrupt(void); | ||
511 | extern void voyager_handle_nmi(void); | ||
512 | /* Commands for the following are */ | ||
513 | #define VOYAGER_PSI_READ 0 | ||
514 | #define VOYAGER_PSI_WRITE 1 | ||
515 | #define VOYAGER_PSI_SUBREAD 2 | ||
516 | #define VOYAGER_PSI_SUBWRITE 3 | ||
517 | extern void voyager_cat_psi(__u8, __u16, __u8 *); | ||
diff --git a/include/asm-x86/vsyscall.h b/include/asm-x86/vsyscall.h new file mode 100644 index 000000000000..3b8ceb4af2cf --- /dev/null +++ b/include/asm-x86/vsyscall.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _ASM_X86_64_VSYSCALL_H_ | ||
2 | #define _ASM_X86_64_VSYSCALL_H_ | ||
3 | |||
4 | enum vsyscall_num { | ||
5 | __NR_vgettimeofday, | ||
6 | __NR_vtime, | ||
7 | __NR_vgetcpu, | ||
8 | }; | ||
9 | |||
10 | #define VSYSCALL_START (-10UL << 20) | ||
11 | #define VSYSCALL_SIZE 1024 | ||
12 | #define VSYSCALL_END (-2UL << 20) | ||
13 | #define VSYSCALL_MAPPED_PAGES 1 | ||
14 | #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr)) | ||
15 | |||
16 | #ifdef __KERNEL__ | ||
17 | #include <linux/seqlock.h> | ||
18 | |||
19 | #define __section_vgetcpu_mode __attribute__ ((unused, __section__ (".vgetcpu_mode"), aligned(16))) | ||
20 | #define __section_jiffies __attribute__ ((unused, __section__ (".jiffies"), aligned(16))) | ||
21 | |||
22 | /* Definitions for CONFIG_GENERIC_TIME definitions */ | ||
23 | #define __section_vsyscall_gtod_data __attribute__ \ | ||
24 | ((unused, __section__ (".vsyscall_gtod_data"),aligned(16))) | ||
25 | #define __section_vsyscall_clock __attribute__ \ | ||
26 | ((unused, __section__ (".vsyscall_clock"),aligned(16))) | ||
27 | #define __vsyscall_fn __attribute__ ((unused,__section__(".vsyscall_fn"))) | ||
28 | |||
29 | #define VGETCPU_RDTSCP 1 | ||
30 | #define VGETCPU_LSL 2 | ||
31 | |||
32 | #define hpet_readl(a) readl((const void __iomem *)fix_to_virt(FIX_HPET_BASE) + a) | ||
33 | #define hpet_writel(d,a) writel(d, (void __iomem *)fix_to_virt(FIX_HPET_BASE) + a) | ||
34 | |||
35 | extern int __vgetcpu_mode; | ||
36 | extern volatile unsigned long __jiffies; | ||
37 | |||
38 | /* kernel space (writeable) */ | ||
39 | extern int vgetcpu_mode; | ||
40 | extern struct timezone sys_tz; | ||
41 | |||
42 | #endif /* __KERNEL__ */ | ||
43 | |||
44 | #endif /* _ASM_X86_64_VSYSCALL_H_ */ | ||
diff --git a/include/asm-x86/vsyscall32.h b/include/asm-x86/vsyscall32.h new file mode 100644 index 000000000000..c631c082f8f7 --- /dev/null +++ b/include/asm-x86/vsyscall32.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_VSYSCALL32_H | ||
2 | #define _ASM_VSYSCALL32_H 1 | ||
3 | |||
4 | /* Values need to match arch/x86_64/ia32/vsyscall.lds */ | ||
5 | |||
6 | #ifdef __ASSEMBLY__ | ||
7 | #define VSYSCALL32_BASE 0xffffe000 | ||
8 | #define VSYSCALL32_SYSEXIT (VSYSCALL32_BASE + 0x410) | ||
9 | #else | ||
10 | #define VSYSCALL32_BASE 0xffffe000UL | ||
11 | #define VSYSCALL32_END (VSYSCALL32_BASE + PAGE_SIZE) | ||
12 | #define VSYSCALL32_EHDR ((const struct elf32_hdr *) VSYSCALL32_BASE) | ||
13 | |||
14 | #define VSYSCALL32_VSYSCALL ((void *)VSYSCALL32_BASE + 0x400) | ||
15 | #define VSYSCALL32_SYSEXIT ((void *)VSYSCALL32_BASE + 0x410) | ||
16 | #define VSYSCALL32_SIGRETURN ((void __user *)VSYSCALL32_BASE + 0x500) | ||
17 | #define VSYSCALL32_RTSIGRETURN ((void __user *)VSYSCALL32_BASE + 0x600) | ||
18 | #endif | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h new file mode 100644 index 000000000000..bc0ee7d961ca --- /dev/null +++ b/include/asm-x86/xen/hypercall.h | |||
@@ -0,0 +1,413 @@ | |||
1 | /****************************************************************************** | ||
2 | * hypercall.h | ||
3 | * | ||
4 | * Linux-specific hypervisor handling. | ||
5 | * | ||
6 | * Copyright (c) 2002-2004, K A Fraser | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License version 2 | ||
10 | * as published by the Free Software Foundation; or, when distributed | ||
11 | * separately from the Linux kernel or incorporated into other | ||
12 | * software packages, subject to the following license: | ||
13 | * | ||
14 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
15 | * of this source file (the "Software"), to deal in the Software without | ||
16 | * restriction, including without limitation the rights to use, copy, modify, | ||
17 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
18 | * and to permit persons to whom the Software is furnished to do so, subject to | ||
19 | * the following conditions: | ||
20 | * | ||
21 | * The above copyright notice and this permission notice shall be included in | ||
22 | * all copies or substantial portions of the Software. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
30 | * IN THE SOFTWARE. | ||
31 | */ | ||
32 | |||
33 | #ifndef __HYPERCALL_H__ | ||
34 | #define __HYPERCALL_H__ | ||
35 | |||
36 | #include <linux/errno.h> | ||
37 | #include <linux/string.h> | ||
38 | |||
39 | #include <xen/interface/xen.h> | ||
40 | #include <xen/interface/sched.h> | ||
41 | #include <xen/interface/physdev.h> | ||
42 | |||
43 | extern struct { char _entry[32]; } hypercall_page[]; | ||
44 | |||
45 | #define _hypercall0(type, name) \ | ||
46 | ({ \ | ||
47 | long __res; \ | ||
48 | asm volatile ( \ | ||
49 | "call %[call]" \ | ||
50 | : "=a" (__res) \ | ||
51 | : [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
52 | : "memory" ); \ | ||
53 | (type)__res; \ | ||
54 | }) | ||
55 | |||
56 | #define _hypercall1(type, name, a1) \ | ||
57 | ({ \ | ||
58 | long __res, __ign1; \ | ||
59 | asm volatile ( \ | ||
60 | "call %[call]" \ | ||
61 | : "=a" (__res), "=b" (__ign1) \ | ||
62 | : "1" ((long)(a1)), \ | ||
63 | [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
64 | : "memory" ); \ | ||
65 | (type)__res; \ | ||
66 | }) | ||
67 | |||
68 | #define _hypercall2(type, name, a1, a2) \ | ||
69 | ({ \ | ||
70 | long __res, __ign1, __ign2; \ | ||
71 | asm volatile ( \ | ||
72 | "call %[call]" \ | ||
73 | : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \ | ||
74 | : "1" ((long)(a1)), "2" ((long)(a2)), \ | ||
75 | [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
76 | : "memory" ); \ | ||
77 | (type)__res; \ | ||
78 | }) | ||
79 | |||
80 | #define _hypercall3(type, name, a1, a2, a3) \ | ||
81 | ({ \ | ||
82 | long __res, __ign1, __ign2, __ign3; \ | ||
83 | asm volatile ( \ | ||
84 | "call %[call]" \ | ||
85 | : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ | ||
86 | "=d" (__ign3) \ | ||
87 | : "1" ((long)(a1)), "2" ((long)(a2)), \ | ||
88 | "3" ((long)(a3)), \ | ||
89 | [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
90 | : "memory" ); \ | ||
91 | (type)__res; \ | ||
92 | }) | ||
93 | |||
94 | #define _hypercall4(type, name, a1, a2, a3, a4) \ | ||
95 | ({ \ | ||
96 | long __res, __ign1, __ign2, __ign3, __ign4; \ | ||
97 | asm volatile ( \ | ||
98 | "call %[call]" \ | ||
99 | : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ | ||
100 | "=d" (__ign3), "=S" (__ign4) \ | ||
101 | : "1" ((long)(a1)), "2" ((long)(a2)), \ | ||
102 | "3" ((long)(a3)), "4" ((long)(a4)), \ | ||
103 | [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
104 | : "memory" ); \ | ||
105 | (type)__res; \ | ||
106 | }) | ||
107 | |||
108 | #define _hypercall5(type, name, a1, a2, a3, a4, a5) \ | ||
109 | ({ \ | ||
110 | long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \ | ||
111 | asm volatile ( \ | ||
112 | "call %[call]" \ | ||
113 | : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ | ||
114 | "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \ | ||
115 | : "1" ((long)(a1)), "2" ((long)(a2)), \ | ||
116 | "3" ((long)(a3)), "4" ((long)(a4)), \ | ||
117 | "5" ((long)(a5)), \ | ||
118 | [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ | ||
119 | : "memory" ); \ | ||
120 | (type)__res; \ | ||
121 | }) | ||
122 | |||
123 | static inline int | ||
124 | HYPERVISOR_set_trap_table(struct trap_info *table) | ||
125 | { | ||
126 | return _hypercall1(int, set_trap_table, table); | ||
127 | } | ||
128 | |||
129 | static inline int | ||
130 | HYPERVISOR_mmu_update(struct mmu_update *req, int count, | ||
131 | int *success_count, domid_t domid) | ||
132 | { | ||
133 | return _hypercall4(int, mmu_update, req, count, success_count, domid); | ||
134 | } | ||
135 | |||
136 | static inline int | ||
137 | HYPERVISOR_mmuext_op(struct mmuext_op *op, int count, | ||
138 | int *success_count, domid_t domid) | ||
139 | { | ||
140 | return _hypercall4(int, mmuext_op, op, count, success_count, domid); | ||
141 | } | ||
142 | |||
143 | static inline int | ||
144 | HYPERVISOR_set_gdt(unsigned long *frame_list, int entries) | ||
145 | { | ||
146 | return _hypercall2(int, set_gdt, frame_list, entries); | ||
147 | } | ||
148 | |||
149 | static inline int | ||
150 | HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp) | ||
151 | { | ||
152 | return _hypercall2(int, stack_switch, ss, esp); | ||
153 | } | ||
154 | |||
155 | static inline int | ||
156 | HYPERVISOR_set_callbacks(unsigned long event_selector, | ||
157 | unsigned long event_address, | ||
158 | unsigned long failsafe_selector, | ||
159 | unsigned long failsafe_address) | ||
160 | { | ||
161 | return _hypercall4(int, set_callbacks, | ||
162 | event_selector, event_address, | ||
163 | failsafe_selector, failsafe_address); | ||
164 | } | ||
165 | |||
166 | static inline int | ||
167 | HYPERVISOR_fpu_taskswitch(int set) | ||
168 | { | ||
169 | return _hypercall1(int, fpu_taskswitch, set); | ||
170 | } | ||
171 | |||
172 | static inline int | ||
173 | HYPERVISOR_sched_op(int cmd, unsigned long arg) | ||
174 | { | ||
175 | return _hypercall2(int, sched_op, cmd, arg); | ||
176 | } | ||
177 | |||
178 | static inline long | ||
179 | HYPERVISOR_set_timer_op(u64 timeout) | ||
180 | { | ||
181 | unsigned long timeout_hi = (unsigned long)(timeout>>32); | ||
182 | unsigned long timeout_lo = (unsigned long)timeout; | ||
183 | return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi); | ||
184 | } | ||
185 | |||
186 | static inline int | ||
187 | HYPERVISOR_set_debugreg(int reg, unsigned long value) | ||
188 | { | ||
189 | return _hypercall2(int, set_debugreg, reg, value); | ||
190 | } | ||
191 | |||
192 | static inline unsigned long | ||
193 | HYPERVISOR_get_debugreg(int reg) | ||
194 | { | ||
195 | return _hypercall1(unsigned long, get_debugreg, reg); | ||
196 | } | ||
197 | |||
198 | static inline int | ||
199 | HYPERVISOR_update_descriptor(u64 ma, u64 desc) | ||
200 | { | ||
201 | return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32); | ||
202 | } | ||
203 | |||
204 | static inline int | ||
205 | HYPERVISOR_memory_op(unsigned int cmd, void *arg) | ||
206 | { | ||
207 | return _hypercall2(int, memory_op, cmd, arg); | ||
208 | } | ||
209 | |||
210 | static inline int | ||
211 | HYPERVISOR_multicall(void *call_list, int nr_calls) | ||
212 | { | ||
213 | return _hypercall2(int, multicall, call_list, nr_calls); | ||
214 | } | ||
215 | |||
216 | static inline int | ||
217 | HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val, | ||
218 | unsigned long flags) | ||
219 | { | ||
220 | unsigned long pte_hi = 0; | ||
221 | #ifdef CONFIG_X86_PAE | ||
222 | pte_hi = new_val.pte_high; | ||
223 | #endif | ||
224 | return _hypercall4(int, update_va_mapping, va, | ||
225 | new_val.pte_low, pte_hi, flags); | ||
226 | } | ||
227 | |||
228 | static inline int | ||
229 | HYPERVISOR_event_channel_op(int cmd, void *arg) | ||
230 | { | ||
231 | int rc = _hypercall2(int, event_channel_op, cmd, arg); | ||
232 | if (unlikely(rc == -ENOSYS)) { | ||
233 | struct evtchn_op op; | ||
234 | op.cmd = cmd; | ||
235 | memcpy(&op.u, arg, sizeof(op.u)); | ||
236 | rc = _hypercall1(int, event_channel_op_compat, &op); | ||
237 | memcpy(arg, &op.u, sizeof(op.u)); | ||
238 | } | ||
239 | return rc; | ||
240 | } | ||
241 | |||
242 | static inline int | ||
243 | HYPERVISOR_xen_version(int cmd, void *arg) | ||
244 | { | ||
245 | return _hypercall2(int, xen_version, cmd, arg); | ||
246 | } | ||
247 | |||
248 | static inline int | ||
249 | HYPERVISOR_console_io(int cmd, int count, char *str) | ||
250 | { | ||
251 | return _hypercall3(int, console_io, cmd, count, str); | ||
252 | } | ||
253 | |||
254 | static inline int | ||
255 | HYPERVISOR_physdev_op(int cmd, void *arg) | ||
256 | { | ||
257 | int rc = _hypercall2(int, physdev_op, cmd, arg); | ||
258 | if (unlikely(rc == -ENOSYS)) { | ||
259 | struct physdev_op op; | ||
260 | op.cmd = cmd; | ||
261 | memcpy(&op.u, arg, sizeof(op.u)); | ||
262 | rc = _hypercall1(int, physdev_op_compat, &op); | ||
263 | memcpy(arg, &op.u, sizeof(op.u)); | ||
264 | } | ||
265 | return rc; | ||
266 | } | ||
267 | |||
268 | static inline int | ||
269 | HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count) | ||
270 | { | ||
271 | return _hypercall3(int, grant_table_op, cmd, uop, count); | ||
272 | } | ||
273 | |||
274 | static inline int | ||
275 | HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, pte_t new_val, | ||
276 | unsigned long flags, domid_t domid) | ||
277 | { | ||
278 | unsigned long pte_hi = 0; | ||
279 | #ifdef CONFIG_X86_PAE | ||
280 | pte_hi = new_val.pte_high; | ||
281 | #endif | ||
282 | return _hypercall5(int, update_va_mapping_otherdomain, va, | ||
283 | new_val.pte_low, pte_hi, flags, domid); | ||
284 | } | ||
285 | |||
286 | static inline int | ||
287 | HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type) | ||
288 | { | ||
289 | return _hypercall2(int, vm_assist, cmd, type); | ||
290 | } | ||
291 | |||
292 | static inline int | ||
293 | HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args) | ||
294 | { | ||
295 | return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); | ||
296 | } | ||
297 | |||
298 | static inline int | ||
299 | HYPERVISOR_suspend(unsigned long srec) | ||
300 | { | ||
301 | return _hypercall3(int, sched_op, SCHEDOP_shutdown, | ||
302 | SHUTDOWN_suspend, srec); | ||
303 | } | ||
304 | |||
305 | static inline int | ||
306 | HYPERVISOR_nmi_op(unsigned long op, unsigned long arg) | ||
307 | { | ||
308 | return _hypercall2(int, nmi_op, op, arg); | ||
309 | } | ||
310 | |||
311 | static inline void | ||
312 | MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, | ||
313 | pte_t new_val, unsigned long flags) | ||
314 | { | ||
315 | mcl->op = __HYPERVISOR_update_va_mapping; | ||
316 | mcl->args[0] = va; | ||
317 | #ifdef CONFIG_X86_PAE | ||
318 | mcl->args[1] = new_val.pte_low; | ||
319 | mcl->args[2] = new_val.pte_high; | ||
320 | #else | ||
321 | mcl->args[1] = new_val.pte_low; | ||
322 | mcl->args[2] = 0; | ||
323 | #endif | ||
324 | mcl->args[3] = flags; | ||
325 | } | ||
326 | |||
327 | static inline void | ||
328 | MULTI_grant_table_op(struct multicall_entry *mcl, unsigned int cmd, | ||
329 | void *uop, unsigned int count) | ||
330 | { | ||
331 | mcl->op = __HYPERVISOR_grant_table_op; | ||
332 | mcl->args[0] = cmd; | ||
333 | mcl->args[1] = (unsigned long)uop; | ||
334 | mcl->args[2] = count; | ||
335 | } | ||
336 | |||
337 | static inline void | ||
338 | MULTI_update_va_mapping_otherdomain(struct multicall_entry *mcl, unsigned long va, | ||
339 | pte_t new_val, unsigned long flags, | ||
340 | domid_t domid) | ||
341 | { | ||
342 | mcl->op = __HYPERVISOR_update_va_mapping_otherdomain; | ||
343 | mcl->args[0] = va; | ||
344 | #ifdef CONFIG_X86_PAE | ||
345 | mcl->args[1] = new_val.pte_low; | ||
346 | mcl->args[2] = new_val.pte_high; | ||
347 | #else | ||
348 | mcl->args[1] = new_val.pte_low; | ||
349 | mcl->args[2] = 0; | ||
350 | #endif | ||
351 | mcl->args[3] = flags; | ||
352 | mcl->args[4] = domid; | ||
353 | } | ||
354 | |||
355 | static inline void | ||
356 | MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr, | ||
357 | struct desc_struct desc) | ||
358 | { | ||
359 | mcl->op = __HYPERVISOR_update_descriptor; | ||
360 | mcl->args[0] = maddr; | ||
361 | mcl->args[1] = maddr >> 32; | ||
362 | mcl->args[2] = desc.a; | ||
363 | mcl->args[3] = desc.b; | ||
364 | } | ||
365 | |||
366 | static inline void | ||
367 | MULTI_memory_op(struct multicall_entry *mcl, unsigned int cmd, void *arg) | ||
368 | { | ||
369 | mcl->op = __HYPERVISOR_memory_op; | ||
370 | mcl->args[0] = cmd; | ||
371 | mcl->args[1] = (unsigned long)arg; | ||
372 | } | ||
373 | |||
374 | static inline void | ||
375 | MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req, | ||
376 | int count, int *success_count, domid_t domid) | ||
377 | { | ||
378 | mcl->op = __HYPERVISOR_mmu_update; | ||
379 | mcl->args[0] = (unsigned long)req; | ||
380 | mcl->args[1] = count; | ||
381 | mcl->args[2] = (unsigned long)success_count; | ||
382 | mcl->args[3] = domid; | ||
383 | } | ||
384 | |||
385 | static inline void | ||
386 | MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, | ||
387 | int *success_count, domid_t domid) | ||
388 | { | ||
389 | mcl->op = __HYPERVISOR_mmuext_op; | ||
390 | mcl->args[0] = (unsigned long)op; | ||
391 | mcl->args[1] = count; | ||
392 | mcl->args[2] = (unsigned long)success_count; | ||
393 | mcl->args[3] = domid; | ||
394 | } | ||
395 | |||
396 | static inline void | ||
397 | MULTI_set_gdt(struct multicall_entry *mcl, unsigned long *frames, int entries) | ||
398 | { | ||
399 | mcl->op = __HYPERVISOR_set_gdt; | ||
400 | mcl->args[0] = (unsigned long)frames; | ||
401 | mcl->args[1] = entries; | ||
402 | } | ||
403 | |||
404 | static inline void | ||
405 | MULTI_stack_switch(struct multicall_entry *mcl, | ||
406 | unsigned long ss, unsigned long esp) | ||
407 | { | ||
408 | mcl->op = __HYPERVISOR_stack_switch; | ||
409 | mcl->args[0] = ss; | ||
410 | mcl->args[1] = esp; | ||
411 | } | ||
412 | |||
413 | #endif /* __HYPERCALL_H__ */ | ||
diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h new file mode 100644 index 000000000000..8e15dd28c91f --- /dev/null +++ b/include/asm-x86/xen/hypervisor.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /****************************************************************************** | ||
2 | * hypervisor.h | ||
3 | * | ||
4 | * Linux-specific hypervisor handling. | ||
5 | * | ||
6 | * Copyright (c) 2002-2004, K A Fraser | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License version 2 | ||
10 | * as published by the Free Software Foundation; or, when distributed | ||
11 | * separately from the Linux kernel or incorporated into other | ||
12 | * software packages, subject to the following license: | ||
13 | * | ||
14 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
15 | * of this source file (the "Software"), to deal in the Software without | ||
16 | * restriction, including without limitation the rights to use, copy, modify, | ||
17 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
18 | * and to permit persons to whom the Software is furnished to do so, subject to | ||
19 | * the following conditions: | ||
20 | * | ||
21 | * The above copyright notice and this permission notice shall be included in | ||
22 | * all copies or substantial portions of the Software. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
30 | * IN THE SOFTWARE. | ||
31 | */ | ||
32 | |||
33 | #ifndef __HYPERVISOR_H__ | ||
34 | #define __HYPERVISOR_H__ | ||
35 | |||
36 | #include <linux/types.h> | ||
37 | #include <linux/kernel.h> | ||
38 | #include <linux/version.h> | ||
39 | |||
40 | #include <xen/interface/xen.h> | ||
41 | #include <xen/interface/version.h> | ||
42 | |||
43 | #include <asm/ptrace.h> | ||
44 | #include <asm/page.h> | ||
45 | #include <asm/desc.h> | ||
46 | #if defined(__i386__) | ||
47 | # ifdef CONFIG_X86_PAE | ||
48 | # include <asm-generic/pgtable-nopud.h> | ||
49 | # else | ||
50 | # include <asm-generic/pgtable-nopmd.h> | ||
51 | # endif | ||
52 | #endif | ||
53 | #include <asm/xen/hypercall.h> | ||
54 | |||
55 | /* arch/i386/kernel/setup.c */ | ||
56 | extern struct shared_info *HYPERVISOR_shared_info; | ||
57 | extern struct start_info *xen_start_info; | ||
58 | #define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN) | ||
59 | |||
60 | /* arch/i386/mach-xen/evtchn.c */ | ||
61 | /* Force a proper event-channel callback from Xen. */ | ||
62 | extern void force_evtchn_callback(void); | ||
63 | |||
64 | /* Turn jiffies into Xen system time. */ | ||
65 | u64 jiffies_to_st(unsigned long jiffies); | ||
66 | |||
67 | |||
68 | #define MULTI_UVMFLAGS_INDEX 3 | ||
69 | #define MULTI_UVMDOMID_INDEX 4 | ||
70 | |||
71 | #define is_running_on_xen() (xen_start_info ? 1 : 0) | ||
72 | |||
73 | #endif /* __HYPERVISOR_H__ */ | ||
diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h new file mode 100644 index 000000000000..165c3968e138 --- /dev/null +++ b/include/asm-x86/xen/interface.h | |||
@@ -0,0 +1,188 @@ | |||
1 | /****************************************************************************** | ||
2 | * arch-x86_32.h | ||
3 | * | ||
4 | * Guest OS interface to x86 32-bit Xen. | ||
5 | * | ||
6 | * Copyright (c) 2004, K A Fraser | ||
7 | */ | ||
8 | |||
9 | #ifndef __XEN_PUBLIC_ARCH_X86_32_H__ | ||
10 | #define __XEN_PUBLIC_ARCH_X86_32_H__ | ||
11 | |||
12 | #ifdef __XEN__ | ||
13 | #define __DEFINE_GUEST_HANDLE(name, type) \ | ||
14 | typedef struct { type *p; } __guest_handle_ ## name | ||
15 | #else | ||
16 | #define __DEFINE_GUEST_HANDLE(name, type) \ | ||
17 | typedef type * __guest_handle_ ## name | ||
18 | #endif | ||
19 | |||
20 | #define DEFINE_GUEST_HANDLE_STRUCT(name) \ | ||
21 | __DEFINE_GUEST_HANDLE(name, struct name) | ||
22 | #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) | ||
23 | #define GUEST_HANDLE(name) __guest_handle_ ## name | ||
24 | |||
25 | #ifndef __ASSEMBLY__ | ||
26 | /* Guest handles for primitive C types. */ | ||
27 | __DEFINE_GUEST_HANDLE(uchar, unsigned char); | ||
28 | __DEFINE_GUEST_HANDLE(uint, unsigned int); | ||
29 | __DEFINE_GUEST_HANDLE(ulong, unsigned long); | ||
30 | DEFINE_GUEST_HANDLE(char); | ||
31 | DEFINE_GUEST_HANDLE(int); | ||
32 | DEFINE_GUEST_HANDLE(long); | ||
33 | DEFINE_GUEST_HANDLE(void); | ||
34 | #endif | ||
35 | |||
36 | /* | ||
37 | * SEGMENT DESCRIPTOR TABLES | ||
38 | */ | ||
39 | /* | ||
40 | * A number of GDT entries are reserved by Xen. These are not situated at the | ||
41 | * start of the GDT because some stupid OSes export hard-coded selector values | ||
42 | * in their ABI. These hard-coded values are always near the start of the GDT, | ||
43 | * so Xen places itself out of the way, at the far end of the GDT. | ||
44 | */ | ||
45 | #define FIRST_RESERVED_GDT_PAGE 14 | ||
46 | #define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096) | ||
47 | #define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8) | ||
48 | |||
49 | /* | ||
50 | * These flat segments are in the Xen-private section of every GDT. Since these | ||
51 | * are also present in the initial GDT, many OSes will be able to avoid | ||
52 | * installing their own GDT. | ||
53 | */ | ||
54 | #define FLAT_RING1_CS 0xe019 /* GDT index 259 */ | ||
55 | #define FLAT_RING1_DS 0xe021 /* GDT index 260 */ | ||
56 | #define FLAT_RING1_SS 0xe021 /* GDT index 260 */ | ||
57 | #define FLAT_RING3_CS 0xe02b /* GDT index 261 */ | ||
58 | #define FLAT_RING3_DS 0xe033 /* GDT index 262 */ | ||
59 | #define FLAT_RING3_SS 0xe033 /* GDT index 262 */ | ||
60 | |||
61 | #define FLAT_KERNEL_CS FLAT_RING1_CS | ||
62 | #define FLAT_KERNEL_DS FLAT_RING1_DS | ||
63 | #define FLAT_KERNEL_SS FLAT_RING1_SS | ||
64 | #define FLAT_USER_CS FLAT_RING3_CS | ||
65 | #define FLAT_USER_DS FLAT_RING3_DS | ||
66 | #define FLAT_USER_SS FLAT_RING3_SS | ||
67 | |||
68 | /* And the trap vector is... */ | ||
69 | #define TRAP_INSTR "int $0x82" | ||
70 | |||
71 | /* | ||
72 | * Virtual addresses beyond this are not modifiable by guest OSes. The | ||
73 | * machine->physical mapping table starts at this address, read-only. | ||
74 | */ | ||
75 | #ifdef CONFIG_X86_PAE | ||
76 | #define __HYPERVISOR_VIRT_START 0xF5800000 | ||
77 | #else | ||
78 | #define __HYPERVISOR_VIRT_START 0xFC000000 | ||
79 | #endif | ||
80 | |||
81 | #ifndef HYPERVISOR_VIRT_START | ||
82 | #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) | ||
83 | #endif | ||
84 | |||
85 | #ifndef machine_to_phys_mapping | ||
86 | #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) | ||
87 | #endif | ||
88 | |||
89 | /* Maximum number of virtual CPUs in multi-processor guests. */ | ||
90 | #define MAX_VIRT_CPUS 32 | ||
91 | |||
92 | #ifndef __ASSEMBLY__ | ||
93 | |||
94 | /* | ||
95 | * Send an array of these to HYPERVISOR_set_trap_table() | ||
96 | */ | ||
97 | #define TI_GET_DPL(_ti) ((_ti)->flags & 3) | ||
98 | #define TI_GET_IF(_ti) ((_ti)->flags & 4) | ||
99 | #define TI_SET_DPL(_ti, _dpl) ((_ti)->flags |= (_dpl)) | ||
100 | #define TI_SET_IF(_ti, _if) ((_ti)->flags |= ((!!(_if))<<2)) | ||
101 | |||
102 | struct trap_info { | ||
103 | uint8_t vector; /* exception vector */ | ||
104 | uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */ | ||
105 | uint16_t cs; /* code selector */ | ||
106 | unsigned long address; /* code offset */ | ||
107 | }; | ||
108 | DEFINE_GUEST_HANDLE_STRUCT(trap_info); | ||
109 | |||
110 | struct cpu_user_regs { | ||
111 | uint32_t ebx; | ||
112 | uint32_t ecx; | ||
113 | uint32_t edx; | ||
114 | uint32_t esi; | ||
115 | uint32_t edi; | ||
116 | uint32_t ebp; | ||
117 | uint32_t eax; | ||
118 | uint16_t error_code; /* private */ | ||
119 | uint16_t entry_vector; /* private */ | ||
120 | uint32_t eip; | ||
121 | uint16_t cs; | ||
122 | uint8_t saved_upcall_mask; | ||
123 | uint8_t _pad0; | ||
124 | uint32_t eflags; /* eflags.IF == !saved_upcall_mask */ | ||
125 | uint32_t esp; | ||
126 | uint16_t ss, _pad1; | ||
127 | uint16_t es, _pad2; | ||
128 | uint16_t ds, _pad3; | ||
129 | uint16_t fs, _pad4; | ||
130 | uint16_t gs, _pad5; | ||
131 | }; | ||
132 | DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs); | ||
133 | |||
134 | typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ | ||
135 | |||
136 | /* | ||
137 | * The following is all CPU context. Note that the fpu_ctxt block is filled | ||
138 | * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. | ||
139 | */ | ||
140 | struct vcpu_guest_context { | ||
141 | /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */ | ||
142 | struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */ | ||
143 | #define VGCF_I387_VALID (1<<0) | ||
144 | #define VGCF_HVM_GUEST (1<<1) | ||
145 | #define VGCF_IN_KERNEL (1<<2) | ||
146 | unsigned long flags; /* VGCF_* flags */ | ||
147 | struct cpu_user_regs user_regs; /* User-level CPU registers */ | ||
148 | struct trap_info trap_ctxt[256]; /* Virtual IDT */ | ||
149 | unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */ | ||
150 | unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */ | ||
151 | unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */ | ||
152 | unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */ | ||
153 | unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */ | ||
154 | unsigned long event_callback_cs; /* CS:EIP of event callback */ | ||
155 | unsigned long event_callback_eip; | ||
156 | unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ | ||
157 | unsigned long failsafe_callback_eip; | ||
158 | unsigned long vm_assist; /* VMASST_TYPE_* bitmap */ | ||
159 | }; | ||
160 | DEFINE_GUEST_HANDLE_STRUCT(vcpu_guest_context); | ||
161 | |||
162 | struct arch_shared_info { | ||
163 | unsigned long max_pfn; /* max pfn that appears in table */ | ||
164 | /* Frame containing list of mfns containing list of mfns containing p2m. */ | ||
165 | unsigned long pfn_to_mfn_frame_list_list; | ||
166 | unsigned long nmi_reason; | ||
167 | }; | ||
168 | |||
169 | struct arch_vcpu_info { | ||
170 | unsigned long cr2; | ||
171 | unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */ | ||
172 | }; | ||
173 | |||
174 | #endif /* !__ASSEMBLY__ */ | ||
175 | |||
176 | /* | ||
177 | * Prefix forces emulation of some non-trapping instructions. | ||
178 | * Currently only CPUID. | ||
179 | */ | ||
180 | #ifdef __ASSEMBLY__ | ||
181 | #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; | ||
182 | #define XEN_CPUID XEN_EMULATE_PREFIX cpuid | ||
183 | #else | ||
184 | #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " | ||
185 | #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" | ||
186 | #endif | ||
187 | |||
188 | #endif | ||
diff --git a/include/asm-x86/xor.h b/include/asm-x86/xor.h new file mode 100644 index 000000000000..11b3bb86e17b --- /dev/null +++ b/include/asm-x86/xor.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #ifdef CONFIG_X86_32 | ||
2 | # include "xor_32.h" | ||
3 | #else | ||
4 | # include "xor_64.h" | ||
5 | #endif | ||
diff --git a/include/asm-x86/xor_32.h b/include/asm-x86/xor_32.h new file mode 100644 index 000000000000..23c86cef3b25 --- /dev/null +++ b/include/asm-x86/xor_32.h | |||
@@ -0,0 +1,883 @@ | |||
1 | /* | ||
2 | * include/asm-i386/xor.h | ||
3 | * | ||
4 | * Optimized RAID-5 checksumming functions for MMX and SSE. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * (for example /usr/src/linux/COPYING); if not, write to the Free | ||
13 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | * High-speed RAID5 checksumming functions utilizing MMX instructions. | ||
18 | * Copyright (C) 1998 Ingo Molnar. | ||
19 | */ | ||
20 | |||
21 | #define LD(x,y) " movq 8*("#x")(%1), %%mm"#y" ;\n" | ||
22 | #define ST(x,y) " movq %%mm"#y", 8*("#x")(%1) ;\n" | ||
23 | #define XO1(x,y) " pxor 8*("#x")(%2), %%mm"#y" ;\n" | ||
24 | #define XO2(x,y) " pxor 8*("#x")(%3), %%mm"#y" ;\n" | ||
25 | #define XO3(x,y) " pxor 8*("#x")(%4), %%mm"#y" ;\n" | ||
26 | #define XO4(x,y) " pxor 8*("#x")(%5), %%mm"#y" ;\n" | ||
27 | |||
28 | #include <asm/i387.h> | ||
29 | |||
30 | static void | ||
31 | xor_pII_mmx_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) | ||
32 | { | ||
33 | unsigned long lines = bytes >> 7; | ||
34 | |||
35 | kernel_fpu_begin(); | ||
36 | |||
37 | __asm__ __volatile__ ( | ||
38 | #undef BLOCK | ||
39 | #define BLOCK(i) \ | ||
40 | LD(i,0) \ | ||
41 | LD(i+1,1) \ | ||
42 | LD(i+2,2) \ | ||
43 | LD(i+3,3) \ | ||
44 | XO1(i,0) \ | ||
45 | ST(i,0) \ | ||
46 | XO1(i+1,1) \ | ||
47 | ST(i+1,1) \ | ||
48 | XO1(i+2,2) \ | ||
49 | ST(i+2,2) \ | ||
50 | XO1(i+3,3) \ | ||
51 | ST(i+3,3) | ||
52 | |||
53 | " .align 32 ;\n" | ||
54 | " 1: ;\n" | ||
55 | |||
56 | BLOCK(0) | ||
57 | BLOCK(4) | ||
58 | BLOCK(8) | ||
59 | BLOCK(12) | ||
60 | |||
61 | " addl $128, %1 ;\n" | ||
62 | " addl $128, %2 ;\n" | ||
63 | " decl %0 ;\n" | ||
64 | " jnz 1b ;\n" | ||
65 | : "+r" (lines), | ||
66 | "+r" (p1), "+r" (p2) | ||
67 | : | ||
68 | : "memory"); | ||
69 | |||
70 | kernel_fpu_end(); | ||
71 | } | ||
72 | |||
73 | static void | ||
74 | xor_pII_mmx_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
75 | unsigned long *p3) | ||
76 | { | ||
77 | unsigned long lines = bytes >> 7; | ||
78 | |||
79 | kernel_fpu_begin(); | ||
80 | |||
81 | __asm__ __volatile__ ( | ||
82 | #undef BLOCK | ||
83 | #define BLOCK(i) \ | ||
84 | LD(i,0) \ | ||
85 | LD(i+1,1) \ | ||
86 | LD(i+2,2) \ | ||
87 | LD(i+3,3) \ | ||
88 | XO1(i,0) \ | ||
89 | XO1(i+1,1) \ | ||
90 | XO1(i+2,2) \ | ||
91 | XO1(i+3,3) \ | ||
92 | XO2(i,0) \ | ||
93 | ST(i,0) \ | ||
94 | XO2(i+1,1) \ | ||
95 | ST(i+1,1) \ | ||
96 | XO2(i+2,2) \ | ||
97 | ST(i+2,2) \ | ||
98 | XO2(i+3,3) \ | ||
99 | ST(i+3,3) | ||
100 | |||
101 | " .align 32 ;\n" | ||
102 | " 1: ;\n" | ||
103 | |||
104 | BLOCK(0) | ||
105 | BLOCK(4) | ||
106 | BLOCK(8) | ||
107 | BLOCK(12) | ||
108 | |||
109 | " addl $128, %1 ;\n" | ||
110 | " addl $128, %2 ;\n" | ||
111 | " addl $128, %3 ;\n" | ||
112 | " decl %0 ;\n" | ||
113 | " jnz 1b ;\n" | ||
114 | : "+r" (lines), | ||
115 | "+r" (p1), "+r" (p2), "+r" (p3) | ||
116 | : | ||
117 | : "memory"); | ||
118 | |||
119 | kernel_fpu_end(); | ||
120 | } | ||
121 | |||
122 | static void | ||
123 | xor_pII_mmx_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
124 | unsigned long *p3, unsigned long *p4) | ||
125 | { | ||
126 | unsigned long lines = bytes >> 7; | ||
127 | |||
128 | kernel_fpu_begin(); | ||
129 | |||
130 | __asm__ __volatile__ ( | ||
131 | #undef BLOCK | ||
132 | #define BLOCK(i) \ | ||
133 | LD(i,0) \ | ||
134 | LD(i+1,1) \ | ||
135 | LD(i+2,2) \ | ||
136 | LD(i+3,3) \ | ||
137 | XO1(i,0) \ | ||
138 | XO1(i+1,1) \ | ||
139 | XO1(i+2,2) \ | ||
140 | XO1(i+3,3) \ | ||
141 | XO2(i,0) \ | ||
142 | XO2(i+1,1) \ | ||
143 | XO2(i+2,2) \ | ||
144 | XO2(i+3,3) \ | ||
145 | XO3(i,0) \ | ||
146 | ST(i,0) \ | ||
147 | XO3(i+1,1) \ | ||
148 | ST(i+1,1) \ | ||
149 | XO3(i+2,2) \ | ||
150 | ST(i+2,2) \ | ||
151 | XO3(i+3,3) \ | ||
152 | ST(i+3,3) | ||
153 | |||
154 | " .align 32 ;\n" | ||
155 | " 1: ;\n" | ||
156 | |||
157 | BLOCK(0) | ||
158 | BLOCK(4) | ||
159 | BLOCK(8) | ||
160 | BLOCK(12) | ||
161 | |||
162 | " addl $128, %1 ;\n" | ||
163 | " addl $128, %2 ;\n" | ||
164 | " addl $128, %3 ;\n" | ||
165 | " addl $128, %4 ;\n" | ||
166 | " decl %0 ;\n" | ||
167 | " jnz 1b ;\n" | ||
168 | : "+r" (lines), | ||
169 | "+r" (p1), "+r" (p2), "+r" (p3), "+r" (p4) | ||
170 | : | ||
171 | : "memory"); | ||
172 | |||
173 | kernel_fpu_end(); | ||
174 | } | ||
175 | |||
176 | |||
177 | static void | ||
178 | xor_pII_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
179 | unsigned long *p3, unsigned long *p4, unsigned long *p5) | ||
180 | { | ||
181 | unsigned long lines = bytes >> 7; | ||
182 | |||
183 | kernel_fpu_begin(); | ||
184 | |||
185 | /* Make sure GCC forgets anything it knows about p4 or p5, | ||
186 | such that it won't pass to the asm volatile below a | ||
187 | register that is shared with any other variable. That's | ||
188 | because we modify p4 and p5 there, but we can't mark them | ||
189 | as read/write, otherwise we'd overflow the 10-asm-operands | ||
190 | limit of GCC < 3.1. */ | ||
191 | __asm__ ("" : "+r" (p4), "+r" (p5)); | ||
192 | |||
193 | __asm__ __volatile__ ( | ||
194 | #undef BLOCK | ||
195 | #define BLOCK(i) \ | ||
196 | LD(i,0) \ | ||
197 | LD(i+1,1) \ | ||
198 | LD(i+2,2) \ | ||
199 | LD(i+3,3) \ | ||
200 | XO1(i,0) \ | ||
201 | XO1(i+1,1) \ | ||
202 | XO1(i+2,2) \ | ||
203 | XO1(i+3,3) \ | ||
204 | XO2(i,0) \ | ||
205 | XO2(i+1,1) \ | ||
206 | XO2(i+2,2) \ | ||
207 | XO2(i+3,3) \ | ||
208 | XO3(i,0) \ | ||
209 | XO3(i+1,1) \ | ||
210 | XO3(i+2,2) \ | ||
211 | XO3(i+3,3) \ | ||
212 | XO4(i,0) \ | ||
213 | ST(i,0) \ | ||
214 | XO4(i+1,1) \ | ||
215 | ST(i+1,1) \ | ||
216 | XO4(i+2,2) \ | ||
217 | ST(i+2,2) \ | ||
218 | XO4(i+3,3) \ | ||
219 | ST(i+3,3) | ||
220 | |||
221 | " .align 32 ;\n" | ||
222 | " 1: ;\n" | ||
223 | |||
224 | BLOCK(0) | ||
225 | BLOCK(4) | ||
226 | BLOCK(8) | ||
227 | BLOCK(12) | ||
228 | |||
229 | " addl $128, %1 ;\n" | ||
230 | " addl $128, %2 ;\n" | ||
231 | " addl $128, %3 ;\n" | ||
232 | " addl $128, %4 ;\n" | ||
233 | " addl $128, %5 ;\n" | ||
234 | " decl %0 ;\n" | ||
235 | " jnz 1b ;\n" | ||
236 | : "+r" (lines), | ||
237 | "+r" (p1), "+r" (p2), "+r" (p3) | ||
238 | : "r" (p4), "r" (p5) | ||
239 | : "memory"); | ||
240 | |||
241 | /* p4 and p5 were modified, and now the variables are dead. | ||
242 | Clobber them just to be sure nobody does something stupid | ||
243 | like assuming they have some legal value. */ | ||
244 | __asm__ ("" : "=r" (p4), "=r" (p5)); | ||
245 | |||
246 | kernel_fpu_end(); | ||
247 | } | ||
248 | |||
249 | #undef LD | ||
250 | #undef XO1 | ||
251 | #undef XO2 | ||
252 | #undef XO3 | ||
253 | #undef XO4 | ||
254 | #undef ST | ||
255 | #undef BLOCK | ||
256 | |||
257 | static void | ||
258 | xor_p5_mmx_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) | ||
259 | { | ||
260 | unsigned long lines = bytes >> 6; | ||
261 | |||
262 | kernel_fpu_begin(); | ||
263 | |||
264 | __asm__ __volatile__ ( | ||
265 | " .align 32 ;\n" | ||
266 | " 1: ;\n" | ||
267 | " movq (%1), %%mm0 ;\n" | ||
268 | " movq 8(%1), %%mm1 ;\n" | ||
269 | " pxor (%2), %%mm0 ;\n" | ||
270 | " movq 16(%1), %%mm2 ;\n" | ||
271 | " movq %%mm0, (%1) ;\n" | ||
272 | " pxor 8(%2), %%mm1 ;\n" | ||
273 | " movq 24(%1), %%mm3 ;\n" | ||
274 | " movq %%mm1, 8(%1) ;\n" | ||
275 | " pxor 16(%2), %%mm2 ;\n" | ||
276 | " movq 32(%1), %%mm4 ;\n" | ||
277 | " movq %%mm2, 16(%1) ;\n" | ||
278 | " pxor 24(%2), %%mm3 ;\n" | ||
279 | " movq 40(%1), %%mm5 ;\n" | ||
280 | " movq %%mm3, 24(%1) ;\n" | ||
281 | " pxor 32(%2), %%mm4 ;\n" | ||
282 | " movq 48(%1), %%mm6 ;\n" | ||
283 | " movq %%mm4, 32(%1) ;\n" | ||
284 | " pxor 40(%2), %%mm5 ;\n" | ||
285 | " movq 56(%1), %%mm7 ;\n" | ||
286 | " movq %%mm5, 40(%1) ;\n" | ||
287 | " pxor 48(%2), %%mm6 ;\n" | ||
288 | " pxor 56(%2), %%mm7 ;\n" | ||
289 | " movq %%mm6, 48(%1) ;\n" | ||
290 | " movq %%mm7, 56(%1) ;\n" | ||
291 | |||
292 | " addl $64, %1 ;\n" | ||
293 | " addl $64, %2 ;\n" | ||
294 | " decl %0 ;\n" | ||
295 | " jnz 1b ;\n" | ||
296 | : "+r" (lines), | ||
297 | "+r" (p1), "+r" (p2) | ||
298 | : | ||
299 | : "memory"); | ||
300 | |||
301 | kernel_fpu_end(); | ||
302 | } | ||
303 | |||
304 | static void | ||
305 | xor_p5_mmx_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
306 | unsigned long *p3) | ||
307 | { | ||
308 | unsigned long lines = bytes >> 6; | ||
309 | |||
310 | kernel_fpu_begin(); | ||
311 | |||
312 | __asm__ __volatile__ ( | ||
313 | " .align 32,0x90 ;\n" | ||
314 | " 1: ;\n" | ||
315 | " movq (%1), %%mm0 ;\n" | ||
316 | " movq 8(%1), %%mm1 ;\n" | ||
317 | " pxor (%2), %%mm0 ;\n" | ||
318 | " movq 16(%1), %%mm2 ;\n" | ||
319 | " pxor 8(%2), %%mm1 ;\n" | ||
320 | " pxor (%3), %%mm0 ;\n" | ||
321 | " pxor 16(%2), %%mm2 ;\n" | ||
322 | " movq %%mm0, (%1) ;\n" | ||
323 | " pxor 8(%3), %%mm1 ;\n" | ||
324 | " pxor 16(%3), %%mm2 ;\n" | ||
325 | " movq 24(%1), %%mm3 ;\n" | ||
326 | " movq %%mm1, 8(%1) ;\n" | ||
327 | " movq 32(%1), %%mm4 ;\n" | ||
328 | " movq 40(%1), %%mm5 ;\n" | ||
329 | " pxor 24(%2), %%mm3 ;\n" | ||
330 | " movq %%mm2, 16(%1) ;\n" | ||
331 | " pxor 32(%2), %%mm4 ;\n" | ||
332 | " pxor 24(%3), %%mm3 ;\n" | ||
333 | " pxor 40(%2), %%mm5 ;\n" | ||
334 | " movq %%mm3, 24(%1) ;\n" | ||
335 | " pxor 32(%3), %%mm4 ;\n" | ||
336 | " pxor 40(%3), %%mm5 ;\n" | ||
337 | " movq 48(%1), %%mm6 ;\n" | ||
338 | " movq %%mm4, 32(%1) ;\n" | ||
339 | " movq 56(%1), %%mm7 ;\n" | ||
340 | " pxor 48(%2), %%mm6 ;\n" | ||
341 | " movq %%mm5, 40(%1) ;\n" | ||
342 | " pxor 56(%2), %%mm7 ;\n" | ||
343 | " pxor 48(%3), %%mm6 ;\n" | ||
344 | " pxor 56(%3), %%mm7 ;\n" | ||
345 | " movq %%mm6, 48(%1) ;\n" | ||
346 | " movq %%mm7, 56(%1) ;\n" | ||
347 | |||
348 | " addl $64, %1 ;\n" | ||
349 | " addl $64, %2 ;\n" | ||
350 | " addl $64, %3 ;\n" | ||
351 | " decl %0 ;\n" | ||
352 | " jnz 1b ;\n" | ||
353 | : "+r" (lines), | ||
354 | "+r" (p1), "+r" (p2), "+r" (p3) | ||
355 | : | ||
356 | : "memory" ); | ||
357 | |||
358 | kernel_fpu_end(); | ||
359 | } | ||
360 | |||
361 | static void | ||
362 | xor_p5_mmx_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
363 | unsigned long *p3, unsigned long *p4) | ||
364 | { | ||
365 | unsigned long lines = bytes >> 6; | ||
366 | |||
367 | kernel_fpu_begin(); | ||
368 | |||
369 | __asm__ __volatile__ ( | ||
370 | " .align 32,0x90 ;\n" | ||
371 | " 1: ;\n" | ||
372 | " movq (%1), %%mm0 ;\n" | ||
373 | " movq 8(%1), %%mm1 ;\n" | ||
374 | " pxor (%2), %%mm0 ;\n" | ||
375 | " movq 16(%1), %%mm2 ;\n" | ||
376 | " pxor 8(%2), %%mm1 ;\n" | ||
377 | " pxor (%3), %%mm0 ;\n" | ||
378 | " pxor 16(%2), %%mm2 ;\n" | ||
379 | " pxor 8(%3), %%mm1 ;\n" | ||
380 | " pxor (%4), %%mm0 ;\n" | ||
381 | " movq 24(%1), %%mm3 ;\n" | ||
382 | " pxor 16(%3), %%mm2 ;\n" | ||
383 | " pxor 8(%4), %%mm1 ;\n" | ||
384 | " movq %%mm0, (%1) ;\n" | ||
385 | " movq 32(%1), %%mm4 ;\n" | ||
386 | " pxor 24(%2), %%mm3 ;\n" | ||
387 | " pxor 16(%4), %%mm2 ;\n" | ||
388 | " movq %%mm1, 8(%1) ;\n" | ||
389 | " movq 40(%1), %%mm5 ;\n" | ||
390 | " pxor 32(%2), %%mm4 ;\n" | ||
391 | " pxor 24(%3), %%mm3 ;\n" | ||
392 | " movq %%mm2, 16(%1) ;\n" | ||
393 | " pxor 40(%2), %%mm5 ;\n" | ||
394 | " pxor 32(%3), %%mm4 ;\n" | ||
395 | " pxor 24(%4), %%mm3 ;\n" | ||
396 | " movq %%mm3, 24(%1) ;\n" | ||
397 | " movq 56(%1), %%mm7 ;\n" | ||
398 | " movq 48(%1), %%mm6 ;\n" | ||
399 | " pxor 40(%3), %%mm5 ;\n" | ||
400 | " pxor 32(%4), %%mm4 ;\n" | ||
401 | " pxor 48(%2), %%mm6 ;\n" | ||
402 | " movq %%mm4, 32(%1) ;\n" | ||
403 | " pxor 56(%2), %%mm7 ;\n" | ||
404 | " pxor 40(%4), %%mm5 ;\n" | ||
405 | " pxor 48(%3), %%mm6 ;\n" | ||
406 | " pxor 56(%3), %%mm7 ;\n" | ||
407 | " movq %%mm5, 40(%1) ;\n" | ||
408 | " pxor 48(%4), %%mm6 ;\n" | ||
409 | " pxor 56(%4), %%mm7 ;\n" | ||
410 | " movq %%mm6, 48(%1) ;\n" | ||
411 | " movq %%mm7, 56(%1) ;\n" | ||
412 | |||
413 | " addl $64, %1 ;\n" | ||
414 | " addl $64, %2 ;\n" | ||
415 | " addl $64, %3 ;\n" | ||
416 | " addl $64, %4 ;\n" | ||
417 | " decl %0 ;\n" | ||
418 | " jnz 1b ;\n" | ||
419 | : "+r" (lines), | ||
420 | "+r" (p1), "+r" (p2), "+r" (p3), "+r" (p4) | ||
421 | : | ||
422 | : "memory"); | ||
423 | |||
424 | kernel_fpu_end(); | ||
425 | } | ||
426 | |||
427 | static void | ||
428 | xor_p5_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
429 | unsigned long *p3, unsigned long *p4, unsigned long *p5) | ||
430 | { | ||
431 | unsigned long lines = bytes >> 6; | ||
432 | |||
433 | kernel_fpu_begin(); | ||
434 | |||
435 | /* Make sure GCC forgets anything it knows about p4 or p5, | ||
436 | such that it won't pass to the asm volatile below a | ||
437 | register that is shared with any other variable. That's | ||
438 | because we modify p4 and p5 there, but we can't mark them | ||
439 | as read/write, otherwise we'd overflow the 10-asm-operands | ||
440 | limit of GCC < 3.1. */ | ||
441 | __asm__ ("" : "+r" (p4), "+r" (p5)); | ||
442 | |||
443 | __asm__ __volatile__ ( | ||
444 | " .align 32,0x90 ;\n" | ||
445 | " 1: ;\n" | ||
446 | " movq (%1), %%mm0 ;\n" | ||
447 | " movq 8(%1), %%mm1 ;\n" | ||
448 | " pxor (%2), %%mm0 ;\n" | ||
449 | " pxor 8(%2), %%mm1 ;\n" | ||
450 | " movq 16(%1), %%mm2 ;\n" | ||
451 | " pxor (%3), %%mm0 ;\n" | ||
452 | " pxor 8(%3), %%mm1 ;\n" | ||
453 | " pxor 16(%2), %%mm2 ;\n" | ||
454 | " pxor (%4), %%mm0 ;\n" | ||
455 | " pxor 8(%4), %%mm1 ;\n" | ||
456 | " pxor 16(%3), %%mm2 ;\n" | ||
457 | " movq 24(%1), %%mm3 ;\n" | ||
458 | " pxor (%5), %%mm0 ;\n" | ||
459 | " pxor 8(%5), %%mm1 ;\n" | ||
460 | " movq %%mm0, (%1) ;\n" | ||
461 | " pxor 16(%4), %%mm2 ;\n" | ||
462 | " pxor 24(%2), %%mm3 ;\n" | ||
463 | " movq %%mm1, 8(%1) ;\n" | ||
464 | " pxor 16(%5), %%mm2 ;\n" | ||
465 | " pxor 24(%3), %%mm3 ;\n" | ||
466 | " movq 32(%1), %%mm4 ;\n" | ||
467 | " movq %%mm2, 16(%1) ;\n" | ||
468 | " pxor 24(%4), %%mm3 ;\n" | ||
469 | " pxor 32(%2), %%mm4 ;\n" | ||
470 | " movq 40(%1), %%mm5 ;\n" | ||
471 | " pxor 24(%5), %%mm3 ;\n" | ||
472 | " pxor 32(%3), %%mm4 ;\n" | ||
473 | " pxor 40(%2), %%mm5 ;\n" | ||
474 | " movq %%mm3, 24(%1) ;\n" | ||
475 | " pxor 32(%4), %%mm4 ;\n" | ||
476 | " pxor 40(%3), %%mm5 ;\n" | ||
477 | " movq 48(%1), %%mm6 ;\n" | ||
478 | " movq 56(%1), %%mm7 ;\n" | ||
479 | " pxor 32(%5), %%mm4 ;\n" | ||
480 | " pxor 40(%4), %%mm5 ;\n" | ||
481 | " pxor 48(%2), %%mm6 ;\n" | ||
482 | " pxor 56(%2), %%mm7 ;\n" | ||
483 | " movq %%mm4, 32(%1) ;\n" | ||
484 | " pxor 48(%3), %%mm6 ;\n" | ||
485 | " pxor 56(%3), %%mm7 ;\n" | ||
486 | " pxor 40(%5), %%mm5 ;\n" | ||
487 | " pxor 48(%4), %%mm6 ;\n" | ||
488 | " pxor 56(%4), %%mm7 ;\n" | ||
489 | " movq %%mm5, 40(%1) ;\n" | ||
490 | " pxor 48(%5), %%mm6 ;\n" | ||
491 | " pxor 56(%5), %%mm7 ;\n" | ||
492 | " movq %%mm6, 48(%1) ;\n" | ||
493 | " movq %%mm7, 56(%1) ;\n" | ||
494 | |||
495 | " addl $64, %1 ;\n" | ||
496 | " addl $64, %2 ;\n" | ||
497 | " addl $64, %3 ;\n" | ||
498 | " addl $64, %4 ;\n" | ||
499 | " addl $64, %5 ;\n" | ||
500 | " decl %0 ;\n" | ||
501 | " jnz 1b ;\n" | ||
502 | : "+r" (lines), | ||
503 | "+r" (p1), "+r" (p2), "+r" (p3) | ||
504 | : "r" (p4), "r" (p5) | ||
505 | : "memory"); | ||
506 | |||
507 | /* p4 and p5 were modified, and now the variables are dead. | ||
508 | Clobber them just to be sure nobody does something stupid | ||
509 | like assuming they have some legal value. */ | ||
510 | __asm__ ("" : "=r" (p4), "=r" (p5)); | ||
511 | |||
512 | kernel_fpu_end(); | ||
513 | } | ||
514 | |||
515 | static struct xor_block_template xor_block_pII_mmx = { | ||
516 | .name = "pII_mmx", | ||
517 | .do_2 = xor_pII_mmx_2, | ||
518 | .do_3 = xor_pII_mmx_3, | ||
519 | .do_4 = xor_pII_mmx_4, | ||
520 | .do_5 = xor_pII_mmx_5, | ||
521 | }; | ||
522 | |||
523 | static struct xor_block_template xor_block_p5_mmx = { | ||
524 | .name = "p5_mmx", | ||
525 | .do_2 = xor_p5_mmx_2, | ||
526 | .do_3 = xor_p5_mmx_3, | ||
527 | .do_4 = xor_p5_mmx_4, | ||
528 | .do_5 = xor_p5_mmx_5, | ||
529 | }; | ||
530 | |||
531 | /* | ||
532 | * Cache avoiding checksumming functions utilizing KNI instructions | ||
533 | * Copyright (C) 1999 Zach Brown (with obvious credit due Ingo) | ||
534 | */ | ||
535 | |||
536 | #define XMMS_SAVE do { \ | ||
537 | preempt_disable(); \ | ||
538 | cr0 = read_cr0(); \ | ||
539 | clts(); \ | ||
540 | __asm__ __volatile__ ( \ | ||
541 | "movups %%xmm0,(%0) ;\n\t" \ | ||
542 | "movups %%xmm1,0x10(%0) ;\n\t" \ | ||
543 | "movups %%xmm2,0x20(%0) ;\n\t" \ | ||
544 | "movups %%xmm3,0x30(%0) ;\n\t" \ | ||
545 | : \ | ||
546 | : "r" (xmm_save) \ | ||
547 | : "memory"); \ | ||
548 | } while(0) | ||
549 | |||
550 | #define XMMS_RESTORE do { \ | ||
551 | __asm__ __volatile__ ( \ | ||
552 | "sfence ;\n\t" \ | ||
553 | "movups (%0),%%xmm0 ;\n\t" \ | ||
554 | "movups 0x10(%0),%%xmm1 ;\n\t" \ | ||
555 | "movups 0x20(%0),%%xmm2 ;\n\t" \ | ||
556 | "movups 0x30(%0),%%xmm3 ;\n\t" \ | ||
557 | : \ | ||
558 | : "r" (xmm_save) \ | ||
559 | : "memory"); \ | ||
560 | write_cr0(cr0); \ | ||
561 | preempt_enable(); \ | ||
562 | } while(0) | ||
563 | |||
564 | #define ALIGN16 __attribute__((aligned(16))) | ||
565 | |||
566 | #define OFFS(x) "16*("#x")" | ||
567 | #define PF_OFFS(x) "256+16*("#x")" | ||
568 | #define PF0(x) " prefetchnta "PF_OFFS(x)"(%1) ;\n" | ||
569 | #define LD(x,y) " movaps "OFFS(x)"(%1), %%xmm"#y" ;\n" | ||
570 | #define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%1) ;\n" | ||
571 | #define PF1(x) " prefetchnta "PF_OFFS(x)"(%2) ;\n" | ||
572 | #define PF2(x) " prefetchnta "PF_OFFS(x)"(%3) ;\n" | ||
573 | #define PF3(x) " prefetchnta "PF_OFFS(x)"(%4) ;\n" | ||
574 | #define PF4(x) " prefetchnta "PF_OFFS(x)"(%5) ;\n" | ||
575 | #define PF5(x) " prefetchnta "PF_OFFS(x)"(%6) ;\n" | ||
576 | #define XO1(x,y) " xorps "OFFS(x)"(%2), %%xmm"#y" ;\n" | ||
577 | #define XO2(x,y) " xorps "OFFS(x)"(%3), %%xmm"#y" ;\n" | ||
578 | #define XO3(x,y) " xorps "OFFS(x)"(%4), %%xmm"#y" ;\n" | ||
579 | #define XO4(x,y) " xorps "OFFS(x)"(%5), %%xmm"#y" ;\n" | ||
580 | #define XO5(x,y) " xorps "OFFS(x)"(%6), %%xmm"#y" ;\n" | ||
581 | |||
582 | |||
583 | static void | ||
584 | xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) | ||
585 | { | ||
586 | unsigned long lines = bytes >> 8; | ||
587 | char xmm_save[16*4] ALIGN16; | ||
588 | int cr0; | ||
589 | |||
590 | XMMS_SAVE; | ||
591 | |||
592 | __asm__ __volatile__ ( | ||
593 | #undef BLOCK | ||
594 | #define BLOCK(i) \ | ||
595 | LD(i,0) \ | ||
596 | LD(i+1,1) \ | ||
597 | PF1(i) \ | ||
598 | PF1(i+2) \ | ||
599 | LD(i+2,2) \ | ||
600 | LD(i+3,3) \ | ||
601 | PF0(i+4) \ | ||
602 | PF0(i+6) \ | ||
603 | XO1(i,0) \ | ||
604 | XO1(i+1,1) \ | ||
605 | XO1(i+2,2) \ | ||
606 | XO1(i+3,3) \ | ||
607 | ST(i,0) \ | ||
608 | ST(i+1,1) \ | ||
609 | ST(i+2,2) \ | ||
610 | ST(i+3,3) \ | ||
611 | |||
612 | |||
613 | PF0(0) | ||
614 | PF0(2) | ||
615 | |||
616 | " .align 32 ;\n" | ||
617 | " 1: ;\n" | ||
618 | |||
619 | BLOCK(0) | ||
620 | BLOCK(4) | ||
621 | BLOCK(8) | ||
622 | BLOCK(12) | ||
623 | |||
624 | " addl $256, %1 ;\n" | ||
625 | " addl $256, %2 ;\n" | ||
626 | " decl %0 ;\n" | ||
627 | " jnz 1b ;\n" | ||
628 | : "+r" (lines), | ||
629 | "+r" (p1), "+r" (p2) | ||
630 | : | ||
631 | : "memory"); | ||
632 | |||
633 | XMMS_RESTORE; | ||
634 | } | ||
635 | |||
636 | static void | ||
637 | xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
638 | unsigned long *p3) | ||
639 | { | ||
640 | unsigned long lines = bytes >> 8; | ||
641 | char xmm_save[16*4] ALIGN16; | ||
642 | int cr0; | ||
643 | |||
644 | XMMS_SAVE; | ||
645 | |||
646 | __asm__ __volatile__ ( | ||
647 | #undef BLOCK | ||
648 | #define BLOCK(i) \ | ||
649 | PF1(i) \ | ||
650 | PF1(i+2) \ | ||
651 | LD(i,0) \ | ||
652 | LD(i+1,1) \ | ||
653 | LD(i+2,2) \ | ||
654 | LD(i+3,3) \ | ||
655 | PF2(i) \ | ||
656 | PF2(i+2) \ | ||
657 | PF0(i+4) \ | ||
658 | PF0(i+6) \ | ||
659 | XO1(i,0) \ | ||
660 | XO1(i+1,1) \ | ||
661 | XO1(i+2,2) \ | ||
662 | XO1(i+3,3) \ | ||
663 | XO2(i,0) \ | ||
664 | XO2(i+1,1) \ | ||
665 | XO2(i+2,2) \ | ||
666 | XO2(i+3,3) \ | ||
667 | ST(i,0) \ | ||
668 | ST(i+1,1) \ | ||
669 | ST(i+2,2) \ | ||
670 | ST(i+3,3) \ | ||
671 | |||
672 | |||
673 | PF0(0) | ||
674 | PF0(2) | ||
675 | |||
676 | " .align 32 ;\n" | ||
677 | " 1: ;\n" | ||
678 | |||
679 | BLOCK(0) | ||
680 | BLOCK(4) | ||
681 | BLOCK(8) | ||
682 | BLOCK(12) | ||
683 | |||
684 | " addl $256, %1 ;\n" | ||
685 | " addl $256, %2 ;\n" | ||
686 | " addl $256, %3 ;\n" | ||
687 | " decl %0 ;\n" | ||
688 | " jnz 1b ;\n" | ||
689 | : "+r" (lines), | ||
690 | "+r" (p1), "+r"(p2), "+r"(p3) | ||
691 | : | ||
692 | : "memory" ); | ||
693 | |||
694 | XMMS_RESTORE; | ||
695 | } | ||
696 | |||
697 | static void | ||
698 | xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
699 | unsigned long *p3, unsigned long *p4) | ||
700 | { | ||
701 | unsigned long lines = bytes >> 8; | ||
702 | char xmm_save[16*4] ALIGN16; | ||
703 | int cr0; | ||
704 | |||
705 | XMMS_SAVE; | ||
706 | |||
707 | __asm__ __volatile__ ( | ||
708 | #undef BLOCK | ||
709 | #define BLOCK(i) \ | ||
710 | PF1(i) \ | ||
711 | PF1(i+2) \ | ||
712 | LD(i,0) \ | ||
713 | LD(i+1,1) \ | ||
714 | LD(i+2,2) \ | ||
715 | LD(i+3,3) \ | ||
716 | PF2(i) \ | ||
717 | PF2(i+2) \ | ||
718 | XO1(i,0) \ | ||
719 | XO1(i+1,1) \ | ||
720 | XO1(i+2,2) \ | ||
721 | XO1(i+3,3) \ | ||
722 | PF3(i) \ | ||
723 | PF3(i+2) \ | ||
724 | PF0(i+4) \ | ||
725 | PF0(i+6) \ | ||
726 | XO2(i,0) \ | ||
727 | XO2(i+1,1) \ | ||
728 | XO2(i+2,2) \ | ||
729 | XO2(i+3,3) \ | ||
730 | XO3(i,0) \ | ||
731 | XO3(i+1,1) \ | ||
732 | XO3(i+2,2) \ | ||
733 | XO3(i+3,3) \ | ||
734 | ST(i,0) \ | ||
735 | ST(i+1,1) \ | ||
736 | ST(i+2,2) \ | ||
737 | ST(i+3,3) \ | ||
738 | |||
739 | |||
740 | PF0(0) | ||
741 | PF0(2) | ||
742 | |||
743 | " .align 32 ;\n" | ||
744 | " 1: ;\n" | ||
745 | |||
746 | BLOCK(0) | ||
747 | BLOCK(4) | ||
748 | BLOCK(8) | ||
749 | BLOCK(12) | ||
750 | |||
751 | " addl $256, %1 ;\n" | ||
752 | " addl $256, %2 ;\n" | ||
753 | " addl $256, %3 ;\n" | ||
754 | " addl $256, %4 ;\n" | ||
755 | " decl %0 ;\n" | ||
756 | " jnz 1b ;\n" | ||
757 | : "+r" (lines), | ||
758 | "+r" (p1), "+r" (p2), "+r" (p3), "+r" (p4) | ||
759 | : | ||
760 | : "memory" ); | ||
761 | |||
762 | XMMS_RESTORE; | ||
763 | } | ||
764 | |||
765 | static void | ||
766 | xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
767 | unsigned long *p3, unsigned long *p4, unsigned long *p5) | ||
768 | { | ||
769 | unsigned long lines = bytes >> 8; | ||
770 | char xmm_save[16*4] ALIGN16; | ||
771 | int cr0; | ||
772 | |||
773 | XMMS_SAVE; | ||
774 | |||
775 | /* Make sure GCC forgets anything it knows about p4 or p5, | ||
776 | such that it won't pass to the asm volatile below a | ||
777 | register that is shared with any other variable. That's | ||
778 | because we modify p4 and p5 there, but we can't mark them | ||
779 | as read/write, otherwise we'd overflow the 10-asm-operands | ||
780 | limit of GCC < 3.1. */ | ||
781 | __asm__ ("" : "+r" (p4), "+r" (p5)); | ||
782 | |||
783 | __asm__ __volatile__ ( | ||
784 | #undef BLOCK | ||
785 | #define BLOCK(i) \ | ||
786 | PF1(i) \ | ||
787 | PF1(i+2) \ | ||
788 | LD(i,0) \ | ||
789 | LD(i+1,1) \ | ||
790 | LD(i+2,2) \ | ||
791 | LD(i+3,3) \ | ||
792 | PF2(i) \ | ||
793 | PF2(i+2) \ | ||
794 | XO1(i,0) \ | ||
795 | XO1(i+1,1) \ | ||
796 | XO1(i+2,2) \ | ||
797 | XO1(i+3,3) \ | ||
798 | PF3(i) \ | ||
799 | PF3(i+2) \ | ||
800 | XO2(i,0) \ | ||
801 | XO2(i+1,1) \ | ||
802 | XO2(i+2,2) \ | ||
803 | XO2(i+3,3) \ | ||
804 | PF4(i) \ | ||
805 | PF4(i+2) \ | ||
806 | PF0(i+4) \ | ||
807 | PF0(i+6) \ | ||
808 | XO3(i,0) \ | ||
809 | XO3(i+1,1) \ | ||
810 | XO3(i+2,2) \ | ||
811 | XO3(i+3,3) \ | ||
812 | XO4(i,0) \ | ||
813 | XO4(i+1,1) \ | ||
814 | XO4(i+2,2) \ | ||
815 | XO4(i+3,3) \ | ||
816 | ST(i,0) \ | ||
817 | ST(i+1,1) \ | ||
818 | ST(i+2,2) \ | ||
819 | ST(i+3,3) \ | ||
820 | |||
821 | |||
822 | PF0(0) | ||
823 | PF0(2) | ||
824 | |||
825 | " .align 32 ;\n" | ||
826 | " 1: ;\n" | ||
827 | |||
828 | BLOCK(0) | ||
829 | BLOCK(4) | ||
830 | BLOCK(8) | ||
831 | BLOCK(12) | ||
832 | |||
833 | " addl $256, %1 ;\n" | ||
834 | " addl $256, %2 ;\n" | ||
835 | " addl $256, %3 ;\n" | ||
836 | " addl $256, %4 ;\n" | ||
837 | " addl $256, %5 ;\n" | ||
838 | " decl %0 ;\n" | ||
839 | " jnz 1b ;\n" | ||
840 | : "+r" (lines), | ||
841 | "+r" (p1), "+r" (p2), "+r" (p3) | ||
842 | : "r" (p4), "r" (p5) | ||
843 | : "memory"); | ||
844 | |||
845 | /* p4 and p5 were modified, and now the variables are dead. | ||
846 | Clobber them just to be sure nobody does something stupid | ||
847 | like assuming they have some legal value. */ | ||
848 | __asm__ ("" : "=r" (p4), "=r" (p5)); | ||
849 | |||
850 | XMMS_RESTORE; | ||
851 | } | ||
852 | |||
853 | static struct xor_block_template xor_block_pIII_sse = { | ||
854 | .name = "pIII_sse", | ||
855 | .do_2 = xor_sse_2, | ||
856 | .do_3 = xor_sse_3, | ||
857 | .do_4 = xor_sse_4, | ||
858 | .do_5 = xor_sse_5, | ||
859 | }; | ||
860 | |||
861 | /* Also try the generic routines. */ | ||
862 | #include <asm-generic/xor.h> | ||
863 | |||
864 | #undef XOR_TRY_TEMPLATES | ||
865 | #define XOR_TRY_TEMPLATES \ | ||
866 | do { \ | ||
867 | xor_speed(&xor_block_8regs); \ | ||
868 | xor_speed(&xor_block_8regs_p); \ | ||
869 | xor_speed(&xor_block_32regs); \ | ||
870 | xor_speed(&xor_block_32regs_p); \ | ||
871 | if (cpu_has_xmm) \ | ||
872 | xor_speed(&xor_block_pIII_sse); \ | ||
873 | if (cpu_has_mmx) { \ | ||
874 | xor_speed(&xor_block_pII_mmx); \ | ||
875 | xor_speed(&xor_block_p5_mmx); \ | ||
876 | } \ | ||
877 | } while (0) | ||
878 | |||
879 | /* We force the use of the SSE xor block because it can write around L2. | ||
880 | We may also be able to load into the L1 only depending on how the cpu | ||
881 | deals with a load to a line that is being prefetched. */ | ||
882 | #define XOR_SELECT_TEMPLATE(FASTEST) \ | ||
883 | (cpu_has_xmm ? &xor_block_pIII_sse : FASTEST) | ||
diff --git a/include/asm-x86/xor_64.h b/include/asm-x86/xor_64.h new file mode 100644 index 000000000000..f942fcc21831 --- /dev/null +++ b/include/asm-x86/xor_64.h | |||
@@ -0,0 +1,354 @@ | |||
1 | /* | ||
2 | * include/asm-x86_64/xor.h | ||
3 | * | ||
4 | * Optimized RAID-5 checksumming functions for MMX and SSE. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * (for example /usr/src/linux/COPYING); if not, write to the Free | ||
13 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
14 | */ | ||
15 | |||
16 | |||
17 | /* | ||
18 | * Cache avoiding checksumming functions utilizing KNI instructions | ||
19 | * Copyright (C) 1999 Zach Brown (with obvious credit due Ingo) | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * Based on | ||
24 | * High-speed RAID5 checksumming functions utilizing SSE instructions. | ||
25 | * Copyright (C) 1998 Ingo Molnar. | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | * x86-64 changes / gcc fixes from Andi Kleen. | ||
30 | * Copyright 2002 Andi Kleen, SuSE Labs. | ||
31 | * | ||
32 | * This hasn't been optimized for the hammer yet, but there are likely | ||
33 | * no advantages to be gotten from x86-64 here anyways. | ||
34 | */ | ||
35 | |||
36 | typedef struct { unsigned long a,b; } __attribute__((aligned(16))) xmm_store_t; | ||
37 | |||
38 | /* Doesn't use gcc to save the XMM registers, because there is no easy way to | ||
39 | tell it to do a clts before the register saving. */ | ||
40 | #define XMMS_SAVE do { \ | ||
41 | preempt_disable(); \ | ||
42 | asm volatile ( \ | ||
43 | "movq %%cr0,%0 ;\n\t" \ | ||
44 | "clts ;\n\t" \ | ||
45 | "movups %%xmm0,(%1) ;\n\t" \ | ||
46 | "movups %%xmm1,0x10(%1) ;\n\t" \ | ||
47 | "movups %%xmm2,0x20(%1) ;\n\t" \ | ||
48 | "movups %%xmm3,0x30(%1) ;\n\t" \ | ||
49 | : "=&r" (cr0) \ | ||
50 | : "r" (xmm_save) \ | ||
51 | : "memory"); \ | ||
52 | } while(0) | ||
53 | |||
54 | #define XMMS_RESTORE do { \ | ||
55 | asm volatile ( \ | ||
56 | "sfence ;\n\t" \ | ||
57 | "movups (%1),%%xmm0 ;\n\t" \ | ||
58 | "movups 0x10(%1),%%xmm1 ;\n\t" \ | ||
59 | "movups 0x20(%1),%%xmm2 ;\n\t" \ | ||
60 | "movups 0x30(%1),%%xmm3 ;\n\t" \ | ||
61 | "movq %0,%%cr0 ;\n\t" \ | ||
62 | : \ | ||
63 | : "r" (cr0), "r" (xmm_save) \ | ||
64 | : "memory"); \ | ||
65 | preempt_enable(); \ | ||
66 | } while(0) | ||
67 | |||
68 | #define OFFS(x) "16*("#x")" | ||
69 | #define PF_OFFS(x) "256+16*("#x")" | ||
70 | #define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) ;\n" | ||
71 | #define LD(x,y) " movaps "OFFS(x)"(%[p1]), %%xmm"#y" ;\n" | ||
72 | #define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]) ;\n" | ||
73 | #define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) ;\n" | ||
74 | #define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) ;\n" | ||
75 | #define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) ;\n" | ||
76 | #define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) ;\n" | ||
77 | #define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) ;\n" | ||
78 | #define XO1(x,y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n" | ||
79 | #define XO2(x,y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n" | ||
80 | #define XO3(x,y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n" | ||
81 | #define XO4(x,y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n" | ||
82 | #define XO5(x,y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n" | ||
83 | |||
84 | |||
85 | static void | ||
86 | xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) | ||
87 | { | ||
88 | unsigned int lines = bytes >> 8; | ||
89 | unsigned long cr0; | ||
90 | xmm_store_t xmm_save[4]; | ||
91 | |||
92 | XMMS_SAVE; | ||
93 | |||
94 | asm volatile ( | ||
95 | #undef BLOCK | ||
96 | #define BLOCK(i) \ | ||
97 | LD(i,0) \ | ||
98 | LD(i+1,1) \ | ||
99 | PF1(i) \ | ||
100 | PF1(i+2) \ | ||
101 | LD(i+2,2) \ | ||
102 | LD(i+3,3) \ | ||
103 | PF0(i+4) \ | ||
104 | PF0(i+6) \ | ||
105 | XO1(i,0) \ | ||
106 | XO1(i+1,1) \ | ||
107 | XO1(i+2,2) \ | ||
108 | XO1(i+3,3) \ | ||
109 | ST(i,0) \ | ||
110 | ST(i+1,1) \ | ||
111 | ST(i+2,2) \ | ||
112 | ST(i+3,3) \ | ||
113 | |||
114 | |||
115 | PF0(0) | ||
116 | PF0(2) | ||
117 | |||
118 | " .align 32 ;\n" | ||
119 | " 1: ;\n" | ||
120 | |||
121 | BLOCK(0) | ||
122 | BLOCK(4) | ||
123 | BLOCK(8) | ||
124 | BLOCK(12) | ||
125 | |||
126 | " addq %[inc], %[p1] ;\n" | ||
127 | " addq %[inc], %[p2] ;\n" | ||
128 | " decl %[cnt] ; jnz 1b" | ||
129 | : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines) | ||
130 | : [inc] "r" (256UL) | ||
131 | : "memory"); | ||
132 | |||
133 | XMMS_RESTORE; | ||
134 | } | ||
135 | |||
136 | static void | ||
137 | xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
138 | unsigned long *p3) | ||
139 | { | ||
140 | unsigned int lines = bytes >> 8; | ||
141 | xmm_store_t xmm_save[4]; | ||
142 | unsigned long cr0; | ||
143 | |||
144 | XMMS_SAVE; | ||
145 | |||
146 | __asm__ __volatile__ ( | ||
147 | #undef BLOCK | ||
148 | #define BLOCK(i) \ | ||
149 | PF1(i) \ | ||
150 | PF1(i+2) \ | ||
151 | LD(i,0) \ | ||
152 | LD(i+1,1) \ | ||
153 | LD(i+2,2) \ | ||
154 | LD(i+3,3) \ | ||
155 | PF2(i) \ | ||
156 | PF2(i+2) \ | ||
157 | PF0(i+4) \ | ||
158 | PF0(i+6) \ | ||
159 | XO1(i,0) \ | ||
160 | XO1(i+1,1) \ | ||
161 | XO1(i+2,2) \ | ||
162 | XO1(i+3,3) \ | ||
163 | XO2(i,0) \ | ||
164 | XO2(i+1,1) \ | ||
165 | XO2(i+2,2) \ | ||
166 | XO2(i+3,3) \ | ||
167 | ST(i,0) \ | ||
168 | ST(i+1,1) \ | ||
169 | ST(i+2,2) \ | ||
170 | ST(i+3,3) \ | ||
171 | |||
172 | |||
173 | PF0(0) | ||
174 | PF0(2) | ||
175 | |||
176 | " .align 32 ;\n" | ||
177 | " 1: ;\n" | ||
178 | |||
179 | BLOCK(0) | ||
180 | BLOCK(4) | ||
181 | BLOCK(8) | ||
182 | BLOCK(12) | ||
183 | |||
184 | " addq %[inc], %[p1] ;\n" | ||
185 | " addq %[inc], %[p2] ;\n" | ||
186 | " addq %[inc], %[p3] ;\n" | ||
187 | " decl %[cnt] ; jnz 1b" | ||
188 | : [cnt] "+r" (lines), | ||
189 | [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3) | ||
190 | : [inc] "r" (256UL) | ||
191 | : "memory"); | ||
192 | XMMS_RESTORE; | ||
193 | } | ||
194 | |||
195 | static void | ||
196 | xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
197 | unsigned long *p3, unsigned long *p4) | ||
198 | { | ||
199 | unsigned int lines = bytes >> 8; | ||
200 | xmm_store_t xmm_save[4]; | ||
201 | unsigned long cr0; | ||
202 | |||
203 | XMMS_SAVE; | ||
204 | |||
205 | __asm__ __volatile__ ( | ||
206 | #undef BLOCK | ||
207 | #define BLOCK(i) \ | ||
208 | PF1(i) \ | ||
209 | PF1(i+2) \ | ||
210 | LD(i,0) \ | ||
211 | LD(i+1,1) \ | ||
212 | LD(i+2,2) \ | ||
213 | LD(i+3,3) \ | ||
214 | PF2(i) \ | ||
215 | PF2(i+2) \ | ||
216 | XO1(i,0) \ | ||
217 | XO1(i+1,1) \ | ||
218 | XO1(i+2,2) \ | ||
219 | XO1(i+3,3) \ | ||
220 | PF3(i) \ | ||
221 | PF3(i+2) \ | ||
222 | PF0(i+4) \ | ||
223 | PF0(i+6) \ | ||
224 | XO2(i,0) \ | ||
225 | XO2(i+1,1) \ | ||
226 | XO2(i+2,2) \ | ||
227 | XO2(i+3,3) \ | ||
228 | XO3(i,0) \ | ||
229 | XO3(i+1,1) \ | ||
230 | XO3(i+2,2) \ | ||
231 | XO3(i+3,3) \ | ||
232 | ST(i,0) \ | ||
233 | ST(i+1,1) \ | ||
234 | ST(i+2,2) \ | ||
235 | ST(i+3,3) \ | ||
236 | |||
237 | |||
238 | PF0(0) | ||
239 | PF0(2) | ||
240 | |||
241 | " .align 32 ;\n" | ||
242 | " 1: ;\n" | ||
243 | |||
244 | BLOCK(0) | ||
245 | BLOCK(4) | ||
246 | BLOCK(8) | ||
247 | BLOCK(12) | ||
248 | |||
249 | " addq %[inc], %[p1] ;\n" | ||
250 | " addq %[inc], %[p2] ;\n" | ||
251 | " addq %[inc], %[p3] ;\n" | ||
252 | " addq %[inc], %[p4] ;\n" | ||
253 | " decl %[cnt] ; jnz 1b" | ||
254 | : [cnt] "+c" (lines), | ||
255 | [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4) | ||
256 | : [inc] "r" (256UL) | ||
257 | : "memory" ); | ||
258 | |||
259 | XMMS_RESTORE; | ||
260 | } | ||
261 | |||
262 | static void | ||
263 | xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, | ||
264 | unsigned long *p3, unsigned long *p4, unsigned long *p5) | ||
265 | { | ||
266 | unsigned int lines = bytes >> 8; | ||
267 | xmm_store_t xmm_save[4]; | ||
268 | unsigned long cr0; | ||
269 | |||
270 | XMMS_SAVE; | ||
271 | |||
272 | __asm__ __volatile__ ( | ||
273 | #undef BLOCK | ||
274 | #define BLOCK(i) \ | ||
275 | PF1(i) \ | ||
276 | PF1(i+2) \ | ||
277 | LD(i,0) \ | ||
278 | LD(i+1,1) \ | ||
279 | LD(i+2,2) \ | ||
280 | LD(i+3,3) \ | ||
281 | PF2(i) \ | ||
282 | PF2(i+2) \ | ||
283 | XO1(i,0) \ | ||
284 | XO1(i+1,1) \ | ||
285 | XO1(i+2,2) \ | ||
286 | XO1(i+3,3) \ | ||
287 | PF3(i) \ | ||
288 | PF3(i+2) \ | ||
289 | XO2(i,0) \ | ||
290 | XO2(i+1,1) \ | ||
291 | XO2(i+2,2) \ | ||
292 | XO2(i+3,3) \ | ||
293 | PF4(i) \ | ||
294 | PF4(i+2) \ | ||
295 | PF0(i+4) \ | ||
296 | PF0(i+6) \ | ||
297 | XO3(i,0) \ | ||
298 | XO3(i+1,1) \ | ||
299 | XO3(i+2,2) \ | ||
300 | XO3(i+3,3) \ | ||
301 | XO4(i,0) \ | ||
302 | XO4(i+1,1) \ | ||
303 | XO4(i+2,2) \ | ||
304 | XO4(i+3,3) \ | ||
305 | ST(i,0) \ | ||
306 | ST(i+1,1) \ | ||
307 | ST(i+2,2) \ | ||
308 | ST(i+3,3) \ | ||
309 | |||
310 | |||
311 | PF0(0) | ||
312 | PF0(2) | ||
313 | |||
314 | " .align 32 ;\n" | ||
315 | " 1: ;\n" | ||
316 | |||
317 | BLOCK(0) | ||
318 | BLOCK(4) | ||
319 | BLOCK(8) | ||
320 | BLOCK(12) | ||
321 | |||
322 | " addq %[inc], %[p1] ;\n" | ||
323 | " addq %[inc], %[p2] ;\n" | ||
324 | " addq %[inc], %[p3] ;\n" | ||
325 | " addq %[inc], %[p4] ;\n" | ||
326 | " addq %[inc], %[p5] ;\n" | ||
327 | " decl %[cnt] ; jnz 1b" | ||
328 | : [cnt] "+c" (lines), | ||
329 | [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4), | ||
330 | [p5] "+r" (p5) | ||
331 | : [inc] "r" (256UL) | ||
332 | : "memory"); | ||
333 | |||
334 | XMMS_RESTORE; | ||
335 | } | ||
336 | |||
337 | static struct xor_block_template xor_block_sse = { | ||
338 | .name = "generic_sse", | ||
339 | .do_2 = xor_sse_2, | ||
340 | .do_3 = xor_sse_3, | ||
341 | .do_4 = xor_sse_4, | ||
342 | .do_5 = xor_sse_5, | ||
343 | }; | ||
344 | |||
345 | #undef XOR_TRY_TEMPLATES | ||
346 | #define XOR_TRY_TEMPLATES \ | ||
347 | do { \ | ||
348 | xor_speed(&xor_block_sse); \ | ||
349 | } while (0) | ||
350 | |||
351 | /* We force the use of the SSE xor block because it can write around L2. | ||
352 | We may also be able to load into the L1 only depending on how the cpu | ||
353 | deals with a load to a line that is being prefetched. */ | ||
354 | #define XOR_SELECT_TEMPLATE(FASTEST) (&xor_block_sse) | ||