]>
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> | |
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, write to the Free Software | |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 | * | |
24 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
25 | * | |
26 | */ | |
27 | ||
1da177e4 LT |
28 | #include <linux/module.h> |
29 | #include <linux/kernel.h> | |
30 | #include <linux/slab.h> | |
31 | #include <linux/mm.h> | |
32 | #include <linux/pci.h> | |
1da177e4 LT |
33 | #include <linux/interrupt.h> |
34 | #include <linux/kmod.h> | |
35 | #include <linux/delay.h> | |
f507654d | 36 | #include <linux/dmi.h> |
1da177e4 LT |
37 | #include <linux/workqueue.h> |
38 | #include <linux/nmi.h> | |
ad71860a | 39 | #include <linux/acpi.h> |
1da177e4 LT |
40 | #include <acpi/acpi.h> |
41 | #include <asm/io.h> | |
42 | #include <acpi/acpi_bus.h> | |
43 | #include <acpi/processor.h> | |
44 | #include <asm/uaccess.h> | |
45 | ||
46 | #include <linux/efi.h> | |
47 | ||
1da177e4 | 48 | #define _COMPONENT ACPI_OS_SERVICES |
f52fd66d | 49 | ACPI_MODULE_NAME("osl"); |
1da177e4 | 50 | #define PREFIX "ACPI: " |
4be44fcd LB |
51 | struct acpi_os_dpc { |
52 | acpi_osd_exec_callback function; | |
53 | void *context; | |
65f27f38 | 54 | struct work_struct work; |
1da177e4 LT |
55 | }; |
56 | ||
57 | #ifdef CONFIG_ACPI_CUSTOM_DSDT | |
58 | #include CONFIG_ACPI_CUSTOM_DSDT_FILE | |
59 | #endif | |
60 | ||
61 | #ifdef ENABLE_DEBUGGER | |
62 | #include <linux/kdb.h> | |
63 | ||
64 | /* stuff for debugger support */ | |
65 | int acpi_in_debugger; | |
66 | EXPORT_SYMBOL(acpi_in_debugger); | |
67 | ||
68 | extern char line_buf[80]; | |
4be44fcd | 69 | #endif /*ENABLE_DEBUGGER */ |
1da177e4 LT |
70 | |
71 | static unsigned int acpi_irq_irq; | |
72 | static acpi_osd_handler acpi_irq_handler; | |
73 | static void *acpi_irq_context; | |
74 | static struct workqueue_struct *kacpid_wq; | |
88db5e14 | 75 | static struct workqueue_struct *kacpi_notify_wq; |
1da177e4 | 76 | |
ae00d812 LB |
77 | #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ |
78 | static char osi_additional_string[OSI_STRING_LENGTH_MAX]; | |
79 | ||
f507654d | 80 | int osi_linux; /* disable _OSI(Linux) by default */ |
f507654d LB |
81 | |
82 | #ifdef CONFIG_DMI | |
dd272b57 | 83 | static struct __initdata dmi_system_id acpi_osl_dmi_table[]; |
f507654d LB |
84 | #endif |
85 | ||
9a47cdb1 BH |
86 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
87 | unsigned int length, char *desc) | |
88 | { | |
89 | struct resource *res; | |
90 | ||
91 | if (!addr->address || !length) | |
92 | return; | |
93 | ||
eee3c859 | 94 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
9a47cdb1 | 95 | res = request_region(addr->address, length, desc); |
eee3c859 | 96 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) |
9a47cdb1 BH |
97 | res = request_mem_region(addr->address, length, desc); |
98 | } | |
99 | ||
100 | static int __init acpi_reserve_resources(void) | |
101 | { | |
eee3c859 | 102 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, |
9a47cdb1 BH |
103 | "ACPI PM1a_EVT_BLK"); |
104 | ||
eee3c859 | 105 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, |
9a47cdb1 BH |
106 | "ACPI PM1b_EVT_BLK"); |
107 | ||
eee3c859 | 108 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, |
9a47cdb1 BH |
109 | "ACPI PM1a_CNT_BLK"); |
110 | ||
eee3c859 | 111 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, |
9a47cdb1 BH |
112 | "ACPI PM1b_CNT_BLK"); |
113 | ||
eee3c859 LB |
114 | if (acpi_gbl_FADT.pm_timer_length == 4) |
115 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); | |
9a47cdb1 | 116 | |
eee3c859 | 117 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, |
9a47cdb1 BH |
118 | "ACPI PM2_CNT_BLK"); |
119 | ||
120 | /* Length of GPE blocks must be a non-negative multiple of 2 */ | |
121 | ||
eee3c859 LB |
122 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) |
123 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, | |
124 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); | |
9a47cdb1 | 125 | |
eee3c859 LB |
126 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) |
127 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, | |
128 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); | |
9a47cdb1 BH |
129 | |
130 | return 0; | |
131 | } | |
132 | device_initcall(acpi_reserve_resources); | |
133 | ||
dd272b57 | 134 | acpi_status __init acpi_os_initialize(void) |
1da177e4 | 135 | { |
f507654d | 136 | dmi_check_system(acpi_osl_dmi_table); |
1da177e4 LT |
137 | return AE_OK; |
138 | } | |
139 | ||
4be44fcd | 140 | acpi_status acpi_os_initialize1(void) |
1da177e4 LT |
141 | { |
142 | /* | |
143 | * Initialize PCI configuration space access, as we'll need to access | |
144 | * it while walking the namespace (bus 0 and root bridges w/ _BBNs). | |
145 | */ | |
1da177e4 | 146 | if (!raw_pci_ops) { |
4be44fcd LB |
147 | printk(KERN_ERR PREFIX |
148 | "Access to PCI configuration space unavailable\n"); | |
1da177e4 LT |
149 | return AE_NULL_ENTRY; |
150 | } | |
1da177e4 | 151 | kacpid_wq = create_singlethread_workqueue("kacpid"); |
88db5e14 | 152 | kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify"); |
1da177e4 | 153 | BUG_ON(!kacpid_wq); |
88db5e14 | 154 | BUG_ON(!kacpi_notify_wq); |
1da177e4 LT |
155 | return AE_OK; |
156 | } | |
157 | ||
4be44fcd | 158 | acpi_status acpi_os_terminate(void) |
1da177e4 LT |
159 | { |
160 | if (acpi_irq_handler) { | |
161 | acpi_os_remove_interrupt_handler(acpi_irq_irq, | |
162 | acpi_irq_handler); | |
163 | } | |
164 | ||
165 | destroy_workqueue(kacpid_wq); | |
88db5e14 | 166 | destroy_workqueue(kacpi_notify_wq); |
1da177e4 LT |
167 | |
168 | return AE_OK; | |
169 | } | |
170 | ||
4be44fcd | 171 | void acpi_os_printf(const char *fmt, ...) |
1da177e4 LT |
172 | { |
173 | va_list args; | |
174 | va_start(args, fmt); | |
175 | acpi_os_vprintf(fmt, args); | |
176 | va_end(args); | |
177 | } | |
4be44fcd | 178 | |
1da177e4 LT |
179 | EXPORT_SYMBOL(acpi_os_printf); |
180 | ||
4be44fcd | 181 | void acpi_os_vprintf(const char *fmt, va_list args) |
1da177e4 LT |
182 | { |
183 | static char buffer[512]; | |
4be44fcd | 184 | |
1da177e4 LT |
185 | vsprintf(buffer, fmt, args); |
186 | ||
187 | #ifdef ENABLE_DEBUGGER | |
188 | if (acpi_in_debugger) { | |
189 | kdb_printf("%s", buffer); | |
190 | } else { | |
191 | printk("%s", buffer); | |
192 | } | |
193 | #else | |
194 | printk("%s", buffer); | |
195 | #endif | |
196 | } | |
197 | ||
ad71860a | 198 | acpi_physical_address __init acpi_os_get_root_pointer(void) |
1da177e4 LT |
199 | { |
200 | if (efi_enabled) { | |
b2c99e3c | 201 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
ad71860a | 202 | return efi.acpi20; |
b2c99e3c | 203 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
ad71860a | 204 | return efi.acpi; |
1da177e4 | 205 | else { |
4be44fcd LB |
206 | printk(KERN_ERR PREFIX |
207 | "System description tables not found\n"); | |
ad71860a | 208 | return 0; |
1da177e4 | 209 | } |
ad71860a AS |
210 | } else |
211 | return acpi_find_rsdp(); | |
1da177e4 LT |
212 | } |
213 | ||
ad71860a | 214 | void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size) |
1da177e4 | 215 | { |
9f4fd61f BH |
216 | if (phys > ULONG_MAX) { |
217 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); | |
70c0846e | 218 | return NULL; |
1da177e4 | 219 | } |
ad71860a AS |
220 | if (acpi_gbl_permanent_mmap) |
221 | /* | |
222 | * ioremap checks to ensure this is in reserved space | |
223 | */ | |
224 | return ioremap((unsigned long)phys, size); | |
225 | else | |
226 | return __acpi_map_table((unsigned long)phys, size); | |
1da177e4 | 227 | } |
55a82ab3 | 228 | EXPORT_SYMBOL_GPL(acpi_os_map_memory); |
1da177e4 | 229 | |
4be44fcd | 230 | void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) |
1da177e4 | 231 | { |
ad71860a AS |
232 | if (acpi_gbl_permanent_mmap) { |
233 | iounmap(virt); | |
234 | } | |
1da177e4 | 235 | } |
55a82ab3 | 236 | EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); |
1da177e4 LT |
237 | |
238 | #ifdef ACPI_FUTURE_USAGE | |
239 | acpi_status | |
4be44fcd | 240 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
1da177e4 | 241 | { |
4be44fcd | 242 | if (!phys || !virt) |
1da177e4 LT |
243 | return AE_BAD_PARAMETER; |
244 | ||
245 | *phys = virt_to_phys(virt); | |
246 | ||
247 | return AE_OK; | |
248 | } | |
249 | #endif | |
250 | ||
251 | #define ACPI_MAX_OVERRIDE_LEN 100 | |
252 | ||
253 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; | |
254 | ||
255 | acpi_status | |
4be44fcd LB |
256 | acpi_os_predefined_override(const struct acpi_predefined_names *init_val, |
257 | acpi_string * new_val) | |
1da177e4 LT |
258 | { |
259 | if (!init_val || !new_val) | |
260 | return AE_BAD_PARAMETER; | |
261 | ||
262 | *new_val = NULL; | |
4be44fcd | 263 | if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { |
1da177e4 | 264 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", |
4be44fcd | 265 | acpi_os_name); |
1da177e4 LT |
266 | *new_val = acpi_os_name; |
267 | } | |
268 | ||
269 | return AE_OK; | |
270 | } | |
271 | ||
272 | acpi_status | |
4be44fcd LB |
273 | acpi_os_table_override(struct acpi_table_header * existing_table, |
274 | struct acpi_table_header ** new_table) | |
1da177e4 LT |
275 | { |
276 | if (!existing_table || !new_table) | |
277 | return AE_BAD_PARAMETER; | |
278 | ||
279 | #ifdef CONFIG_ACPI_CUSTOM_DSDT | |
280 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) | |
4be44fcd | 281 | *new_table = (struct acpi_table_header *)AmlCode; |
1da177e4 LT |
282 | else |
283 | *new_table = NULL; | |
284 | #else | |
285 | *new_table = NULL; | |
286 | #endif | |
287 | return AE_OK; | |
288 | } | |
289 | ||
7d12e780 | 290 | static irqreturn_t acpi_irq(int irq, void *dev_id) |
1da177e4 | 291 | { |
4be44fcd | 292 | return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; |
1da177e4 LT |
293 | } |
294 | ||
295 | acpi_status | |
4be44fcd LB |
296 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, |
297 | void *context) | |
1da177e4 LT |
298 | { |
299 | unsigned int irq; | |
300 | ||
301 | /* | |
302 | * Ignore the GSI from the core, and use the value in our copy of the | |
303 | * FADT. It may not be the same if an interrupt source override exists | |
304 | * for the SCI. | |
305 | */ | |
cee324b1 | 306 | gsi = acpi_gbl_FADT.sci_interrupt; |
1da177e4 LT |
307 | if (acpi_gsi_to_irq(gsi, &irq) < 0) { |
308 | printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", | |
309 | gsi); | |
310 | return AE_OK; | |
311 | } | |
312 | ||
313 | acpi_irq_handler = handler; | |
314 | acpi_irq_context = context; | |
dace1453 | 315 | if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { |
1da177e4 LT |
316 | printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); |
317 | return AE_NOT_ACQUIRED; | |
318 | } | |
319 | acpi_irq_irq = irq; | |
320 | ||
321 | return AE_OK; | |
322 | } | |
323 | ||
4be44fcd | 324 | acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) |
1da177e4 LT |
325 | { |
326 | if (irq) { | |
327 | free_irq(irq, acpi_irq); | |
328 | acpi_irq_handler = NULL; | |
329 | acpi_irq_irq = 0; | |
330 | } | |
331 | ||
332 | return AE_OK; | |
333 | } | |
334 | ||
335 | /* | |
336 | * Running in interpreter thread context, safe to sleep | |
337 | */ | |
338 | ||
4be44fcd | 339 | void acpi_os_sleep(acpi_integer ms) |
1da177e4 | 340 | { |
01a527ec | 341 | schedule_timeout_interruptible(msecs_to_jiffies(ms)); |
1da177e4 | 342 | } |
4be44fcd | 343 | |
1da177e4 LT |
344 | EXPORT_SYMBOL(acpi_os_sleep); |
345 | ||
4be44fcd | 346 | void acpi_os_stall(u32 us) |
1da177e4 LT |
347 | { |
348 | while (us) { | |
349 | u32 delay = 1000; | |
350 | ||
351 | if (delay > us) | |
352 | delay = us; | |
353 | udelay(delay); | |
354 | touch_nmi_watchdog(); | |
355 | us -= delay; | |
356 | } | |
357 | } | |
4be44fcd | 358 | |
1da177e4 LT |
359 | EXPORT_SYMBOL(acpi_os_stall); |
360 | ||
361 | /* | |
362 | * Support ACPI 3.0 AML Timer operand | |
363 | * Returns 64-bit free-running, monotonically increasing timer | |
364 | * with 100ns granularity | |
365 | */ | |
4be44fcd | 366 | u64 acpi_os_get_timer(void) |
1da177e4 LT |
367 | { |
368 | static u64 t; | |
369 | ||
370 | #ifdef CONFIG_HPET | |
371 | /* TBD: use HPET if available */ | |
372 | #endif | |
373 | ||
374 | #ifdef CONFIG_X86_PM_TIMER | |
375 | /* TBD: default to PM timer if HPET was not available */ | |
376 | #endif | |
377 | if (!t) | |
378 | printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n"); | |
379 | ||
380 | return ++t; | |
381 | } | |
382 | ||
4be44fcd | 383 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
1da177e4 LT |
384 | { |
385 | u32 dummy; | |
386 | ||
387 | if (!value) | |
388 | value = &dummy; | |
389 | ||
4be44fcd | 390 | switch (width) { |
1da177e4 | 391 | case 8: |
4be44fcd | 392 | *(u8 *) value = inb(port); |
1da177e4 LT |
393 | break; |
394 | case 16: | |
4be44fcd | 395 | *(u16 *) value = inw(port); |
1da177e4 LT |
396 | break; |
397 | case 32: | |
4be44fcd | 398 | *(u32 *) value = inl(port); |
1da177e4 LT |
399 | break; |
400 | default: | |
401 | BUG(); | |
402 | } | |
403 | ||
404 | return AE_OK; | |
405 | } | |
4be44fcd | 406 | |
1da177e4 LT |
407 | EXPORT_SYMBOL(acpi_os_read_port); |
408 | ||
4be44fcd | 409 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
1da177e4 | 410 | { |
4be44fcd | 411 | switch (width) { |
1da177e4 LT |
412 | case 8: |
413 | outb(value, port); | |
414 | break; | |
415 | case 16: | |
416 | outw(value, port); | |
417 | break; | |
418 | case 32: | |
419 | outl(value, port); | |
420 | break; | |
421 | default: | |
422 | BUG(); | |
423 | } | |
424 | ||
425 | return AE_OK; | |
426 | } | |
4be44fcd | 427 | |
1da177e4 LT |
428 | EXPORT_SYMBOL(acpi_os_write_port); |
429 | ||
430 | acpi_status | |
4be44fcd | 431 | acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) |
1da177e4 | 432 | { |
4be44fcd LB |
433 | u32 dummy; |
434 | void __iomem *virt_addr; | |
1da177e4 | 435 | |
9f4fd61f | 436 | virt_addr = ioremap(phys_addr, width); |
1da177e4 LT |
437 | if (!value) |
438 | value = &dummy; | |
439 | ||
440 | switch (width) { | |
441 | case 8: | |
4be44fcd | 442 | *(u8 *) value = readb(virt_addr); |
1da177e4 LT |
443 | break; |
444 | case 16: | |
4be44fcd | 445 | *(u16 *) value = readw(virt_addr); |
1da177e4 LT |
446 | break; |
447 | case 32: | |
4be44fcd | 448 | *(u32 *) value = readl(virt_addr); |
1da177e4 LT |
449 | break; |
450 | default: | |
451 | BUG(); | |
452 | } | |
453 | ||
9f4fd61f | 454 | iounmap(virt_addr); |
1da177e4 LT |
455 | |
456 | return AE_OK; | |
457 | } | |
458 | ||
459 | acpi_status | |
4be44fcd | 460 | acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) |
1da177e4 | 461 | { |
4be44fcd | 462 | void __iomem *virt_addr; |
1da177e4 | 463 | |
9f4fd61f | 464 | virt_addr = ioremap(phys_addr, width); |
1da177e4 LT |
465 | |
466 | switch (width) { | |
467 | case 8: | |
468 | writeb(value, virt_addr); | |
469 | break; | |
470 | case 16: | |
471 | writew(value, virt_addr); | |
472 | break; | |
473 | case 32: | |
474 | writel(value, virt_addr); | |
475 | break; | |
476 | default: | |
477 | BUG(); | |
478 | } | |
479 | ||
9f4fd61f | 480 | iounmap(virt_addr); |
1da177e4 LT |
481 | |
482 | return AE_OK; | |
483 | } | |
484 | ||
1da177e4 | 485 | acpi_status |
4be44fcd LB |
486 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
487 | void *value, u32 width) | |
1da177e4 LT |
488 | { |
489 | int result, size; | |
490 | ||
491 | if (!value) | |
492 | return AE_BAD_PARAMETER; | |
493 | ||
494 | switch (width) { | |
495 | case 8: | |
496 | size = 1; | |
497 | break; | |
498 | case 16: | |
499 | size = 2; | |
500 | break; | |
501 | case 32: | |
502 | size = 4; | |
503 | break; | |
504 | default: | |
505 | return AE_ERROR; | |
506 | } | |
507 | ||
508 | BUG_ON(!raw_pci_ops); | |
509 | ||
510 | result = raw_pci_ops->read(pci_id->segment, pci_id->bus, | |
4be44fcd LB |
511 | PCI_DEVFN(pci_id->device, pci_id->function), |
512 | reg, size, value); | |
1da177e4 LT |
513 | |
514 | return (result ? AE_ERROR : AE_OK); | |
515 | } | |
4be44fcd | 516 | |
1da177e4 LT |
517 | EXPORT_SYMBOL(acpi_os_read_pci_configuration); |
518 | ||
519 | acpi_status | |
4be44fcd LB |
520 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
521 | acpi_integer value, u32 width) | |
1da177e4 LT |
522 | { |
523 | int result, size; | |
524 | ||
525 | switch (width) { | |
526 | case 8: | |
527 | size = 1; | |
528 | break; | |
529 | case 16: | |
530 | size = 2; | |
531 | break; | |
532 | case 32: | |
533 | size = 4; | |
534 | break; | |
535 | default: | |
536 | return AE_ERROR; | |
537 | } | |
538 | ||
539 | BUG_ON(!raw_pci_ops); | |
540 | ||
541 | result = raw_pci_ops->write(pci_id->segment, pci_id->bus, | |
4be44fcd LB |
542 | PCI_DEVFN(pci_id->device, pci_id->function), |
543 | reg, size, value); | |
1da177e4 LT |
544 | |
545 | return (result ? AE_ERROR : AE_OK); | |
546 | } | |
547 | ||
548 | /* TODO: Change code to take advantage of driver model more */ | |
4be44fcd LB |
549 | static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ |
550 | acpi_handle chandle, /* current node */ | |
551 | struct acpi_pci_id **id, | |
552 | int *is_bridge, u8 * bus_number) | |
1da177e4 | 553 | { |
4be44fcd LB |
554 | acpi_handle handle; |
555 | struct acpi_pci_id *pci_id = *id; | |
556 | acpi_status status; | |
557 | unsigned long temp; | |
558 | acpi_object_type type; | |
559 | u8 tu8; | |
1da177e4 LT |
560 | |
561 | acpi_get_parent(chandle, &handle); | |
562 | if (handle != rhandle) { | |
4be44fcd LB |
563 | acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, |
564 | bus_number); | |
1da177e4 LT |
565 | |
566 | status = acpi_get_type(handle, &type); | |
4be44fcd | 567 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) |
1da177e4 LT |
568 | return; |
569 | ||
4be44fcd LB |
570 | status = |
571 | acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, | |
572 | &temp); | |
1da177e4 | 573 | if (ACPI_SUCCESS(status)) { |
4be44fcd LB |
574 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); |
575 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); | |
1da177e4 LT |
576 | |
577 | if (*is_bridge) | |
578 | pci_id->bus = *bus_number; | |
579 | ||
580 | /* any nicer way to get bus number of bridge ? */ | |
4be44fcd LB |
581 | status = |
582 | acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, | |
583 | 8); | |
584 | if (ACPI_SUCCESS(status) | |
585 | && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { | |
586 | status = | |
587 | acpi_os_read_pci_configuration(pci_id, 0x18, | |
588 | &tu8, 8); | |
1da177e4 LT |
589 | if (!ACPI_SUCCESS(status)) { |
590 | /* Certainly broken... FIX ME */ | |
591 | return; | |
592 | } | |
593 | *is_bridge = 1; | |
594 | pci_id->bus = tu8; | |
4be44fcd LB |
595 | status = |
596 | acpi_os_read_pci_configuration(pci_id, 0x19, | |
597 | &tu8, 8); | |
1da177e4 LT |
598 | if (ACPI_SUCCESS(status)) { |
599 | *bus_number = tu8; | |
600 | } | |
601 | } else | |
602 | *is_bridge = 0; | |
603 | } | |
604 | } | |
605 | } | |
606 | ||
4be44fcd LB |
607 | void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ |
608 | acpi_handle chandle, /* current node */ | |
609 | struct acpi_pci_id **id) | |
1da177e4 LT |
610 | { |
611 | int is_bridge = 1; | |
612 | u8 bus_number = (*id)->bus; | |
613 | ||
614 | acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); | |
615 | } | |
616 | ||
65f27f38 | 617 | static void acpi_os_execute_deferred(struct work_struct *work) |
88db5e14 AS |
618 | { |
619 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | |
620 | if (!dpc) { | |
621 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | |
622 | return; | |
623 | } | |
624 | ||
625 | dpc->function(dpc->context); | |
626 | kfree(dpc); | |
627 | ||
628 | /* Yield cpu to notify thread */ | |
629 | cond_resched(); | |
630 | ||
631 | return; | |
632 | } | |
633 | ||
634 | static void acpi_os_execute_notify(struct work_struct *work) | |
1da177e4 | 635 | { |
65f27f38 | 636 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
1da177e4 | 637 | |
1da177e4 | 638 | if (!dpc) { |
6468463a | 639 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
d550d98d | 640 | return; |
1da177e4 LT |
641 | } |
642 | ||
643 | dpc->function(dpc->context); | |
644 | ||
645 | kfree(dpc); | |
646 | ||
d550d98d | 647 | return; |
1da177e4 LT |
648 | } |
649 | ||
b8d35192 AS |
650 | /******************************************************************************* |
651 | * | |
652 | * FUNCTION: acpi_os_execute | |
653 | * | |
654 | * PARAMETERS: Type - Type of the callback | |
655 | * Function - Function to be executed | |
656 | * Context - Function parameters | |
657 | * | |
658 | * RETURN: Status | |
659 | * | |
660 | * DESCRIPTION: Depending on type, either queues function for deferred execution or | |
661 | * immediately executes function on a separate thread. | |
662 | * | |
663 | ******************************************************************************/ | |
664 | ||
665 | acpi_status acpi_os_execute(acpi_execute_type type, | |
4be44fcd | 666 | acpi_osd_exec_callback function, void *context) |
1da177e4 | 667 | { |
4be44fcd LB |
668 | acpi_status status = AE_OK; |
669 | struct acpi_os_dpc *dpc; | |
72945b2b | 670 | |
72945b2b LB |
671 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
672 | "Scheduling function [%p(%p)] for deferred execution.\n", | |
673 | function, context)); | |
1da177e4 LT |
674 | |
675 | if (!function) | |
88db5e14 | 676 | return AE_BAD_PARAMETER; |
72945b2b | 677 | |
1da177e4 LT |
678 | /* |
679 | * Allocate/initialize DPC structure. Note that this memory will be | |
65f27f38 | 680 | * freed by the callee. The kernel handles the work_struct list in a |
1da177e4 LT |
681 | * way that allows us to also free its memory inside the callee. |
682 | * Because we may want to schedule several tasks with different | |
683 | * parameters we can't use the approach some kernel code uses of | |
65f27f38 | 684 | * having a static work_struct. |
1da177e4 | 685 | */ |
72945b2b | 686 | |
65f27f38 | 687 | dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); |
1da177e4 | 688 | if (!dpc) |
b976fe19 LT |
689 | return_ACPI_STATUS(AE_NO_MEMORY); |
690 | ||
1da177e4 LT |
691 | dpc->function = function; |
692 | dpc->context = context; | |
b976fe19 | 693 | |
88db5e14 AS |
694 | if (type == OSL_NOTIFY_HANDLER) { |
695 | INIT_WORK(&dpc->work, acpi_os_execute_notify); | |
696 | if (!queue_work(kacpi_notify_wq, &dpc->work)) { | |
697 | status = AE_ERROR; | |
698 | kfree(dpc); | |
699 | } | |
700 | } else { | |
701 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | |
702 | if (!queue_work(kacpid_wq, &dpc->work)) { | |
703 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | |
b976fe19 | 704 | "Call to queue_work() failed.\n")); |
88db5e14 AS |
705 | status = AE_ERROR; |
706 | kfree(dpc); | |
707 | } | |
1da177e4 | 708 | } |
b976fe19 | 709 | return_ACPI_STATUS(status); |
1da177e4 | 710 | } |
4be44fcd | 711 | |
b8d35192 | 712 | EXPORT_SYMBOL(acpi_os_execute); |
1da177e4 | 713 | |
4be44fcd | 714 | void acpi_os_wait_events_complete(void *context) |
1da177e4 LT |
715 | { |
716 | flush_workqueue(kacpid_wq); | |
717 | } | |
4be44fcd | 718 | |
1da177e4 LT |
719 | EXPORT_SYMBOL(acpi_os_wait_events_complete); |
720 | ||
721 | /* | |
722 | * Allocate the memory for a spinlock and initialize it. | |
723 | */ | |
967440e3 | 724 | acpi_status acpi_os_create_lock(acpi_spinlock * handle) |
1da177e4 | 725 | { |
967440e3 | 726 | spin_lock_init(*handle); |
1da177e4 | 727 | |
d550d98d | 728 | return AE_OK; |
1da177e4 LT |
729 | } |
730 | ||
1da177e4 LT |
731 | /* |
732 | * Deallocate the memory for a spinlock. | |
733 | */ | |
967440e3 | 734 | void acpi_os_delete_lock(acpi_spinlock handle) |
1da177e4 | 735 | { |
d550d98d | 736 | return; |
1da177e4 LT |
737 | } |
738 | ||
1da177e4 | 739 | acpi_status |
4be44fcd | 740 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
1da177e4 | 741 | { |
4be44fcd | 742 | struct semaphore *sem = NULL; |
1da177e4 | 743 | |
1da177e4 LT |
744 | |
745 | sem = acpi_os_allocate(sizeof(struct semaphore)); | |
746 | if (!sem) | |
d550d98d | 747 | return AE_NO_MEMORY; |
1da177e4 LT |
748 | memset(sem, 0, sizeof(struct semaphore)); |
749 | ||
750 | sema_init(sem, initial_units); | |
751 | ||
4be44fcd | 752 | *handle = (acpi_handle *) sem; |
1da177e4 | 753 | |
4be44fcd LB |
754 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", |
755 | *handle, initial_units)); | |
1da177e4 | 756 | |
d550d98d | 757 | return AE_OK; |
1da177e4 | 758 | } |
1da177e4 | 759 | |
4be44fcd | 760 | EXPORT_SYMBOL(acpi_os_create_semaphore); |
1da177e4 LT |
761 | |
762 | /* | |
763 | * TODO: A better way to delete semaphores? Linux doesn't have a | |
764 | * 'delete_semaphore()' function -- may result in an invalid | |
765 | * pointer dereference for non-synchronized consumers. Should | |
766 | * we at least check for blocked threads and signal/cancel them? | |
767 | */ | |
768 | ||
4be44fcd | 769 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) |
1da177e4 | 770 | { |
4be44fcd | 771 | struct semaphore *sem = (struct semaphore *)handle; |
1da177e4 | 772 | |
1da177e4 LT |
773 | |
774 | if (!sem) | |
d550d98d | 775 | return AE_BAD_PARAMETER; |
1da177e4 | 776 | |
4be44fcd | 777 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); |
1da177e4 | 778 | |
02438d87 | 779 | kfree(sem); |
4be44fcd | 780 | sem = NULL; |
1da177e4 | 781 | |
d550d98d | 782 | return AE_OK; |
1da177e4 | 783 | } |
1da177e4 | 784 | |
4be44fcd | 785 | EXPORT_SYMBOL(acpi_os_delete_semaphore); |
1da177e4 LT |
786 | |
787 | /* | |
788 | * TODO: The kernel doesn't have a 'down_timeout' function -- had to | |
789 | * improvise. The process is to sleep for one scheduler quantum | |
790 | * until the semaphore becomes available. Downside is that this | |
791 | * may result in starvation for timeout-based waits when there's | |
792 | * lots of semaphore activity. | |
793 | * | |
794 | * TODO: Support for units > 1? | |
795 | */ | |
4be44fcd | 796 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) |
1da177e4 | 797 | { |
4be44fcd LB |
798 | acpi_status status = AE_OK; |
799 | struct semaphore *sem = (struct semaphore *)handle; | |
800 | int ret = 0; | |
1da177e4 | 801 | |
1da177e4 LT |
802 | |
803 | if (!sem || (units < 1)) | |
d550d98d | 804 | return AE_BAD_PARAMETER; |
1da177e4 LT |
805 | |
806 | if (units > 1) | |
d550d98d | 807 | return AE_SUPPORT; |
1da177e4 | 808 | |
4be44fcd LB |
809 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", |
810 | handle, units, timeout)); | |
1da177e4 | 811 | |
d68909f4 LB |
812 | /* |
813 | * This can be called during resume with interrupts off. | |
814 | * Like boot-time, we should be single threaded and will | |
815 | * always get the lock if we try -- timeout or not. | |
816 | * If this doesn't succeed, then we will oops courtesy of | |
817 | * might_sleep() in down(). | |
818 | */ | |
819 | if (!down_trylock(sem)) | |
820 | return AE_OK; | |
821 | ||
4be44fcd | 822 | switch (timeout) { |
1da177e4 LT |
823 | /* |
824 | * No Wait: | |
825 | * -------- | |
826 | * A zero timeout value indicates that we shouldn't wait - just | |
827 | * acquire the semaphore if available otherwise return AE_TIME | |
828 | * (a.k.a. 'would block'). | |
829 | */ | |
4be44fcd LB |
830 | case 0: |
831 | if (down_trylock(sem)) | |
1da177e4 LT |
832 | status = AE_TIME; |
833 | break; | |
834 | ||
835 | /* | |
836 | * Wait Indefinitely: | |
837 | * ------------------ | |
838 | */ | |
4be44fcd | 839 | case ACPI_WAIT_FOREVER: |
1da177e4 LT |
840 | down(sem); |
841 | break; | |
842 | ||
843 | /* | |
844 | * Wait w/ Timeout: | |
845 | * ---------------- | |
846 | */ | |
4be44fcd | 847 | default: |
1da177e4 LT |
848 | // TODO: A better timeout algorithm? |
849 | { | |
850 | int i = 0; | |
4be44fcd | 851 | static const int quantum_ms = 1000 / HZ; |
1da177e4 LT |
852 | |
853 | ret = down_trylock(sem); | |
dacd9b80 | 854 | for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) { |
01a527ec | 855 | schedule_timeout_interruptible(1); |
1da177e4 LT |
856 | ret = down_trylock(sem); |
857 | } | |
4be44fcd | 858 | |
1da177e4 LT |
859 | if (ret != 0) |
860 | status = AE_TIME; | |
861 | } | |
862 | break; | |
863 | } | |
864 | ||
865 | if (ACPI_FAILURE(status)) { | |
9e7e2c04 | 866 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
a6fc6720 | 867 | "Failed to acquire semaphore[%p|%d|%d], %s", |
4be44fcd LB |
868 | handle, units, timeout, |
869 | acpi_format_exception(status))); | |
870 | } else { | |
871 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | |
a6fc6720 | 872 | "Acquired semaphore[%p|%d|%d]", handle, |
4be44fcd | 873 | units, timeout)); |
1da177e4 LT |
874 | } |
875 | ||
d550d98d | 876 | return status; |
1da177e4 | 877 | } |
1da177e4 | 878 | |
4be44fcd | 879 | EXPORT_SYMBOL(acpi_os_wait_semaphore); |
1da177e4 LT |
880 | |
881 | /* | |
882 | * TODO: Support for units > 1? | |
883 | */ | |
4be44fcd | 884 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) |
1da177e4 | 885 | { |
4be44fcd | 886 | struct semaphore *sem = (struct semaphore *)handle; |
1da177e4 | 887 | |
1da177e4 LT |
888 | |
889 | if (!sem || (units < 1)) | |
d550d98d | 890 | return AE_BAD_PARAMETER; |
1da177e4 LT |
891 | |
892 | if (units > 1) | |
d550d98d | 893 | return AE_SUPPORT; |
1da177e4 | 894 | |
4be44fcd LB |
895 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, |
896 | units)); | |
1da177e4 LT |
897 | |
898 | up(sem); | |
899 | ||
d550d98d | 900 | return AE_OK; |
1da177e4 | 901 | } |
4be44fcd | 902 | |
1da177e4 LT |
903 | EXPORT_SYMBOL(acpi_os_signal_semaphore); |
904 | ||
905 | #ifdef ACPI_FUTURE_USAGE | |
4be44fcd | 906 | u32 acpi_os_get_line(char *buffer) |
1da177e4 LT |
907 | { |
908 | ||
909 | #ifdef ENABLE_DEBUGGER | |
910 | if (acpi_in_debugger) { | |
911 | u32 chars; | |
912 | ||
913 | kdb_read(buffer, sizeof(line_buf)); | |
914 | ||
915 | /* remove the CR kdb includes */ | |
916 | chars = strlen(buffer) - 1; | |
917 | buffer[chars] = '\0'; | |
918 | } | |
919 | #endif | |
920 | ||
921 | return 0; | |
922 | } | |
4be44fcd | 923 | #endif /* ACPI_FUTURE_USAGE */ |
1da177e4 | 924 | |
4be44fcd | 925 | acpi_status acpi_os_signal(u32 function, void *info) |
1da177e4 | 926 | { |
4be44fcd | 927 | switch (function) { |
1da177e4 LT |
928 | case ACPI_SIGNAL_FATAL: |
929 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); | |
930 | break; | |
931 | case ACPI_SIGNAL_BREAKPOINT: | |
932 | /* | |
933 | * AML Breakpoint | |
934 | * ACPI spec. says to treat it as a NOP unless | |
935 | * you are debugging. So if/when we integrate | |
936 | * AML debugger into the kernel debugger its | |
937 | * hook will go here. But until then it is | |
938 | * not useful to print anything on breakpoints. | |
939 | */ | |
940 | break; | |
941 | default: | |
942 | break; | |
943 | } | |
944 | ||
945 | return AE_OK; | |
946 | } | |
4be44fcd | 947 | |
1da177e4 LT |
948 | EXPORT_SYMBOL(acpi_os_signal); |
949 | ||
4be44fcd | 950 | static int __init acpi_os_name_setup(char *str) |
1da177e4 LT |
951 | { |
952 | char *p = acpi_os_name; | |
4be44fcd | 953 | int count = ACPI_MAX_OVERRIDE_LEN - 1; |
1da177e4 LT |
954 | |
955 | if (!str || !*str) | |
956 | return 0; | |
957 | ||
958 | for (; count-- && str && *str; str++) { | |
959 | if (isalnum(*str) || *str == ' ' || *str == ':') | |
960 | *p++ = *str; | |
961 | else if (*str == '\'' || *str == '"') | |
962 | continue; | |
963 | else | |
964 | break; | |
965 | } | |
966 | *p = 0; | |
967 | ||
968 | return 1; | |
4be44fcd | 969 | |
1da177e4 LT |
970 | } |
971 | ||
972 | __setup("acpi_os_name=", acpi_os_name_setup); | |
973 | ||
f507654d LB |
974 | static void enable_osi_linux(int enable) { |
975 | ||
976 | if (osi_linux != enable) | |
977 | printk(KERN_INFO PREFIX "%sabled _OSI(Linux)\n", | |
978 | enable ? "En": "Dis"); | |
979 | ||
980 | osi_linux = enable; | |
981 | return; | |
982 | } | |
983 | ||
1da177e4 | 984 | /* |
ae00d812 LB |
985 | * Modify the list of "OS Interfaces" reported to BIOS via _OSI |
986 | * | |
1da177e4 | 987 | * empty string disables _OSI |
ae00d812 LB |
988 | * string starting with '!' disables that string |
989 | * otherwise string is added to list, augmenting built-in strings | |
1da177e4 | 990 | */ |
4be44fcd | 991 | static int __init acpi_osi_setup(char *str) |
1da177e4 LT |
992 | { |
993 | if (str == NULL || *str == '\0') { | |
994 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); | |
995 | acpi_gbl_create_osi_method = FALSE; | |
ae00d812 LB |
996 | } else if (*str == '!') { |
997 | if (acpi_osi_invalidate(++str) == AE_OK) | |
998 | printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); | |
f507654d LB |
999 | } else if (!strcmp("!Linux", str)) { |
1000 | enable_osi_linux(0); | |
1001 | } else if (!strcmp("Linux", str)) { | |
1002 | enable_osi_linux(1); | |
ae00d812 LB |
1003 | } else if (*osi_additional_string == '\0') { |
1004 | strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX); | |
1005 | printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); | |
1da177e4 LT |
1006 | } |
1007 | ||
1008 | return 1; | |
1009 | } | |
1010 | ||
1011 | __setup("acpi_osi=", acpi_osi_setup); | |
1012 | ||
1013 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ | |
4be44fcd | 1014 | static int __init acpi_serialize_setup(char *str) |
1da177e4 LT |
1015 | { |
1016 | printk(KERN_INFO PREFIX "serialize enabled\n"); | |
1017 | ||
1018 | acpi_gbl_all_methods_serialized = TRUE; | |
1019 | ||
1020 | return 1; | |
1021 | } | |
1022 | ||
1023 | __setup("acpi_serialize", acpi_serialize_setup); | |
1024 | ||
1025 | /* | |
1026 | * Wake and Run-Time GPES are expected to be separate. | |
1027 | * We disable wake-GPEs at run-time to prevent spurious | |
1028 | * interrupts. | |
1029 | * | |
1030 | * However, if a system exists that shares Wake and | |
1031 | * Run-time events on the same GPE this flag is available | |
1032 | * to tell Linux to keep the wake-time GPEs enabled at run-time. | |
1033 | */ | |
4be44fcd | 1034 | static int __init acpi_wake_gpes_always_on_setup(char *str) |
1da177e4 LT |
1035 | { |
1036 | printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); | |
1037 | ||
1038 | acpi_gbl_leave_wake_gpes_disabled = FALSE; | |
1039 | ||
1040 | return 1; | |
1041 | } | |
1042 | ||
1043 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); | |
1044 | ||
1045 | /* | |
1046 | * max_cstate is defined in the base kernel so modules can | |
1047 | * change it w/o depending on the state of the processor module. | |
1048 | */ | |
1049 | unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; | |
1050 | ||
1da177e4 | 1051 | EXPORT_SYMBOL(max_cstate); |
73459f73 RM |
1052 | |
1053 | /* | |
1054 | * Acquire a spinlock. | |
1055 | * | |
1056 | * handle is a pointer to the spinlock_t. | |
73459f73 RM |
1057 | */ |
1058 | ||
967440e3 | 1059 | acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) |
73459f73 | 1060 | { |
b8e4d893 | 1061 | acpi_cpu_flags flags; |
967440e3 | 1062 | spin_lock_irqsave(lockp, flags); |
73459f73 RM |
1063 | return flags; |
1064 | } | |
1065 | ||
1066 | /* | |
1067 | * Release a spinlock. See above. | |
1068 | */ | |
1069 | ||
967440e3 | 1070 | void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags) |
73459f73 | 1071 | { |
967440e3 | 1072 | spin_unlock_irqrestore(lockp, flags); |
73459f73 RM |
1073 | } |
1074 | ||
73459f73 RM |
1075 | #ifndef ACPI_USE_LOCAL_CACHE |
1076 | ||
1077 | /******************************************************************************* | |
1078 | * | |
1079 | * FUNCTION: acpi_os_create_cache | |
1080 | * | |
b229cf92 BM |
1081 | * PARAMETERS: name - Ascii name for the cache |
1082 | * size - Size of each cached object | |
1083 | * depth - Maximum depth of the cache (in objects) <ignored> | |
1084 | * cache - Where the new cache object is returned | |
73459f73 | 1085 | * |
b229cf92 | 1086 | * RETURN: status |
73459f73 RM |
1087 | * |
1088 | * DESCRIPTION: Create a cache object | |
1089 | * | |
1090 | ******************************************************************************/ | |
1091 | ||
1092 | acpi_status | |
4be44fcd | 1093 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) |
73459f73 | 1094 | { |
4be44fcd | 1095 | *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); |
a6fdbf90 | 1096 | if (*cache == NULL) |
b229cf92 BM |
1097 | return AE_ERROR; |
1098 | else | |
1099 | return AE_OK; | |
73459f73 RM |
1100 | } |
1101 | ||
1102 | /******************************************************************************* | |
1103 | * | |
1104 | * FUNCTION: acpi_os_purge_cache | |
1105 | * | |
1106 | * PARAMETERS: Cache - Handle to cache object | |
1107 | * | |
1108 | * RETURN: Status | |
1109 | * | |
1110 | * DESCRIPTION: Free all objects within the requested cache. | |
1111 | * | |
1112 | ******************************************************************************/ | |
1113 | ||
4be44fcd | 1114 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) |
73459f73 | 1115 | { |
50dd0969 | 1116 | kmem_cache_shrink(cache); |
4be44fcd | 1117 | return (AE_OK); |
73459f73 RM |
1118 | } |
1119 | ||
1120 | /******************************************************************************* | |
1121 | * | |
1122 | * FUNCTION: acpi_os_delete_cache | |
1123 | * | |
1124 | * PARAMETERS: Cache - Handle to cache object | |
1125 | * | |
1126 | * RETURN: Status | |
1127 | * | |
1128 | * DESCRIPTION: Free all objects within the requested cache and delete the | |
1129 | * cache object. | |
1130 | * | |
1131 | ******************************************************************************/ | |
1132 | ||
4be44fcd | 1133 | acpi_status acpi_os_delete_cache(acpi_cache_t * cache) |
73459f73 | 1134 | { |
1a1d92c1 | 1135 | kmem_cache_destroy(cache); |
4be44fcd | 1136 | return (AE_OK); |
73459f73 RM |
1137 | } |
1138 | ||
1139 | /******************************************************************************* | |
1140 | * | |
1141 | * FUNCTION: acpi_os_release_object | |
1142 | * | |
1143 | * PARAMETERS: Cache - Handle to cache object | |
1144 | * Object - The object to be released | |
1145 | * | |
1146 | * RETURN: None | |
1147 | * | |
1148 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | |
1149 | * the object is deleted. | |
1150 | * | |
1151 | ******************************************************************************/ | |
1152 | ||
4be44fcd | 1153 | acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) |
73459f73 | 1154 | { |
4be44fcd LB |
1155 | kmem_cache_free(cache, object); |
1156 | return (AE_OK); | |
73459f73 RM |
1157 | } |
1158 | ||
b229cf92 BM |
1159 | /****************************************************************************** |
1160 | * | |
1161 | * FUNCTION: acpi_os_validate_interface | |
1162 | * | |
1163 | * PARAMETERS: interface - Requested interface to be validated | |
1164 | * | |
1165 | * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise | |
1166 | * | |
1167 | * DESCRIPTION: Match an interface string to the interfaces supported by the | |
1168 | * host. Strings originate from an AML call to the _OSI method. | |
1169 | * | |
1170 | *****************************************************************************/ | |
1171 | ||
1172 | acpi_status | |
1173 | acpi_os_validate_interface (char *interface) | |
1174 | { | |
ae00d812 LB |
1175 | if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX)) |
1176 | return AE_OK; | |
f507654d LB |
1177 | if (!strcmp("Linux", interface)) { |
1178 | printk(KERN_WARNING PREFIX | |
1179 | "System BIOS is requesting _OSI(Linux)\n"); | |
f507654d LB |
1180 | printk(KERN_WARNING PREFIX |
1181 | "If \"acpi_osi=Linux\" works better,\n" | |
1182 | "Please send dmidecode " | |
1183 | "to linux-acpi@vger.kernel.org\n"); | |
f507654d LB |
1184 | if(osi_linux) |
1185 | return AE_OK; | |
1186 | } | |
ae00d812 | 1187 | return AE_SUPPORT; |
b229cf92 BM |
1188 | } |
1189 | ||
b229cf92 BM |
1190 | /****************************************************************************** |
1191 | * | |
1192 | * FUNCTION: acpi_os_validate_address | |
1193 | * | |
1194 | * PARAMETERS: space_id - ACPI space ID | |
1195 | * address - Physical address | |
1196 | * length - Address length | |
1197 | * | |
1198 | * RETURN: AE_OK if address/length is valid for the space_id. Otherwise, | |
1199 | * should return AE_AML_ILLEGAL_ADDRESS. | |
1200 | * | |
1201 | * DESCRIPTION: Validate a system address via the host OS. Used to validate | |
1202 | * the addresses accessed by AML operation regions. | |
1203 | * | |
1204 | *****************************************************************************/ | |
1205 | ||
1206 | acpi_status | |
1207 | acpi_os_validate_address ( | |
1208 | u8 space_id, | |
1209 | acpi_physical_address address, | |
1210 | acpi_size length) | |
1211 | { | |
1212 | ||
1213 | return AE_OK; | |
1214 | } | |
1215 | ||
f507654d | 1216 | #ifdef CONFIG_DMI |
f507654d LB |
1217 | static int dmi_osi_linux(struct dmi_system_id *d) |
1218 | { | |
072971d7 | 1219 | printk(KERN_NOTICE "%s detected: enabling _OSI(Linux)\n", d->ident); |
f507654d LB |
1220 | enable_osi_linux(1); |
1221 | return 0; | |
1222 | } | |
f507654d | 1223 | |
dd272b57 | 1224 | static struct dmi_system_id acpi_osl_dmi_table[] __initdata = { |
f507654d LB |
1225 | /* |
1226 | * Boxes that need _OSI(Linux) | |
1227 | */ | |
1228 | { | |
1229 | .callback = dmi_osi_linux, | |
1230 | .ident = "Intel Napa CRB", | |
1231 | .matches = { | |
1232 | DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"), | |
1233 | DMI_MATCH(DMI_BOARD_NAME, "MPAD-MSAE Customer Reference Boards"), | |
1234 | }, | |
1235 | }, | |
f507654d LB |
1236 | {} |
1237 | }; | |
1238 | #endif /* CONFIG_DMI */ | |
b229cf92 | 1239 | |
73459f73 | 1240 | #endif |