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>
32 #include <linux/pci.h>
33 #include <linux/smp_lock.h>
34 #include <linux/interrupt.h>
35 #include <linux/kmod.h>
36 #include <linux/delay.h>
37 #include <linux/workqueue.h>
38 #include <linux/nmi.h>
39 #include <acpi/acpi.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: "
51 acpi_osd_exec_callback function;
53 struct work_struct work;
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 static void __init acpi_request_region (struct acpi_generic_address *addr,
79 unsigned int length, char *desc)
83 if (!addr->address || !length)
86 if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_IO)
87 res = request_region(addr->address, length, desc);
88 else if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
89 res = request_mem_region(addr->address, length, desc);
92 static int __init acpi_reserve_resources(void)
94 acpi_request_region(&acpi_fadt.xpm1a_evt_blk, acpi_fadt.pm1_evt_len,
97 acpi_request_region(&acpi_fadt.xpm1b_evt_blk, acpi_fadt.pm1_evt_len,
100 acpi_request_region(&acpi_fadt.xpm1a_cnt_blk, acpi_fadt.pm1_cnt_len,
101 "ACPI PM1a_CNT_BLK");
103 acpi_request_region(&acpi_fadt.xpm1b_cnt_blk, acpi_fadt.pm1_cnt_len,
104 "ACPI PM1b_CNT_BLK");
106 if (acpi_fadt.pm_tm_len == 4)
107 acpi_request_region(&acpi_fadt.xpm_tmr_blk, 4, "ACPI PM_TMR");
109 acpi_request_region(&acpi_fadt.xpm2_cnt_blk, acpi_fadt.pm2_cnt_len,
112 /* Length of GPE blocks must be a non-negative multiple of 2 */
114 if (!(acpi_fadt.gpe0_blk_len & 0x1))
115 acpi_request_region(&acpi_fadt.xgpe0_blk,
116 acpi_fadt.gpe0_blk_len, "ACPI GPE0_BLK");
118 if (!(acpi_fadt.gpe1_blk_len & 0x1))
119 acpi_request_region(&acpi_fadt.xgpe1_blk,
120 acpi_fadt.gpe1_blk_len, "ACPI GPE1_BLK");
124 device_initcall(acpi_reserve_resources);
126 acpi_status acpi_os_initialize(void)
131 acpi_status acpi_os_initialize1(void)
134 * Initialize PCI configuration space access, as we'll need to access
135 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
138 printk(KERN_ERR PREFIX
139 "Access to PCI configuration space unavailable\n");
140 return AE_NULL_ENTRY;
142 kacpid_wq = create_singlethread_workqueue("kacpid");
148 acpi_status acpi_os_terminate(void)
150 if (acpi_irq_handler) {
151 acpi_os_remove_interrupt_handler(acpi_irq_irq,
155 destroy_workqueue(kacpid_wq);
160 void acpi_os_printf(const char *fmt, ...)
164 acpi_os_vprintf(fmt, args);
168 EXPORT_SYMBOL(acpi_os_printf);
170 void acpi_os_vprintf(const char *fmt, va_list args)
172 static char buffer[512];
174 vsprintf(buffer, fmt, args);
176 #ifdef ENABLE_DEBUGGER
177 if (acpi_in_debugger) {
178 kdb_printf("%s", buffer);
180 printk("%s", buffer);
183 printk("%s", buffer);
187 acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
190 addr->pointer_type = ACPI_PHYSICAL_POINTER;
191 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
192 addr->pointer.physical = efi.acpi20;
193 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
194 addr->pointer.physical = efi.acpi;
196 printk(KERN_ERR PREFIX
197 "System description tables not found\n");
201 if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
202 printk(KERN_ERR PREFIX
203 "System description tables not found\n");
212 acpi_os_map_memory(acpi_physical_address phys, acpi_size size,
213 void __iomem ** virt)
215 if (phys > ULONG_MAX) {
216 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
217 return AE_BAD_PARAMETER;
220 * ioremap checks to ensure this is in reserved space
222 *virt = ioremap((unsigned long)phys, size);
229 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
231 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
235 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
237 #ifdef ACPI_FUTURE_USAGE
239 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
242 return AE_BAD_PARAMETER;
244 *phys = virt_to_phys(virt);
250 #define ACPI_MAX_OVERRIDE_LEN 100
252 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
255 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
256 acpi_string * new_val)
258 if (!init_val || !new_val)
259 return AE_BAD_PARAMETER;
262 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
263 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
265 *new_val = acpi_os_name;
272 acpi_os_table_override(struct acpi_table_header * existing_table,
273 struct acpi_table_header ** new_table)
275 if (!existing_table || !new_table)
276 return AE_BAD_PARAMETER;
278 #ifdef CONFIG_ACPI_CUSTOM_DSDT
279 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
280 *new_table = (struct acpi_table_header *)AmlCode;
289 static irqreturn_t acpi_irq(int irq, void *dev_id)
291 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
295 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
301 * Ignore the GSI from the core, and use the value in our copy of the
302 * FADT. It may not be the same if an interrupt source override exists
305 gsi = acpi_fadt.sci_int;
306 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
307 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
312 acpi_irq_handler = handler;
313 acpi_irq_context = context;
314 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
315 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
316 return AE_NOT_ACQUIRED;
323 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
326 free_irq(irq, acpi_irq);
327 acpi_irq_handler = NULL;
335 * Running in interpreter thread context, safe to sleep
338 void acpi_os_sleep(acpi_integer ms)
340 schedule_timeout_interruptible(msecs_to_jiffies(ms));
343 EXPORT_SYMBOL(acpi_os_sleep);
345 void acpi_os_stall(u32 us)
353 touch_nmi_watchdog();
358 EXPORT_SYMBOL(acpi_os_stall);
361 * Support ACPI 3.0 AML Timer operand
362 * Returns 64-bit free-running, monotonically increasing timer
363 * with 100ns granularity
365 u64 acpi_os_get_timer(void)
370 /* TBD: use HPET if available */
373 #ifdef CONFIG_X86_PM_TIMER
374 /* TBD: default to PM timer if HPET was not available */
377 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
382 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
391 *(u8 *) value = inb(port);
394 *(u16 *) value = inw(port);
397 *(u32 *) value = inl(port);
406 EXPORT_SYMBOL(acpi_os_read_port);
408 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
427 EXPORT_SYMBOL(acpi_os_write_port);
430 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
433 void __iomem *virt_addr;
435 virt_addr = ioremap(phys_addr, width);
441 *(u8 *) value = readb(virt_addr);
444 *(u16 *) value = readw(virt_addr);
447 *(u32 *) value = readl(virt_addr);
459 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
461 void __iomem *virt_addr;
463 virt_addr = ioremap(phys_addr, width);
467 writeb(value, virt_addr);
470 writew(value, virt_addr);
473 writel(value, virt_addr);
485 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
486 void *value, u32 width)
491 return AE_BAD_PARAMETER;
507 BUG_ON(!raw_pci_ops);
509 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
510 PCI_DEVFN(pci_id->device, pci_id->function),
513 return (result ? AE_ERROR : AE_OK);
516 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
519 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
520 acpi_integer value, u32 width)
538 BUG_ON(!raw_pci_ops);
540 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
541 PCI_DEVFN(pci_id->device, pci_id->function),
544 return (result ? AE_ERROR : AE_OK);
547 /* TODO: Change code to take advantage of driver model more */
548 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
549 acpi_handle chandle, /* current node */
550 struct acpi_pci_id **id,
551 int *is_bridge, u8 * bus_number)
554 struct acpi_pci_id *pci_id = *id;
557 acpi_object_type type;
560 acpi_get_parent(chandle, &handle);
561 if (handle != rhandle) {
562 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
565 status = acpi_get_type(handle, &type);
566 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
570 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
572 if (ACPI_SUCCESS(status)) {
573 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
574 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
577 pci_id->bus = *bus_number;
579 /* any nicer way to get bus number of bridge ? */
581 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
583 if (ACPI_SUCCESS(status)
584 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
586 acpi_os_read_pci_configuration(pci_id, 0x18,
588 if (!ACPI_SUCCESS(status)) {
589 /* Certainly broken... FIX ME */
595 acpi_os_read_pci_configuration(pci_id, 0x19,
597 if (ACPI_SUCCESS(status)) {
606 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
607 acpi_handle chandle, /* current node */
608 struct acpi_pci_id **id)
611 u8 bus_number = (*id)->bus;
613 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
616 static void acpi_os_execute_deferred(struct work_struct *work)
618 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
620 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
624 dpc->function(dpc->context);
631 /*******************************************************************************
633 * FUNCTION: acpi_os_execute
635 * PARAMETERS: Type - Type of the callback
636 * Function - Function to be executed
637 * Context - Function parameters
641 * DESCRIPTION: Depending on type, either queues function for deferred execution or
642 * immediately executes function on a separate thread.
644 ******************************************************************************/
646 acpi_status acpi_os_execute(acpi_execute_type type,
647 acpi_osd_exec_callback function, void *context)
649 acpi_status status = AE_OK;
650 struct acpi_os_dpc *dpc;
652 ACPI_FUNCTION_TRACE("os_queue_for_execution");
654 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
655 "Scheduling function [%p(%p)] for deferred execution.\n",
659 return_ACPI_STATUS(AE_BAD_PARAMETER);
662 * Allocate/initialize DPC structure. Note that this memory will be
663 * freed by the callee. The kernel handles the work_struct list in a
664 * way that allows us to also free its memory inside the callee.
665 * Because we may want to schedule several tasks with different
666 * parameters we can't use the approach some kernel code uses of
667 * having a static work_struct.
670 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
672 return_ACPI_STATUS(AE_NO_MEMORY);
674 dpc->function = function;
675 dpc->context = context;
677 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
678 if (!queue_work(kacpid_wq, &dpc->work)) {
679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
680 "Call to queue_work() failed.\n"));
685 return_ACPI_STATUS(status);
688 EXPORT_SYMBOL(acpi_os_execute);
690 void acpi_os_wait_events_complete(void *context)
692 flush_workqueue(kacpid_wq);
695 EXPORT_SYMBOL(acpi_os_wait_events_complete);
698 * Allocate the memory for a spinlock and initialize it.
700 acpi_status acpi_os_create_lock(acpi_spinlock * handle)
702 spin_lock_init(*handle);
708 * Deallocate the memory for a spinlock.
710 void acpi_os_delete_lock(acpi_spinlock handle)
716 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
718 struct semaphore *sem = NULL;
721 sem = acpi_os_allocate(sizeof(struct semaphore));
724 memset(sem, 0, sizeof(struct semaphore));
726 sema_init(sem, initial_units);
728 *handle = (acpi_handle *) sem;
730 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
731 *handle, initial_units));
736 EXPORT_SYMBOL(acpi_os_create_semaphore);
739 * TODO: A better way to delete semaphores? Linux doesn't have a
740 * 'delete_semaphore()' function -- may result in an invalid
741 * pointer dereference for non-synchronized consumers. Should
742 * we at least check for blocked threads and signal/cancel them?
745 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
747 struct semaphore *sem = (struct semaphore *)handle;
751 return AE_BAD_PARAMETER;
753 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
761 EXPORT_SYMBOL(acpi_os_delete_semaphore);
764 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
765 * improvise. The process is to sleep for one scheduler quantum
766 * until the semaphore becomes available. Downside is that this
767 * may result in starvation for timeout-based waits when there's
768 * lots of semaphore activity.
770 * TODO: Support for units > 1?
772 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
774 acpi_status status = AE_OK;
775 struct semaphore *sem = (struct semaphore *)handle;
779 if (!sem || (units < 1))
780 return AE_BAD_PARAMETER;
785 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
786 handle, units, timeout));
789 * This can be called during resume with interrupts off.
790 * Like boot-time, we should be single threaded and will
791 * always get the lock if we try -- timeout or not.
792 * If this doesn't succeed, then we will oops courtesy of
793 * might_sleep() in down().
795 if (!down_trylock(sem))
802 * A zero timeout value indicates that we shouldn't wait - just
803 * acquire the semaphore if available otherwise return AE_TIME
804 * (a.k.a. 'would block').
807 if (down_trylock(sem))
815 case ACPI_WAIT_FOREVER:
824 // TODO: A better timeout algorithm?
827 static const int quantum_ms = 1000 / HZ;
829 ret = down_trylock(sem);
830 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
831 schedule_timeout_interruptible(1);
832 ret = down_trylock(sem);
841 if (ACPI_FAILURE(status)) {
842 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
843 "Failed to acquire semaphore[%p|%d|%d], %s",
844 handle, units, timeout,
845 acpi_format_exception(status)));
847 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
848 "Acquired semaphore[%p|%d|%d]", handle,
855 EXPORT_SYMBOL(acpi_os_wait_semaphore);
858 * TODO: Support for units > 1?
860 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
862 struct semaphore *sem = (struct semaphore *)handle;
865 if (!sem || (units < 1))
866 return AE_BAD_PARAMETER;
871 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
879 EXPORT_SYMBOL(acpi_os_signal_semaphore);
881 #ifdef ACPI_FUTURE_USAGE
882 u32 acpi_os_get_line(char *buffer)
885 #ifdef ENABLE_DEBUGGER
886 if (acpi_in_debugger) {
889 kdb_read(buffer, sizeof(line_buf));
891 /* remove the CR kdb includes */
892 chars = strlen(buffer) - 1;
893 buffer[chars] = '\0';
899 #endif /* ACPI_FUTURE_USAGE */
901 /* Assumes no unreadable holes inbetween */
902 u8 acpi_os_readable(void *ptr, acpi_size len)
904 #if defined(__i386__) || defined(__x86_64__)
906 return !__get_user(tmp, (char __user *)ptr)
907 && !__get_user(tmp, (char __user *)ptr + len - 1);
912 #ifdef ACPI_FUTURE_USAGE
913 u8 acpi_os_writable(void *ptr, acpi_size len)
915 /* could do dummy write (racy) or a kernel page table lookup.
916 The later may be difficult at early boot when kmap doesn't work yet. */
921 acpi_status acpi_os_signal(u32 function, void *info)
924 case ACPI_SIGNAL_FATAL:
925 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
927 case ACPI_SIGNAL_BREAKPOINT:
930 * ACPI spec. says to treat it as a NOP unless
931 * you are debugging. So if/when we integrate
932 * AML debugger into the kernel debugger its
933 * hook will go here. But until then it is
934 * not useful to print anything on breakpoints.
944 EXPORT_SYMBOL(acpi_os_signal);
946 static int __init acpi_os_name_setup(char *str)
948 char *p = acpi_os_name;
949 int count = ACPI_MAX_OVERRIDE_LEN - 1;
954 for (; count-- && str && *str; str++) {
955 if (isalnum(*str) || *str == ' ' || *str == ':')
957 else if (*str == '\'' || *str == '"')
968 __setup("acpi_os_name=", acpi_os_name_setup);
972 * empty string disables _OSI
973 * TBD additional string adds to _OSI
975 static int __init acpi_osi_setup(char *str)
977 if (str == NULL || *str == '\0') {
978 printk(KERN_INFO PREFIX "_OSI method disabled\n");
979 acpi_gbl_create_osi_method = FALSE;
982 printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n",
989 __setup("acpi_osi=", acpi_osi_setup);
991 /* enable serialization to combat AE_ALREADY_EXISTS errors */
992 static int __init acpi_serialize_setup(char *str)
994 printk(KERN_INFO PREFIX "serialize enabled\n");
996 acpi_gbl_all_methods_serialized = TRUE;
1001 __setup("acpi_serialize", acpi_serialize_setup);
1004 * Wake and Run-Time GPES are expected to be separate.
1005 * We disable wake-GPEs at run-time to prevent spurious
1008 * However, if a system exists that shares Wake and
1009 * Run-time events on the same GPE this flag is available
1010 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1012 static int __init acpi_wake_gpes_always_on_setup(char *str)
1014 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1016 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1021 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1023 static int __init acpi_hotkey_setup(char *str)
1025 acpi_specific_hotkey_enabled = FALSE;
1029 __setup("acpi_generic_hotkey", acpi_hotkey_setup);
1032 * max_cstate is defined in the base kernel so modules can
1033 * change it w/o depending on the state of the processor module.
1035 unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1037 EXPORT_SYMBOL(max_cstate);
1040 * Acquire a spinlock.
1042 * handle is a pointer to the spinlock_t.
1045 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1047 acpi_cpu_flags flags;
1048 spin_lock_irqsave(lockp, flags);
1053 * Release a spinlock. See above.
1056 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1058 spin_unlock_irqrestore(lockp, flags);
1061 #ifndef ACPI_USE_LOCAL_CACHE
1063 /*******************************************************************************
1065 * FUNCTION: acpi_os_create_cache
1067 * PARAMETERS: name - Ascii name for the cache
1068 * size - Size of each cached object
1069 * depth - Maximum depth of the cache (in objects) <ignored>
1070 * cache - Where the new cache object is returned
1074 * DESCRIPTION: Create a cache object
1076 ******************************************************************************/
1079 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1081 *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL);
1088 /*******************************************************************************
1090 * FUNCTION: acpi_os_purge_cache
1092 * PARAMETERS: Cache - Handle to cache object
1096 * DESCRIPTION: Free all objects within the requested cache.
1098 ******************************************************************************/
1100 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1102 (void)kmem_cache_shrink(cache);
1106 /*******************************************************************************
1108 * FUNCTION: acpi_os_delete_cache
1110 * PARAMETERS: Cache - Handle to cache object
1114 * DESCRIPTION: Free all objects within the requested cache and delete the
1117 ******************************************************************************/
1119 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1121 kmem_cache_destroy(cache);
1125 /*******************************************************************************
1127 * FUNCTION: acpi_os_release_object
1129 * PARAMETERS: Cache - Handle to cache object
1130 * Object - The object to be released
1134 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1135 * the object is deleted.
1137 ******************************************************************************/
1139 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1141 kmem_cache_free(cache, object);
1145 /******************************************************************************
1147 * FUNCTION: acpi_os_validate_interface
1149 * PARAMETERS: interface - Requested interface to be validated
1151 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1153 * DESCRIPTION: Match an interface string to the interfaces supported by the
1154 * host. Strings originate from an AML call to the _OSI method.
1156 *****************************************************************************/
1159 acpi_os_validate_interface (char *interface)
1166 /******************************************************************************
1168 * FUNCTION: acpi_os_validate_address
1170 * PARAMETERS: space_id - ACPI space ID
1171 * address - Physical address
1172 * length - Address length
1174 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1175 * should return AE_AML_ILLEGAL_ADDRESS.
1177 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1178 * the addresses accessed by AML operation regions.
1180 *****************************************************************************/
1183 acpi_os_validate_address (
1185 acpi_physical_address address,