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 <acpi/acpi.h>
42 #include <acpi/acpi_bus.h>
43 #include <acpi/processor.h>
44 #include <asm/uaccess.h>
46 #include <linux/efi.h>
48 #define _COMPONENT ACPI_OS_SERVICES
49 ACPI_MODULE_NAME("osl")
50 #define PREFIX "ACPI: "
52 acpi_osd_exec_callback function;
56 #ifdef CONFIG_ACPI_CUSTOM_DSDT
57 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
60 #ifdef ENABLE_DEBUGGER
61 #include <linux/kdb.h>
63 /* stuff for debugger support */
65 EXPORT_SYMBOL(acpi_in_debugger);
67 extern char line_buf[80];
68 #endif /*ENABLE_DEBUGGER */
70 int acpi_specific_hotkey_enabled;
71 EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
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;
78 acpi_status acpi_os_initialize(void)
83 acpi_status acpi_os_initialize1(void)
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).
89 #ifdef CONFIG_ACPI_PCI
91 printk(KERN_ERR PREFIX
92 "Access to PCI configuration space unavailable\n");
96 kacpid_wq = create_singlethread_workqueue("kacpid");
102 acpi_status acpi_os_terminate(void)
104 if (acpi_irq_handler) {
105 acpi_os_remove_interrupt_handler(acpi_irq_irq,
109 destroy_workqueue(kacpid_wq);
114 void acpi_os_printf(const char *fmt, ...)
118 acpi_os_vprintf(fmt, args);
122 EXPORT_SYMBOL(acpi_os_printf);
124 void acpi_os_vprintf(const char *fmt, va_list args)
126 static char buffer[512];
128 vsprintf(buffer, fmt, args);
130 #ifdef ENABLE_DEBUGGER
131 if (acpi_in_debugger) {
132 kdb_printf("%s", buffer);
134 printk("%s", buffer);
137 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;
162 addr->pointer.physical =
163 (acpi_physical_address) virt_to_phys(efi.acpi20);
165 addr->pointer.physical =
166 (acpi_physical_address) virt_to_phys(efi.acpi);
168 printk(KERN_ERR PREFIX
169 "System description tables not found\n");
173 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
174 printk(KERN_ERR PREFIX
175 "System description tables not found\n");
184 acpi_os_map_memory(acpi_physical_address phys, acpi_size size,
185 void __iomem ** virt)
188 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) {
189 *virt = (void __iomem *)phys_to_virt(phys);
191 *virt = ioremap(phys, size);
194 if (phys > ULONG_MAX) {
195 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
196 return AE_BAD_PARAMETER;
199 * ioremap checks to ensure this is in reserved space
201 *virt = ioremap((unsigned long)phys, size);
210 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
215 #ifdef ACPI_FUTURE_USAGE
217 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
220 return AE_BAD_PARAMETER;
222 *phys = virt_to_phys(virt);
228 #define ACPI_MAX_OVERRIDE_LEN 100
230 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
233 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
234 acpi_string * new_val)
236 if (!init_val || !new_val)
237 return AE_BAD_PARAMETER;
240 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
241 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
243 *new_val = acpi_os_name;
250 acpi_os_table_override(struct acpi_table_header * existing_table,
251 struct acpi_table_header ** new_table)
253 if (!existing_table || !new_table)
254 return AE_BAD_PARAMETER;
256 #ifdef CONFIG_ACPI_CUSTOM_DSDT
257 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
258 *new_table = (struct acpi_table_header *)AmlCode;
267 static irqreturn_t acpi_irq(int irq, void *dev_id, struct pt_regs *regs)
269 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
273 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
279 * Ignore the GSI from the core, and use the value in our copy of the
280 * FADT. It may not be the same if an interrupt source override exists
283 gsi = acpi_fadt.sci_int;
284 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
285 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
290 acpi_irq_handler = handler;
291 acpi_irq_context = context;
292 if (request_irq(irq, acpi_irq, SA_SHIRQ, "acpi", acpi_irq)) {
293 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
294 return AE_NOT_ACQUIRED;
301 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
304 free_irq(irq, acpi_irq);
305 acpi_irq_handler = NULL;
313 * Running in interpreter thread context, safe to sleep
316 void acpi_os_sleep(acpi_integer ms)
318 current->state = TASK_INTERRUPTIBLE;
319 schedule_timeout(((signed long)ms * HZ) / 1000);
322 EXPORT_SYMBOL(acpi_os_sleep);
324 void acpi_os_stall(u32 us)
332 touch_nmi_watchdog();
337 EXPORT_SYMBOL(acpi_os_stall);
340 * Support ACPI 3.0 AML Timer operand
341 * Returns 64-bit free-running, monotonically increasing timer
342 * with 100ns granularity
344 u64 acpi_os_get_timer(void)
349 /* TBD: use HPET if available */
352 #ifdef CONFIG_X86_PM_TIMER
353 /* TBD: default to PM timer if HPET was not available */
356 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
361 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
370 *(u8 *) value = inb(port);
373 *(u16 *) value = inw(port);
376 *(u32 *) value = inl(port);
385 EXPORT_SYMBOL(acpi_os_read_port);
387 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
406 EXPORT_SYMBOL(acpi_os_write_port);
409 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
412 void __iomem *virt_addr;
416 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
417 /* HACK ALERT! We can use readb/w/l on real memory too.. */
418 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
421 virt_addr = ioremap(phys_addr, width);
424 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
430 *(u8 *) value = readb(virt_addr);
433 *(u16 *) value = readw(virt_addr);
436 *(u32 *) value = readl(virt_addr);
451 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
453 void __iomem *virt_addr;
457 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
458 /* HACK ALERT! We can use writeb/w/l on real memory too */
459 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
462 virt_addr = ioremap(phys_addr, width);
465 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
469 writeb(value, virt_addr);
472 writew(value, virt_addr);
475 writel(value, virt_addr);
487 #ifdef CONFIG_ACPI_PCI
490 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
491 void *value, u32 width)
496 return AE_BAD_PARAMETER;
512 BUG_ON(!raw_pci_ops);
514 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
515 PCI_DEVFN(pci_id->device, pci_id->function),
518 return (result ? AE_ERROR : AE_OK);
521 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
524 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
525 acpi_integer value, u32 width)
543 BUG_ON(!raw_pci_ops);
545 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
546 PCI_DEVFN(pci_id->device, pci_id->function),
549 return (result ? AE_ERROR : AE_OK);
552 /* TODO: Change code to take advantage of driver model more */
553 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
554 acpi_handle chandle, /* current node */
555 struct acpi_pci_id **id,
556 int *is_bridge, u8 * bus_number)
559 struct acpi_pci_id *pci_id = *id;
562 acpi_object_type type;
565 acpi_get_parent(chandle, &handle);
566 if (handle != rhandle) {
567 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
570 status = acpi_get_type(handle, &type);
571 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
575 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
577 if (ACPI_SUCCESS(status)) {
578 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
579 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
582 pci_id->bus = *bus_number;
584 /* any nicer way to get bus number of bridge ? */
586 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
588 if (ACPI_SUCCESS(status)
589 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
591 acpi_os_read_pci_configuration(pci_id, 0x18,
593 if (!ACPI_SUCCESS(status)) {
594 /* Certainly broken... FIX ME */
600 acpi_os_read_pci_configuration(pci_id, 0x19,
602 if (ACPI_SUCCESS(status)) {
611 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
612 acpi_handle chandle, /* current node */
613 struct acpi_pci_id **id)
616 u8 bus_number = (*id)->bus;
618 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
621 #else /*!CONFIG_ACPI_PCI */
624 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id,
625 u32 reg, acpi_integer value, u32 width)
631 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id,
632 u32 reg, void *value, u32 width)
637 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
638 acpi_handle chandle, /* current node */
639 struct acpi_pci_id **id)
643 #endif /*CONFIG_ACPI_PCI */
645 static void acpi_os_execute_deferred(void *context)
647 struct acpi_os_dpc *dpc = NULL;
649 ACPI_FUNCTION_TRACE("os_execute_deferred");
651 dpc = (struct acpi_os_dpc *)context;
653 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
657 dpc->function(dpc->context);
665 acpi_os_queue_for_execution(u32 priority,
666 acpi_osd_exec_callback function, void *context)
668 acpi_status status = AE_OK;
669 struct acpi_os_dpc *dpc;
670 struct work_struct *task;
672 ACPI_FUNCTION_TRACE("os_queue_for_execution");
674 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
675 "Scheduling function [%p(%p)] for deferred execution.\n",
679 return_ACPI_STATUS(AE_BAD_PARAMETER);
682 * Allocate/initialize DPC structure. Note that this memory will be
683 * freed by the callee. The kernel handles the tq_struct list in a
684 * way that allows us to also free its memory inside the callee.
685 * Because we may want to schedule several tasks with different
686 * parameters we can't use the approach some kernel code uses of
687 * having a static tq_struct.
688 * We can save time and code by allocating the DPC and tq_structs
689 * from the same memory.
693 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
696 return_ACPI_STATUS(AE_NO_MEMORY);
698 dpc->function = function;
699 dpc->context = context;
701 task = (void *)(dpc + 1);
702 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
704 if (!queue_work(kacpid_wq, task)) {
705 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
706 "Call to queue_work() failed.\n"));
711 return_ACPI_STATUS(status);
714 EXPORT_SYMBOL(acpi_os_queue_for_execution);
716 void acpi_os_wait_events_complete(void *context)
718 flush_workqueue(kacpid_wq);
721 EXPORT_SYMBOL(acpi_os_wait_events_complete);
724 * Allocate the memory for a spinlock and initialize it.
726 acpi_status acpi_os_create_lock(acpi_handle * out_handle)
728 spinlock_t *lock_ptr;
730 ACPI_FUNCTION_TRACE("os_create_lock");
732 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
734 spin_lock_init(lock_ptr);
736 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
738 *out_handle = lock_ptr;
740 return_ACPI_STATUS(AE_OK);
744 * Deallocate the memory for a spinlock.
746 void acpi_os_delete_lock(acpi_handle handle)
748 ACPI_FUNCTION_TRACE("os_create_lock");
750 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
752 acpi_os_free(handle);
758 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
760 struct semaphore *sem = NULL;
762 ACPI_FUNCTION_TRACE("os_create_semaphore");
764 sem = acpi_os_allocate(sizeof(struct semaphore));
766 return_ACPI_STATUS(AE_NO_MEMORY);
767 memset(sem, 0, sizeof(struct semaphore));
769 sema_init(sem, initial_units);
771 *handle = (acpi_handle *) sem;
773 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
774 *handle, initial_units));
776 return_ACPI_STATUS(AE_OK);
779 EXPORT_SYMBOL(acpi_os_create_semaphore);
782 * TODO: A better way to delete semaphores? Linux doesn't have a
783 * 'delete_semaphore()' function -- may result in an invalid
784 * pointer dereference for non-synchronized consumers. Should
785 * we at least check for blocked threads and signal/cancel them?
788 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
790 struct semaphore *sem = (struct semaphore *)handle;
792 ACPI_FUNCTION_TRACE("os_delete_semaphore");
795 return_ACPI_STATUS(AE_BAD_PARAMETER);
797 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
802 return_ACPI_STATUS(AE_OK);
805 EXPORT_SYMBOL(acpi_os_delete_semaphore);
808 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
809 * improvise. The process is to sleep for one scheduler quantum
810 * until the semaphore becomes available. Downside is that this
811 * may result in starvation for timeout-based waits when there's
812 * lots of semaphore activity.
814 * TODO: Support for units > 1?
816 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
818 acpi_status status = AE_OK;
819 struct semaphore *sem = (struct semaphore *)handle;
822 ACPI_FUNCTION_TRACE("os_wait_semaphore");
824 if (!sem || (units < 1))
825 return_ACPI_STATUS(AE_BAD_PARAMETER);
828 return_ACPI_STATUS(AE_SUPPORT);
830 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
831 handle, units, timeout));
840 * A zero timeout value indicates that we shouldn't wait - just
841 * acquire the semaphore if available otherwise return AE_TIME
842 * (a.k.a. 'would block').
845 if (down_trylock(sem))
853 case ACPI_WAIT_FOREVER:
862 // TODO: A better timeout algorithm?
865 static const int quantum_ms = 1000 / HZ;
867 ret = down_trylock(sem);
868 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
869 current->state = TASK_INTERRUPTIBLE;
871 ret = down_trylock(sem);
880 if (ACPI_FAILURE(status)) {
881 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
882 "Failed to acquire semaphore[%p|%d|%d], %s\n",
883 handle, units, timeout,
884 acpi_format_exception(status)));
886 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
887 "Acquired semaphore[%p|%d|%d]\n", handle,
891 return_ACPI_STATUS(status);
894 EXPORT_SYMBOL(acpi_os_wait_semaphore);
897 * TODO: Support for units > 1?
899 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
901 struct semaphore *sem = (struct semaphore *)handle;
903 ACPI_FUNCTION_TRACE("os_signal_semaphore");
905 if (!sem || (units < 1))
906 return_ACPI_STATUS(AE_BAD_PARAMETER);
909 return_ACPI_STATUS(AE_SUPPORT);
911 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
916 return_ACPI_STATUS(AE_OK);
919 EXPORT_SYMBOL(acpi_os_signal_semaphore);
921 #ifdef ACPI_FUTURE_USAGE
922 u32 acpi_os_get_line(char *buffer)
925 #ifdef ENABLE_DEBUGGER
926 if (acpi_in_debugger) {
929 kdb_read(buffer, sizeof(line_buf));
931 /* remove the CR kdb includes */
932 chars = strlen(buffer) - 1;
933 buffer[chars] = '\0';
939 #endif /* ACPI_FUTURE_USAGE */
941 /* Assumes no unreadable holes inbetween */
942 u8 acpi_os_readable(void *ptr, acpi_size len)
944 #if defined(__i386__) || defined(__x86_64__)
946 return !__get_user(tmp, (char __user *)ptr)
947 && !__get_user(tmp, (char __user *)ptr + len - 1);
952 #ifdef ACPI_FUTURE_USAGE
953 u8 acpi_os_writable(void *ptr, acpi_size len)
955 /* could do dummy write (racy) or a kernel page table lookup.
956 The later may be difficult at early boot when kmap doesn't work yet. */
961 u32 acpi_os_get_thread_id(void)
969 acpi_status acpi_os_signal(u32 function, void *info)
972 case ACPI_SIGNAL_FATAL:
973 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
975 case ACPI_SIGNAL_BREAKPOINT:
978 * ACPI spec. says to treat it as a NOP unless
979 * you are debugging. So if/when we integrate
980 * AML debugger into the kernel debugger its
981 * hook will go here. But until then it is
982 * not useful to print anything on breakpoints.
992 EXPORT_SYMBOL(acpi_os_signal);
994 static int __init acpi_os_name_setup(char *str)
996 char *p = acpi_os_name;
997 int count = ACPI_MAX_OVERRIDE_LEN - 1;
1002 for (; count-- && str && *str; str++) {
1003 if (isalnum(*str) || *str == ' ' || *str == ':')
1005 else if (*str == '\'' || *str == '"')
1016 __setup("acpi_os_name=", acpi_os_name_setup);
1020 * empty string disables _OSI
1021 * TBD additional string adds to _OSI
1023 static int __init acpi_osi_setup(char *str)
1025 if (str == NULL || *str == '\0') {
1026 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1027 acpi_gbl_create_osi_method = FALSE;
1030 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
1037 __setup("acpi_osi=", acpi_osi_setup);
1039 /* enable serialization to combat AE_ALREADY_EXISTS errors */
1040 static int __init acpi_serialize_setup(char *str)
1042 printk(KERN_INFO PREFIX "serialize enabled\n");
1044 acpi_gbl_all_methods_serialized = TRUE;
1049 __setup("acpi_serialize", acpi_serialize_setup);
1052 * Wake and Run-Time GPES are expected to be separate.
1053 * We disable wake-GPEs at run-time to prevent spurious
1056 * However, if a system exists that shares Wake and
1057 * Run-time events on the same GPE this flag is available
1058 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1060 static int __init acpi_wake_gpes_always_on_setup(char *str)
1062 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1064 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1069 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1071 int __init acpi_hotkey_setup(char *str)
1073 acpi_specific_hotkey_enabled = TRUE;
1077 __setup("acpi_specific_hotkey", acpi_hotkey_setup);
1080 * max_cstate is defined in the base kernel so modules can
1081 * change it w/o depending on the state of the processor module.
1083 unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1085 EXPORT_SYMBOL(max_cstate);
1088 * Acquire a spinlock.
1090 * handle is a pointer to the spinlock_t.
1091 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1092 * that indicates whether we are at interrupt level.
1095 unsigned long acpi_os_acquire_lock(acpi_handle handle)
1097 unsigned long flags;
1098 spin_lock_irqsave((spinlock_t *) handle, flags);
1103 * Release a spinlock. See above.
1106 void acpi_os_release_lock(acpi_handle handle, unsigned long flags)
1108 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1111 #ifndef ACPI_USE_LOCAL_CACHE
1113 /*******************************************************************************
1115 * FUNCTION: acpi_os_create_cache
1117 * PARAMETERS: CacheName - Ascii name for the cache
1118 * ObjectSize - Size of each cached object
1119 * MaxDepth - Maximum depth of the cache (in objects)
1120 * ReturnCache - Where the new cache object is returned
1124 * DESCRIPTION: Create a cache object
1126 ******************************************************************************/
1129 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1131 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1135 /*******************************************************************************
1137 * FUNCTION: acpi_os_purge_cache
1139 * PARAMETERS: Cache - Handle to cache object
1143 * DESCRIPTION: Free all objects within the requested cache.
1145 ******************************************************************************/
1147 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1149 (void)kmem_cache_shrink(cache);
1153 /*******************************************************************************
1155 * FUNCTION: acpi_os_delete_cache
1157 * PARAMETERS: Cache - Handle to cache object
1161 * DESCRIPTION: Free all objects within the requested cache and delete the
1164 ******************************************************************************/
1166 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1168 (void)kmem_cache_destroy(cache);
1172 /*******************************************************************************
1174 * FUNCTION: acpi_os_release_object
1176 * PARAMETERS: Cache - Handle to cache object
1177 * Object - The object to be released
1181 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1182 * the object is deleted.
1184 ******************************************************************************/
1186 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1188 kmem_cache_free(cache, object);
1192 /*******************************************************************************
1194 * FUNCTION: acpi_os_acquire_object
1196 * PARAMETERS: Cache - Handle to cache object
1197 * ReturnObject - Where the object is returned
1201 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
1202 * the object is allocated.
1204 ******************************************************************************/
1206 void *acpi_os_acquire_object(acpi_cache_t * cache)
1208 void *object = kmem_cache_alloc(cache, GFP_KERNEL);