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 <linux/acpi.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
;
54 struct work_struct work
;
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 static unsigned int acpi_irq_irq
;
72 static acpi_osd_handler acpi_irq_handler
;
73 static void *acpi_irq_context
;
74 static struct workqueue_struct
*kacpid_wq
;
76 static void __init
acpi_request_region (struct acpi_generic_address
*addr
,
77 unsigned int length
, char *desc
)
81 if (!addr
->address
|| !length
)
84 if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_IO
)
85 res
= request_region(addr
->address
, length
, desc
);
86 else if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
)
87 res
= request_mem_region(addr
->address
, length
, desc
);
90 static int __init
acpi_reserve_resources(void)
92 acpi_request_region(&acpi_gbl_FADT
.xpm1a_event_block
, acpi_gbl_FADT
.pm1_event_length
,
95 acpi_request_region(&acpi_gbl_FADT
.xpm1b_event_block
, acpi_gbl_FADT
.pm1_event_length
,
98 acpi_request_region(&acpi_gbl_FADT
.xpm1a_control_block
, acpi_gbl_FADT
.pm1_control_length
,
101 acpi_request_region(&acpi_gbl_FADT
.xpm1b_control_block
, acpi_gbl_FADT
.pm1_control_length
,
102 "ACPI PM1b_CNT_BLK");
104 if (acpi_gbl_FADT
.pm_timer_length
== 4)
105 acpi_request_region(&acpi_gbl_FADT
.xpm_timer_block
, 4, "ACPI PM_TMR");
107 acpi_request_region(&acpi_gbl_FADT
.xpm2_control_block
, acpi_gbl_FADT
.pm2_control_length
,
110 /* Length of GPE blocks must be a non-negative multiple of 2 */
112 if (!(acpi_gbl_FADT
.gpe0_block_length
& 0x1))
113 acpi_request_region(&acpi_gbl_FADT
.xgpe0_block
,
114 acpi_gbl_FADT
.gpe0_block_length
, "ACPI GPE0_BLK");
116 if (!(acpi_gbl_FADT
.gpe1_block_length
& 0x1))
117 acpi_request_region(&acpi_gbl_FADT
.xgpe1_block
,
118 acpi_gbl_FADT
.gpe1_block_length
, "ACPI GPE1_BLK");
122 device_initcall(acpi_reserve_resources
);
124 acpi_status
acpi_os_initialize(void)
129 acpi_status
acpi_os_initialize1(void)
132 * Initialize PCI configuration space access, as we'll need to access
133 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
136 printk(KERN_ERR PREFIX
137 "Access to PCI configuration space unavailable\n");
138 return AE_NULL_ENTRY
;
140 kacpid_wq
= create_singlethread_workqueue("kacpid");
146 acpi_status
acpi_os_terminate(void)
148 if (acpi_irq_handler
) {
149 acpi_os_remove_interrupt_handler(acpi_irq_irq
,
153 destroy_workqueue(kacpid_wq
);
158 void acpi_os_printf(const char *fmt
, ...)
162 acpi_os_vprintf(fmt
, args
);
166 EXPORT_SYMBOL(acpi_os_printf
);
168 void acpi_os_vprintf(const char *fmt
, va_list args
)
170 static char buffer
[512];
172 vsprintf(buffer
, fmt
, args
);
174 #ifdef ENABLE_DEBUGGER
175 if (acpi_in_debugger
) {
176 kdb_printf("%s", buffer
);
178 printk("%s", buffer
);
181 printk("%s", buffer
);
185 acpi_physical_address __init
acpi_os_get_root_pointer(void)
188 if (efi
.acpi20
!= EFI_INVALID_TABLE_ADDR
)
190 else if (efi
.acpi
!= EFI_INVALID_TABLE_ADDR
)
193 printk(KERN_ERR PREFIX
194 "System description tables not found\n");
198 return acpi_find_rsdp();
201 void __iomem
*acpi_os_map_memory(acpi_physical_address phys
, acpi_size size
)
203 if (phys
> ULONG_MAX
) {
204 printk(KERN_ERR PREFIX
"Cannot map memory that high\n");
207 if (acpi_gbl_permanent_mmap
)
209 * ioremap checks to ensure this is in reserved space
211 return ioremap((unsigned long)phys
, size
);
213 return __acpi_map_table((unsigned long)phys
, size
);
215 EXPORT_SYMBOL_GPL(acpi_os_map_memory
);
217 void acpi_os_unmap_memory(void __iomem
* virt
, acpi_size size
)
219 if (acpi_gbl_permanent_mmap
) {
223 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory
);
225 #ifdef ACPI_FUTURE_USAGE
227 acpi_os_get_physical_address(void *virt
, acpi_physical_address
* phys
)
230 return AE_BAD_PARAMETER
;
232 *phys
= virt_to_phys(virt
);
238 #define ACPI_MAX_OVERRIDE_LEN 100
240 static char acpi_os_name
[ACPI_MAX_OVERRIDE_LEN
];
243 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
244 acpi_string
* new_val
)
246 if (!init_val
|| !new_val
)
247 return AE_BAD_PARAMETER
;
250 if (!memcmp(init_val
->name
, "_OS_", 4) && strlen(acpi_os_name
)) {
251 printk(KERN_INFO PREFIX
"Overriding _OS definition to '%s'\n",
253 *new_val
= acpi_os_name
;
260 acpi_os_table_override(struct acpi_table_header
* existing_table
,
261 struct acpi_table_header
** new_table
)
263 if (!existing_table
|| !new_table
)
264 return AE_BAD_PARAMETER
;
266 #ifdef CONFIG_ACPI_CUSTOM_DSDT
267 if (strncmp(existing_table
->signature
, "DSDT", 4) == 0)
268 *new_table
= (struct acpi_table_header
*)AmlCode
;
277 static irqreturn_t
acpi_irq(int irq
, void *dev_id
)
279 return (*acpi_irq_handler
) (acpi_irq_context
) ? IRQ_HANDLED
: IRQ_NONE
;
283 acpi_os_install_interrupt_handler(u32 gsi
, acpi_osd_handler handler
,
289 * Ignore the GSI from the core, and use the value in our copy of the
290 * FADT. It may not be the same if an interrupt source override exists
293 gsi
= acpi_gbl_FADT
.sci_interrupt
;
294 if (acpi_gsi_to_irq(gsi
, &irq
) < 0) {
295 printk(KERN_ERR PREFIX
"SCI (ACPI GSI %d) not registered\n",
300 acpi_irq_handler
= handler
;
301 acpi_irq_context
= context
;
302 if (request_irq(irq
, acpi_irq
, IRQF_SHARED
, "acpi", acpi_irq
)) {
303 printk(KERN_ERR PREFIX
"SCI (IRQ%d) allocation failed\n", irq
);
304 return AE_NOT_ACQUIRED
;
311 acpi_status
acpi_os_remove_interrupt_handler(u32 irq
, acpi_osd_handler handler
)
314 free_irq(irq
, acpi_irq
);
315 acpi_irq_handler
= NULL
;
323 * Running in interpreter thread context, safe to sleep
326 void acpi_os_sleep(acpi_integer ms
)
328 schedule_timeout_interruptible(msecs_to_jiffies(ms
));
331 EXPORT_SYMBOL(acpi_os_sleep
);
333 void acpi_os_stall(u32 us
)
341 touch_nmi_watchdog();
346 EXPORT_SYMBOL(acpi_os_stall
);
349 * Support ACPI 3.0 AML Timer operand
350 * Returns 64-bit free-running, monotonically increasing timer
351 * with 100ns granularity
353 u64
acpi_os_get_timer(void)
358 /* TBD: use HPET if available */
361 #ifdef CONFIG_X86_PM_TIMER
362 /* TBD: default to PM timer if HPET was not available */
365 printk(KERN_ERR PREFIX
"acpi_os_get_timer() TBD\n");
370 acpi_status
acpi_os_read_port(acpi_io_address port
, u32
* value
, u32 width
)
379 *(u8
*) value
= inb(port
);
382 *(u16
*) value
= inw(port
);
385 *(u32
*) value
= inl(port
);
394 EXPORT_SYMBOL(acpi_os_read_port
);
396 acpi_status
acpi_os_write_port(acpi_io_address port
, u32 value
, u32 width
)
415 EXPORT_SYMBOL(acpi_os_write_port
);
418 acpi_os_read_memory(acpi_physical_address phys_addr
, u32
* value
, u32 width
)
421 void __iomem
*virt_addr
;
423 virt_addr
= ioremap(phys_addr
, width
);
429 *(u8
*) value
= readb(virt_addr
);
432 *(u16
*) value
= readw(virt_addr
);
435 *(u32
*) value
= readl(virt_addr
);
447 acpi_os_write_memory(acpi_physical_address phys_addr
, u32 value
, u32 width
)
449 void __iomem
*virt_addr
;
451 virt_addr
= ioremap(phys_addr
, width
);
455 writeb(value
, virt_addr
);
458 writew(value
, virt_addr
);
461 writel(value
, virt_addr
);
473 acpi_os_read_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
474 void *value
, u32 width
)
479 return AE_BAD_PARAMETER
;
495 BUG_ON(!raw_pci_ops
);
497 result
= raw_pci_ops
->read(pci_id
->segment
, pci_id
->bus
,
498 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
501 return (result
? AE_ERROR
: AE_OK
);
504 EXPORT_SYMBOL(acpi_os_read_pci_configuration
);
507 acpi_os_write_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
508 acpi_integer value
, u32 width
)
526 BUG_ON(!raw_pci_ops
);
528 result
= raw_pci_ops
->write(pci_id
->segment
, pci_id
->bus
,
529 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
532 return (result
? AE_ERROR
: AE_OK
);
535 /* TODO: Change code to take advantage of driver model more */
536 static void acpi_os_derive_pci_id_2(acpi_handle rhandle
, /* upper bound */
537 acpi_handle chandle
, /* current node */
538 struct acpi_pci_id
**id
,
539 int *is_bridge
, u8
* bus_number
)
542 struct acpi_pci_id
*pci_id
= *id
;
545 acpi_object_type type
;
548 acpi_get_parent(chandle
, &handle
);
549 if (handle
!= rhandle
) {
550 acpi_os_derive_pci_id_2(rhandle
, handle
, &pci_id
, is_bridge
,
553 status
= acpi_get_type(handle
, &type
);
554 if ((ACPI_FAILURE(status
)) || (type
!= ACPI_TYPE_DEVICE
))
558 acpi_evaluate_integer(handle
, METHOD_NAME__ADR
, NULL
,
560 if (ACPI_SUCCESS(status
)) {
561 pci_id
->device
= ACPI_HIWORD(ACPI_LODWORD(temp
));
562 pci_id
->function
= ACPI_LOWORD(ACPI_LODWORD(temp
));
565 pci_id
->bus
= *bus_number
;
567 /* any nicer way to get bus number of bridge ? */
569 acpi_os_read_pci_configuration(pci_id
, 0x0e, &tu8
,
571 if (ACPI_SUCCESS(status
)
572 && ((tu8
& 0x7f) == 1 || (tu8
& 0x7f) == 2)) {
574 acpi_os_read_pci_configuration(pci_id
, 0x18,
576 if (!ACPI_SUCCESS(status
)) {
577 /* Certainly broken... FIX ME */
583 acpi_os_read_pci_configuration(pci_id
, 0x19,
585 if (ACPI_SUCCESS(status
)) {
594 void acpi_os_derive_pci_id(acpi_handle rhandle
, /* upper bound */
595 acpi_handle chandle
, /* current node */
596 struct acpi_pci_id
**id
)
599 u8 bus_number
= (*id
)->bus
;
601 acpi_os_derive_pci_id_2(rhandle
, chandle
, id
, &is_bridge
, &bus_number
);
604 static void acpi_os_execute_deferred(struct work_struct
*work
)
606 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
609 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
613 dpc
->function(dpc
->context
);
620 /*******************************************************************************
622 * FUNCTION: acpi_os_execute
624 * PARAMETERS: Type - Type of the callback
625 * Function - Function to be executed
626 * Context - Function parameters
630 * DESCRIPTION: Depending on type, either queues function for deferred execution or
631 * immediately executes function on a separate thread.
633 ******************************************************************************/
635 acpi_status
acpi_os_execute(acpi_execute_type type
,
636 acpi_osd_exec_callback function
, void *context
)
638 acpi_status status
= AE_OK
;
639 struct acpi_os_dpc
*dpc
;
641 ACPI_FUNCTION_TRACE("os_queue_for_execution");
643 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
644 "Scheduling function [%p(%p)] for deferred execution.\n",
648 return_ACPI_STATUS(AE_BAD_PARAMETER
);
651 * Allocate/initialize DPC structure. Note that this memory will be
652 * freed by the callee. The kernel handles the work_struct list in a
653 * way that allows us to also free its memory inside the callee.
654 * Because we may want to schedule several tasks with different
655 * parameters we can't use the approach some kernel code uses of
656 * having a static work_struct.
659 dpc
= kmalloc(sizeof(struct acpi_os_dpc
), GFP_ATOMIC
);
661 return_ACPI_STATUS(AE_NO_MEMORY
);
663 dpc
->function
= function
;
664 dpc
->context
= context
;
666 INIT_WORK(&dpc
->work
, acpi_os_execute_deferred
);
667 if (!queue_work(kacpid_wq
, &dpc
->work
)) {
668 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
669 "Call to queue_work() failed.\n"));
674 return_ACPI_STATUS(status
);
677 EXPORT_SYMBOL(acpi_os_execute
);
679 void acpi_os_wait_events_complete(void *context
)
681 flush_workqueue(kacpid_wq
);
684 EXPORT_SYMBOL(acpi_os_wait_events_complete
);
687 * Allocate the memory for a spinlock and initialize it.
689 acpi_status
acpi_os_create_lock(acpi_spinlock
* handle
)
691 spin_lock_init(*handle
);
697 * Deallocate the memory for a spinlock.
699 void acpi_os_delete_lock(acpi_spinlock handle
)
705 acpi_os_create_semaphore(u32 max_units
, u32 initial_units
, acpi_handle
* handle
)
707 struct semaphore
*sem
= NULL
;
710 sem
= acpi_os_allocate(sizeof(struct semaphore
));
713 memset(sem
, 0, sizeof(struct semaphore
));
715 sema_init(sem
, initial_units
);
717 *handle
= (acpi_handle
*) sem
;
719 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating semaphore[%p|%d].\n",
720 *handle
, initial_units
));
725 EXPORT_SYMBOL(acpi_os_create_semaphore
);
728 * TODO: A better way to delete semaphores? Linux doesn't have a
729 * 'delete_semaphore()' function -- may result in an invalid
730 * pointer dereference for non-synchronized consumers. Should
731 * we at least check for blocked threads and signal/cancel them?
734 acpi_status
acpi_os_delete_semaphore(acpi_handle handle
)
736 struct semaphore
*sem
= (struct semaphore
*)handle
;
740 return AE_BAD_PARAMETER
;
742 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting semaphore[%p].\n", handle
));
750 EXPORT_SYMBOL(acpi_os_delete_semaphore
);
753 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
754 * improvise. The process is to sleep for one scheduler quantum
755 * until the semaphore becomes available. Downside is that this
756 * may result in starvation for timeout-based waits when there's
757 * lots of semaphore activity.
759 * TODO: Support for units > 1?
761 acpi_status
acpi_os_wait_semaphore(acpi_handle handle
, u32 units
, u16 timeout
)
763 acpi_status status
= AE_OK
;
764 struct semaphore
*sem
= (struct semaphore
*)handle
;
768 if (!sem
|| (units
< 1))
769 return AE_BAD_PARAMETER
;
774 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Waiting for semaphore[%p|%d|%d]\n",
775 handle
, units
, timeout
));
778 * This can be called during resume with interrupts off.
779 * Like boot-time, we should be single threaded and will
780 * always get the lock if we try -- timeout or not.
781 * If this doesn't succeed, then we will oops courtesy of
782 * might_sleep() in down().
784 if (!down_trylock(sem
))
791 * A zero timeout value indicates that we shouldn't wait - just
792 * acquire the semaphore if available otherwise return AE_TIME
793 * (a.k.a. 'would block').
796 if (down_trylock(sem
))
804 case ACPI_WAIT_FOREVER
:
813 // TODO: A better timeout algorithm?
816 static const int quantum_ms
= 1000 / HZ
;
818 ret
= down_trylock(sem
);
819 for (i
= timeout
; (i
> 0 && ret
!= 0); i
-= quantum_ms
) {
820 schedule_timeout_interruptible(1);
821 ret
= down_trylock(sem
);
830 if (ACPI_FAILURE(status
)) {
831 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
832 "Failed to acquire semaphore[%p|%d|%d], %s",
833 handle
, units
, timeout
,
834 acpi_format_exception(status
)));
836 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
837 "Acquired semaphore[%p|%d|%d]", handle
,
844 EXPORT_SYMBOL(acpi_os_wait_semaphore
);
847 * TODO: Support for units > 1?
849 acpi_status
acpi_os_signal_semaphore(acpi_handle handle
, u32 units
)
851 struct semaphore
*sem
= (struct semaphore
*)handle
;
854 if (!sem
|| (units
< 1))
855 return AE_BAD_PARAMETER
;
860 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Signaling semaphore[%p|%d]\n", handle
,
868 EXPORT_SYMBOL(acpi_os_signal_semaphore
);
870 #ifdef ACPI_FUTURE_USAGE
871 u32
acpi_os_get_line(char *buffer
)
874 #ifdef ENABLE_DEBUGGER
875 if (acpi_in_debugger
) {
878 kdb_read(buffer
, sizeof(line_buf
));
880 /* remove the CR kdb includes */
881 chars
= strlen(buffer
) - 1;
882 buffer
[chars
] = '\0';
888 #endif /* ACPI_FUTURE_USAGE */
890 acpi_status
acpi_os_signal(u32 function
, void *info
)
893 case ACPI_SIGNAL_FATAL
:
894 printk(KERN_ERR PREFIX
"Fatal opcode executed\n");
896 case ACPI_SIGNAL_BREAKPOINT
:
899 * ACPI spec. says to treat it as a NOP unless
900 * you are debugging. So if/when we integrate
901 * AML debugger into the kernel debugger its
902 * hook will go here. But until then it is
903 * not useful to print anything on breakpoints.
913 EXPORT_SYMBOL(acpi_os_signal
);
915 static int __init
acpi_os_name_setup(char *str
)
917 char *p
= acpi_os_name
;
918 int count
= ACPI_MAX_OVERRIDE_LEN
- 1;
923 for (; count
-- && str
&& *str
; str
++) {
924 if (isalnum(*str
) || *str
== ' ' || *str
== ':')
926 else if (*str
== '\'' || *str
== '"')
937 __setup("acpi_os_name=", acpi_os_name_setup
);
941 * empty string disables _OSI
942 * TBD additional string adds to _OSI
944 static int __init
acpi_osi_setup(char *str
)
946 if (str
== NULL
|| *str
== '\0') {
947 printk(KERN_INFO PREFIX
"_OSI method disabled\n");
948 acpi_gbl_create_osi_method
= FALSE
;
951 printk(KERN_ERR PREFIX
"_OSI additional string ignored -- %s\n",
958 __setup("acpi_osi=", acpi_osi_setup
);
960 /* enable serialization to combat AE_ALREADY_EXISTS errors */
961 static int __init
acpi_serialize_setup(char *str
)
963 printk(KERN_INFO PREFIX
"serialize enabled\n");
965 acpi_gbl_all_methods_serialized
= TRUE
;
970 __setup("acpi_serialize", acpi_serialize_setup
);
973 * Wake and Run-Time GPES are expected to be separate.
974 * We disable wake-GPEs at run-time to prevent spurious
977 * However, if a system exists that shares Wake and
978 * Run-time events on the same GPE this flag is available
979 * to tell Linux to keep the wake-time GPEs enabled at run-time.
981 static int __init
acpi_wake_gpes_always_on_setup(char *str
)
983 printk(KERN_INFO PREFIX
"wake GPEs not disabled\n");
985 acpi_gbl_leave_wake_gpes_disabled
= FALSE
;
990 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup
);
993 * max_cstate is defined in the base kernel so modules can
994 * change it w/o depending on the state of the processor module.
996 unsigned int max_cstate
= ACPI_PROCESSOR_MAX_POWER
;
998 EXPORT_SYMBOL(max_cstate
);
1001 * Acquire a spinlock.
1003 * handle is a pointer to the spinlock_t.
1006 acpi_cpu_flags
acpi_os_acquire_lock(acpi_spinlock lockp
)
1008 acpi_cpu_flags flags
;
1009 spin_lock_irqsave(lockp
, flags
);
1014 * Release a spinlock. See above.
1017 void acpi_os_release_lock(acpi_spinlock lockp
, acpi_cpu_flags flags
)
1019 spin_unlock_irqrestore(lockp
, flags
);
1022 #ifndef ACPI_USE_LOCAL_CACHE
1024 /*******************************************************************************
1026 * FUNCTION: acpi_os_create_cache
1028 * PARAMETERS: name - Ascii name for the cache
1029 * size - Size of each cached object
1030 * depth - Maximum depth of the cache (in objects) <ignored>
1031 * cache - Where the new cache object is returned
1035 * DESCRIPTION: Create a cache object
1037 ******************************************************************************/
1040 acpi_os_create_cache(char *name
, u16 size
, u16 depth
, acpi_cache_t
** cache
)
1042 *cache
= kmem_cache_create(name
, size
, 0, 0, NULL
, NULL
);
1049 /*******************************************************************************
1051 * FUNCTION: acpi_os_purge_cache
1053 * PARAMETERS: Cache - Handle to cache object
1057 * DESCRIPTION: Free all objects within the requested cache.
1059 ******************************************************************************/
1061 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
)
1063 kmem_cache_shrink(cache
);
1067 /*******************************************************************************
1069 * FUNCTION: acpi_os_delete_cache
1071 * PARAMETERS: Cache - Handle to cache object
1075 * DESCRIPTION: Free all objects within the requested cache and delete the
1078 ******************************************************************************/
1080 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
)
1082 kmem_cache_destroy(cache
);
1086 /*******************************************************************************
1088 * FUNCTION: acpi_os_release_object
1090 * PARAMETERS: Cache - Handle to cache object
1091 * Object - The object to be released
1095 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1096 * the object is deleted.
1098 ******************************************************************************/
1100 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
)
1102 kmem_cache_free(cache
, object
);
1106 /******************************************************************************
1108 * FUNCTION: acpi_os_validate_interface
1110 * PARAMETERS: interface - Requested interface to be validated
1112 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1114 * DESCRIPTION: Match an interface string to the interfaces supported by the
1115 * host. Strings originate from an AML call to the _OSI method.
1117 *****************************************************************************/
1120 acpi_os_validate_interface (char *interface
)
1127 /******************************************************************************
1129 * FUNCTION: acpi_os_validate_address
1131 * PARAMETERS: space_id - ACPI space ID
1132 * address - Physical address
1133 * length - Address length
1135 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1136 * should return AE_AML_ILLEGAL_ADDRESS.
1138 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1139 * the addresses accessed by AML operation regions.
1141 *****************************************************************************/
1144 acpi_os_validate_address (
1146 acpi_physical_address address
,