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 
30 #define COMPILER_DEPENDENT_INT64   long long
31 #define COMPILER_DEPENDENT_UINT64  unsigned long long
32 
33 /*
34  * Calling conventions:
35  *
36  * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
37  * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
38  * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
39  * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
40  */
41 #define ACPI_SYSTEM_XFACE
42 #define ACPI_EXTERNAL_XFACE
43 #define ACPI_INTERNAL_XFACE
44 #define ACPI_INTERNAL_VAR_XFACE
45 
46 /* Asm macros */
47 
48 #define ACPI_ASM_MACROS
49 #define BREAKPOINT3
50 #define ACPI_DISABLE_IRQS() local_irq_disable()
51 #define ACPI_ENABLE_IRQS()  local_irq_enable()
52 #define ACPI_FLUSH_CPU_CACHE()	wbinvd()
53 
54 int __acpi_acquire_global_lock(unsigned int *lock);
55 int __acpi_release_global_lock(unsigned int *lock);
56 
57 #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
58 	((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
59 
60 #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
61 	((Acq) = __acpi_release_global_lock(&facs->global_lock))
62 
63 /*
64  * Math helper asm macros
65  */
66 #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
67 	asm("divl %2;"				     \
68 	    :"=a"(q32), "=d"(r32)		     \
69 	    :"r"(d32),				     \
70 	     "0"(n_lo), "1"(n_hi))
71 
72 
73 #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
74 	asm("shrl   $1,%2	;"	\
75 	    "rcrl   $1,%3;"		\
76 	    :"=r"(n_hi), "=r"(n_lo)	\
77 	    :"0"(n_hi), "1"(n_lo))
78 
79 extern bool acpi_lapic, acpi_ioapic, acpi_noirq;
80 extern bool acpi_force, acpi_ht, acpi_disabled;
81 extern u32 acpi_smi_cmd;
82 extern u8 acpi_enable_value, acpi_disable_value;
83 void acpi_pic_sci_set_trigger(unsigned int, u16);
84 
disable_acpi(void)85 static inline void disable_acpi(void)
86 {
87 	acpi_disabled = 1;
88 	acpi_ht = 0;
89 	acpi_noirq = 1;
90 }
91 
acpi_noirq_set(void)92 static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
93 
94 /* routines for saving/restoring kernel state */
95 extern int acpi_save_state_mem(void);
96 extern int acpi_save_state_disk(void);
97 extern void acpi_restore_state_mem(void);
98 
99 extern unsigned long acpi_wakeup_address;
100 
101 /* early initialization routine */
102 extern void acpi_reserve_bootmem(void);
103 
104 #define ARCH_HAS_POWER_INIT	1
105 
106 extern s8 acpi_numa;
107 extern int acpi_scan_nodes(u64 start, u64 end);
108 #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
109 
110 #ifdef CONFIG_ACPI_SLEEP
111 
112 extern struct acpi_sleep_info acpi_sinfo;
113 #define acpi_video_flags bootsym(video_flags)
114 struct xenpf_enter_acpi_sleep;
115 extern int acpi_enter_sleep(struct xenpf_enter_acpi_sleep *sleep);
116 extern int acpi_enter_state(u32 state);
117 
118 struct acpi_sleep_info {
119     struct acpi_generic_address pm1a_cnt_blk;
120     struct acpi_generic_address pm1b_cnt_blk;
121     struct acpi_generic_address pm1a_evt_blk;
122     struct acpi_generic_address pm1b_evt_blk;
123     struct acpi_generic_address sleep_control;
124     struct acpi_generic_address sleep_status;
125     union {
126         uint16_t pm1a_cnt_val;
127         uint8_t sleep_type_a;
128     };
129     union {
130         uint16_t pm1b_cnt_val;
131         uint8_t sleep_type_b;
132     };
133     uint32_t sleep_state;
134     uint64_t wakeup_vector;
135     uint32_t vector_width;
136     bool_t sleep_extended;
137 };
138 
139 #endif /* CONFIG_ACPI_SLEEP */
140 
141 #define MAX_MADT_ENTRIES	MAX(256, 2 * NR_CPUS)
142 extern u32 x86_acpiid_to_apicid[];
143 #define MAX_LOCAL_APIC		MAX(256, 4 * NR_CPUS)
144 
145 #define INVALID_ACPIID		(-1U)
146 
147 extern u32 pmtmr_ioport;
148 extern unsigned int pmtmr_width;
149 
150 int acpi_dmar_init(void);
151 void acpi_mmcfg_init(void);
152 
153 /* Incremented whenever we transition through S3. Value is 1 during boot. */
154 extern uint32_t system_reset_counter;
155 
156 void hvm_acpi_power_button(struct domain *d);
157 void hvm_acpi_sleep_button(struct domain *d);
158 
159 /* suspend/resume */
160 void save_rest_processor_state(void);
161 void restore_rest_processor_state(void);
162 
163 #define ACPI_MAP_MEM_ATTR	PAGE_HYPERVISOR_UCMINUS
164 
165 #endif /*__X86_ASM_ACPI_H*/
166