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/config.h>
29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/slab.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 <linux/kthread.h>
41 #include <acpi/acpi.h>
43 #include <acpi/acpi_bus.h>
44 #include <acpi/processor.h>
45 #include <asm/uaccess.h>
47 #include <linux/efi.h>
49 #define _COMPONENT ACPI_OS_SERVICES
50 ACPI_MODULE_NAME("osl")
51 #define PREFIX "ACPI: "
53 acpi_osd_exec_callback function
;
57 #ifdef CONFIG_ACPI_CUSTOM_DSDT
58 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
61 #ifdef ENABLE_DEBUGGER
62 #include <linux/kdb.h>
64 /* stuff for debugger support */
66 EXPORT_SYMBOL(acpi_in_debugger
);
68 extern char line_buf
[80];
69 #endif /*ENABLE_DEBUGGER */
71 int acpi_specific_hotkey_enabled
= TRUE
;
72 EXPORT_SYMBOL(acpi_specific_hotkey_enabled
);
74 static unsigned int acpi_irq_irq
;
75 static acpi_osd_handler acpi_irq_handler
;
76 static void *acpi_irq_context
;
77 static struct workqueue_struct
*kacpid_wq
;
79 acpi_status
acpi_os_initialize(void)
84 acpi_status
acpi_os_initialize1(void)
87 * Initialize PCI configuration space access, as we'll need to access
88 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
91 printk(KERN_ERR PREFIX
92 "Access to PCI configuration space unavailable\n");
95 kacpid_wq
= create_singlethread_workqueue("kacpid");
101 acpi_status
acpi_os_terminate(void)
103 if (acpi_irq_handler
) {
104 acpi_os_remove_interrupt_handler(acpi_irq_irq
,
108 destroy_workqueue(kacpid_wq
);
113 void acpi_os_printf(const char *fmt
, ...)
117 acpi_os_vprintf(fmt
, args
);
121 EXPORT_SYMBOL(acpi_os_printf
);
123 void acpi_os_vprintf(const char *fmt
, va_list args
)
125 static char buffer
[512];
127 vsprintf(buffer
, fmt
, args
);
129 #ifdef ENABLE_DEBUGGER
130 if (acpi_in_debugger
) {
131 kdb_printf("%s", buffer
);
133 printk("%s", buffer
);
136 printk("%s", buffer
);
141 extern int acpi_in_resume
;
142 void *acpi_os_allocate(acpi_size size
)
145 return kmalloc(size
, GFP_ATOMIC
);
147 return kmalloc(size
, GFP_KERNEL
);
150 void acpi_os_free(void *ptr
)
155 EXPORT_SYMBOL(acpi_os_free
);
157 acpi_status
acpi_os_get_root_pointer(u32 flags
, struct acpi_pointer
*addr
)
160 addr
->pointer_type
= ACPI_PHYSICAL_POINTER
;
161 if (efi
.acpi20
!= EFI_INVALID_TABLE_ADDR
)
162 addr
->pointer
.physical
= efi
.acpi20
;
163 else if (efi
.acpi
!= EFI_INVALID_TABLE_ADDR
)
164 addr
->pointer
.physical
= efi
.acpi
;
166 printk(KERN_ERR PREFIX
167 "System description tables not found\n");
171 if (ACPI_FAILURE(acpi_find_root_pointer(flags
, addr
))) {
172 printk(KERN_ERR PREFIX
173 "System description tables not found\n");
182 acpi_os_map_memory(acpi_physical_address phys
, acpi_size size
,
183 void __iomem
** virt
)
185 if (phys
> ULONG_MAX
) {
186 printk(KERN_ERR PREFIX
"Cannot map memory that high\n");
187 return AE_BAD_PARAMETER
;
190 * ioremap checks to ensure this is in reserved space
192 *virt
= ioremap((unsigned long)phys
, size
);
199 EXPORT_SYMBOL_GPL(acpi_os_map_memory
);
201 void acpi_os_unmap_memory(void __iomem
* virt
, acpi_size size
)
205 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory
);
207 #ifdef ACPI_FUTURE_USAGE
209 acpi_os_get_physical_address(void *virt
, acpi_physical_address
* phys
)
212 return AE_BAD_PARAMETER
;
214 *phys
= virt_to_phys(virt
);
220 #define ACPI_MAX_OVERRIDE_LEN 100
222 static char acpi_os_name
[ACPI_MAX_OVERRIDE_LEN
];
225 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
226 acpi_string
* new_val
)
228 if (!init_val
|| !new_val
)
229 return AE_BAD_PARAMETER
;
232 if (!memcmp(init_val
->name
, "_OS_", 4) && strlen(acpi_os_name
)) {
233 printk(KERN_INFO PREFIX
"Overriding _OS definition to '%s'\n",
235 *new_val
= acpi_os_name
;
242 acpi_os_table_override(struct acpi_table_header
* existing_table
,
243 struct acpi_table_header
** new_table
)
245 if (!existing_table
|| !new_table
)
246 return AE_BAD_PARAMETER
;
248 #ifdef CONFIG_ACPI_CUSTOM_DSDT
249 if (strncmp(existing_table
->signature
, "DSDT", 4) == 0)
250 *new_table
= (struct acpi_table_header
*)AmlCode
;
259 static irqreturn_t
acpi_irq(int irq
, void *dev_id
, struct pt_regs
*regs
)
261 return (*acpi_irq_handler
) (acpi_irq_context
) ? IRQ_HANDLED
: IRQ_NONE
;
265 acpi_os_install_interrupt_handler(u32 gsi
, acpi_osd_handler handler
,
271 * Ignore the GSI from the core, and use the value in our copy of the
272 * FADT. It may not be the same if an interrupt source override exists
275 gsi
= acpi_fadt
.sci_int
;
276 if (acpi_gsi_to_irq(gsi
, &irq
) < 0) {
277 printk(KERN_ERR PREFIX
"SCI (ACPI GSI %d) not registered\n",
282 acpi_irq_handler
= handler
;
283 acpi_irq_context
= context
;
284 if (request_irq(irq
, acpi_irq
, SA_SHIRQ
, "acpi", acpi_irq
)) {
285 printk(KERN_ERR PREFIX
"SCI (IRQ%d) allocation failed\n", irq
);
286 return AE_NOT_ACQUIRED
;
293 acpi_status
acpi_os_remove_interrupt_handler(u32 irq
, acpi_osd_handler handler
)
296 free_irq(irq
, acpi_irq
);
297 acpi_irq_handler
= NULL
;
305 * Running in interpreter thread context, safe to sleep
308 void acpi_os_sleep(acpi_integer ms
)
310 schedule_timeout_interruptible(msecs_to_jiffies(ms
));
313 EXPORT_SYMBOL(acpi_os_sleep
);
315 void acpi_os_stall(u32 us
)
323 touch_nmi_watchdog();
328 EXPORT_SYMBOL(acpi_os_stall
);
331 * Support ACPI 3.0 AML Timer operand
332 * Returns 64-bit free-running, monotonically increasing timer
333 * with 100ns granularity
335 u64
acpi_os_get_timer(void)
340 /* TBD: use HPET if available */
343 #ifdef CONFIG_X86_PM_TIMER
344 /* TBD: default to PM timer if HPET was not available */
347 printk(KERN_ERR PREFIX
"acpi_os_get_timer() TBD\n");
352 acpi_status
acpi_os_read_port(acpi_io_address port
, u32
* value
, u32 width
)
361 *(u8
*) value
= inb(port
);
364 *(u16
*) value
= inw(port
);
367 *(u32
*) value
= inl(port
);
376 EXPORT_SYMBOL(acpi_os_read_port
);
378 acpi_status
acpi_os_write_port(acpi_io_address port
, u32 value
, u32 width
)
397 EXPORT_SYMBOL(acpi_os_write_port
);
400 acpi_os_read_memory(acpi_physical_address phys_addr
, u32
* value
, u32 width
)
403 void __iomem
*virt_addr
;
405 virt_addr
= ioremap(phys_addr
, width
);
411 *(u8
*) value
= readb(virt_addr
);
414 *(u16
*) value
= readw(virt_addr
);
417 *(u32
*) value
= readl(virt_addr
);
429 acpi_os_write_memory(acpi_physical_address phys_addr
, u32 value
, u32 width
)
431 void __iomem
*virt_addr
;
433 virt_addr
= ioremap(phys_addr
, width
);
437 writeb(value
, virt_addr
);
440 writew(value
, virt_addr
);
443 writel(value
, virt_addr
);
455 acpi_os_read_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
456 void *value
, u32 width
)
461 return AE_BAD_PARAMETER
;
477 BUG_ON(!raw_pci_ops
);
479 result
= raw_pci_ops
->read(pci_id
->segment
, pci_id
->bus
,
480 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
483 return (result
? AE_ERROR
: AE_OK
);
486 EXPORT_SYMBOL(acpi_os_read_pci_configuration
);
489 acpi_os_write_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
490 acpi_integer value
, u32 width
)
508 BUG_ON(!raw_pci_ops
);
510 result
= raw_pci_ops
->write(pci_id
->segment
, pci_id
->bus
,
511 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
514 return (result
? AE_ERROR
: AE_OK
);
517 /* TODO: Change code to take advantage of driver model more */
518 static void acpi_os_derive_pci_id_2(acpi_handle rhandle
, /* upper bound */
519 acpi_handle chandle
, /* current node */
520 struct acpi_pci_id
**id
,
521 int *is_bridge
, u8
* bus_number
)
524 struct acpi_pci_id
*pci_id
= *id
;
527 acpi_object_type type
;
530 acpi_get_parent(chandle
, &handle
);
531 if (handle
!= rhandle
) {
532 acpi_os_derive_pci_id_2(rhandle
, handle
, &pci_id
, is_bridge
,
535 status
= acpi_get_type(handle
, &type
);
536 if ((ACPI_FAILURE(status
)) || (type
!= ACPI_TYPE_DEVICE
))
540 acpi_evaluate_integer(handle
, METHOD_NAME__ADR
, NULL
,
542 if (ACPI_SUCCESS(status
)) {
543 pci_id
->device
= ACPI_HIWORD(ACPI_LODWORD(temp
));
544 pci_id
->function
= ACPI_LOWORD(ACPI_LODWORD(temp
));
547 pci_id
->bus
= *bus_number
;
549 /* any nicer way to get bus number of bridge ? */
551 acpi_os_read_pci_configuration(pci_id
, 0x0e, &tu8
,
553 if (ACPI_SUCCESS(status
)
554 && ((tu8
& 0x7f) == 1 || (tu8
& 0x7f) == 2)) {
556 acpi_os_read_pci_configuration(pci_id
, 0x18,
558 if (!ACPI_SUCCESS(status
)) {
559 /* Certainly broken... FIX ME */
565 acpi_os_read_pci_configuration(pci_id
, 0x19,
567 if (ACPI_SUCCESS(status
)) {
576 void acpi_os_derive_pci_id(acpi_handle rhandle
, /* upper bound */
577 acpi_handle chandle
, /* current node */
578 struct acpi_pci_id
**id
)
581 u8 bus_number
= (*id
)->bus
;
583 acpi_os_derive_pci_id_2(rhandle
, chandle
, id
, &is_bridge
, &bus_number
);
586 static void acpi_os_execute_deferred(void *context
)
588 struct acpi_os_dpc
*dpc
= NULL
;
590 ACPI_FUNCTION_TRACE("os_execute_deferred");
592 dpc
= (struct acpi_os_dpc
*)context
;
594 ACPI_ERROR((AE_INFO
, "Invalid (NULL) context"));
598 dpc
->function(dpc
->context
);
605 static int acpi_os_execute_thread(void *context
)
607 struct acpi_os_dpc
*dpc
= (struct acpi_os_dpc
*)context
;
609 dpc
->function(dpc
->context
);
615 /*******************************************************************************
617 * FUNCTION: acpi_os_execute
619 * PARAMETERS: Type - Type of the callback
620 * Function - Function to be executed
621 * Context - Function parameters
625 * DESCRIPTION: Depending on type, either queues function for deferred execution or
626 * immediately executes function on a separate thread.
628 ******************************************************************************/
630 acpi_status
acpi_os_execute(acpi_execute_type type
,
631 acpi_osd_exec_callback function
, void *context
)
633 acpi_status status
= AE_OK
;
634 struct acpi_os_dpc
*dpc
;
635 struct work_struct
*task
;
636 struct task_struct
*p
;
639 return AE_BAD_PARAMETER
;
641 * Allocate/initialize DPC structure. Note that this memory will be
642 * freed by the callee. The kernel handles the tq_struct list in a
643 * way that allows us to also free its memory inside the callee.
644 * Because we may want to schedule several tasks with different
645 * parameters we can't use the approach some kernel code uses of
646 * having a static tq_struct.
647 * We can save time and code by allocating the DPC and tq_structs
648 * from the same memory.
650 if (type
== OSL_NOTIFY_HANDLER
) {
651 dpc
= kmalloc(sizeof(struct acpi_os_dpc
), GFP_KERNEL
);
653 dpc
= kmalloc(sizeof(struct acpi_os_dpc
) +
654 sizeof(struct work_struct
), GFP_ATOMIC
);
658 dpc
->function
= function
;
659 dpc
->context
= context
;
661 if (type
== OSL_NOTIFY_HANDLER
) {
662 p
= kthread_create(acpi_os_execute_thread
, dpc
, "kacpid_notify");
666 status
= AE_NO_MEMORY
;
670 task
= (void *)(dpc
+ 1);
671 INIT_WORK(task
, acpi_os_execute_deferred
, (void *)dpc
);
672 if (!queue_work(kacpid_wq
, task
)) {
680 EXPORT_SYMBOL(acpi_os_execute
);
682 void acpi_os_wait_events_complete(void *context
)
684 flush_workqueue(kacpid_wq
);
687 EXPORT_SYMBOL(acpi_os_wait_events_complete
);
690 * Allocate the memory for a spinlock and initialize it.
692 acpi_status
acpi_os_create_lock(acpi_handle
* out_handle
)
694 spinlock_t
*lock_ptr
;
696 ACPI_FUNCTION_TRACE("os_create_lock");
698 lock_ptr
= acpi_os_allocate(sizeof(spinlock_t
));
700 spin_lock_init(lock_ptr
);
702 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating spinlock[%p].\n", lock_ptr
));
704 *out_handle
= lock_ptr
;
706 return_ACPI_STATUS(AE_OK
);
710 * Deallocate the memory for a spinlock.
712 void acpi_os_delete_lock(acpi_handle handle
)
714 ACPI_FUNCTION_TRACE("os_create_lock");
716 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting spinlock[%p].\n", handle
));
718 acpi_os_free(handle
);
724 acpi_os_create_semaphore(u32 max_units
, u32 initial_units
, acpi_handle
* handle
)
726 struct semaphore
*sem
= NULL
;
728 ACPI_FUNCTION_TRACE("os_create_semaphore");
730 sem
= acpi_os_allocate(sizeof(struct semaphore
));
732 return_ACPI_STATUS(AE_NO_MEMORY
);
733 memset(sem
, 0, sizeof(struct semaphore
));
735 sema_init(sem
, initial_units
);
737 *handle
= (acpi_handle
*) sem
;
739 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating semaphore[%p|%d].\n",
740 *handle
, initial_units
));
742 return_ACPI_STATUS(AE_OK
);
745 EXPORT_SYMBOL(acpi_os_create_semaphore
);
748 * TODO: A better way to delete semaphores? Linux doesn't have a
749 * 'delete_semaphore()' function -- may result in an invalid
750 * pointer dereference for non-synchronized consumers. Should
751 * we at least check for blocked threads and signal/cancel them?
754 acpi_status
acpi_os_delete_semaphore(acpi_handle handle
)
756 struct semaphore
*sem
= (struct semaphore
*)handle
;
758 ACPI_FUNCTION_TRACE("os_delete_semaphore");
761 return_ACPI_STATUS(AE_BAD_PARAMETER
);
763 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting semaphore[%p].\n", handle
));
768 return_ACPI_STATUS(AE_OK
);
771 EXPORT_SYMBOL(acpi_os_delete_semaphore
);
774 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
775 * improvise. The process is to sleep for one scheduler quantum
776 * until the semaphore becomes available. Downside is that this
777 * may result in starvation for timeout-based waits when there's
778 * lots of semaphore activity.
780 * TODO: Support for units > 1?
782 acpi_status
acpi_os_wait_semaphore(acpi_handle handle
, u32 units
, u16 timeout
)
784 acpi_status status
= AE_OK
;
785 struct semaphore
*sem
= (struct semaphore
*)handle
;
788 ACPI_FUNCTION_TRACE("os_wait_semaphore");
790 if (!sem
|| (units
< 1))
791 return_ACPI_STATUS(AE_BAD_PARAMETER
);
794 return_ACPI_STATUS(AE_SUPPORT
);
796 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Waiting for semaphore[%p|%d|%d]\n",
797 handle
, units
, timeout
));
803 * A zero timeout value indicates that we shouldn't wait - just
804 * acquire the semaphore if available otherwise return AE_TIME
805 * (a.k.a. 'would block').
808 if (down_trylock(sem
))
816 case ACPI_WAIT_FOREVER
:
825 // TODO: A better timeout algorithm?
828 static const int quantum_ms
= 1000 / HZ
;
830 ret
= down_trylock(sem
);
831 for (i
= timeout
; (i
> 0 && ret
!= 0); i
-= quantum_ms
) {
832 schedule_timeout_interruptible(1);
833 ret
= down_trylock(sem
);
842 if (ACPI_FAILURE(status
)) {
843 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
844 "Failed to acquire semaphore[%p|%d|%d], %s",
845 handle
, units
, timeout
,
846 acpi_format_exception(status
)));
848 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
849 "Acquired semaphore[%p|%d|%d]", handle
,
853 return_ACPI_STATUS(status
);
856 EXPORT_SYMBOL(acpi_os_wait_semaphore
);
859 * TODO: Support for units > 1?
861 acpi_status
acpi_os_signal_semaphore(acpi_handle handle
, u32 units
)
863 struct semaphore
*sem
= (struct semaphore
*)handle
;
865 ACPI_FUNCTION_TRACE("os_signal_semaphore");
867 if (!sem
|| (units
< 1))
868 return_ACPI_STATUS(AE_BAD_PARAMETER
);
871 return_ACPI_STATUS(AE_SUPPORT
);
873 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Signaling semaphore[%p|%d]\n", handle
,
878 return_ACPI_STATUS(AE_OK
);
881 EXPORT_SYMBOL(acpi_os_signal_semaphore
);
883 #ifdef ACPI_FUTURE_USAGE
884 u32
acpi_os_get_line(char *buffer
)
887 #ifdef ENABLE_DEBUGGER
888 if (acpi_in_debugger
) {
891 kdb_read(buffer
, sizeof(line_buf
));
893 /* remove the CR kdb includes */
894 chars
= strlen(buffer
) - 1;
895 buffer
[chars
] = '\0';
901 #endif /* ACPI_FUTURE_USAGE */
903 /* Assumes no unreadable holes inbetween */
904 u8
acpi_os_readable(void *ptr
, acpi_size len
)
906 #if defined(__i386__) || defined(__x86_64__)
908 return !__get_user(tmp
, (char __user
*)ptr
)
909 && !__get_user(tmp
, (char __user
*)ptr
+ len
- 1);
914 #ifdef ACPI_FUTURE_USAGE
915 u8
acpi_os_writable(void *ptr
, acpi_size len
)
917 /* could do dummy write (racy) or a kernel page table lookup.
918 The later may be difficult at early boot when kmap doesn't work yet. */
923 acpi_status
acpi_os_signal(u32 function
, void *info
)
926 case ACPI_SIGNAL_FATAL
:
927 printk(KERN_ERR PREFIX
"Fatal opcode executed\n");
929 case ACPI_SIGNAL_BREAKPOINT
:
932 * ACPI spec. says to treat it as a NOP unless
933 * you are debugging. So if/when we integrate
934 * AML debugger into the kernel debugger its
935 * hook will go here. But until then it is
936 * not useful to print anything on breakpoints.
946 EXPORT_SYMBOL(acpi_os_signal
);
948 static int __init
acpi_os_name_setup(char *str
)
950 char *p
= acpi_os_name
;
951 int count
= ACPI_MAX_OVERRIDE_LEN
- 1;
956 for (; count
-- && str
&& *str
; str
++) {
957 if (isalnum(*str
) || *str
== ' ' || *str
== ':')
959 else if (*str
== '\'' || *str
== '"')
970 __setup("acpi_os_name=", acpi_os_name_setup
);
974 * empty string disables _OSI
975 * TBD additional string adds to _OSI
977 static int __init
acpi_osi_setup(char *str
)
979 if (str
== NULL
|| *str
== '\0') {
980 printk(KERN_INFO PREFIX
"_OSI method disabled\n");
981 acpi_gbl_create_osi_method
= FALSE
;
984 printk(KERN_ERR PREFIX
"_OSI additional string ignored -- %s\n",
991 __setup("acpi_osi=", acpi_osi_setup
);
993 /* enable serialization to combat AE_ALREADY_EXISTS errors */
994 static int __init
acpi_serialize_setup(char *str
)
996 printk(KERN_INFO PREFIX
"serialize enabled\n");
998 acpi_gbl_all_methods_serialized
= TRUE
;
1003 __setup("acpi_serialize", acpi_serialize_setup
);
1006 * Wake and Run-Time GPES are expected to be separate.
1007 * We disable wake-GPEs at run-time to prevent spurious
1010 * However, if a system exists that shares Wake and
1011 * Run-time events on the same GPE this flag is available
1012 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1014 static int __init
acpi_wake_gpes_always_on_setup(char *str
)
1016 printk(KERN_INFO PREFIX
"wake GPEs not disabled\n");
1018 acpi_gbl_leave_wake_gpes_disabled
= FALSE
;
1023 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup
);
1025 static int __init
acpi_hotkey_setup(char *str
)
1027 acpi_specific_hotkey_enabled
= FALSE
;
1031 __setup("acpi_generic_hotkey", acpi_hotkey_setup
);
1034 * max_cstate is defined in the base kernel so modules can
1035 * change it w/o depending on the state of the processor module.
1037 unsigned int max_cstate
= ACPI_PROCESSOR_MAX_POWER
;
1039 EXPORT_SYMBOL(max_cstate
);
1042 * Acquire a spinlock.
1044 * handle is a pointer to the spinlock_t.
1047 acpi_cpu_flags
acpi_os_acquire_lock(acpi_handle handle
)
1049 acpi_cpu_flags flags
;
1050 spin_lock_irqsave((spinlock_t
*) handle
, flags
);
1055 * Release a spinlock. See above.
1058 void acpi_os_release_lock(acpi_handle handle
, acpi_cpu_flags flags
)
1060 spin_unlock_irqrestore((spinlock_t
*) handle
, flags
);
1063 #ifndef ACPI_USE_LOCAL_CACHE
1065 /*******************************************************************************
1067 * FUNCTION: acpi_os_create_cache
1069 * PARAMETERS: name - Ascii name for the cache
1070 * size - Size of each cached object
1071 * depth - Maximum depth of the cache (in objects) <ignored>
1072 * cache - Where the new cache object is returned
1076 * DESCRIPTION: Create a cache object
1078 ******************************************************************************/
1081 acpi_os_create_cache(char *name
, u16 size
, u16 depth
, acpi_cache_t
** cache
)
1083 *cache
= kmem_cache_create(name
, size
, 0, 0, NULL
, NULL
);
1090 /*******************************************************************************
1092 * FUNCTION: acpi_os_purge_cache
1094 * PARAMETERS: Cache - Handle to cache object
1098 * DESCRIPTION: Free all objects within the requested cache.
1100 ******************************************************************************/
1102 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
)
1104 (void)kmem_cache_shrink(cache
);
1108 /*******************************************************************************
1110 * FUNCTION: acpi_os_delete_cache
1112 * PARAMETERS: Cache - Handle to cache object
1116 * DESCRIPTION: Free all objects within the requested cache and delete the
1119 ******************************************************************************/
1121 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
)
1123 (void)kmem_cache_destroy(cache
);
1127 /*******************************************************************************
1129 * FUNCTION: acpi_os_release_object
1131 * PARAMETERS: Cache - Handle to cache object
1132 * Object - The object to be released
1136 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1137 * the object is deleted.
1139 ******************************************************************************/
1141 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
)
1143 kmem_cache_free(cache
, object
);
1147 /*******************************************************************************
1149 * FUNCTION: acpi_os_acquire_object
1151 * PARAMETERS: Cache - Handle to cache object
1152 * ReturnObject - Where the object is returned
1156 * DESCRIPTION: Return a zero-filled object.
1158 ******************************************************************************/
1160 void *acpi_os_acquire_object(acpi_cache_t
* cache
)
1162 void *object
= kmem_cache_zalloc(cache
, GFP_KERNEL
);
1167 /******************************************************************************
1169 * FUNCTION: acpi_os_validate_interface
1171 * PARAMETERS: interface - Requested interface to be validated
1173 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1175 * DESCRIPTION: Match an interface string to the interfaces supported by the
1176 * host. Strings originate from an AML call to the _OSI method.
1178 *****************************************************************************/
1181 acpi_os_validate_interface (char *interface
)
1188 /******************************************************************************
1190 * FUNCTION: acpi_os_validate_address
1192 * PARAMETERS: space_id - ACPI space ID
1193 * address - Physical address
1194 * length - Address length
1196 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1197 * should return AE_AML_ILLEGAL_ADDRESS.
1199 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1200 * the addresses accessed by AML operation regions.
1202 *****************************************************************************/
1205 acpi_os_validate_address (
1207 acpi_physical_address address
,