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 = TRUE;
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).
90 printk(KERN_ERR PREFIX
91 "Access to PCI configuration space unavailable\n");
94 kacpid_wq = create_singlethread_workqueue("kacpid");
100 acpi_status acpi_os_terminate(void)
102 if (acpi_irq_handler) {
103 acpi_os_remove_interrupt_handler(acpi_irq_irq,
107 destroy_workqueue(kacpid_wq);
112 void acpi_os_printf(const char *fmt, ...)
116 acpi_os_vprintf(fmt, args);
120 EXPORT_SYMBOL(acpi_os_printf);
122 void acpi_os_vprintf(const char *fmt, va_list args)
124 static char buffer[512];
126 vsprintf(buffer, fmt, args);
128 #ifdef ENABLE_DEBUGGER
129 if (acpi_in_debugger) {
130 kdb_printf("%s", buffer);
132 printk("%s", buffer);
135 printk("%s", buffer);
139 extern int acpi_in_resume;
140 void *acpi_os_allocate(acpi_size size)
143 return kmalloc(size, GFP_ATOMIC);
145 return kmalloc(size, GFP_KERNEL);
148 void acpi_os_free(void *ptr)
153 EXPORT_SYMBOL(acpi_os_free);
155 acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
158 addr->pointer_type = ACPI_PHYSICAL_POINTER;
160 addr->pointer.physical =
161 (acpi_physical_address) virt_to_phys(efi.acpi20);
163 addr->pointer.physical =
164 (acpi_physical_address) virt_to_phys(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)
186 if (EFI_MEMORY_WB & efi_mem_attributes(phys)) {
187 *virt = (void __iomem *)phys_to_virt(phys);
189 *virt = ioremap(phys, size);
192 if (phys > ULONG_MAX) {
193 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
194 return AE_BAD_PARAMETER;
197 * ioremap checks to ensure this is in reserved space
199 *virt = ioremap((unsigned long)phys, size);
207 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
209 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
213 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
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 schedule_timeout_interruptible(msecs_to_jiffies(ms));
321 EXPORT_SYMBOL(acpi_os_sleep);
323 void acpi_os_stall(u32 us)
331 touch_nmi_watchdog();
336 EXPORT_SYMBOL(acpi_os_stall);
339 * Support ACPI 3.0 AML Timer operand
340 * Returns 64-bit free-running, monotonically increasing timer
341 * with 100ns granularity
343 u64 acpi_os_get_timer(void)
348 /* TBD: use HPET if available */
351 #ifdef CONFIG_X86_PM_TIMER
352 /* TBD: default to PM timer if HPET was not available */
355 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
360 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
369 *(u8 *) value = inb(port);
372 *(u16 *) value = inw(port);
375 *(u32 *) value = inl(port);
384 EXPORT_SYMBOL(acpi_os_read_port);
386 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
405 EXPORT_SYMBOL(acpi_os_write_port);
408 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
411 void __iomem *virt_addr;
415 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
416 /* HACK ALERT! We can use readb/w/l on real memory too.. */
417 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
420 virt_addr = ioremap(phys_addr, width);
423 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
429 *(u8 *) value = readb(virt_addr);
432 *(u16 *) value = readw(virt_addr);
435 *(u32 *) value = readl(virt_addr);
450 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
452 void __iomem *virt_addr;
456 if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) {
457 /* HACK ALERT! We can use writeb/w/l on real memory too */
458 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
461 virt_addr = ioremap(phys_addr, width);
464 virt_addr = (void __iomem *)phys_to_virt(phys_addr);
468 writeb(value, virt_addr);
471 writew(value, virt_addr);
474 writel(value, virt_addr);
487 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
488 void *value, u32 width)
493 return AE_BAD_PARAMETER;
509 BUG_ON(!raw_pci_ops);
511 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
512 PCI_DEVFN(pci_id->device, pci_id->function),
515 return (result ? AE_ERROR : AE_OK);
518 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
521 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
522 acpi_integer value, u32 width)
540 BUG_ON(!raw_pci_ops);
542 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
543 PCI_DEVFN(pci_id->device, pci_id->function),
546 return (result ? AE_ERROR : AE_OK);
549 /* TODO: Change code to take advantage of driver model more */
550 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
551 acpi_handle chandle, /* current node */
552 struct acpi_pci_id **id,
553 int *is_bridge, u8 * bus_number)
556 struct acpi_pci_id *pci_id = *id;
559 acpi_object_type type;
562 acpi_get_parent(chandle, &handle);
563 if (handle != rhandle) {
564 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
567 status = acpi_get_type(handle, &type);
568 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
572 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
574 if (ACPI_SUCCESS(status)) {
575 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
576 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
579 pci_id->bus = *bus_number;
581 /* any nicer way to get bus number of bridge ? */
583 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
585 if (ACPI_SUCCESS(status)
586 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
588 acpi_os_read_pci_configuration(pci_id, 0x18,
590 if (!ACPI_SUCCESS(status)) {
591 /* Certainly broken... FIX ME */
597 acpi_os_read_pci_configuration(pci_id, 0x19,
599 if (ACPI_SUCCESS(status)) {
608 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
609 acpi_handle chandle, /* current node */
610 struct acpi_pci_id **id)
613 u8 bus_number = (*id)->bus;
615 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
618 static void acpi_os_execute_deferred(void *context)
620 struct acpi_os_dpc *dpc = NULL;
622 ACPI_FUNCTION_TRACE("os_execute_deferred");
624 dpc = (struct acpi_os_dpc *)context;
626 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
630 dpc->function(dpc->context);
638 acpi_os_queue_for_execution(u32 priority,
639 acpi_osd_exec_callback function, void *context)
641 acpi_status status = AE_OK;
642 struct acpi_os_dpc *dpc;
643 struct work_struct *task;
645 ACPI_FUNCTION_TRACE("os_queue_for_execution");
647 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
648 "Scheduling function [%p(%p)] for deferred execution.\n",
652 return_ACPI_STATUS(AE_BAD_PARAMETER);
655 * Allocate/initialize DPC structure. Note that this memory will be
656 * freed by the callee. The kernel handles the tq_struct list in a
657 * way that allows us to also free its memory inside the callee.
658 * Because we may want to schedule several tasks with different
659 * parameters we can't use the approach some kernel code uses of
660 * having a static tq_struct.
661 * We can save time and code by allocating the DPC and tq_structs
662 * from the same memory.
666 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
669 return_ACPI_STATUS(AE_NO_MEMORY);
671 dpc->function = function;
672 dpc->context = context;
674 task = (void *)(dpc + 1);
675 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
677 if (!queue_work(kacpid_wq, task)) {
678 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
679 "Call to queue_work() failed.\n"));
684 return_ACPI_STATUS(status);
687 EXPORT_SYMBOL(acpi_os_queue_for_execution);
689 void acpi_os_wait_events_complete(void *context)
691 flush_workqueue(kacpid_wq);
694 EXPORT_SYMBOL(acpi_os_wait_events_complete);
697 * Allocate the memory for a spinlock and initialize it.
699 acpi_status acpi_os_create_lock(acpi_handle * out_handle)
701 spinlock_t *lock_ptr;
703 ACPI_FUNCTION_TRACE("os_create_lock");
705 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
707 spin_lock_init(lock_ptr);
709 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
711 *out_handle = lock_ptr;
713 return_ACPI_STATUS(AE_OK);
717 * Deallocate the memory for a spinlock.
719 void acpi_os_delete_lock(acpi_handle handle)
721 ACPI_FUNCTION_TRACE("os_create_lock");
723 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
725 acpi_os_free(handle);
731 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
733 struct semaphore *sem = NULL;
735 ACPI_FUNCTION_TRACE("os_create_semaphore");
737 sem = acpi_os_allocate(sizeof(struct semaphore));
739 return_ACPI_STATUS(AE_NO_MEMORY);
740 memset(sem, 0, sizeof(struct semaphore));
742 sema_init(sem, initial_units);
744 *handle = (acpi_handle *) sem;
746 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
747 *handle, initial_units));
749 return_ACPI_STATUS(AE_OK);
752 EXPORT_SYMBOL(acpi_os_create_semaphore);
755 * TODO: A better way to delete semaphores? Linux doesn't have a
756 * 'delete_semaphore()' function -- may result in an invalid
757 * pointer dereference for non-synchronized consumers. Should
758 * we at least check for blocked threads and signal/cancel them?
761 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
763 struct semaphore *sem = (struct semaphore *)handle;
765 ACPI_FUNCTION_TRACE("os_delete_semaphore");
768 return_ACPI_STATUS(AE_BAD_PARAMETER);
770 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
775 return_ACPI_STATUS(AE_OK);
778 EXPORT_SYMBOL(acpi_os_delete_semaphore);
781 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
782 * improvise. The process is to sleep for one scheduler quantum
783 * until the semaphore becomes available. Downside is that this
784 * may result in starvation for timeout-based waits when there's
785 * lots of semaphore activity.
787 * TODO: Support for units > 1?
789 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
791 acpi_status status = AE_OK;
792 struct semaphore *sem = (struct semaphore *)handle;
795 ACPI_FUNCTION_TRACE("os_wait_semaphore");
797 if (!sem || (units < 1))
798 return_ACPI_STATUS(AE_BAD_PARAMETER);
801 return_ACPI_STATUS(AE_SUPPORT);
803 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
804 handle, units, timeout));
813 * A zero timeout value indicates that we shouldn't wait - just
814 * acquire the semaphore if available otherwise return AE_TIME
815 * (a.k.a. 'would block').
818 if (down_trylock(sem))
826 case ACPI_WAIT_FOREVER:
835 // TODO: A better timeout algorithm?
838 static const int quantum_ms = 1000 / HZ;
840 ret = down_trylock(sem);
841 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
842 schedule_timeout_interruptible(1);
843 ret = down_trylock(sem);
852 if (ACPI_FAILURE(status)) {
853 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
854 "Failed to acquire semaphore[%p|%d|%d], %s\n",
855 handle, units, timeout,
856 acpi_format_exception(status)));
858 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
859 "Acquired semaphore[%p|%d|%d]\n", handle,
863 return_ACPI_STATUS(status);
866 EXPORT_SYMBOL(acpi_os_wait_semaphore);
869 * TODO: Support for units > 1?
871 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
873 struct semaphore *sem = (struct semaphore *)handle;
875 ACPI_FUNCTION_TRACE("os_signal_semaphore");
877 if (!sem || (units < 1))
878 return_ACPI_STATUS(AE_BAD_PARAMETER);
881 return_ACPI_STATUS(AE_SUPPORT);
883 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
888 return_ACPI_STATUS(AE_OK);
891 EXPORT_SYMBOL(acpi_os_signal_semaphore);
893 #ifdef ACPI_FUTURE_USAGE
894 u32 acpi_os_get_line(char *buffer)
897 #ifdef ENABLE_DEBUGGER
898 if (acpi_in_debugger) {
901 kdb_read(buffer, sizeof(line_buf));
903 /* remove the CR kdb includes */
904 chars = strlen(buffer) - 1;
905 buffer[chars] = '\0';
911 #endif /* ACPI_FUTURE_USAGE */
913 /* Assumes no unreadable holes inbetween */
914 u8 acpi_os_readable(void *ptr, acpi_size len)
916 #if defined(__i386__) || defined(__x86_64__)
918 return !__get_user(tmp, (char __user *)ptr)
919 && !__get_user(tmp, (char __user *)ptr + len - 1);
924 #ifdef ACPI_FUTURE_USAGE
925 u8 acpi_os_writable(void *ptr, acpi_size len)
927 /* could do dummy write (racy) or a kernel page table lookup.
928 The later may be difficult at early boot when kmap doesn't work yet. */
933 u32 acpi_os_get_thread_id(void)
941 acpi_status acpi_os_signal(u32 function, void *info)
944 case ACPI_SIGNAL_FATAL:
945 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
947 case ACPI_SIGNAL_BREAKPOINT:
950 * ACPI spec. says to treat it as a NOP unless
951 * you are debugging. So if/when we integrate
952 * AML debugger into the kernel debugger its
953 * hook will go here. But until then it is
954 * not useful to print anything on breakpoints.
964 EXPORT_SYMBOL(acpi_os_signal);
966 static int __init acpi_os_name_setup(char *str)
968 char *p = acpi_os_name;
969 int count = ACPI_MAX_OVERRIDE_LEN - 1;
974 for (; count-- && str && *str; str++) {
975 if (isalnum(*str) || *str == ' ' || *str == ':')
977 else if (*str == '\'' || *str == '"')
988 __setup("acpi_os_name=", acpi_os_name_setup);
992 * empty string disables _OSI
993 * TBD additional string adds to _OSI
995 static int __init acpi_osi_setup(char *str)
997 if (str == NULL || *str == '\0') {
998 printk(KERN_INFO PREFIX "_OSI method disabled\n");
999 acpi_gbl_create_osi_method = FALSE;
1002 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
1009 __setup("acpi_osi=", acpi_osi_setup);
1011 /* enable serialization to combat AE_ALREADY_EXISTS errors */
1012 static int __init acpi_serialize_setup(char *str)
1014 printk(KERN_INFO PREFIX "serialize enabled\n");
1016 acpi_gbl_all_methods_serialized = TRUE;
1021 __setup("acpi_serialize", acpi_serialize_setup);
1024 * Wake and Run-Time GPES are expected to be separate.
1025 * We disable wake-GPEs at run-time to prevent spurious
1028 * However, if a system exists that shares Wake and
1029 * Run-time events on the same GPE this flag is available
1030 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1032 static int __init acpi_wake_gpes_always_on_setup(char *str)
1034 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1036 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1041 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1043 static int __init acpi_hotkey_setup(char *str)
1045 acpi_specific_hotkey_enabled = FALSE;
1049 __setup("acpi_generic_hotkey", acpi_hotkey_setup);
1052 * max_cstate is defined in the base kernel so modules can
1053 * change it w/o depending on the state of the processor module.
1055 unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1057 EXPORT_SYMBOL(max_cstate);
1060 * Acquire a spinlock.
1062 * handle is a pointer to the spinlock_t.
1063 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1064 * that indicates whether we are at interrupt level.
1067 unsigned long acpi_os_acquire_lock(acpi_handle handle)
1069 unsigned long flags;
1070 spin_lock_irqsave((spinlock_t *) handle, flags);
1075 * Release a spinlock. See above.
1078 void acpi_os_release_lock(acpi_handle handle, unsigned long flags)
1080 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1083 #ifndef ACPI_USE_LOCAL_CACHE
1085 /*******************************************************************************
1087 * FUNCTION: acpi_os_create_cache
1089 * PARAMETERS: CacheName - Ascii name for the cache
1090 * ObjectSize - Size of each cached object
1091 * MaxDepth - Maximum depth of the cache (in objects)
1092 * ReturnCache - Where the new cache object is returned
1096 * DESCRIPTION: Create a cache object
1098 ******************************************************************************/
1101 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1103 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1107 /*******************************************************************************
1109 * FUNCTION: acpi_os_purge_cache
1111 * PARAMETERS: Cache - Handle to cache object
1115 * DESCRIPTION: Free all objects within the requested cache.
1117 ******************************************************************************/
1119 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1121 (void)kmem_cache_shrink(cache);
1125 /*******************************************************************************
1127 * FUNCTION: acpi_os_delete_cache
1129 * PARAMETERS: Cache - Handle to cache object
1133 * DESCRIPTION: Free all objects within the requested cache and delete the
1136 ******************************************************************************/
1138 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1140 (void)kmem_cache_destroy(cache);
1144 /*******************************************************************************
1146 * FUNCTION: acpi_os_release_object
1148 * PARAMETERS: Cache - Handle to cache object
1149 * Object - The object to be released
1153 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1154 * the object is deleted.
1156 ******************************************************************************/
1158 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1160 kmem_cache_free(cache, object);
1164 /*******************************************************************************
1166 * FUNCTION: acpi_os_acquire_object
1168 * PARAMETERS: Cache - Handle to cache object
1169 * ReturnObject - Where the object is returned
1173 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
1174 * the object is allocated.
1176 ******************************************************************************/
1178 void *acpi_os_acquire_object(acpi_cache_t * cache)
1180 void *object = kmem_cache_alloc(cache, GFP_KERNEL);