1 #ifndef _ASM_X86_ACPI_H
2 #define _ASM_X86_ACPI_H
3
4 /*
5 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; If not, see <http://www.gnu.org/licenses/>.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26 #include <acpi/pdc_intel.h>
27 #include <acpi/acconfig.h>
28 #include <acpi/actbl.h>
29 #include <xen/errno.h>
30
31 #define COMPILER_DEPENDENT_INT64 long long
32 #define COMPILER_DEPENDENT_UINT64 unsigned long long
33
34 /*
35 * Calling conventions:
36 *
37 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
38 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
39 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
40 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
41 */
42 #define ACPI_SYSTEM_XFACE
43 #define ACPI_EXTERNAL_XFACE
44 #define ACPI_INTERNAL_XFACE
45 #define ACPI_INTERNAL_VAR_XFACE
46
47 /* Asm macros */
48
49 #define ACPI_ASM_MACROS
50 #define BREAKPOINT3
51 #define ACPI_DISABLE_IRQS() local_irq_disable()
52 #define ACPI_ENABLE_IRQS() local_irq_enable()
53 #define ACPI_FLUSH_CPU_CACHE() wbinvd()
54
55 int __acpi_acquire_global_lock(unsigned int *lock);
56 int __acpi_release_global_lock(unsigned int *lock);
57
58 #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
59 ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
60
61 #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
62 ((Acq) = __acpi_release_global_lock(&facs->global_lock))
63
64 /*
65 * Math helper asm macros
66 */
67 #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
68 asm("divl %2;" \
69 :"=a"(q32), "=d"(r32) \
70 :"r"(d32), \
71 "0"(n_lo), "1"(n_hi))
72
73
74 #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
75 asm("shrl $1,%2 ;" \
76 "rcrl $1,%3;" \
77 :"=r"(n_hi), "=r"(n_lo) \
78 :"0"(n_hi), "1"(n_lo))
79
80 extern bool acpi_lapic, acpi_ioapic, acpi_noirq;
81 extern bool acpi_force, acpi_ht, acpi_disabled;
82 extern u32 acpi_smi_cmd;
83 extern u8 acpi_enable_value, acpi_disable_value;
84 void acpi_pic_sci_set_trigger(unsigned int, u16);
85
disable_acpi(void)86 static inline void disable_acpi(void)
87 {
88 acpi_disabled = 1;
89 acpi_ht = 0;
90 acpi_noirq = 1;
91 }
92
acpi_noirq_set(void)93 static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
94
95 /* routines for saving/restoring kernel state */
96 extern int acpi_save_state_mem(void);
97 extern int acpi_save_state_disk(void);
98 extern void acpi_restore_state_mem(void);
99
100 extern unsigned long acpi_wakeup_address;
101
102 #define ARCH_HAS_POWER_INIT 1
103
104 extern s8 acpi_numa;
105 extern int acpi_scan_nodes(u64 start, u64 end);
106 #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
107
108 extern struct acpi_sleep_info acpi_sinfo;
109 #define acpi_video_flags bootsym(video_flags)
110 struct xenpf_enter_acpi_sleep;
111 extern int acpi_enter_sleep(struct xenpf_enter_acpi_sleep *sleep);
112 extern int acpi_enter_state(u32 state);
113
114 struct acpi_sleep_info {
115 struct acpi_generic_address pm1a_cnt_blk;
116 struct acpi_generic_address pm1b_cnt_blk;
117 struct acpi_generic_address pm1a_evt_blk;
118 struct acpi_generic_address pm1b_evt_blk;
119 struct acpi_generic_address sleep_control;
120 struct acpi_generic_address sleep_status;
121 union {
122 uint16_t pm1a_cnt_val;
123 uint8_t sleep_type_a;
124 };
125 union {
126 uint16_t pm1b_cnt_val;
127 uint8_t sleep_type_b;
128 };
129 uint32_t sleep_state;
130 uint64_t wakeup_vector;
131 uint32_t vector_width;
132 bool_t sleep_extended;
133 };
134
135 #define MAX_MADT_ENTRIES MAX(256, 2 * NR_CPUS)
136 extern u32 x86_acpiid_to_apicid[];
137 #define MAX_LOCAL_APIC MAX(256, 4 * NR_CPUS)
138
139 #define INVALID_ACPIID (-1U)
140
141 extern u32 pmtmr_ioport;
142 extern unsigned int pmtmr_width;
143
144 int acpi_dmar_init(void);
145 int acpi_ivrs_init(void);
146
acpi_iommu_init(void)147 static inline int acpi_iommu_init(void)
148 {
149 int ret = acpi_dmar_init();
150
151 return ret == -ENODEV ? acpi_ivrs_init() : ret;
152 }
153
154 void acpi_mmcfg_init(void);
155
156 /* Incremented whenever we transition through S3. Value is 1 during boot. */
157 extern uint32_t system_reset_counter;
158
159 void hvm_acpi_power_button(struct domain *d);
160 void hvm_acpi_sleep_button(struct domain *d);
161
162 /* suspend/resume */
163 void save_rest_processor_state(void);
164 void restore_rest_processor_state(void);
165
166 #define ACPI_MAP_MEM_ATTR PAGE_HYPERVISOR_UCMINUS
167
168 #endif /*__X86_ASM_ACPI_H*/
169