Kprobes: The ON/OFF knob thru debugfs
[linux-2.6/cjktty.git] / drivers / acpi / osl.c
blobc2bed56915e1eafe1559d906ba06661764990d45
1 /*
2 * acpi_osl.c - OS-dependent functions ($Revision: 83 $)
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>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
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
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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>
33 #include <linux/interrupt.h>
34 #include <linux/kmod.h>
35 #include <linux/delay.h>
36 #include <linux/workqueue.h>
37 #include <linux/nmi.h>
38 #include <linux/acpi.h>
39 #include <acpi/acpi.h>
40 #include <asm/io.h>
41 #include <acpi/acpi_bus.h>
42 #include <acpi/processor.h>
43 #include <asm/uaccess.h>
45 #include <linux/efi.h>
47 #define _COMPONENT ACPI_OS_SERVICES
48 ACPI_MODULE_NAME("osl");
49 #define PREFIX "ACPI: "
50 struct acpi_os_dpc {
51 acpi_osd_exec_callback function;
52 void *context;
53 struct work_struct work;
56 #ifdef CONFIG_ACPI_CUSTOM_DSDT
57 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
58 #endif
60 #ifdef ENABLE_DEBUGGER
61 #include <linux/kdb.h>
63 /* stuff for debugger support */
64 int acpi_in_debugger;
65 EXPORT_SYMBOL(acpi_in_debugger);
67 extern char line_buf[80];
68 #endif /*ENABLE_DEBUGGER */
70 static unsigned int acpi_irq_irq;
71 static acpi_osd_handler acpi_irq_handler;
72 static void *acpi_irq_context;
73 static struct workqueue_struct *kacpid_wq;
75 static void __init acpi_request_region (struct acpi_generic_address *addr,
76 unsigned int length, char *desc)
78 struct resource *res;
80 if (!addr->address || !length)
81 return;
83 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
84 res = request_region(addr->address, length, desc);
85 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
86 res = request_mem_region(addr->address, length, desc);
89 static int __init acpi_reserve_resources(void)
91 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
92 "ACPI PM1a_EVT_BLK");
94 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
95 "ACPI PM1b_EVT_BLK");
97 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
98 "ACPI PM1a_CNT_BLK");
100 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
101 "ACPI PM1b_CNT_BLK");
103 if (acpi_gbl_FADT.pm_timer_length == 4)
104 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
106 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
107 "ACPI PM2_CNT_BLK");
109 /* Length of GPE blocks must be a non-negative multiple of 2 */
111 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
112 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
113 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
115 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
116 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
117 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
119 return 0;
121 device_initcall(acpi_reserve_resources);
123 acpi_status acpi_os_initialize(void)
125 return AE_OK;
128 acpi_status acpi_os_initialize1(void)
131 * Initialize PCI configuration space access, as we'll need to access
132 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
134 if (!raw_pci_ops) {
135 printk(KERN_ERR PREFIX
136 "Access to PCI configuration space unavailable\n");
137 return AE_NULL_ENTRY;
139 kacpid_wq = create_singlethread_workqueue("kacpid");
140 BUG_ON(!kacpid_wq);
142 return AE_OK;
145 acpi_status acpi_os_terminate(void)
147 if (acpi_irq_handler) {
148 acpi_os_remove_interrupt_handler(acpi_irq_irq,
149 acpi_irq_handler);
152 destroy_workqueue(kacpid_wq);
154 return AE_OK;
157 void acpi_os_printf(const char *fmt, ...)
159 va_list args;
160 va_start(args, fmt);
161 acpi_os_vprintf(fmt, args);
162 va_end(args);
165 EXPORT_SYMBOL(acpi_os_printf);
167 void acpi_os_vprintf(const char *fmt, va_list args)
169 static char buffer[512];
171 vsprintf(buffer, fmt, args);
173 #ifdef ENABLE_DEBUGGER
174 if (acpi_in_debugger) {
175 kdb_printf("%s", buffer);
176 } else {
177 printk("%s", buffer);
179 #else
180 printk("%s", buffer);
181 #endif
184 acpi_physical_address __init acpi_os_get_root_pointer(void)
186 if (efi_enabled) {
187 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
188 return efi.acpi20;
189 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
190 return efi.acpi;
191 else {
192 printk(KERN_ERR PREFIX
193 "System description tables not found\n");
194 return 0;
196 } else
197 return acpi_find_rsdp();
200 void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
202 if (phys > ULONG_MAX) {
203 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
204 return NULL;
206 if (acpi_gbl_permanent_mmap)
208 * ioremap checks to ensure this is in reserved space
210 return ioremap((unsigned long)phys, size);
211 else
212 return __acpi_map_table((unsigned long)phys, size);
214 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
216 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
218 if (acpi_gbl_permanent_mmap) {
219 iounmap(virt);
222 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
224 #ifdef ACPI_FUTURE_USAGE
225 acpi_status
226 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
228 if (!phys || !virt)
229 return AE_BAD_PARAMETER;
231 *phys = virt_to_phys(virt);
233 return AE_OK;
235 #endif
237 #define ACPI_MAX_OVERRIDE_LEN 100
239 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
241 acpi_status
242 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
243 acpi_string * new_val)
245 if (!init_val || !new_val)
246 return AE_BAD_PARAMETER;
248 *new_val = NULL;
249 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
250 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
251 acpi_os_name);
252 *new_val = acpi_os_name;
255 return AE_OK;
258 acpi_status
259 acpi_os_table_override(struct acpi_table_header * existing_table,
260 struct acpi_table_header ** new_table)
262 if (!existing_table || !new_table)
263 return AE_BAD_PARAMETER;
265 #ifdef CONFIG_ACPI_CUSTOM_DSDT
266 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
267 *new_table = (struct acpi_table_header *)AmlCode;
268 else
269 *new_table = NULL;
270 #else
271 *new_table = NULL;
272 #endif
273 return AE_OK;
276 static irqreturn_t acpi_irq(int irq, void *dev_id)
278 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
281 acpi_status
282 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
283 void *context)
285 unsigned int irq;
288 * Ignore the GSI from the core, and use the value in our copy of the
289 * FADT. It may not be the same if an interrupt source override exists
290 * for the SCI.
292 gsi = acpi_gbl_FADT.sci_interrupt;
293 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
294 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
295 gsi);
296 return AE_OK;
299 acpi_irq_handler = handler;
300 acpi_irq_context = context;
301 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
302 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
303 return AE_NOT_ACQUIRED;
305 acpi_irq_irq = irq;
307 return AE_OK;
310 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
312 if (irq) {
313 free_irq(irq, acpi_irq);
314 acpi_irq_handler = NULL;
315 acpi_irq_irq = 0;
318 return AE_OK;
322 * Running in interpreter thread context, safe to sleep
325 void acpi_os_sleep(acpi_integer ms)
327 schedule_timeout_interruptible(msecs_to_jiffies(ms));
330 EXPORT_SYMBOL(acpi_os_sleep);
332 void acpi_os_stall(u32 us)
334 while (us) {
335 u32 delay = 1000;
337 if (delay > us)
338 delay = us;
339 udelay(delay);
340 touch_nmi_watchdog();
341 us -= delay;
345 EXPORT_SYMBOL(acpi_os_stall);
348 * Support ACPI 3.0 AML Timer operand
349 * Returns 64-bit free-running, monotonically increasing timer
350 * with 100ns granularity
352 u64 acpi_os_get_timer(void)
354 static u64 t;
356 #ifdef CONFIG_HPET
357 /* TBD: use HPET if available */
358 #endif
360 #ifdef CONFIG_X86_PM_TIMER
361 /* TBD: default to PM timer if HPET was not available */
362 #endif
363 if (!t)
364 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
366 return ++t;
369 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
371 u32 dummy;
373 if (!value)
374 value = &dummy;
376 switch (width) {
377 case 8:
378 *(u8 *) value = inb(port);
379 break;
380 case 16:
381 *(u16 *) value = inw(port);
382 break;
383 case 32:
384 *(u32 *) value = inl(port);
385 break;
386 default:
387 BUG();
390 return AE_OK;
393 EXPORT_SYMBOL(acpi_os_read_port);
395 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
397 switch (width) {
398 case 8:
399 outb(value, port);
400 break;
401 case 16:
402 outw(value, port);
403 break;
404 case 32:
405 outl(value, port);
406 break;
407 default:
408 BUG();
411 return AE_OK;
414 EXPORT_SYMBOL(acpi_os_write_port);
416 acpi_status
417 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
419 u32 dummy;
420 void __iomem *virt_addr;
422 virt_addr = ioremap(phys_addr, width);
423 if (!value)
424 value = &dummy;
426 switch (width) {
427 case 8:
428 *(u8 *) value = readb(virt_addr);
429 break;
430 case 16:
431 *(u16 *) value = readw(virt_addr);
432 break;
433 case 32:
434 *(u32 *) value = readl(virt_addr);
435 break;
436 default:
437 BUG();
440 iounmap(virt_addr);
442 return AE_OK;
445 acpi_status
446 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
448 void __iomem *virt_addr;
450 virt_addr = ioremap(phys_addr, width);
452 switch (width) {
453 case 8:
454 writeb(value, virt_addr);
455 break;
456 case 16:
457 writew(value, virt_addr);
458 break;
459 case 32:
460 writel(value, virt_addr);
461 break;
462 default:
463 BUG();
466 iounmap(virt_addr);
468 return AE_OK;
471 acpi_status
472 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
473 void *value, u32 width)
475 int result, size;
477 if (!value)
478 return AE_BAD_PARAMETER;
480 switch (width) {
481 case 8:
482 size = 1;
483 break;
484 case 16:
485 size = 2;
486 break;
487 case 32:
488 size = 4;
489 break;
490 default:
491 return AE_ERROR;
494 BUG_ON(!raw_pci_ops);
496 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
497 PCI_DEVFN(pci_id->device, pci_id->function),
498 reg, size, value);
500 return (result ? AE_ERROR : AE_OK);
503 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
505 acpi_status
506 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
507 acpi_integer value, u32 width)
509 int result, size;
511 switch (width) {
512 case 8:
513 size = 1;
514 break;
515 case 16:
516 size = 2;
517 break;
518 case 32:
519 size = 4;
520 break;
521 default:
522 return AE_ERROR;
525 BUG_ON(!raw_pci_ops);
527 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
528 PCI_DEVFN(pci_id->device, pci_id->function),
529 reg, size, value);
531 return (result ? AE_ERROR : AE_OK);
534 /* TODO: Change code to take advantage of driver model more */
535 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
536 acpi_handle chandle, /* current node */
537 struct acpi_pci_id **id,
538 int *is_bridge, u8 * bus_number)
540 acpi_handle handle;
541 struct acpi_pci_id *pci_id = *id;
542 acpi_status status;
543 unsigned long temp;
544 acpi_object_type type;
545 u8 tu8;
547 acpi_get_parent(chandle, &handle);
548 if (handle != rhandle) {
549 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
550 bus_number);
552 status = acpi_get_type(handle, &type);
553 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
554 return;
556 status =
557 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
558 &temp);
559 if (ACPI_SUCCESS(status)) {
560 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
561 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
563 if (*is_bridge)
564 pci_id->bus = *bus_number;
566 /* any nicer way to get bus number of bridge ? */
567 status =
568 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
570 if (ACPI_SUCCESS(status)
571 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
572 status =
573 acpi_os_read_pci_configuration(pci_id, 0x18,
574 &tu8, 8);
575 if (!ACPI_SUCCESS(status)) {
576 /* Certainly broken... FIX ME */
577 return;
579 *is_bridge = 1;
580 pci_id->bus = tu8;
581 status =
582 acpi_os_read_pci_configuration(pci_id, 0x19,
583 &tu8, 8);
584 if (ACPI_SUCCESS(status)) {
585 *bus_number = tu8;
587 } else
588 *is_bridge = 0;
593 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
594 acpi_handle chandle, /* current node */
595 struct acpi_pci_id **id)
597 int is_bridge = 1;
598 u8 bus_number = (*id)->bus;
600 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
603 static void acpi_os_execute_deferred(struct work_struct *work)
605 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
607 if (!dpc) {
608 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
609 return;
612 dpc->function(dpc->context);
614 kfree(dpc);
616 return;
619 /*******************************************************************************
621 * FUNCTION: acpi_os_execute
623 * PARAMETERS: Type - Type of the callback
624 * Function - Function to be executed
625 * Context - Function parameters
627 * RETURN: Status
629 * DESCRIPTION: Depending on type, either queues function for deferred execution or
630 * immediately executes function on a separate thread.
632 ******************************************************************************/
634 acpi_status acpi_os_execute(acpi_execute_type type,
635 acpi_osd_exec_callback function, void *context)
637 acpi_status status = AE_OK;
638 struct acpi_os_dpc *dpc;
640 ACPI_FUNCTION_TRACE("os_queue_for_execution");
642 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
643 "Scheduling function [%p(%p)] for deferred execution.\n",
644 function, context));
646 if (!function)
647 return_ACPI_STATUS(AE_BAD_PARAMETER);
650 * Allocate/initialize DPC structure. Note that this memory will be
651 * freed by the callee. The kernel handles the work_struct list in a
652 * way that allows us to also free its memory inside the callee.
653 * Because we may want to schedule several tasks with different
654 * parameters we can't use the approach some kernel code uses of
655 * having a static work_struct.
658 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
659 if (!dpc)
660 return_ACPI_STATUS(AE_NO_MEMORY);
662 dpc->function = function;
663 dpc->context = context;
665 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
666 if (!queue_work(kacpid_wq, &dpc->work)) {
667 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
668 "Call to queue_work() failed.\n"));
669 kfree(dpc);
670 status = AE_ERROR;
673 return_ACPI_STATUS(status);
676 EXPORT_SYMBOL(acpi_os_execute);
678 void acpi_os_wait_events_complete(void *context)
680 flush_workqueue(kacpid_wq);
683 EXPORT_SYMBOL(acpi_os_wait_events_complete);
686 * Allocate the memory for a spinlock and initialize it.
688 acpi_status acpi_os_create_lock(acpi_spinlock * handle)
690 spin_lock_init(*handle);
692 return AE_OK;
696 * Deallocate the memory for a spinlock.
698 void acpi_os_delete_lock(acpi_spinlock handle)
700 return;
703 acpi_status
704 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
706 struct semaphore *sem = NULL;
709 sem = acpi_os_allocate(sizeof(struct semaphore));
710 if (!sem)
711 return AE_NO_MEMORY;
712 memset(sem, 0, sizeof(struct semaphore));
714 sema_init(sem, initial_units);
716 *handle = (acpi_handle *) sem;
718 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
719 *handle, initial_units));
721 return AE_OK;
724 EXPORT_SYMBOL(acpi_os_create_semaphore);
727 * TODO: A better way to delete semaphores? Linux doesn't have a
728 * 'delete_semaphore()' function -- may result in an invalid
729 * pointer dereference for non-synchronized consumers. Should
730 * we at least check for blocked threads and signal/cancel them?
733 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
735 struct semaphore *sem = (struct semaphore *)handle;
738 if (!sem)
739 return AE_BAD_PARAMETER;
741 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
743 kfree(sem);
744 sem = NULL;
746 return AE_OK;
749 EXPORT_SYMBOL(acpi_os_delete_semaphore);
752 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
753 * improvise. The process is to sleep for one scheduler quantum
754 * until the semaphore becomes available. Downside is that this
755 * may result in starvation for timeout-based waits when there's
756 * lots of semaphore activity.
758 * TODO: Support for units > 1?
760 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
762 acpi_status status = AE_OK;
763 struct semaphore *sem = (struct semaphore *)handle;
764 int ret = 0;
767 if (!sem || (units < 1))
768 return AE_BAD_PARAMETER;
770 if (units > 1)
771 return AE_SUPPORT;
773 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
774 handle, units, timeout));
777 * This can be called during resume with interrupts off.
778 * Like boot-time, we should be single threaded and will
779 * always get the lock if we try -- timeout or not.
780 * If this doesn't succeed, then we will oops courtesy of
781 * might_sleep() in down().
783 if (!down_trylock(sem))
784 return AE_OK;
786 switch (timeout) {
788 * No Wait:
789 * --------
790 * A zero timeout value indicates that we shouldn't wait - just
791 * acquire the semaphore if available otherwise return AE_TIME
792 * (a.k.a. 'would block').
794 case 0:
795 if (down_trylock(sem))
796 status = AE_TIME;
797 break;
800 * Wait Indefinitely:
801 * ------------------
803 case ACPI_WAIT_FOREVER:
804 down(sem);
805 break;
808 * Wait w/ Timeout:
809 * ----------------
811 default:
812 // TODO: A better timeout algorithm?
814 int i = 0;
815 static const int quantum_ms = 1000 / HZ;
817 ret = down_trylock(sem);
818 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
819 schedule_timeout_interruptible(1);
820 ret = down_trylock(sem);
823 if (ret != 0)
824 status = AE_TIME;
826 break;
829 if (ACPI_FAILURE(status)) {
830 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
831 "Failed to acquire semaphore[%p|%d|%d], %s",
832 handle, units, timeout,
833 acpi_format_exception(status)));
834 } else {
835 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
836 "Acquired semaphore[%p|%d|%d]", handle,
837 units, timeout));
840 return status;
843 EXPORT_SYMBOL(acpi_os_wait_semaphore);
846 * TODO: Support for units > 1?
848 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
850 struct semaphore *sem = (struct semaphore *)handle;
853 if (!sem || (units < 1))
854 return AE_BAD_PARAMETER;
856 if (units > 1)
857 return AE_SUPPORT;
859 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
860 units));
862 up(sem);
864 return AE_OK;
867 EXPORT_SYMBOL(acpi_os_signal_semaphore);
869 #ifdef ACPI_FUTURE_USAGE
870 u32 acpi_os_get_line(char *buffer)
873 #ifdef ENABLE_DEBUGGER
874 if (acpi_in_debugger) {
875 u32 chars;
877 kdb_read(buffer, sizeof(line_buf));
879 /* remove the CR kdb includes */
880 chars = strlen(buffer) - 1;
881 buffer[chars] = '\0';
883 #endif
885 return 0;
887 #endif /* ACPI_FUTURE_USAGE */
889 acpi_status acpi_os_signal(u32 function, void *info)
891 switch (function) {
892 case ACPI_SIGNAL_FATAL:
893 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
894 break;
895 case ACPI_SIGNAL_BREAKPOINT:
897 * AML Breakpoint
898 * ACPI spec. says to treat it as a NOP unless
899 * you are debugging. So if/when we integrate
900 * AML debugger into the kernel debugger its
901 * hook will go here. But until then it is
902 * not useful to print anything on breakpoints.
904 break;
905 default:
906 break;
909 return AE_OK;
912 EXPORT_SYMBOL(acpi_os_signal);
914 static int __init acpi_os_name_setup(char *str)
916 char *p = acpi_os_name;
917 int count = ACPI_MAX_OVERRIDE_LEN - 1;
919 if (!str || !*str)
920 return 0;
922 for (; count-- && str && *str; str++) {
923 if (isalnum(*str) || *str == ' ' || *str == ':')
924 *p++ = *str;
925 else if (*str == '\'' || *str == '"')
926 continue;
927 else
928 break;
930 *p = 0;
932 return 1;
936 __setup("acpi_os_name=", acpi_os_name_setup);
939 * _OSI control
940 * empty string disables _OSI
941 * TBD additional string adds to _OSI
943 static int __init acpi_osi_setup(char *str)
945 if (str == NULL || *str == '\0') {
946 printk(KERN_INFO PREFIX "_OSI method disabled\n");
947 acpi_gbl_create_osi_method = FALSE;
948 } else {
949 /* TBD */
950 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
951 str);
954 return 1;
957 __setup("acpi_osi=", acpi_osi_setup);
959 /* enable serialization to combat AE_ALREADY_EXISTS errors */
960 static int __init acpi_serialize_setup(char *str)
962 printk(KERN_INFO PREFIX "serialize enabled\n");
964 acpi_gbl_all_methods_serialized = TRUE;
966 return 1;
969 __setup("acpi_serialize", acpi_serialize_setup);
972 * Wake and Run-Time GPES are expected to be separate.
973 * We disable wake-GPEs at run-time to prevent spurious
974 * interrupts.
976 * However, if a system exists that shares Wake and
977 * Run-time events on the same GPE this flag is available
978 * to tell Linux to keep the wake-time GPEs enabled at run-time.
980 static int __init acpi_wake_gpes_always_on_setup(char *str)
982 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
984 acpi_gbl_leave_wake_gpes_disabled = FALSE;
986 return 1;
989 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
992 * max_cstate is defined in the base kernel so modules can
993 * change it w/o depending on the state of the processor module.
995 unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
997 EXPORT_SYMBOL(max_cstate);
1000 * Acquire a spinlock.
1002 * handle is a pointer to the spinlock_t.
1005 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1007 acpi_cpu_flags flags;
1008 spin_lock_irqsave(lockp, flags);
1009 return flags;
1013 * Release a spinlock. See above.
1016 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1018 spin_unlock_irqrestore(lockp, flags);
1021 #ifndef ACPI_USE_LOCAL_CACHE
1023 /*******************************************************************************
1025 * FUNCTION: acpi_os_create_cache
1027 * PARAMETERS: name - Ascii name for the cache
1028 * size - Size of each cached object
1029 * depth - Maximum depth of the cache (in objects) <ignored>
1030 * cache - Where the new cache object is returned
1032 * RETURN: status
1034 * DESCRIPTION: Create a cache object
1036 ******************************************************************************/
1038 acpi_status
1039 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1041 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1042 if (*cache == NULL)
1043 return AE_ERROR;
1044 else
1045 return AE_OK;
1048 /*******************************************************************************
1050 * FUNCTION: acpi_os_purge_cache
1052 * PARAMETERS: Cache - Handle to cache object
1054 * RETURN: Status
1056 * DESCRIPTION: Free all objects within the requested cache.
1058 ******************************************************************************/
1060 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1062 kmem_cache_shrink(cache);
1063 return (AE_OK);
1066 /*******************************************************************************
1068 * FUNCTION: acpi_os_delete_cache
1070 * PARAMETERS: Cache - Handle to cache object
1072 * RETURN: Status
1074 * DESCRIPTION: Free all objects within the requested cache and delete the
1075 * cache object.
1077 ******************************************************************************/
1079 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1081 kmem_cache_destroy(cache);
1082 return (AE_OK);
1085 /*******************************************************************************
1087 * FUNCTION: acpi_os_release_object
1089 * PARAMETERS: Cache - Handle to cache object
1090 * Object - The object to be released
1092 * RETURN: None
1094 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1095 * the object is deleted.
1097 ******************************************************************************/
1099 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1101 kmem_cache_free(cache, object);
1102 return (AE_OK);
1105 /******************************************************************************
1107 * FUNCTION: acpi_os_validate_interface
1109 * PARAMETERS: interface - Requested interface to be validated
1111 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1113 * DESCRIPTION: Match an interface string to the interfaces supported by the
1114 * host. Strings originate from an AML call to the _OSI method.
1116 *****************************************************************************/
1118 acpi_status
1119 acpi_os_validate_interface (char *interface)
1122 return AE_SUPPORT;
1126 /******************************************************************************
1128 * FUNCTION: acpi_os_validate_address
1130 * PARAMETERS: space_id - ACPI space ID
1131 * address - Physical address
1132 * length - Address length
1134 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1135 * should return AE_AML_ILLEGAL_ADDRESS.
1137 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1138 * the addresses accessed by AML operation regions.
1140 *****************************************************************************/
1142 acpi_status
1143 acpi_os_validate_address (
1144 u8 space_id,
1145 acpi_physical_address address,
1146 acpi_size length)
1149 return AE_OK;
1153 #endif