Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * acpi_osl.c - OS-dependent functions ($Revision: 83 $) | |
3 | * | |
4 | * Copyright (C) 2000 Andrew Henroid | |
5 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | |
6 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | |
f1241c87 MW |
7 | * Copyright (c) 2008 Intel Corporation |
8 | * Author: Matthew Wilcox <willy@linux.intel.com> | |
1da177e4 LT |
9 | * |
10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License | |
23 | * along with this program; if not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 | * | |
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
27 | * | |
28 | */ | |
29 | ||
1da177e4 LT |
30 | #include <linux/module.h> |
31 | #include <linux/kernel.h> | |
32 | #include <linux/slab.h> | |
33 | #include <linux/mm.h> | |
34 | #include <linux/pci.h> | |
1da177e4 LT |
35 | #include <linux/interrupt.h> |
36 | #include <linux/kmod.h> | |
37 | #include <linux/delay.h> | |
38 | #include <linux/workqueue.h> | |
39 | #include <linux/nmi.h> | |
ad71860a | 40 | #include <linux/acpi.h> |
2d6d9fd3 | 41 | #include <linux/acpi_io.h> |
1da177e4 | 42 | #include <linux/efi.h> |
df92e695 TR |
43 | #include <linux/ioport.h> |
44 | #include <linux/list.h> | |
f1241c87 MW |
45 | #include <linux/jiffies.h> |
46 | #include <linux/semaphore.h> | |
47 | ||
48 | #include <asm/io.h> | |
49 | #include <asm/uaccess.h> | |
50 | ||
51 | #include <acpi/acpi.h> | |
52 | #include <acpi/acpi_bus.h> | |
53 | #include <acpi/processor.h> | |
1da177e4 | 54 | |
1da177e4 | 55 | #define _COMPONENT ACPI_OS_SERVICES |
f52fd66d | 56 | ACPI_MODULE_NAME("osl"); |
1da177e4 | 57 | #define PREFIX "ACPI: " |
4be44fcd LB |
58 | struct acpi_os_dpc { |
59 | acpi_osd_exec_callback function; | |
60 | void *context; | |
65f27f38 | 61 | struct work_struct work; |
9ac61856 | 62 | int wait; |
1da177e4 LT |
63 | }; |
64 | ||
65 | #ifdef CONFIG_ACPI_CUSTOM_DSDT | |
66 | #include CONFIG_ACPI_CUSTOM_DSDT_FILE | |
67 | #endif | |
68 | ||
69 | #ifdef ENABLE_DEBUGGER | |
70 | #include <linux/kdb.h> | |
71 | ||
72 | /* stuff for debugger support */ | |
73 | int acpi_in_debugger; | |
74 | EXPORT_SYMBOL(acpi_in_debugger); | |
75 | ||
76 | extern char line_buf[80]; | |
4be44fcd | 77 | #endif /*ENABLE_DEBUGGER */ |
1da177e4 LT |
78 | |
79 | static unsigned int acpi_irq_irq; | |
80 | static acpi_osd_handler acpi_irq_handler; | |
81 | static void *acpi_irq_context; | |
82 | static struct workqueue_struct *kacpid_wq; | |
88db5e14 | 83 | static struct workqueue_struct *kacpi_notify_wq; |
c02256be | 84 | static struct workqueue_struct *kacpi_hotplug_wq; |
1da177e4 | 85 | |
df92e695 TR |
86 | struct acpi_res_list { |
87 | resource_size_t start; | |
88 | resource_size_t end; | |
89 | acpi_adr_space_type resource_type; /* IO port, System memory, ...*/ | |
90 | char name[5]; /* only can have a length of 4 chars, make use of this | |
91 | one instead of res->name, no need to kalloc then */ | |
92 | struct list_head resource_list; | |
a5fe1a03 | 93 | int count; |
df92e695 TR |
94 | }; |
95 | ||
96 | static LIST_HEAD(resource_list_head); | |
97 | static DEFINE_SPINLOCK(acpi_res_lock); | |
98 | ||
620242ae MS |
99 | /* |
100 | * This list of permanent mappings is for memory that may be accessed from | |
101 | * interrupt context, where we can't do the ioremap(). | |
102 | */ | |
103 | struct acpi_ioremap { | |
104 | struct list_head list; | |
105 | void __iomem *virt; | |
106 | acpi_physical_address phys; | |
107 | acpi_size size; | |
4a3cba5e | 108 | struct kref ref; |
620242ae MS |
109 | }; |
110 | ||
111 | static LIST_HEAD(acpi_ioremaps); | |
112 | static DEFINE_SPINLOCK(acpi_ioremap_lock); | |
113 | ||
b0ed7a91 | 114 | static void __init acpi_osi_setup_late(void); |
ae00d812 | 115 | |
d4b7dc49 | 116 | /* |
a6e0887f | 117 | * The story of _OSI(Linux) |
d4b7dc49 | 118 | * |
a6e0887f LB |
119 | * From pre-history through Linux-2.6.22, |
120 | * Linux responded TRUE upon a BIOS OSI(Linux) query. | |
d4b7dc49 | 121 | * |
a6e0887f LB |
122 | * Unfortunately, reference BIOS writers got wind of this |
123 | * and put OSI(Linux) in their example code, quickly exposing | |
124 | * this string as ill-conceived and opening the door to | |
125 | * an un-bounded number of BIOS incompatibilities. | |
d4b7dc49 | 126 | * |
a6e0887f LB |
127 | * For example, OSI(Linux) was used on resume to re-POST a |
128 | * video card on one system, because Linux at that time | |
129 | * could not do a speedy restore in its native driver. | |
130 | * But then upon gaining quick native restore capability, | |
131 | * Linux has no way to tell the BIOS to skip the time-consuming | |
132 | * POST -- putting Linux at a permanent performance disadvantage. | |
133 | * On another system, the BIOS writer used OSI(Linux) | |
134 | * to infer native OS support for IPMI! On other systems, | |
135 | * OSI(Linux) simply got in the way of Linux claiming to | |
136 | * be compatible with other operating systems, exposing | |
137 | * BIOS issues such as skipped device initialization. | |
d4b7dc49 | 138 | * |
a6e0887f LB |
139 | * So "Linux" turned out to be a really poor chose of |
140 | * OSI string, and from Linux-2.6.23 onward we respond FALSE. | |
d4b7dc49 LB |
141 | * |
142 | * BIOS writers should NOT query _OSI(Linux) on future systems. | |
a6e0887f LB |
143 | * Linux will complain on the console when it sees it, and return FALSE. |
144 | * To get Linux to return TRUE for your system will require | |
145 | * a kernel source update to add a DMI entry, | |
146 | * or boot with "acpi_osi=Linux" | |
d4b7dc49 | 147 | */ |
d4b7dc49 | 148 | |
1d15d84e | 149 | static struct osi_linux { |
d4b7dc49 LB |
150 | unsigned int enable:1; |
151 | unsigned int dmi:1; | |
152 | unsigned int cmdline:1; | |
d90aa92c | 153 | } osi_linux = {0, 0, 0}; |
f507654d | 154 | |
b0ed7a91 LM |
155 | static u32 acpi_osi_handler(acpi_string interface, u32 supported) |
156 | { | |
157 | if (!strcmp("Linux", interface)) { | |
158 | ||
3af283e1 | 159 | printk(KERN_NOTICE FW_BUG PREFIX |
b0ed7a91 LM |
160 | "BIOS _OSI(Linux) query %s%s\n", |
161 | osi_linux.enable ? "honored" : "ignored", | |
162 | osi_linux.cmdline ? " via cmdline" : | |
163 | osi_linux.dmi ? " via DMI" : ""); | |
164 | } | |
165 | ||
166 | return supported; | |
167 | } | |
168 | ||
9a47cdb1 BH |
169 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
170 | unsigned int length, char *desc) | |
171 | { | |
9a47cdb1 BH |
172 | if (!addr->address || !length) |
173 | return; | |
174 | ||
cfa806f0 | 175 | /* Resources are never freed */ |
eee3c859 | 176 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
cfa806f0 | 177 | request_region(addr->address, length, desc); |
eee3c859 | 178 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) |
cfa806f0 | 179 | request_mem_region(addr->address, length, desc); |
9a47cdb1 BH |
180 | } |
181 | ||
182 | static int __init acpi_reserve_resources(void) | |
183 | { | |
eee3c859 | 184 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, |
9a47cdb1 BH |
185 | "ACPI PM1a_EVT_BLK"); |
186 | ||
eee3c859 | 187 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, |
9a47cdb1 BH |
188 | "ACPI PM1b_EVT_BLK"); |
189 | ||
eee3c859 | 190 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, |
9a47cdb1 BH |
191 | "ACPI PM1a_CNT_BLK"); |
192 | ||
eee3c859 | 193 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, |
9a47cdb1 BH |
194 | "ACPI PM1b_CNT_BLK"); |
195 | ||
eee3c859 LB |
196 | if (acpi_gbl_FADT.pm_timer_length == 4) |
197 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); | |
9a47cdb1 | 198 | |
eee3c859 | 199 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, |
9a47cdb1 BH |
200 | "ACPI PM2_CNT_BLK"); |
201 | ||
202 | /* Length of GPE blocks must be a non-negative multiple of 2 */ | |
203 | ||
eee3c859 LB |
204 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) |
205 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, | |
206 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); | |
9a47cdb1 | 207 | |
eee3c859 LB |
208 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) |
209 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, | |
210 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); | |
9a47cdb1 BH |
211 | |
212 | return 0; | |
213 | } | |
214 | device_initcall(acpi_reserve_resources); | |
215 | ||
4be44fcd | 216 | void acpi_os_printf(const char *fmt, ...) |
1da177e4 LT |
217 | { |
218 | va_list args; | |
219 | va_start(args, fmt); | |
220 | acpi_os_vprintf(fmt, args); | |
221 | va_end(args); | |
222 | } | |
4be44fcd | 223 | |
4be44fcd | 224 | void acpi_os_vprintf(const char *fmt, va_list args) |
1da177e4 LT |
225 | { |
226 | static char buffer[512]; | |
4be44fcd | 227 | |
1da177e4 LT |
228 | vsprintf(buffer, fmt, args); |
229 | ||
230 | #ifdef ENABLE_DEBUGGER | |
231 | if (acpi_in_debugger) { | |
232 | kdb_printf("%s", buffer); | |
233 | } else { | |
4d939155 | 234 | printk(KERN_CONT "%s", buffer); |
1da177e4 LT |
235 | } |
236 | #else | |
4d939155 | 237 | printk(KERN_CONT "%s", buffer); |
1da177e4 LT |
238 | #endif |
239 | } | |
240 | ||
ad71860a | 241 | acpi_physical_address __init acpi_os_get_root_pointer(void) |
1da177e4 LT |
242 | { |
243 | if (efi_enabled) { | |
b2c99e3c | 244 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
ad71860a | 245 | return efi.acpi20; |
b2c99e3c | 246 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
ad71860a | 247 | return efi.acpi; |
1da177e4 | 248 | else { |
4be44fcd LB |
249 | printk(KERN_ERR PREFIX |
250 | "System description tables not found\n"); | |
ad71860a | 251 | return 0; |
1da177e4 | 252 | } |
239665a3 LB |
253 | } else { |
254 | acpi_physical_address pa = 0; | |
255 | ||
256 | acpi_find_root_pointer(&pa); | |
257 | return pa; | |
258 | } | |
1da177e4 LT |
259 | } |
260 | ||
78cdb3ed | 261 | /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ |
4a3cba5e MS |
262 | static struct acpi_ioremap * |
263 | acpi_map_lookup(acpi_physical_address phys, acpi_size size) | |
620242ae MS |
264 | { |
265 | struct acpi_ioremap *map; | |
266 | ||
78cdb3ed | 267 | list_for_each_entry_rcu(map, &acpi_ioremaps, list) |
620242ae MS |
268 | if (map->phys <= phys && |
269 | phys + size <= map->phys + map->size) | |
4a3cba5e MS |
270 | return map; |
271 | ||
272 | return NULL; | |
273 | } | |
274 | ||
275 | /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ | |
276 | static void __iomem * | |
277 | acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size) | |
278 | { | |
279 | struct acpi_ioremap *map; | |
280 | ||
281 | map = acpi_map_lookup(phys, size); | |
282 | if (map) | |
283 | return map->virt + (phys - map->phys); | |
620242ae MS |
284 | |
285 | return NULL; | |
286 | } | |
287 | ||
78cdb3ed | 288 | /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ |
620242ae MS |
289 | static struct acpi_ioremap * |
290 | acpi_map_lookup_virt(void __iomem *virt, acpi_size size) | |
291 | { | |
292 | struct acpi_ioremap *map; | |
293 | ||
78cdb3ed | 294 | list_for_each_entry_rcu(map, &acpi_ioremaps, list) |
4a3cba5e MS |
295 | if (map->virt <= virt && |
296 | virt + size <= map->virt + map->size) | |
620242ae MS |
297 | return map; |
298 | ||
299 | return NULL; | |
300 | } | |
301 | ||
2fdf0741 JB |
302 | void __iomem *__init_refok |
303 | acpi_os_map_memory(acpi_physical_address phys, acpi_size size) | |
1da177e4 | 304 | { |
4a3cba5e | 305 | struct acpi_ioremap *map, *tmp_map; |
2d6d9fd3 | 306 | unsigned long flags; |
620242ae | 307 | void __iomem *virt; |
2d6d9fd3 RW |
308 | acpi_physical_address pg_off; |
309 | acpi_size pg_sz; | |
620242ae | 310 | |
9f4fd61f BH |
311 | if (phys > ULONG_MAX) { |
312 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); | |
70c0846e | 313 | return NULL; |
1da177e4 | 314 | } |
620242ae MS |
315 | |
316 | if (!acpi_gbl_permanent_mmap) | |
ad71860a | 317 | return __acpi_map_table((unsigned long)phys, size); |
620242ae MS |
318 | |
319 | map = kzalloc(sizeof(*map), GFP_KERNEL); | |
320 | if (!map) | |
321 | return NULL; | |
322 | ||
4a3cba5e MS |
323 | pg_off = round_down(phys, PAGE_SIZE); |
324 | pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; | |
2d6d9fd3 | 325 | virt = acpi_os_ioremap(pg_off, pg_sz); |
620242ae MS |
326 | if (!virt) { |
327 | kfree(map); | |
328 | return NULL; | |
329 | } | |
330 | ||
331 | INIT_LIST_HEAD(&map->list); | |
332 | map->virt = virt; | |
4a3cba5e MS |
333 | map->phys = pg_off; |
334 | map->size = pg_sz; | |
335 | kref_init(&map->ref); | |
620242ae MS |
336 | |
337 | spin_lock_irqsave(&acpi_ioremap_lock, flags); | |
4a3cba5e MS |
338 | /* Check if page has already been mapped. */ |
339 | tmp_map = acpi_map_lookup(phys, size); | |
340 | if (tmp_map) { | |
341 | kref_get(&tmp_map->ref); | |
342 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); | |
343 | iounmap(map->virt); | |
344 | kfree(map); | |
345 | return tmp_map->virt + (phys - tmp_map->phys); | |
346 | } | |
78cdb3ed | 347 | list_add_tail_rcu(&map->list, &acpi_ioremaps); |
620242ae MS |
348 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
349 | ||
4a3cba5e | 350 | return map->virt + (phys - map->phys); |
1da177e4 | 351 | } |
55a82ab3 | 352 | EXPORT_SYMBOL_GPL(acpi_os_map_memory); |
1da177e4 | 353 | |
4a3cba5e MS |
354 | static void acpi_kref_del_iomap(struct kref *ref) |
355 | { | |
356 | struct acpi_ioremap *map; | |
357 | ||
358 | map = container_of(ref, struct acpi_ioremap, ref); | |
359 | list_del_rcu(&map->list); | |
360 | } | |
361 | ||
0d3a9cf5 | 362 | void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size) |
1da177e4 | 363 | { |
620242ae MS |
364 | struct acpi_ioremap *map; |
365 | unsigned long flags; | |
4a3cba5e | 366 | int del; |
620242ae MS |
367 | |
368 | if (!acpi_gbl_permanent_mmap) { | |
7d97277b | 369 | __acpi_unmap_table(virt, size); |
620242ae MS |
370 | return; |
371 | } | |
372 | ||
373 | spin_lock_irqsave(&acpi_ioremap_lock, flags); | |
374 | map = acpi_map_lookup_virt(virt, size); | |
375 | if (!map) { | |
376 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); | |
377 | printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); | |
378 | dump_stack(); | |
379 | return; | |
380 | } | |
381 | ||
4a3cba5e | 382 | del = kref_put(&map->ref, acpi_kref_del_iomap); |
620242ae MS |
383 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
384 | ||
4a3cba5e MS |
385 | if (!del) |
386 | return; | |
387 | ||
78cdb3ed | 388 | synchronize_rcu(); |
620242ae MS |
389 | iounmap(map->virt); |
390 | kfree(map); | |
1da177e4 | 391 | } |
55a82ab3 | 392 | EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); |
1da177e4 | 393 | |
0d3a9cf5 | 394 | void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size) |
7d97277b YL |
395 | { |
396 | if (!acpi_gbl_permanent_mmap) | |
397 | __acpi_unmap_table(virt, size); | |
398 | } | |
399 | ||
29718521 MS |
400 | int acpi_os_map_generic_address(struct acpi_generic_address *addr) |
401 | { | |
402 | void __iomem *virt; | |
403 | ||
404 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) | |
405 | return 0; | |
406 | ||
407 | if (!addr->address || !addr->bit_width) | |
408 | return -EINVAL; | |
409 | ||
410 | virt = acpi_os_map_memory(addr->address, addr->bit_width / 8); | |
411 | if (!virt) | |
412 | return -EIO; | |
413 | ||
414 | return 0; | |
415 | } | |
416 | EXPORT_SYMBOL_GPL(acpi_os_map_generic_address); | |
417 | ||
418 | void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) | |
419 | { | |
420 | void __iomem *virt; | |
421 | unsigned long flags; | |
422 | acpi_size size = addr->bit_width / 8; | |
423 | ||
424 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) | |
425 | return; | |
426 | ||
427 | if (!addr->address || !addr->bit_width) | |
428 | return; | |
429 | ||
430 | spin_lock_irqsave(&acpi_ioremap_lock, flags); | |
431 | virt = acpi_map_vaddr_lookup(addr->address, size); | |
432 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); | |
433 | ||
434 | acpi_os_unmap_memory(virt, size); | |
435 | } | |
436 | EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address); | |
437 | ||
1da177e4 LT |
438 | #ifdef ACPI_FUTURE_USAGE |
439 | acpi_status | |
4be44fcd | 440 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
1da177e4 | 441 | { |
4be44fcd | 442 | if (!phys || !virt) |
1da177e4 LT |
443 | return AE_BAD_PARAMETER; |
444 | ||
445 | *phys = virt_to_phys(virt); | |
446 | ||
447 | return AE_OK; | |
448 | } | |
449 | #endif | |
450 | ||
451 | #define ACPI_MAX_OVERRIDE_LEN 100 | |
452 | ||
453 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; | |
454 | ||
455 | acpi_status | |
4be44fcd LB |
456 | acpi_os_predefined_override(const struct acpi_predefined_names *init_val, |
457 | acpi_string * new_val) | |
1da177e4 LT |
458 | { |
459 | if (!init_val || !new_val) | |
460 | return AE_BAD_PARAMETER; | |
461 | ||
462 | *new_val = NULL; | |
4be44fcd | 463 | if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { |
1da177e4 | 464 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", |
4be44fcd | 465 | acpi_os_name); |
1da177e4 LT |
466 | *new_val = acpi_os_name; |
467 | } | |
468 | ||
469 | return AE_OK; | |
470 | } | |
471 | ||
472 | acpi_status | |
4be44fcd LB |
473 | acpi_os_table_override(struct acpi_table_header * existing_table, |
474 | struct acpi_table_header ** new_table) | |
1da177e4 LT |
475 | { |
476 | if (!existing_table || !new_table) | |
477 | return AE_BAD_PARAMETER; | |
478 | ||
71fc47a9 MG |
479 | *new_table = NULL; |
480 | ||
1da177e4 LT |
481 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
482 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) | |
4be44fcd | 483 | *new_table = (struct acpi_table_header *)AmlCode; |
1da177e4 | 484 | #endif |
6ed31e92 ÉP |
485 | if (*new_table != NULL) { |
486 | printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " | |
487 | "this is unsafe: tainting kernel\n", | |
488 | existing_table->signature, | |
489 | existing_table->oem_table_id); | |
490 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); | |
491 | } | |
1da177e4 LT |
492 | return AE_OK; |
493 | } | |
494 | ||
7d12e780 | 495 | static irqreturn_t acpi_irq(int irq, void *dev_id) |
1da177e4 | 496 | { |
5229e87d LB |
497 | u32 handled; |
498 | ||
499 | handled = (*acpi_irq_handler) (acpi_irq_context); | |
500 | ||
501 | if (handled) { | |
502 | acpi_irq_handled++; | |
503 | return IRQ_HANDLED; | |
88bea188 LB |
504 | } else { |
505 | acpi_irq_not_handled++; | |
5229e87d | 506 | return IRQ_NONE; |
88bea188 | 507 | } |
1da177e4 LT |
508 | } |
509 | ||
510 | acpi_status | |
4be44fcd LB |
511 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, |
512 | void *context) | |
1da177e4 LT |
513 | { |
514 | unsigned int irq; | |
515 | ||
5229e87d LB |
516 | acpi_irq_stats_init(); |
517 | ||
1da177e4 LT |
518 | /* |
519 | * Ignore the GSI from the core, and use the value in our copy of the | |
520 | * FADT. It may not be the same if an interrupt source override exists | |
521 | * for the SCI. | |
522 | */ | |
cee324b1 | 523 | gsi = acpi_gbl_FADT.sci_interrupt; |
1da177e4 LT |
524 | if (acpi_gsi_to_irq(gsi, &irq) < 0) { |
525 | printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", | |
526 | gsi); | |
527 | return AE_OK; | |
528 | } | |
529 | ||
530 | acpi_irq_handler = handler; | |
531 | acpi_irq_context = context; | |
dace1453 | 532 | if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { |
1da177e4 LT |
533 | printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); |
534 | return AE_NOT_ACQUIRED; | |
535 | } | |
536 | acpi_irq_irq = irq; | |
537 | ||
538 | return AE_OK; | |
539 | } | |
540 | ||
4be44fcd | 541 | acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) |
1da177e4 LT |
542 | { |
543 | if (irq) { | |
544 | free_irq(irq, acpi_irq); | |
545 | acpi_irq_handler = NULL; | |
546 | acpi_irq_irq = 0; | |
547 | } | |
548 | ||
549 | return AE_OK; | |
550 | } | |
551 | ||
552 | /* | |
553 | * Running in interpreter thread context, safe to sleep | |
554 | */ | |
555 | ||
439913ff | 556 | void acpi_os_sleep(u64 ms) |
1da177e4 | 557 | { |
01a527ec | 558 | schedule_timeout_interruptible(msecs_to_jiffies(ms)); |
1da177e4 | 559 | } |
4be44fcd | 560 | |
4be44fcd | 561 | void acpi_os_stall(u32 us) |
1da177e4 LT |
562 | { |
563 | while (us) { | |
564 | u32 delay = 1000; | |
565 | ||
566 | if (delay > us) | |
567 | delay = us; | |
568 | udelay(delay); | |
569 | touch_nmi_watchdog(); | |
570 | us -= delay; | |
571 | } | |
572 | } | |
4be44fcd | 573 | |
1da177e4 LT |
574 | /* |
575 | * Support ACPI 3.0 AML Timer operand | |
576 | * Returns 64-bit free-running, monotonically increasing timer | |
577 | * with 100ns granularity | |
578 | */ | |
4be44fcd | 579 | u64 acpi_os_get_timer(void) |
1da177e4 LT |
580 | { |
581 | static u64 t; | |
582 | ||
583 | #ifdef CONFIG_HPET | |
584 | /* TBD: use HPET if available */ | |
585 | #endif | |
586 | ||
587 | #ifdef CONFIG_X86_PM_TIMER | |
588 | /* TBD: default to PM timer if HPET was not available */ | |
589 | #endif | |
590 | if (!t) | |
591 | printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n"); | |
592 | ||
593 | return ++t; | |
594 | } | |
595 | ||
4be44fcd | 596 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
1da177e4 LT |
597 | { |
598 | u32 dummy; | |
599 | ||
600 | if (!value) | |
601 | value = &dummy; | |
602 | ||
49fbabf5 ZY |
603 | *value = 0; |
604 | if (width <= 8) { | |
4be44fcd | 605 | *(u8 *) value = inb(port); |
49fbabf5 | 606 | } else if (width <= 16) { |
4be44fcd | 607 | *(u16 *) value = inw(port); |
49fbabf5 | 608 | } else if (width <= 32) { |
4be44fcd | 609 | *(u32 *) value = inl(port); |
49fbabf5 | 610 | } else { |
1da177e4 LT |
611 | BUG(); |
612 | } | |
613 | ||
614 | return AE_OK; | |
615 | } | |
4be44fcd | 616 | |
1da177e4 LT |
617 | EXPORT_SYMBOL(acpi_os_read_port); |
618 | ||
4be44fcd | 619 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
1da177e4 | 620 | { |
49fbabf5 | 621 | if (width <= 8) { |
1da177e4 | 622 | outb(value, port); |
49fbabf5 | 623 | } else if (width <= 16) { |
1da177e4 | 624 | outw(value, port); |
49fbabf5 | 625 | } else if (width <= 32) { |
1da177e4 | 626 | outl(value, port); |
49fbabf5 | 627 | } else { |
1da177e4 LT |
628 | BUG(); |
629 | } | |
630 | ||
631 | return AE_OK; | |
632 | } | |
4be44fcd | 633 | |
1da177e4 LT |
634 | EXPORT_SYMBOL(acpi_os_write_port); |
635 | ||
636 | acpi_status | |
4be44fcd | 637 | acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) |
1da177e4 | 638 | { |
4be44fcd | 639 | void __iomem *virt_addr; |
884b821f RW |
640 | unsigned int size = width / 8; |
641 | bool unmap = false; | |
642 | u32 dummy; | |
620242ae | 643 | |
78cdb3ed | 644 | rcu_read_lock(); |
620242ae | 645 | virt_addr = acpi_map_vaddr_lookup(phys_addr, size); |
620242ae | 646 | if (!virt_addr) { |
884b821f | 647 | rcu_read_unlock(); |
2d6d9fd3 | 648 | virt_addr = acpi_os_ioremap(phys_addr, size); |
884b821f RW |
649 | if (!virt_addr) |
650 | return AE_BAD_ADDRESS; | |
651 | unmap = true; | |
620242ae | 652 | } |
884b821f | 653 | |
1da177e4 LT |
654 | if (!value) |
655 | value = &dummy; | |
656 | ||
657 | switch (width) { | |
658 | case 8: | |
4be44fcd | 659 | *(u8 *) value = readb(virt_addr); |
1da177e4 LT |
660 | break; |
661 | case 16: | |
4be44fcd | 662 | *(u16 *) value = readw(virt_addr); |
1da177e4 LT |
663 | break; |
664 | case 32: | |
4be44fcd | 665 | *(u32 *) value = readl(virt_addr); |
1da177e4 LT |
666 | break; |
667 | default: | |
668 | BUG(); | |
669 | } | |
670 | ||
620242ae MS |
671 | if (unmap) |
672 | iounmap(virt_addr); | |
884b821f RW |
673 | else |
674 | rcu_read_unlock(); | |
1da177e4 LT |
675 | |
676 | return AE_OK; | |
677 | } | |
678 | ||
679 | acpi_status | |
4be44fcd | 680 | acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) |
1da177e4 | 681 | { |
4be44fcd | 682 | void __iomem *virt_addr; |
884b821f RW |
683 | unsigned int size = width / 8; |
684 | bool unmap = false; | |
620242ae | 685 | |
78cdb3ed | 686 | rcu_read_lock(); |
620242ae | 687 | virt_addr = acpi_map_vaddr_lookup(phys_addr, size); |
620242ae | 688 | if (!virt_addr) { |
884b821f | 689 | rcu_read_unlock(); |
2d6d9fd3 | 690 | virt_addr = acpi_os_ioremap(phys_addr, size); |
884b821f RW |
691 | if (!virt_addr) |
692 | return AE_BAD_ADDRESS; | |
693 | unmap = true; | |
620242ae | 694 | } |
1da177e4 LT |
695 | |
696 | switch (width) { | |
697 | case 8: | |
698 | writeb(value, virt_addr); | |
699 | break; | |
700 | case 16: | |
701 | writew(value, virt_addr); | |
702 | break; | |
703 | case 32: | |
704 | writel(value, virt_addr); | |
705 | break; | |
706 | default: | |
707 | BUG(); | |
708 | } | |
709 | ||
620242ae MS |
710 | if (unmap) |
711 | iounmap(virt_addr); | |
884b821f RW |
712 | else |
713 | rcu_read_unlock(); | |
1da177e4 LT |
714 | |
715 | return AE_OK; | |
716 | } | |
717 | ||
1da177e4 | 718 | acpi_status |
4be44fcd | 719 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
c5f0231e | 720 | u64 *value, u32 width) |
1da177e4 LT |
721 | { |
722 | int result, size; | |
c5f0231e | 723 | u32 value32; |
1da177e4 LT |
724 | |
725 | if (!value) | |
726 | return AE_BAD_PARAMETER; | |
727 | ||
728 | switch (width) { | |
729 | case 8: | |
730 | size = 1; | |
731 | break; | |
732 | case 16: | |
733 | size = 2; | |
734 | break; | |
735 | case 32: | |
736 | size = 4; | |
737 | break; | |
738 | default: | |
739 | return AE_ERROR; | |
740 | } | |
741 | ||
b6ce068a MW |
742 | result = raw_pci_read(pci_id->segment, pci_id->bus, |
743 | PCI_DEVFN(pci_id->device, pci_id->function), | |
c5f0231e BM |
744 | reg, size, &value32); |
745 | *value = value32; | |
1da177e4 LT |
746 | |
747 | return (result ? AE_ERROR : AE_OK); | |
748 | } | |
4be44fcd | 749 | |
1da177e4 | 750 | acpi_status |
4be44fcd | 751 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
439913ff | 752 | u64 value, u32 width) |
1da177e4 LT |
753 | { |
754 | int result, size; | |
755 | ||
756 | switch (width) { | |
757 | case 8: | |
758 | size = 1; | |
759 | break; | |
760 | case 16: | |
761 | size = 2; | |
762 | break; | |
763 | case 32: | |
764 | size = 4; | |
765 | break; | |
766 | default: | |
767 | return AE_ERROR; | |
768 | } | |
769 | ||
b6ce068a MW |
770 | result = raw_pci_write(pci_id->segment, pci_id->bus, |
771 | PCI_DEVFN(pci_id->device, pci_id->function), | |
772 | reg, size, value); | |
1da177e4 LT |
773 | |
774 | return (result ? AE_ERROR : AE_OK); | |
775 | } | |
776 | ||
65f27f38 | 777 | static void acpi_os_execute_deferred(struct work_struct *work) |
88db5e14 AS |
778 | { |
779 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | |
88db5e14 | 780 | |
9ac61856 BH |
781 | if (dpc->wait) |
782 | acpi_os_wait_events_complete(NULL); | |
19cd847a ZR |
783 | |
784 | dpc->function(dpc->context); | |
785 | kfree(dpc); | |
19cd847a ZR |
786 | } |
787 | ||
b8d35192 AS |
788 | /******************************************************************************* |
789 | * | |
790 | * FUNCTION: acpi_os_execute | |
791 | * | |
792 | * PARAMETERS: Type - Type of the callback | |
793 | * Function - Function to be executed | |
794 | * Context - Function parameters | |
795 | * | |
796 | * RETURN: Status | |
797 | * | |
798 | * DESCRIPTION: Depending on type, either queues function for deferred execution or | |
799 | * immediately executes function on a separate thread. | |
800 | * | |
801 | ******************************************************************************/ | |
802 | ||
19cd847a ZR |
803 | static acpi_status __acpi_os_execute(acpi_execute_type type, |
804 | acpi_osd_exec_callback function, void *context, int hp) | |
1da177e4 | 805 | { |
4be44fcd LB |
806 | acpi_status status = AE_OK; |
807 | struct acpi_os_dpc *dpc; | |
17bc54ee | 808 | struct workqueue_struct *queue; |
19cd847a | 809 | int ret; |
72945b2b LB |
810 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
811 | "Scheduling function [%p(%p)] for deferred execution.\n", | |
812 | function, context)); | |
1da177e4 | 813 | |
1da177e4 LT |
814 | /* |
815 | * Allocate/initialize DPC structure. Note that this memory will be | |
65f27f38 | 816 | * freed by the callee. The kernel handles the work_struct list in a |
1da177e4 LT |
817 | * way that allows us to also free its memory inside the callee. |
818 | * Because we may want to schedule several tasks with different | |
819 | * parameters we can't use the approach some kernel code uses of | |
65f27f38 | 820 | * having a static work_struct. |
1da177e4 | 821 | */ |
72945b2b | 822 | |
65f27f38 | 823 | dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); |
1da177e4 | 824 | if (!dpc) |
889c78be | 825 | return AE_NO_MEMORY; |
b976fe19 | 826 | |
1da177e4 LT |
827 | dpc->function = function; |
828 | dpc->context = context; | |
b976fe19 | 829 | |
c02256be ZR |
830 | /* |
831 | * We can't run hotplug code in keventd_wq/kacpid_wq/kacpid_notify_wq | |
832 | * because the hotplug code may call driver .remove() functions, | |
833 | * which invoke flush_scheduled_work/acpi_os_wait_events_complete | |
834 | * to flush these workqueues. | |
835 | */ | |
836 | queue = hp ? kacpi_hotplug_wq : | |
837 | (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); | |
9ac61856 | 838 | dpc->wait = hp ? 1 : 0; |
bc73675b ZR |
839 | |
840 | if (queue == kacpi_hotplug_wq) | |
841 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | |
842 | else if (queue == kacpi_notify_wq) | |
843 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | |
844 | else | |
845 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | |
846 | ||
8fec62b2 TH |
847 | /* |
848 | * On some machines, a software-initiated SMI causes corruption unless | |
849 | * the SMI runs on CPU 0. An SMI can be initiated by any AML, but | |
850 | * typically it's done in GPE-related methods that are run via | |
851 | * workqueues, so we can avoid the known corruption cases by always | |
852 | * queueing on CPU 0. | |
853 | */ | |
854 | ret = queue_work_on(0, queue, &dpc->work); | |
19cd847a ZR |
855 | |
856 | if (!ret) { | |
55ac9a01 LM |
857 | printk(KERN_ERR PREFIX |
858 | "Call to queue_work() failed.\n"); | |
17bc54ee AS |
859 | status = AE_ERROR; |
860 | kfree(dpc); | |
1da177e4 | 861 | } |
889c78be | 862 | return status; |
1da177e4 | 863 | } |
4be44fcd | 864 | |
19cd847a ZR |
865 | acpi_status acpi_os_execute(acpi_execute_type type, |
866 | acpi_osd_exec_callback function, void *context) | |
867 | { | |
868 | return __acpi_os_execute(type, function, context, 0); | |
869 | } | |
b8d35192 | 870 | EXPORT_SYMBOL(acpi_os_execute); |
1da177e4 | 871 | |
19cd847a ZR |
872 | acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function, |
873 | void *context) | |
874 | { | |
875 | return __acpi_os_execute(0, function, context, 1); | |
876 | } | |
877 | ||
4be44fcd | 878 | void acpi_os_wait_events_complete(void *context) |
1da177e4 LT |
879 | { |
880 | flush_workqueue(kacpid_wq); | |
2f67a069 | 881 | flush_workqueue(kacpi_notify_wq); |
1da177e4 | 882 | } |
4be44fcd | 883 | |
1da177e4 LT |
884 | EXPORT_SYMBOL(acpi_os_wait_events_complete); |
885 | ||
1da177e4 | 886 | acpi_status |
4be44fcd | 887 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
1da177e4 | 888 | { |
4be44fcd | 889 | struct semaphore *sem = NULL; |
1da177e4 | 890 | |
1da177e4 LT |
891 | sem = acpi_os_allocate(sizeof(struct semaphore)); |
892 | if (!sem) | |
d550d98d | 893 | return AE_NO_MEMORY; |
1da177e4 LT |
894 | memset(sem, 0, sizeof(struct semaphore)); |
895 | ||
896 | sema_init(sem, initial_units); | |
897 | ||
4be44fcd | 898 | *handle = (acpi_handle *) sem; |
1da177e4 | 899 | |
4be44fcd LB |
900 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", |
901 | *handle, initial_units)); | |
1da177e4 | 902 | |
d550d98d | 903 | return AE_OK; |
1da177e4 | 904 | } |
1da177e4 | 905 | |
1da177e4 LT |
906 | /* |
907 | * TODO: A better way to delete semaphores? Linux doesn't have a | |
908 | * 'delete_semaphore()' function -- may result in an invalid | |
909 | * pointer dereference for non-synchronized consumers. Should | |
910 | * we at least check for blocked threads and signal/cancel them? | |
911 | */ | |
912 | ||
4be44fcd | 913 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) |
1da177e4 | 914 | { |
4be44fcd | 915 | struct semaphore *sem = (struct semaphore *)handle; |
1da177e4 | 916 | |
1da177e4 | 917 | if (!sem) |
d550d98d | 918 | return AE_BAD_PARAMETER; |
1da177e4 | 919 | |
4be44fcd | 920 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); |
1da177e4 | 921 | |
f1241c87 | 922 | BUG_ON(!list_empty(&sem->wait_list)); |
02438d87 | 923 | kfree(sem); |
4be44fcd | 924 | sem = NULL; |
1da177e4 | 925 | |
d550d98d | 926 | return AE_OK; |
1da177e4 | 927 | } |
1da177e4 | 928 | |
1da177e4 | 929 | /* |
1da177e4 LT |
930 | * TODO: Support for units > 1? |
931 | */ | |
4be44fcd | 932 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) |
1da177e4 | 933 | { |
4be44fcd LB |
934 | acpi_status status = AE_OK; |
935 | struct semaphore *sem = (struct semaphore *)handle; | |
f1241c87 | 936 | long jiffies; |
4be44fcd | 937 | int ret = 0; |
1da177e4 | 938 | |
1da177e4 | 939 | if (!sem || (units < 1)) |
d550d98d | 940 | return AE_BAD_PARAMETER; |
1da177e4 LT |
941 | |
942 | if (units > 1) | |
d550d98d | 943 | return AE_SUPPORT; |
1da177e4 | 944 | |
4be44fcd LB |
945 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", |
946 | handle, units, timeout)); | |
1da177e4 | 947 | |
f1241c87 MW |
948 | if (timeout == ACPI_WAIT_FOREVER) |
949 | jiffies = MAX_SCHEDULE_TIMEOUT; | |
950 | else | |
951 | jiffies = msecs_to_jiffies(timeout); | |
952 | ||
953 | ret = down_timeout(sem, jiffies); | |
954 | if (ret) | |
955 | status = AE_TIME; | |
1da177e4 LT |
956 | |
957 | if (ACPI_FAILURE(status)) { | |
9e7e2c04 | 958 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
a6fc6720 | 959 | "Failed to acquire semaphore[%p|%d|%d], %s", |
4be44fcd LB |
960 | handle, units, timeout, |
961 | acpi_format_exception(status))); | |
962 | } else { | |
963 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | |
a6fc6720 | 964 | "Acquired semaphore[%p|%d|%d]", handle, |
4be44fcd | 965 | units, timeout)); |
1da177e4 LT |
966 | } |
967 | ||
d550d98d | 968 | return status; |
1da177e4 | 969 | } |
1da177e4 | 970 | |
1da177e4 LT |
971 | /* |
972 | * TODO: Support for units > 1? | |
973 | */ | |
4be44fcd | 974 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) |
1da177e4 | 975 | { |
4be44fcd | 976 | struct semaphore *sem = (struct semaphore *)handle; |
1da177e4 | 977 | |
1da177e4 | 978 | if (!sem || (units < 1)) |
d550d98d | 979 | return AE_BAD_PARAMETER; |
1da177e4 LT |
980 | |
981 | if (units > 1) | |
d550d98d | 982 | return AE_SUPPORT; |
1da177e4 | 983 | |
4be44fcd LB |
984 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, |
985 | units)); | |
1da177e4 LT |
986 | |
987 | up(sem); | |
988 | ||
d550d98d | 989 | return AE_OK; |
1da177e4 | 990 | } |
4be44fcd | 991 | |
1da177e4 | 992 | #ifdef ACPI_FUTURE_USAGE |
4be44fcd | 993 | u32 acpi_os_get_line(char *buffer) |
1da177e4 LT |
994 | { |
995 | ||
996 | #ifdef ENABLE_DEBUGGER | |
997 | if (acpi_in_debugger) { | |
998 | u32 chars; | |
999 | ||
1000 | kdb_read(buffer, sizeof(line_buf)); | |
1001 | ||
1002 | /* remove the CR kdb includes */ | |
1003 | chars = strlen(buffer) - 1; | |
1004 | buffer[chars] = '\0'; | |
1005 | } | |
1006 | #endif | |
1007 | ||
1008 | return 0; | |
1009 | } | |
4be44fcd | 1010 | #endif /* ACPI_FUTURE_USAGE */ |
1da177e4 | 1011 | |
4be44fcd | 1012 | acpi_status acpi_os_signal(u32 function, void *info) |
1da177e4 | 1013 | { |
4be44fcd | 1014 | switch (function) { |
1da177e4 LT |
1015 | case ACPI_SIGNAL_FATAL: |
1016 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); | |
1017 | break; | |
1018 | case ACPI_SIGNAL_BREAKPOINT: | |
1019 | /* | |
1020 | * AML Breakpoint | |
1021 | * ACPI spec. says to treat it as a NOP unless | |
1022 | * you are debugging. So if/when we integrate | |
1023 | * AML debugger into the kernel debugger its | |
1024 | * hook will go here. But until then it is | |
1025 | * not useful to print anything on breakpoints. | |
1026 | */ | |
1027 | break; | |
1028 | default: | |
1029 | break; | |
1030 | } | |
1031 | ||
1032 | return AE_OK; | |
1033 | } | |
4be44fcd | 1034 | |
4be44fcd | 1035 | static int __init acpi_os_name_setup(char *str) |
1da177e4 LT |
1036 | { |
1037 | char *p = acpi_os_name; | |
4be44fcd | 1038 | int count = ACPI_MAX_OVERRIDE_LEN - 1; |
1da177e4 LT |
1039 | |
1040 | if (!str || !*str) | |
1041 | return 0; | |
1042 | ||
1043 | for (; count-- && str && *str; str++) { | |
1044 | if (isalnum(*str) || *str == ' ' || *str == ':') | |
1045 | *p++ = *str; | |
1046 | else if (*str == '\'' || *str == '"') | |
1047 | continue; | |
1048 | else | |
1049 | break; | |
1050 | } | |
1051 | *p = 0; | |
1052 | ||
1053 | return 1; | |
4be44fcd | 1054 | |
1da177e4 LT |
1055 | } |
1056 | ||
1057 | __setup("acpi_os_name=", acpi_os_name_setup); | |
1058 | ||
12d32064 LM |
1059 | #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ |
1060 | #define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */ | |
1061 | ||
1062 | struct osi_setup_entry { | |
1063 | char string[OSI_STRING_LENGTH_MAX]; | |
1064 | bool enable; | |
1065 | }; | |
1066 | ||
1067 | static struct osi_setup_entry __initdata osi_setup_entries[OSI_STRING_ENTRIES_MAX]; | |
1068 | ||
d90aa92c LM |
1069 | void __init acpi_osi_setup(char *str) |
1070 | { | |
12d32064 LM |
1071 | struct osi_setup_entry *osi; |
1072 | bool enable = true; | |
1073 | int i; | |
1074 | ||
d90aa92c LM |
1075 | if (!acpi_gbl_create_osi_method) |
1076 | return; | |
1077 | ||
1078 | if (str == NULL || *str == '\0') { | |
1079 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); | |
1080 | acpi_gbl_create_osi_method = FALSE; | |
12d32064 LM |
1081 | return; |
1082 | } | |
1083 | ||
1084 | if (*str == '!') { | |
1085 | str++; | |
1086 | enable = false; | |
1087 | } | |
1088 | ||
1089 | for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { | |
1090 | osi = &osi_setup_entries[i]; | |
1091 | if (!strcmp(osi->string, str)) { | |
1092 | osi->enable = enable; | |
1093 | break; | |
1094 | } else if (osi->string[0] == '\0') { | |
1095 | osi->enable = enable; | |
1096 | strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); | |
1097 | break; | |
1098 | } | |
1099 | } | |
d90aa92c LM |
1100 | } |
1101 | ||
d4b7dc49 LB |
1102 | static void __init set_osi_linux(unsigned int enable) |
1103 | { | |
d90aa92c | 1104 | if (osi_linux.enable != enable) |
d4b7dc49 | 1105 | osi_linux.enable = enable; |
b0ed7a91 LM |
1106 | |
1107 | if (osi_linux.enable) | |
1108 | acpi_osi_setup("Linux"); | |
1109 | else | |
1110 | acpi_osi_setup("!Linux"); | |
1111 | ||
d4b7dc49 LB |
1112 | return; |
1113 | } | |
1114 | ||
1115 | static void __init acpi_cmdline_osi_linux(unsigned int enable) | |
1116 | { | |
d90aa92c LM |
1117 | osi_linux.cmdline = 1; /* cmdline set the default and override DMI */ |
1118 | osi_linux.dmi = 0; | |
d4b7dc49 LB |
1119 | set_osi_linux(enable); |
1120 | ||
1121 | return; | |
1122 | } | |
1123 | ||
1124 | void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) | |
1125 | { | |
d4b7dc49 LB |
1126 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); |
1127 | ||
1128 | if (enable == -1) | |
1129 | return; | |
1130 | ||
d90aa92c | 1131 | osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ |
d4b7dc49 | 1132 | set_osi_linux(enable); |
f507654d | 1133 | |
f507654d LB |
1134 | return; |
1135 | } | |
1136 | ||
1da177e4 | 1137 | /* |
ae00d812 LB |
1138 | * Modify the list of "OS Interfaces" reported to BIOS via _OSI |
1139 | * | |
1da177e4 | 1140 | * empty string disables _OSI |
ae00d812 LB |
1141 | * string starting with '!' disables that string |
1142 | * otherwise string is added to list, augmenting built-in strings | |
1da177e4 | 1143 | */ |
b0ed7a91 | 1144 | static void __init acpi_osi_setup_late(void) |
1da177e4 | 1145 | { |
12d32064 LM |
1146 | struct osi_setup_entry *osi; |
1147 | char *str; | |
1148 | int i; | |
d90aa92c | 1149 | acpi_status status; |
b0ed7a91 | 1150 | |
12d32064 LM |
1151 | for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { |
1152 | osi = &osi_setup_entries[i]; | |
1153 | str = osi->string; | |
b0ed7a91 | 1154 | |
12d32064 LM |
1155 | if (*str == '\0') |
1156 | break; | |
1157 | if (osi->enable) { | |
1158 | status = acpi_install_interface(str); | |
d90aa92c | 1159 | |
12d32064 LM |
1160 | if (ACPI_SUCCESS(status)) |
1161 | printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); | |
1162 | } else { | |
1163 | status = acpi_remove_interface(str); | |
d90aa92c | 1164 | |
12d32064 LM |
1165 | if (ACPI_SUCCESS(status)) |
1166 | printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); | |
1167 | } | |
b0ed7a91 LM |
1168 | } |
1169 | } | |
1170 | ||
d90aa92c | 1171 | static int __init osi_setup(char *str) |
b0ed7a91 | 1172 | { |
d90aa92c LM |
1173 | if (str && !strcmp("Linux", str)) |
1174 | acpi_cmdline_osi_linux(1); | |
1175 | else if (str && !strcmp("!Linux", str)) | |
1176 | acpi_cmdline_osi_linux(0); | |
1177 | else | |
1178 | acpi_osi_setup(str); | |
1da177e4 LT |
1179 | |
1180 | return 1; | |
1181 | } | |
1182 | ||
d90aa92c | 1183 | __setup("acpi_osi=", osi_setup); |
1da177e4 LT |
1184 | |
1185 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ | |
4be44fcd | 1186 | static int __init acpi_serialize_setup(char *str) |
1da177e4 LT |
1187 | { |
1188 | printk(KERN_INFO PREFIX "serialize enabled\n"); | |
1189 | ||
1190 | acpi_gbl_all_methods_serialized = TRUE; | |
1191 | ||
1192 | return 1; | |
1193 | } | |
1194 | ||
1195 | __setup("acpi_serialize", acpi_serialize_setup); | |
1196 | ||
df92e695 TR |
1197 | /* Check of resource interference between native drivers and ACPI |
1198 | * OperationRegions (SystemIO and System Memory only). | |
1199 | * IO ports and memory declared in ACPI might be used by the ACPI subsystem | |
1200 | * in arbitrary AML code and can interfere with legacy drivers. | |
1201 | * acpi_enforce_resources= can be set to: | |
1202 | * | |
7e90560c | 1203 | * - strict (default) (2) |
df92e695 | 1204 | * -> further driver trying to access the resources will not load |
7e90560c | 1205 | * - lax (1) |
df92e695 TR |
1206 | * -> further driver trying to access the resources will load, but you |
1207 | * get a system message that something might go wrong... | |
1208 | * | |
1209 | * - no (0) | |
1210 | * -> ACPI Operation Region resources will not be registered | |
1211 | * | |
1212 | */ | |
1213 | #define ENFORCE_RESOURCES_STRICT 2 | |
1214 | #define ENFORCE_RESOURCES_LAX 1 | |
1215 | #define ENFORCE_RESOURCES_NO 0 | |
1216 | ||
7e90560c | 1217 | static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; |
df92e695 TR |
1218 | |
1219 | static int __init acpi_enforce_resources_setup(char *str) | |
1220 | { | |
1221 | if (str == NULL || *str == '\0') | |
1222 | return 0; | |
1223 | ||
1224 | if (!strcmp("strict", str)) | |
1225 | acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; | |
1226 | else if (!strcmp("lax", str)) | |
1227 | acpi_enforce_resources = ENFORCE_RESOURCES_LAX; | |
1228 | else if (!strcmp("no", str)) | |
1229 | acpi_enforce_resources = ENFORCE_RESOURCES_NO; | |
1230 | ||
1231 | return 1; | |
1232 | } | |
1233 | ||
1234 | __setup("acpi_enforce_resources=", acpi_enforce_resources_setup); | |
1235 | ||
1236 | /* Check for resource conflicts between ACPI OperationRegions and native | |
1237 | * drivers */ | |
876fba43 | 1238 | int acpi_check_resource_conflict(const struct resource *res) |
df92e695 TR |
1239 | { |
1240 | struct acpi_res_list *res_list_elem; | |
106d1a0a | 1241 | int ioport = 0, clash = 0; |
df92e695 TR |
1242 | |
1243 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) | |
1244 | return 0; | |
1245 | if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) | |
1246 | return 0; | |
1247 | ||
1248 | ioport = res->flags & IORESOURCE_IO; | |
1249 | ||
1250 | spin_lock(&acpi_res_lock); | |
1251 | list_for_each_entry(res_list_elem, &resource_list_head, | |
1252 | resource_list) { | |
1253 | if (ioport && (res_list_elem->resource_type | |
1254 | != ACPI_ADR_SPACE_SYSTEM_IO)) | |
1255 | continue; | |
1256 | if (!ioport && (res_list_elem->resource_type | |
1257 | != ACPI_ADR_SPACE_SYSTEM_MEMORY)) | |
1258 | continue; | |
1259 | ||
1260 | if (res->end < res_list_elem->start | |
1261 | || res_list_elem->end < res->start) | |
1262 | continue; | |
1263 | clash = 1; | |
1264 | break; | |
1265 | } | |
1266 | spin_unlock(&acpi_res_lock); | |
1267 | ||
1268 | if (clash) { | |
1269 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { | |
1638bca8 | 1270 | printk(KERN_WARNING "ACPI: resource %s %pR" |
106d1a0a TR |
1271 | " conflicts with ACPI region %s " |
1272 | "[%s 0x%zx-0x%zx]\n", | |
1638bca8 | 1273 | res->name, res, res_list_elem->name, |
106d1a0a TR |
1274 | (res_list_elem->resource_type == |
1275 | ACPI_ADR_SPACE_SYSTEM_IO) ? "io" : "mem", | |
1276 | (size_t) res_list_elem->start, | |
1277 | (size_t) res_list_elem->end); | |
14f03343 JD |
1278 | if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) |
1279 | printk(KERN_NOTICE "ACPI: This conflict may" | |
1280 | " cause random problems and system" | |
1281 | " instability\n"); | |
1282 | printk(KERN_INFO "ACPI: If an ACPI driver is available" | |
1283 | " for this device, you should use it instead of" | |
1284 | " the native driver\n"); | |
df92e695 TR |
1285 | } |
1286 | if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT) | |
1287 | return -EBUSY; | |
1288 | } | |
1289 | return 0; | |
1290 | } | |
443dea72 | 1291 | EXPORT_SYMBOL(acpi_check_resource_conflict); |
df92e695 TR |
1292 | |
1293 | int acpi_check_region(resource_size_t start, resource_size_t n, | |
1294 | const char *name) | |
1295 | { | |
1296 | struct resource res = { | |
1297 | .start = start, | |
1298 | .end = start + n - 1, | |
1299 | .name = name, | |
1300 | .flags = IORESOURCE_IO, | |
1301 | }; | |
1302 | ||
1303 | return acpi_check_resource_conflict(&res); | |
1304 | } | |
1305 | EXPORT_SYMBOL(acpi_check_region); | |
1306 | ||
70dd6bea JD |
1307 | /* |
1308 | * Let drivers know whether the resource checks are effective | |
1309 | */ | |
1310 | int acpi_resources_are_enforced(void) | |
1311 | { | |
1312 | return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT; | |
1313 | } | |
1314 | EXPORT_SYMBOL(acpi_resources_are_enforced); | |
1315 | ||
9f63b88b LM |
1316 | /* |
1317 | * Create and initialize a spinlock. | |
1318 | */ | |
1319 | acpi_status | |
1320 | acpi_os_create_lock(acpi_spinlock *out_handle) | |
1321 | { | |
1322 | spinlock_t *lock; | |
1323 | ||
1324 | lock = ACPI_ALLOCATE(sizeof(spinlock_t)); | |
1325 | if (!lock) | |
1326 | return AE_NO_MEMORY; | |
1327 | spin_lock_init(lock); | |
1328 | *out_handle = lock; | |
1329 | ||
1330 | return AE_OK; | |
1331 | } | |
1332 | ||
1333 | /* | |
1334 | * Deallocate the memory for a spinlock. | |
1335 | */ | |
1336 | void acpi_os_delete_lock(acpi_spinlock handle) | |
1337 | { | |
1338 | ACPI_FREE(handle); | |
1339 | } | |
1340 | ||
73459f73 RM |
1341 | /* |
1342 | * Acquire a spinlock. | |
1343 | * | |
1344 | * handle is a pointer to the spinlock_t. | |
73459f73 RM |
1345 | */ |
1346 | ||
967440e3 | 1347 | acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) |
73459f73 | 1348 | { |
b8e4d893 | 1349 | acpi_cpu_flags flags; |
967440e3 | 1350 | spin_lock_irqsave(lockp, flags); |
73459f73 RM |
1351 | return flags; |
1352 | } | |
1353 | ||
1354 | /* | |
1355 | * Release a spinlock. See above. | |
1356 | */ | |
1357 | ||
967440e3 | 1358 | void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags) |
73459f73 | 1359 | { |
967440e3 | 1360 | spin_unlock_irqrestore(lockp, flags); |
73459f73 RM |
1361 | } |
1362 | ||
73459f73 RM |
1363 | #ifndef ACPI_USE_LOCAL_CACHE |
1364 | ||
1365 | /******************************************************************************* | |
1366 | * | |
1367 | * FUNCTION: acpi_os_create_cache | |
1368 | * | |
b229cf92 BM |
1369 | * PARAMETERS: name - Ascii name for the cache |
1370 | * size - Size of each cached object | |
1371 | * depth - Maximum depth of the cache (in objects) <ignored> | |
1372 | * cache - Where the new cache object is returned | |
73459f73 | 1373 | * |
b229cf92 | 1374 | * RETURN: status |
73459f73 RM |
1375 | * |
1376 | * DESCRIPTION: Create a cache object | |
1377 | * | |
1378 | ******************************************************************************/ | |
1379 | ||
1380 | acpi_status | |
4be44fcd | 1381 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) |
73459f73 | 1382 | { |
20c2df83 | 1383 | *cache = kmem_cache_create(name, size, 0, 0, NULL); |
a6fdbf90 | 1384 | if (*cache == NULL) |
b229cf92 BM |
1385 | return AE_ERROR; |
1386 | else | |
1387 | return AE_OK; | |
73459f73 RM |
1388 | } |
1389 | ||
1390 | /******************************************************************************* | |
1391 | * | |
1392 | * FUNCTION: acpi_os_purge_cache | |
1393 | * | |
1394 | * PARAMETERS: Cache - Handle to cache object | |
1395 | * | |
1396 | * RETURN: Status | |
1397 | * | |
1398 | * DESCRIPTION: Free all objects within the requested cache. | |
1399 | * | |
1400 | ******************************************************************************/ | |
1401 | ||
4be44fcd | 1402 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) |
73459f73 | 1403 | { |
50dd0969 | 1404 | kmem_cache_shrink(cache); |
4be44fcd | 1405 | return (AE_OK); |
73459f73 RM |
1406 | } |
1407 | ||
1408 | /******************************************************************************* | |
1409 | * | |
1410 | * FUNCTION: acpi_os_delete_cache | |
1411 | * | |
1412 | * PARAMETERS: Cache - Handle to cache object | |
1413 | * | |
1414 | * RETURN: Status | |
1415 | * | |
1416 | * DESCRIPTION: Free all objects within the requested cache and delete the | |
1417 | * cache object. | |
1418 | * | |
1419 | ******************************************************************************/ | |
1420 | ||
4be44fcd | 1421 | acpi_status acpi_os_delete_cache(acpi_cache_t * cache) |
73459f73 | 1422 | { |
1a1d92c1 | 1423 | kmem_cache_destroy(cache); |
4be44fcd | 1424 | return (AE_OK); |
73459f73 RM |
1425 | } |
1426 | ||
1427 | /******************************************************************************* | |
1428 | * | |
1429 | * FUNCTION: acpi_os_release_object | |
1430 | * | |
1431 | * PARAMETERS: Cache - Handle to cache object | |
1432 | * Object - The object to be released | |
1433 | * | |
1434 | * RETURN: None | |
1435 | * | |
1436 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | |
1437 | * the object is deleted. | |
1438 | * | |
1439 | ******************************************************************************/ | |
1440 | ||
4be44fcd | 1441 | acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) |
73459f73 | 1442 | { |
4be44fcd LB |
1443 | kmem_cache_free(cache, object); |
1444 | return (AE_OK); | |
73459f73 RM |
1445 | } |
1446 | ||
a5fe1a03 LM |
1447 | static inline int acpi_res_list_add(struct acpi_res_list *res) |
1448 | { | |
1449 | struct acpi_res_list *res_list_elem; | |
1450 | ||
1451 | list_for_each_entry(res_list_elem, &resource_list_head, | |
1452 | resource_list) { | |
1453 | ||
1454 | if (res->resource_type == res_list_elem->resource_type && | |
1455 | res->start == res_list_elem->start && | |
1456 | res->end == res_list_elem->end) { | |
1457 | ||
1458 | /* | |
1459 | * The Region(addr,len) already exist in the list, | |
1460 | * just increase the count | |
1461 | */ | |
1462 | ||
1463 | res_list_elem->count++; | |
1464 | return 0; | |
1465 | } | |
1466 | } | |
1467 | ||
1468 | res->count = 1; | |
1469 | list_add(&res->resource_list, &resource_list_head); | |
1470 | return 1; | |
1471 | } | |
1472 | ||
1473 | static inline void acpi_res_list_del(struct acpi_res_list *res) | |
1474 | { | |
1475 | struct acpi_res_list *res_list_elem; | |
1476 | ||
1477 | list_for_each_entry(res_list_elem, &resource_list_head, | |
1478 | resource_list) { | |
1479 | ||
1480 | if (res->resource_type == res_list_elem->resource_type && | |
1481 | res->start == res_list_elem->start && | |
1482 | res->end == res_list_elem->end) { | |
1483 | ||
1484 | /* | |
1485 | * If the res count is decreased to 0, | |
1486 | * remove and free it | |
1487 | */ | |
1488 | ||
1489 | if (--res_list_elem->count == 0) { | |
1490 | list_del(&res_list_elem->resource_list); | |
1491 | kfree(res_list_elem); | |
1492 | } | |
1493 | return; | |
1494 | } | |
1495 | } | |
1496 | } | |
1497 | ||
1498 | acpi_status | |
1499 | acpi_os_invalidate_address( | |
1500 | u8 space_id, | |
1501 | acpi_physical_address address, | |
1502 | acpi_size length) | |
1503 | { | |
1504 | struct acpi_res_list res; | |
1505 | ||
1506 | switch (space_id) { | |
1507 | case ACPI_ADR_SPACE_SYSTEM_IO: | |
1508 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | |
88393161 | 1509 | /* Only interference checks against SystemIO and SystemMemory |
a5fe1a03 LM |
1510 | are needed */ |
1511 | res.start = address; | |
1512 | res.end = address + length - 1; | |
1513 | res.resource_type = space_id; | |
1514 | spin_lock(&acpi_res_lock); | |
1515 | acpi_res_list_del(&res); | |
1516 | spin_unlock(&acpi_res_lock); | |
1517 | break; | |
1518 | case ACPI_ADR_SPACE_PCI_CONFIG: | |
1519 | case ACPI_ADR_SPACE_EC: | |
1520 | case ACPI_ADR_SPACE_SMBUS: | |
1521 | case ACPI_ADR_SPACE_CMOS: | |
1522 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | |
1523 | case ACPI_ADR_SPACE_DATA_TABLE: | |
1524 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | |
1525 | break; | |
1526 | } | |
1527 | return AE_OK; | |
1528 | } | |
1529 | ||
b229cf92 BM |
1530 | /****************************************************************************** |
1531 | * | |
1532 | * FUNCTION: acpi_os_validate_address | |
1533 | * | |
1534 | * PARAMETERS: space_id - ACPI space ID | |
1535 | * address - Physical address | |
1536 | * length - Address length | |
1537 | * | |
1538 | * RETURN: AE_OK if address/length is valid for the space_id. Otherwise, | |
1539 | * should return AE_AML_ILLEGAL_ADDRESS. | |
1540 | * | |
1541 | * DESCRIPTION: Validate a system address via the host OS. Used to validate | |
1542 | * the addresses accessed by AML operation regions. | |
1543 | * | |
1544 | *****************************************************************************/ | |
1545 | ||
1546 | acpi_status | |
1547 | acpi_os_validate_address ( | |
1548 | u8 space_id, | |
1549 | acpi_physical_address address, | |
df92e695 TR |
1550 | acpi_size length, |
1551 | char *name) | |
b229cf92 | 1552 | { |
df92e695 | 1553 | struct acpi_res_list *res; |
a5fe1a03 | 1554 | int added; |
df92e695 TR |
1555 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) |
1556 | return AE_OK; | |
b229cf92 | 1557 | |
df92e695 TR |
1558 | switch (space_id) { |
1559 | case ACPI_ADR_SPACE_SYSTEM_IO: | |
1560 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | |
88393161 | 1561 | /* Only interference checks against SystemIO and SystemMemory |
df92e695 TR |
1562 | are needed */ |
1563 | res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL); | |
1564 | if (!res) | |
1565 | return AE_OK; | |
1566 | /* ACPI names are fixed to 4 bytes, still better use strlcpy */ | |
1567 | strlcpy(res->name, name, 5); | |
1568 | res->start = address; | |
1569 | res->end = address + length - 1; | |
1570 | res->resource_type = space_id; | |
1571 | spin_lock(&acpi_res_lock); | |
a5fe1a03 | 1572 | added = acpi_res_list_add(res); |
df92e695 | 1573 | spin_unlock(&acpi_res_lock); |
a5fe1a03 LM |
1574 | pr_debug("%s %s resource: start: 0x%llx, end: 0x%llx, " |
1575 | "name: %s\n", added ? "Added" : "Already exist", | |
1576 | (space_id == ACPI_ADR_SPACE_SYSTEM_IO) | |
df92e695 TR |
1577 | ? "SystemIO" : "System Memory", |
1578 | (unsigned long long)res->start, | |
1579 | (unsigned long long)res->end, | |
1580 | res->name); | |
a5fe1a03 LM |
1581 | if (!added) |
1582 | kfree(res); | |
df92e695 TR |
1583 | break; |
1584 | case ACPI_ADR_SPACE_PCI_CONFIG: | |
1585 | case ACPI_ADR_SPACE_EC: | |
1586 | case ACPI_ADR_SPACE_SMBUS: | |
1587 | case ACPI_ADR_SPACE_CMOS: | |
1588 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | |
1589 | case ACPI_ADR_SPACE_DATA_TABLE: | |
1590 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | |
1591 | break; | |
1592 | } | |
1593 | return AE_OK; | |
b229cf92 | 1594 | } |
73459f73 | 1595 | #endif |
d362edaf MS |
1596 | |
1597 | acpi_status __init acpi_os_initialize(void) | |
1598 | { | |
1599 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); | |
1600 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block); | |
1601 | acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block); | |
1602 | acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block); | |
1603 | ||
1604 | return AE_OK; | |
1605 | } | |
1606 | ||
32d47eef | 1607 | acpi_status __init acpi_os_initialize1(void) |
d362edaf MS |
1608 | { |
1609 | kacpid_wq = create_workqueue("kacpid"); | |
1610 | kacpi_notify_wq = create_workqueue("kacpi_notify"); | |
1611 | kacpi_hotplug_wq = create_workqueue("kacpi_hotplug"); | |
1612 | BUG_ON(!kacpid_wq); | |
1613 | BUG_ON(!kacpi_notify_wq); | |
1614 | BUG_ON(!kacpi_hotplug_wq); | |
1bd64d42 LB |
1615 | acpi_install_interface_handler(acpi_osi_handler); |
1616 | acpi_osi_setup_late(); | |
d362edaf MS |
1617 | return AE_OK; |
1618 | } | |
1619 | ||
1620 | acpi_status acpi_os_terminate(void) | |
1621 | { | |
1622 | if (acpi_irq_handler) { | |
1623 | acpi_os_remove_interrupt_handler(acpi_irq_irq, | |
1624 | acpi_irq_handler); | |
1625 | } | |
1626 | ||
1627 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe1_block); | |
1628 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block); | |
1629 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block); | |
1630 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block); | |
1631 | ||
1632 | destroy_workqueue(kacpid_wq); | |
1633 | destroy_workqueue(kacpi_notify_wq); | |
1634 | destroy_workqueue(kacpi_hotplug_wq); | |
1635 | ||
1636 | return AE_OK; | |
1637 | } |