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