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/interrupt.h>
34 #include <linux/kmod.h>
35 #include <linux/delay.h>
36 #include <linux/dmi.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;
75 static struct workqueue_struct *kacpi_notify_wq;
77 #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
78 static char osi_additional_string[OSI_STRING_LENGTH_MAX];
80 static int osi_linux; /* disable _OSI(Linux) by default */
82 static void __init acpi_request_region (struct acpi_generic_address *addr,
83 unsigned int length, char *desc)
87 if (!addr->address || !length)
90 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
91 res = request_region(addr->address, length, desc);
92 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
93 res = request_mem_region(addr->address, length, desc);
96 static int __init acpi_reserve_resources(void)
98 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
101 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
102 "ACPI PM1b_EVT_BLK");
104 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
105 "ACPI PM1a_CNT_BLK");
107 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
108 "ACPI PM1b_CNT_BLK");
110 if (acpi_gbl_FADT.pm_timer_length == 4)
111 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
113 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
116 /* Length of GPE blocks must be a non-negative multiple of 2 */
118 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
119 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
120 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
122 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
123 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
124 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
128 device_initcall(acpi_reserve_resources);
130 acpi_status __init acpi_os_initialize(void)
135 acpi_status acpi_os_initialize1(void)
138 * Initialize PCI configuration space access, as we'll need to access
139 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
142 printk(KERN_ERR PREFIX
143 "Access to PCI configuration space unavailable\n");
144 return AE_NULL_ENTRY;
146 kacpid_wq = create_singlethread_workqueue("kacpid");
147 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
149 BUG_ON(!kacpi_notify_wq);
153 acpi_status acpi_os_terminate(void)
155 if (acpi_irq_handler) {
156 acpi_os_remove_interrupt_handler(acpi_irq_irq,
160 destroy_workqueue(kacpid_wq);
161 destroy_workqueue(kacpi_notify_wq);
166 void acpi_os_printf(const char *fmt, ...)
170 acpi_os_vprintf(fmt, args);
174 EXPORT_SYMBOL(acpi_os_printf);
176 void acpi_os_vprintf(const char *fmt, va_list args)
178 static char buffer[512];
180 vsprintf(buffer, fmt, args);
182 #ifdef ENABLE_DEBUGGER
183 if (acpi_in_debugger) {
184 kdb_printf("%s", buffer);
186 printk("%s", buffer);
189 printk("%s", buffer);
193 acpi_physical_address __init acpi_os_get_root_pointer(void)
196 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
198 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
201 printk(KERN_ERR PREFIX
202 "System description tables not found\n");
206 return acpi_find_rsdp();
209 void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
211 if (phys > ULONG_MAX) {
212 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
215 if (acpi_gbl_permanent_mmap)
217 * ioremap checks to ensure this is in reserved space
219 return ioremap((unsigned long)phys, size);
221 return __acpi_map_table((unsigned long)phys, size);
223 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
225 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
227 if (acpi_gbl_permanent_mmap) {
231 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
233 #ifdef ACPI_FUTURE_USAGE
235 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
238 return AE_BAD_PARAMETER;
240 *phys = virt_to_phys(virt);
246 #define ACPI_MAX_OVERRIDE_LEN 100
248 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
251 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
252 acpi_string * new_val)
254 if (!init_val || !new_val)
255 return AE_BAD_PARAMETER;
258 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
259 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
261 *new_val = acpi_os_name;
268 acpi_os_table_override(struct acpi_table_header * existing_table,
269 struct acpi_table_header ** new_table)
271 if (!existing_table || !new_table)
272 return AE_BAD_PARAMETER;
274 #ifdef CONFIG_ACPI_CUSTOM_DSDT
275 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
276 *new_table = (struct acpi_table_header *)AmlCode;
285 static irqreturn_t acpi_irq(int irq, void *dev_id)
287 return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE;
291 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
297 * Ignore the GSI from the core, and use the value in our copy of the
298 * FADT. It may not be the same if an interrupt source override exists
301 gsi = acpi_gbl_FADT.sci_interrupt;
302 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
303 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
308 acpi_irq_handler = handler;
309 acpi_irq_context = context;
310 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
311 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
312 return AE_NOT_ACQUIRED;
319 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
322 free_irq(irq, acpi_irq);
323 acpi_irq_handler = NULL;
331 * Running in interpreter thread context, safe to sleep
334 void acpi_os_sleep(acpi_integer ms)
336 schedule_timeout_interruptible(msecs_to_jiffies(ms));
339 EXPORT_SYMBOL(acpi_os_sleep);
341 void acpi_os_stall(u32 us)
349 touch_nmi_watchdog();
354 EXPORT_SYMBOL(acpi_os_stall);
357 * Support ACPI 3.0 AML Timer operand
358 * Returns 64-bit free-running, monotonically increasing timer
359 * with 100ns granularity
361 u64 acpi_os_get_timer(void)
366 /* TBD: use HPET if available */
369 #ifdef CONFIG_X86_PM_TIMER
370 /* TBD: default to PM timer if HPET was not available */
373 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
378 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
387 *(u8 *) value = inb(port);
388 } else if (width <= 16) {
389 *(u16 *) value = inw(port);
390 } else if (width <= 32) {
391 *(u32 *) value = inl(port);
399 EXPORT_SYMBOL(acpi_os_read_port);
401 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
405 } else if (width <= 16) {
407 } else if (width <= 32) {
416 EXPORT_SYMBOL(acpi_os_write_port);
419 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
422 void __iomem *virt_addr;
424 virt_addr = ioremap(phys_addr, width);
430 *(u8 *) value = readb(virt_addr);
433 *(u16 *) value = readw(virt_addr);
436 *(u32 *) value = readl(virt_addr);
448 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
450 void __iomem *virt_addr;
452 virt_addr = ioremap(phys_addr, width);
456 writeb(value, virt_addr);
459 writew(value, virt_addr);
462 writel(value, virt_addr);
474 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
475 void *value, u32 width)
480 return AE_BAD_PARAMETER;
496 BUG_ON(!raw_pci_ops);
498 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
499 PCI_DEVFN(pci_id->device, pci_id->function),
502 return (result ? AE_ERROR : AE_OK);
505 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
508 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
509 acpi_integer value, u32 width)
527 BUG_ON(!raw_pci_ops);
529 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
530 PCI_DEVFN(pci_id->device, pci_id->function),
533 return (result ? AE_ERROR : AE_OK);
536 /* TODO: Change code to take advantage of driver model more */
537 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
538 acpi_handle chandle, /* current node */
539 struct acpi_pci_id **id,
540 int *is_bridge, u8 * bus_number)
543 struct acpi_pci_id *pci_id = *id;
546 acpi_object_type type;
549 acpi_get_parent(chandle, &handle);
550 if (handle != rhandle) {
551 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
554 status = acpi_get_type(handle, &type);
555 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
559 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
561 if (ACPI_SUCCESS(status)) {
562 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
563 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
566 pci_id->bus = *bus_number;
568 /* any nicer way to get bus number of bridge ? */
570 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
572 if (ACPI_SUCCESS(status)
573 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
575 acpi_os_read_pci_configuration(pci_id, 0x18,
577 if (!ACPI_SUCCESS(status)) {
578 /* Certainly broken... FIX ME */
584 acpi_os_read_pci_configuration(pci_id, 0x19,
586 if (ACPI_SUCCESS(status)) {
595 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
596 acpi_handle chandle, /* current node */
597 struct acpi_pci_id **id)
600 u8 bus_number = (*id)->bus;
602 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
605 static void acpi_os_execute_deferred(struct work_struct *work)
607 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);
616 /* Yield cpu to notify thread */
622 static void acpi_os_execute_notify(struct work_struct *work)
624 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
627 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
631 dpc->function(dpc->context);
638 /*******************************************************************************
640 * FUNCTION: acpi_os_execute
642 * PARAMETERS: Type - Type of the callback
643 * Function - Function to be executed
644 * Context - Function parameters
648 * DESCRIPTION: Depending on type, either queues function for deferred execution or
649 * immediately executes function on a separate thread.
651 ******************************************************************************/
653 acpi_status acpi_os_execute(acpi_execute_type type,
654 acpi_osd_exec_callback function, void *context)
656 acpi_status status = AE_OK;
657 struct acpi_os_dpc *dpc;
659 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
660 "Scheduling function [%p(%p)] for deferred execution.\n",
664 return AE_BAD_PARAMETER;
667 * Allocate/initialize DPC structure. Note that this memory will be
668 * freed by the callee. The kernel handles the work_struct list in a
669 * way that allows us to also free its memory inside the callee.
670 * Because we may want to schedule several tasks with different
671 * parameters we can't use the approach some kernel code uses of
672 * having a static work_struct.
675 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
677 return_ACPI_STATUS(AE_NO_MEMORY);
679 dpc->function = function;
680 dpc->context = context;
682 if (type == OSL_NOTIFY_HANDLER) {
683 INIT_WORK(&dpc->work, acpi_os_execute_notify);
684 if (!queue_work(kacpi_notify_wq, &dpc->work)) {
689 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
690 if (!queue_work(kacpid_wq, &dpc->work)) {
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
692 "Call to queue_work() failed.\n"));
697 return_ACPI_STATUS(status);
700 EXPORT_SYMBOL(acpi_os_execute);
702 void acpi_os_wait_events_complete(void *context)
704 flush_workqueue(kacpid_wq);
707 EXPORT_SYMBOL(acpi_os_wait_events_complete);
710 * Allocate the memory for a spinlock and initialize it.
712 acpi_status acpi_os_create_lock(acpi_spinlock * handle)
714 spin_lock_init(*handle);
720 * Deallocate the memory for a spinlock.
722 void acpi_os_delete_lock(acpi_spinlock handle)
728 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
730 struct semaphore *sem = NULL;
733 sem = acpi_os_allocate(sizeof(struct semaphore));
736 memset(sem, 0, sizeof(struct semaphore));
738 sema_init(sem, initial_units);
740 *handle = (acpi_handle *) sem;
742 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
743 *handle, initial_units));
748 EXPORT_SYMBOL(acpi_os_create_semaphore);
751 * TODO: A better way to delete semaphores? Linux doesn't have a
752 * 'delete_semaphore()' function -- may result in an invalid
753 * pointer dereference for non-synchronized consumers. Should
754 * we at least check for blocked threads and signal/cancel them?
757 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
759 struct semaphore *sem = (struct semaphore *)handle;
763 return AE_BAD_PARAMETER;
765 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
773 EXPORT_SYMBOL(acpi_os_delete_semaphore);
776 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
777 * improvise. The process is to sleep for one scheduler quantum
778 * until the semaphore becomes available. Downside is that this
779 * may result in starvation for timeout-based waits when there's
780 * lots of semaphore activity.
782 * TODO: Support for units > 1?
784 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
786 acpi_status status = AE_OK;
787 struct semaphore *sem = (struct semaphore *)handle;
791 if (!sem || (units < 1))
792 return AE_BAD_PARAMETER;
797 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
798 handle, units, timeout));
801 * This can be called during resume with interrupts off.
802 * Like boot-time, we should be single threaded and will
803 * always get the lock if we try -- timeout or not.
804 * If this doesn't succeed, then we will oops courtesy of
805 * might_sleep() in down().
807 if (!down_trylock(sem))
814 * A zero timeout value indicates that we shouldn't wait - just
815 * acquire the semaphore if available otherwise return AE_TIME
816 * (a.k.a. 'would block').
819 if (down_trylock(sem))
827 case ACPI_WAIT_FOREVER:
836 // TODO: A better timeout algorithm?
839 static const int quantum_ms = 1000 / HZ;
841 ret = down_trylock(sem);
842 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
843 schedule_timeout_interruptible(1);
844 ret = down_trylock(sem);
853 if (ACPI_FAILURE(status)) {
854 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
855 "Failed to acquire semaphore[%p|%d|%d], %s",
856 handle, units, timeout,
857 acpi_format_exception(status)));
859 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
860 "Acquired semaphore[%p|%d|%d]", handle,
867 EXPORT_SYMBOL(acpi_os_wait_semaphore);
870 * TODO: Support for units > 1?
872 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
874 struct semaphore *sem = (struct semaphore *)handle;
877 if (!sem || (units < 1))
878 return AE_BAD_PARAMETER;
883 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
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 acpi_status acpi_os_signal(u32 function, void *info)
916 case ACPI_SIGNAL_FATAL:
917 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
919 case ACPI_SIGNAL_BREAKPOINT:
922 * ACPI spec. says to treat it as a NOP unless
923 * you are debugging. So if/when we integrate
924 * AML debugger into the kernel debugger its
925 * hook will go here. But until then it is
926 * not useful to print anything on breakpoints.
936 EXPORT_SYMBOL(acpi_os_signal);
938 static int __init acpi_os_name_setup(char *str)
940 char *p = acpi_os_name;
941 int count = ACPI_MAX_OVERRIDE_LEN - 1;
946 for (; count-- && str && *str; str++) {
947 if (isalnum(*str) || *str == ' ' || *str == ':')
949 else if (*str == '\'' || *str == '"')
960 __setup("acpi_os_name=", acpi_os_name_setup);
962 static void enable_osi_linux(int enable) {
964 if (osi_linux != enable)
965 printk(KERN_INFO PREFIX "%sabled _OSI(Linux)\n",
966 enable ? "En": "Dis");
973 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
975 * empty string disables _OSI
976 * string starting with '!' disables that string
977 * otherwise string is added to list, augmenting built-in strings
979 static int __init acpi_osi_setup(char *str)
981 if (str == NULL || *str == '\0') {
982 printk(KERN_INFO PREFIX "_OSI method disabled\n");
983 acpi_gbl_create_osi_method = FALSE;
984 } else if (!strcmp("!Linux", str)) {
986 } else if (*str == '!') {
987 if (acpi_osi_invalidate(++str) == AE_OK)
988 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
989 } else if (!strcmp("Linux", str)) {
991 } else if (*osi_additional_string == '\0') {
992 strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX);
993 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
999 __setup("acpi_osi=", acpi_osi_setup);
1001 /* enable serialization to combat AE_ALREADY_EXISTS errors */
1002 static int __init acpi_serialize_setup(char *str)
1004 printk(KERN_INFO PREFIX "serialize enabled\n");
1006 acpi_gbl_all_methods_serialized = TRUE;
1011 __setup("acpi_serialize", acpi_serialize_setup);
1014 * Wake and Run-Time GPES are expected to be separate.
1015 * We disable wake-GPEs at run-time to prevent spurious
1018 * However, if a system exists that shares Wake and
1019 * Run-time events on the same GPE this flag is available
1020 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1022 static int __init acpi_wake_gpes_always_on_setup(char *str)
1024 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1026 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1031 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1034 * Acquire a spinlock.
1036 * handle is a pointer to the spinlock_t.
1039 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1041 acpi_cpu_flags flags;
1042 spin_lock_irqsave(lockp, flags);
1047 * Release a spinlock. See above.
1050 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1052 spin_unlock_irqrestore(lockp, flags);
1055 #ifndef ACPI_USE_LOCAL_CACHE
1057 /*******************************************************************************
1059 * FUNCTION: acpi_os_create_cache
1061 * PARAMETERS: name - Ascii name for the cache
1062 * size - Size of each cached object
1063 * depth - Maximum depth of the cache (in objects) <ignored>
1064 * cache - Where the new cache object is returned
1068 * DESCRIPTION: Create a cache object
1070 ******************************************************************************/
1073 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1075 *cache = kmem_cache_create(name, size, 0, 0, NULL);
1082 /*******************************************************************************
1084 * FUNCTION: acpi_os_purge_cache
1086 * PARAMETERS: Cache - Handle to cache object
1090 * DESCRIPTION: Free all objects within the requested cache.
1092 ******************************************************************************/
1094 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1096 kmem_cache_shrink(cache);
1100 /*******************************************************************************
1102 * FUNCTION: acpi_os_delete_cache
1104 * PARAMETERS: Cache - Handle to cache object
1108 * DESCRIPTION: Free all objects within the requested cache and delete the
1111 ******************************************************************************/
1113 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1115 kmem_cache_destroy(cache);
1119 /*******************************************************************************
1121 * FUNCTION: acpi_os_release_object
1123 * PARAMETERS: Cache - Handle to cache object
1124 * Object - The object to be released
1128 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1129 * the object is deleted.
1131 ******************************************************************************/
1133 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1135 kmem_cache_free(cache, object);
1140 * acpi_dmi_dump - dump DMI slots needed for blacklist entry
1142 * Returns 0 on success
1144 int acpi_dmi_dump(void)
1150 printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n",
1151 dmi_get_slot(DMI_SYS_VENDOR));
1152 printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n",
1153 dmi_get_slot(DMI_PRODUCT_NAME));
1154 printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n",
1155 dmi_get_slot(DMI_PRODUCT_VERSION));
1156 printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n",
1157 dmi_get_slot(DMI_BOARD_NAME));
1158 printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n",
1159 dmi_get_slot(DMI_BIOS_VENDOR));
1160 printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n",
1161 dmi_get_slot(DMI_BIOS_DATE));
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)
1183 if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX))
1185 if (!strcmp("Linux", interface)) {
1186 printk(KERN_WARNING PREFIX
1187 "System BIOS is requesting _OSI(Linux)\n");
1188 if (acpi_dmi_dump())
1189 printk(KERN_NOTICE PREFIX
1190 "[please extract dmidecode output]\n");
1191 printk(KERN_NOTICE PREFIX
1192 "Please send DMI info above to "
1193 "linux-acpi@vger.kernel.org\n");
1194 printk(KERN_NOTICE PREFIX
1195 "If \"acpi_osi=%sLinux\" works better, "
1196 "please notify linux-acpi@vger.kernel.org\n",
1197 osi_linux ? "!" : "");
1204 /******************************************************************************
1206 * FUNCTION: acpi_os_validate_address
1208 * PARAMETERS: space_id - ACPI space ID
1209 * address - Physical address
1210 * length - Address length
1212 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1213 * should return AE_AML_ILLEGAL_ADDRESS.
1215 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1216 * the addresses accessed by AML operation regions.
1218 *****************************************************************************/
1221 acpi_os_validate_address (
1223 acpi_physical_address address,