1 /*
2 * acpi.h - ACPI Interface
3 *
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; If not, see <http://www.gnu.org/licenses/>.
20 *
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 */
23
24 #ifndef _LINUX_ACPI_H
25 #define _LINUX_ACPI_H
26
27 #ifndef _LINUX
28 #define _LINUX
29 #endif
30
31 #include <xen/list.h>
32
33 #include <acpi/acpi.h>
34 #include <asm/acpi.h>
35
36 #define ACPI_MADT_GET_(fld, x) (((x) & ACPI_MADT_##fld##_MASK) / \
37 (ACPI_MADT_##fld##_MASK & -ACPI_MADT_##fld##_MASK))
38
39 #define ACPI_MADT_GET_POLARITY(inti) ACPI_MADT_GET_(POLARITY, inti)
40 #define ACPI_MADT_GET_TRIGGER(inti) ACPI_MADT_GET_(TRIGGER, inti)
41
42 /*
43 * Fixmap pages to reserve for ACPI boot-time tables (see asm-x86/fixmap.h or
44 * asm-arm/config.h, 64 pages(256KB) is large enough for most cases.)
45 */
46 #define NUM_FIXMAP_ACPI_PAGES 64
47
48 #define BAD_MADT_ENTRY(entry, end) ( \
49 (!(entry)) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \
50 (entry)->header.length < sizeof(*(entry)))
51
52 #ifdef CONFIG_ACPI
53
54 enum acpi_interrupt_id {
55 ACPI_INTERRUPT_PMI = 1,
56 ACPI_INTERRUPT_INIT,
57 ACPI_INTERRUPT_CPEI,
58 ACPI_INTERRUPT_COUNT
59 };
60
61 typedef int (*acpi_madt_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
62
63 typedef int (*acpi_table_handler) (struct acpi_table_header *table);
64
65 typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
66
67 unsigned int acpi_get_processor_id (unsigned int cpu);
68 char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
69 int acpi_boot_init (void);
70 int acpi_boot_table_init (void);
71 int acpi_numa_init (void);
72 int erst_init(void);
73 void acpi_hest_init(void);
74
75 int acpi_table_init (void);
76 int acpi_table_parse(char *id, acpi_table_handler handler);
77 int acpi_parse_entries(char *id, unsigned long table_size,
78 acpi_table_entry_handler handler,
79 struct acpi_table_header *table_header,
80 int entry_id, unsigned int max_entries);
81 int acpi_table_parse_entries(char *id, unsigned long table_size,
82 int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
83 struct acpi_subtable_header *acpi_table_get_entry_madt(enum acpi_madt_type id,
84 unsigned int entry_index);
85 int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
86 int acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
87 unsigned int max_entries);
88 int acpi_parse_srat(struct acpi_table_header *);
89 void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
90 void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
91 void acpi_table_print_srat_entry (struct acpi_subtable_header *srat);
92
93 /* the following four functions are architecture-dependent */
94 void acpi_numa_slit_init (struct acpi_table_slit *slit);
95 void acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *);
96 void acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *);
97 void acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *);
98 void acpi_numa_arch_fixup(void);
99
100 #ifdef CONFIG_ACPI_HOTPLUG_CPU
101 /* Arch dependent functions for cpu hotplug support */
102 int acpi_map_lsapic(acpi_handle handle, int *pcpu);
103 int acpi_unmap_lsapic(int cpu);
104 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
105
106 extern int acpi_mp_config;
107
108 extern u32 pci_mmcfg_base_addr;
109
110 #else /*!CONFIG_ACPI*/
111
112 #define acpi_mp_config 0
113
acpi_boot_init(void)114 static inline int acpi_boot_init(void)
115 {
116 return 0;
117 }
118
acpi_boot_table_init(void)119 static inline int acpi_boot_table_init(void)
120 {
121 return 0;
122 }
123
124 #endif /*!CONFIG_ACPI*/
125
126 int get_cpu_id(u32 acpi_id);
127
128 unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
129 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
130
131 /*
132 * This function undoes the effect of one call to acpi_register_gsi().
133 * If this matches the last registration, any IRQ resources for gsi
134 * are freed.
135 */
136 #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
137 void acpi_unregister_gsi (u32 gsi);
138 #endif
139
140 #ifdef CONFIG_ACPI_CSTATE
141 /*
142 * Set highest legal C-state
143 * 0: C0 okay, but not C1
144 * 1: C1 okay, but not C2
145 * 2: C2 okay, but not C3 etc.
146 */
147
148 extern unsigned int max_cstate;
149
acpi_get_cstate_limit(void)150 static inline unsigned int acpi_get_cstate_limit(void)
151 {
152 return max_cstate;
153 }
acpi_set_cstate_limit(unsigned int new_limit)154 static inline void acpi_set_cstate_limit(unsigned int new_limit)
155 {
156 max_cstate = new_limit;
157 return;
158 }
159 #else
acpi_get_cstate_limit(void)160 static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
acpi_set_cstate_limit(unsigned int new_limit)161 static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
162 #endif
163
164 #ifdef XEN_GUEST_HANDLE_PARAM
165 int acpi_set_pdc_bits(u32 acpi_id, XEN_GUEST_HANDLE_PARAM(uint32));
166 #endif
167 int arch_acpi_set_pdc_bits(u32 acpi_id, u32 *, u32 mask);
168
169 #ifdef CONFIG_ACPI_NUMA
170 int acpi_get_pxm(acpi_handle handle);
171 #else
acpi_get_pxm(acpi_handle handle)172 static inline int acpi_get_pxm(acpi_handle handle)
173 {
174 return 0;
175 }
176 #endif
177
178 void acpi_reboot(void);
179
180 void acpi_dmar_zap(void);
181 void acpi_dmar_reinstate(void);
182
183 #endif /*_LINUX_ACPI_H*/
184