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];
81 * "Ode to _OSI(Linux)"
83 * osi_linux -- Control response to BIOS _OSI(Linux) query.
85 * As Linux evolves, the features that it supports change.
86 * So an OSI string such as "Linux" is not specific enough
87 * to be useful across multiple versions of Linux. It
88 * doesn't identify any particular feature, interface,
89 * or even any particular version of Linux...
91 * Unfortunately, Linux-2.6.22 and earlier responded "yes"
92 * to a BIOS _OSI(Linux) query. When
93 * a reference mobile BIOS started using it, its use
94 * started to spread to many vendor platforms.
95 * As it is not supportable, we need to halt that spread.
97 * Today, most BIOS references to _OSI(Linux) are noise --
98 * they have no functional effect and are just dead code
99 * carried over from the reference BIOS.
101 * The next most common case is that _OSI(Linux) harms Linux,
102 * usually by causing the BIOS to follow paths that are
103 * not tested during Windows validation.
105 * Finally, there is a short list of platforms
106 * where OSI(Linux) benefits Linux.
108 * In Linux-2.6.23, OSI(Linux) is first disabled by default.
109 * DMI is used to disable the dmesg warning about OSI(Linux)
110 * on platforms where it is known to have no effect.
111 * But a dmesg warning remains for systems where
112 * we do not know if OSI(Linux) is good or bad for the system.
113 * DMI is also used to enable OSI(Linux) for the machines
114 * that are known to need it.
116 * BIOS writers should NOT query _OSI(Linux) on future systems.
117 * It will be ignored by default, and to get Linux to
118 * not ignore it will require a kernel source update to
119 * add a DMI entry, or a boot-time "acpi_osi=Linux" invocation.
121 #define OSI_LINUX_ENABLE 0
123 static struct osi_linux {
124 unsigned int enable:1;
126 unsigned int cmdline:1;
127 unsigned int known:1;
128 } osi_linux = { OSI_LINUX_ENABLE, 0, 0, 0};
130 static void __init acpi_request_region (struct acpi_generic_address *addr,
131 unsigned int length, char *desc)
133 struct resource *res;
135 if (!addr->address || !length)
138 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
139 res = request_region(addr->address, length, desc);
140 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
141 res = request_mem_region(addr->address, length, desc);
144 static int __init acpi_reserve_resources(void)
146 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
147 "ACPI PM1a_EVT_BLK");
149 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
150 "ACPI PM1b_EVT_BLK");
152 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
153 "ACPI PM1a_CNT_BLK");
155 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
156 "ACPI PM1b_CNT_BLK");
158 if (acpi_gbl_FADT.pm_timer_length == 4)
159 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
161 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
164 /* Length of GPE blocks must be a non-negative multiple of 2 */
166 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
167 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
168 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
170 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
171 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
172 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
176 device_initcall(acpi_reserve_resources);
178 acpi_status __init acpi_os_initialize(void)
183 acpi_status acpi_os_initialize1(void)
186 * Initialize PCI configuration space access, as we'll need to access
187 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
190 printk(KERN_ERR PREFIX
191 "Access to PCI configuration space unavailable\n");
192 return AE_NULL_ENTRY;
194 kacpid_wq = create_singlethread_workqueue("kacpid");
195 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
197 BUG_ON(!kacpi_notify_wq);
201 acpi_status acpi_os_terminate(void)
203 if (acpi_irq_handler) {
204 acpi_os_remove_interrupt_handler(acpi_irq_irq,
208 destroy_workqueue(kacpid_wq);
209 destroy_workqueue(kacpi_notify_wq);
214 void acpi_os_printf(const char *fmt, ...)
218 acpi_os_vprintf(fmt, args);
222 EXPORT_SYMBOL(acpi_os_printf);
224 void acpi_os_vprintf(const char *fmt, va_list args)
226 static char buffer[512];
228 vsprintf(buffer, fmt, args);
230 #ifdef ENABLE_DEBUGGER
231 if (acpi_in_debugger) {
232 kdb_printf("%s", buffer);
234 printk("%s", buffer);
237 printk("%s", buffer);
241 acpi_physical_address __init acpi_os_get_root_pointer(void)
244 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
246 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
249 printk(KERN_ERR PREFIX
250 "System description tables not found\n");
254 acpi_physical_address pa = 0;
256 acpi_find_root_pointer(&pa);
261 void __iomem *__init_refok
262 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
264 if (phys > ULONG_MAX) {
265 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
268 if (acpi_gbl_permanent_mmap)
270 * ioremap checks to ensure this is in reserved space
272 return ioremap((unsigned long)phys, size);
274 return __acpi_map_table((unsigned long)phys, size);
276 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
278 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
280 if (acpi_gbl_permanent_mmap) {
284 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
286 #ifdef ACPI_FUTURE_USAGE
288 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
291 return AE_BAD_PARAMETER;
293 *phys = virt_to_phys(virt);
299 #define ACPI_MAX_OVERRIDE_LEN 100
301 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
304 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
305 acpi_string * new_val)
307 if (!init_val || !new_val)
308 return AE_BAD_PARAMETER;
311 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
312 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
314 *new_val = acpi_os_name;
321 acpi_os_table_override(struct acpi_table_header * existing_table,
322 struct acpi_table_header ** new_table)
324 if (!existing_table || !new_table)
325 return AE_BAD_PARAMETER;
327 #ifdef CONFIG_ACPI_CUSTOM_DSDT
328 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
329 *new_table = (struct acpi_table_header *)AmlCode;
338 static irqreturn_t acpi_irq(int irq, void *dev_id)
342 handled = (*acpi_irq_handler) (acpi_irq_context);
352 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
357 acpi_irq_stats_init();
360 * Ignore the GSI from the core, and use the value in our copy of the
361 * FADT. It may not be the same if an interrupt source override exists
364 gsi = acpi_gbl_FADT.sci_interrupt;
365 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
366 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
371 acpi_irq_handler = handler;
372 acpi_irq_context = context;
373 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
374 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
375 return AE_NOT_ACQUIRED;
382 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
385 free_irq(irq, acpi_irq);
386 acpi_irq_handler = NULL;
394 * Running in interpreter thread context, safe to sleep
397 void acpi_os_sleep(acpi_integer ms)
399 schedule_timeout_interruptible(msecs_to_jiffies(ms));
402 EXPORT_SYMBOL(acpi_os_sleep);
404 void acpi_os_stall(u32 us)
412 touch_nmi_watchdog();
417 EXPORT_SYMBOL(acpi_os_stall);
420 * Support ACPI 3.0 AML Timer operand
421 * Returns 64-bit free-running, monotonically increasing timer
422 * with 100ns granularity
424 u64 acpi_os_get_timer(void)
429 /* TBD: use HPET if available */
432 #ifdef CONFIG_X86_PM_TIMER
433 /* TBD: default to PM timer if HPET was not available */
436 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
441 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
450 *(u8 *) value = inb(port);
451 } else if (width <= 16) {
452 *(u16 *) value = inw(port);
453 } else if (width <= 32) {
454 *(u32 *) value = inl(port);
462 EXPORT_SYMBOL(acpi_os_read_port);
464 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
468 } else if (width <= 16) {
470 } else if (width <= 32) {
479 EXPORT_SYMBOL(acpi_os_write_port);
482 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
485 void __iomem *virt_addr;
487 virt_addr = ioremap(phys_addr, width);
493 *(u8 *) value = readb(virt_addr);
496 *(u16 *) value = readw(virt_addr);
499 *(u32 *) value = readl(virt_addr);
511 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
513 void __iomem *virt_addr;
515 virt_addr = ioremap(phys_addr, width);
519 writeb(value, virt_addr);
522 writew(value, virt_addr);
525 writel(value, virt_addr);
537 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
538 void *value, u32 width)
543 return AE_BAD_PARAMETER;
559 BUG_ON(!raw_pci_ops);
561 result = raw_pci_ops->read(pci_id->segment, pci_id->bus,
562 PCI_DEVFN(pci_id->device, pci_id->function),
565 return (result ? AE_ERROR : AE_OK);
568 EXPORT_SYMBOL(acpi_os_read_pci_configuration);
571 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
572 acpi_integer value, u32 width)
590 BUG_ON(!raw_pci_ops);
592 result = raw_pci_ops->write(pci_id->segment, pci_id->bus,
593 PCI_DEVFN(pci_id->device, pci_id->function),
596 return (result ? AE_ERROR : AE_OK);
599 /* TODO: Change code to take advantage of driver model more */
600 static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */
601 acpi_handle chandle, /* current node */
602 struct acpi_pci_id **id,
603 int *is_bridge, u8 * bus_number)
606 struct acpi_pci_id *pci_id = *id;
609 acpi_object_type type;
612 acpi_get_parent(chandle, &handle);
613 if (handle != rhandle) {
614 acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge,
617 status = acpi_get_type(handle, &type);
618 if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE))
622 acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
624 if (ACPI_SUCCESS(status)) {
625 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp));
626 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp));
629 pci_id->bus = *bus_number;
631 /* any nicer way to get bus number of bridge ? */
633 acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8,
635 if (ACPI_SUCCESS(status)
636 && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) {
638 acpi_os_read_pci_configuration(pci_id, 0x18,
640 if (!ACPI_SUCCESS(status)) {
641 /* Certainly broken... FIX ME */
647 acpi_os_read_pci_configuration(pci_id, 0x19,
649 if (ACPI_SUCCESS(status)) {
658 void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
659 acpi_handle chandle, /* current node */
660 struct acpi_pci_id **id)
663 u8 bus_number = (*id)->bus;
665 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
668 static void acpi_os_execute_deferred(struct work_struct *work)
670 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
672 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
676 dpc->function(dpc->context);
682 /*******************************************************************************
684 * FUNCTION: acpi_os_execute
686 * PARAMETERS: Type - Type of the callback
687 * Function - Function to be executed
688 * Context - Function parameters
692 * DESCRIPTION: Depending on type, either queues function for deferred execution or
693 * immediately executes function on a separate thread.
695 ******************************************************************************/
697 acpi_status acpi_os_execute(acpi_execute_type type,
698 acpi_osd_exec_callback function, void *context)
700 acpi_status status = AE_OK;
701 struct acpi_os_dpc *dpc;
702 struct workqueue_struct *queue;
703 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
704 "Scheduling function [%p(%p)] for deferred execution.\n",
708 return AE_BAD_PARAMETER;
711 * Allocate/initialize DPC structure. Note that this memory will be
712 * freed by the callee. The kernel handles the work_struct list in a
713 * way that allows us to also free its memory inside the callee.
714 * Because we may want to schedule several tasks with different
715 * parameters we can't use the approach some kernel code uses of
716 * having a static work_struct.
719 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
721 return_ACPI_STATUS(AE_NO_MEMORY);
723 dpc->function = function;
724 dpc->context = context;
726 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
727 queue = (type == OSL_NOTIFY_HANDLER) ? kacpi_notify_wq : kacpid_wq;
728 if (!queue_work(queue, &dpc->work)) {
729 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
730 "Call to queue_work() failed.\n"));
734 return_ACPI_STATUS(status);
737 EXPORT_SYMBOL(acpi_os_execute);
739 void acpi_os_wait_events_complete(void *context)
741 flush_workqueue(kacpid_wq);
744 EXPORT_SYMBOL(acpi_os_wait_events_complete);
747 * Allocate the memory for a spinlock and initialize it.
749 acpi_status acpi_os_create_lock(acpi_spinlock * handle)
751 spin_lock_init(*handle);
757 * Deallocate the memory for a spinlock.
759 void acpi_os_delete_lock(acpi_spinlock handle)
765 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
767 struct semaphore *sem = NULL;
770 sem = acpi_os_allocate(sizeof(struct semaphore));
773 memset(sem, 0, sizeof(struct semaphore));
775 sema_init(sem, initial_units);
777 *handle = (acpi_handle *) sem;
779 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
780 *handle, initial_units));
785 EXPORT_SYMBOL(acpi_os_create_semaphore);
788 * TODO: A better way to delete semaphores? Linux doesn't have a
789 * 'delete_semaphore()' function -- may result in an invalid
790 * pointer dereference for non-synchronized consumers. Should
791 * we at least check for blocked threads and signal/cancel them?
794 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
796 struct semaphore *sem = (struct semaphore *)handle;
800 return AE_BAD_PARAMETER;
802 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
810 EXPORT_SYMBOL(acpi_os_delete_semaphore);
813 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
814 * improvise. The process is to sleep for one scheduler quantum
815 * until the semaphore becomes available. Downside is that this
816 * may result in starvation for timeout-based waits when there's
817 * lots of semaphore activity.
819 * TODO: Support for units > 1?
821 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
823 acpi_status status = AE_OK;
824 struct semaphore *sem = (struct semaphore *)handle;
828 if (!sem || (units < 1))
829 return AE_BAD_PARAMETER;
834 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
835 handle, units, timeout));
838 * This can be called during resume with interrupts off.
839 * Like boot-time, we should be single threaded and will
840 * always get the lock if we try -- timeout or not.
841 * If this doesn't succeed, then we will oops courtesy of
842 * might_sleep() in down().
844 if (!down_trylock(sem))
851 * A zero timeout value indicates that we shouldn't wait - just
852 * acquire the semaphore if available otherwise return AE_TIME
853 * (a.k.a. 'would block').
856 if (down_trylock(sem))
864 case ACPI_WAIT_FOREVER:
873 // TODO: A better timeout algorithm?
876 static const int quantum_ms = 1000 / HZ;
878 ret = down_trylock(sem);
879 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
880 schedule_timeout_interruptible(1);
881 ret = down_trylock(sem);
890 if (ACPI_FAILURE(status)) {
891 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
892 "Failed to acquire semaphore[%p|%d|%d], %s",
893 handle, units, timeout,
894 acpi_format_exception(status)));
896 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
897 "Acquired semaphore[%p|%d|%d]", handle,
904 EXPORT_SYMBOL(acpi_os_wait_semaphore);
907 * TODO: Support for units > 1?
909 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
911 struct semaphore *sem = (struct semaphore *)handle;
914 if (!sem || (units < 1))
915 return AE_BAD_PARAMETER;
920 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
928 EXPORT_SYMBOL(acpi_os_signal_semaphore);
930 #ifdef ACPI_FUTURE_USAGE
931 u32 acpi_os_get_line(char *buffer)
934 #ifdef ENABLE_DEBUGGER
935 if (acpi_in_debugger) {
938 kdb_read(buffer, sizeof(line_buf));
940 /* remove the CR kdb includes */
941 chars = strlen(buffer) - 1;
942 buffer[chars] = '\0';
948 #endif /* ACPI_FUTURE_USAGE */
950 acpi_status acpi_os_signal(u32 function, void *info)
953 case ACPI_SIGNAL_FATAL:
954 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
956 case ACPI_SIGNAL_BREAKPOINT:
959 * ACPI spec. says to treat it as a NOP unless
960 * you are debugging. So if/when we integrate
961 * AML debugger into the kernel debugger its
962 * hook will go here. But until then it is
963 * not useful to print anything on breakpoints.
973 EXPORT_SYMBOL(acpi_os_signal);
975 static int __init acpi_os_name_setup(char *str)
977 char *p = acpi_os_name;
978 int count = ACPI_MAX_OVERRIDE_LEN - 1;
983 for (; count-- && str && *str; str++) {
984 if (isalnum(*str) || *str == ' ' || *str == ':')
986 else if (*str == '\'' || *str == '"')
997 __setup("acpi_os_name=", acpi_os_name_setup);
999 static void __init set_osi_linux(unsigned int enable)
1001 if (osi_linux.enable != enable) {
1002 osi_linux.enable = enable;
1003 printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n",
1004 enable ? "Add": "Delet");
1009 static void __init acpi_cmdline_osi_linux(unsigned int enable)
1011 osi_linux.cmdline = 1; /* cmdline set the default */
1012 set_osi_linux(enable);
1017 void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1019 osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
1021 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
1026 osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */
1028 set_osi_linux(enable);
1034 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
1036 * empty string disables _OSI
1037 * string starting with '!' disables that string
1038 * otherwise string is added to list, augmenting built-in strings
1040 static int __init acpi_osi_setup(char *str)
1042 if (str == NULL || *str == '\0') {
1043 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1044 acpi_gbl_create_osi_method = FALSE;
1045 } else if (!strcmp("!Linux", str)) {
1046 acpi_cmdline_osi_linux(0); /* !enable */
1047 } else if (*str == '!') {
1048 if (acpi_osi_invalidate(++str) == AE_OK)
1049 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
1050 } else if (!strcmp("Linux", str)) {
1051 acpi_cmdline_osi_linux(1); /* enable */
1052 } else if (*osi_additional_string == '\0') {
1053 strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX);
1054 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
1060 __setup("acpi_osi=", acpi_osi_setup);
1062 /* enable serialization to combat AE_ALREADY_EXISTS errors */
1063 static int __init acpi_serialize_setup(char *str)
1065 printk(KERN_INFO PREFIX "serialize enabled\n");
1067 acpi_gbl_all_methods_serialized = TRUE;
1072 __setup("acpi_serialize", acpi_serialize_setup);
1075 * Wake and Run-Time GPES are expected to be separate.
1076 * We disable wake-GPEs at run-time to prevent spurious
1079 * However, if a system exists that shares Wake and
1080 * Run-time events on the same GPE this flag is available
1081 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1083 static int __init acpi_wake_gpes_always_on_setup(char *str)
1085 printk(KERN_INFO PREFIX "wake GPEs not disabled\n");
1087 acpi_gbl_leave_wake_gpes_disabled = FALSE;
1092 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1095 * Acquire a spinlock.
1097 * handle is a pointer to the spinlock_t.
1100 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1102 acpi_cpu_flags flags;
1103 spin_lock_irqsave(lockp, flags);
1108 * Release a spinlock. See above.
1111 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1113 spin_unlock_irqrestore(lockp, flags);
1116 #ifndef ACPI_USE_LOCAL_CACHE
1118 /*******************************************************************************
1120 * FUNCTION: acpi_os_create_cache
1122 * PARAMETERS: name - Ascii name for the cache
1123 * size - Size of each cached object
1124 * depth - Maximum depth of the cache (in objects) <ignored>
1125 * cache - Where the new cache object is returned
1129 * DESCRIPTION: Create a cache object
1131 ******************************************************************************/
1134 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1136 *cache = kmem_cache_create(name, size, 0, 0, NULL);
1143 /*******************************************************************************
1145 * FUNCTION: acpi_os_purge_cache
1147 * PARAMETERS: Cache - Handle to cache object
1151 * DESCRIPTION: Free all objects within the requested cache.
1153 ******************************************************************************/
1155 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1157 kmem_cache_shrink(cache);
1161 /*******************************************************************************
1163 * FUNCTION: acpi_os_delete_cache
1165 * PARAMETERS: Cache - Handle to cache object
1169 * DESCRIPTION: Free all objects within the requested cache and delete the
1172 ******************************************************************************/
1174 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1176 kmem_cache_destroy(cache);
1180 /*******************************************************************************
1182 * FUNCTION: acpi_os_release_object
1184 * PARAMETERS: Cache - Handle to cache object
1185 * Object - The object to be released
1189 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1190 * the object is deleted.
1192 ******************************************************************************/
1194 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1196 kmem_cache_free(cache, object);
1201 * acpi_dmi_dump - dump DMI slots needed for blacklist entry
1203 * Returns 0 on success
1205 static int acpi_dmi_dump(void)
1211 printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n",
1212 dmi_get_system_info(DMI_SYS_VENDOR));
1213 printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n",
1214 dmi_get_system_info(DMI_PRODUCT_NAME));
1215 printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n",
1216 dmi_get_system_info(DMI_PRODUCT_VERSION));
1217 printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n",
1218 dmi_get_system_info(DMI_BOARD_NAME));
1219 printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n",
1220 dmi_get_system_info(DMI_BIOS_VENDOR));
1221 printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n",
1222 dmi_get_system_info(DMI_BIOS_DATE));
1228 /******************************************************************************
1230 * FUNCTION: acpi_os_validate_interface
1232 * PARAMETERS: interface - Requested interface to be validated
1234 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1236 * DESCRIPTION: Match an interface string to the interfaces supported by the
1237 * host. Strings originate from an AML call to the _OSI method.
1239 *****************************************************************************/
1242 acpi_os_validate_interface (char *interface)
1244 if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX))
1246 if (!strcmp("Linux", interface)) {
1248 printk(KERN_NOTICE PREFIX
1249 "BIOS _OSI(Linux) query %s%s\n",
1250 osi_linux.enable ? "honored" : "ignored",
1251 osi_linux.cmdline ? " via cmdline" :
1252 osi_linux.dmi ? " via DMI" : "");
1254 if (!osi_linux.dmi) {
1255 if (acpi_dmi_dump())
1256 printk(KERN_NOTICE PREFIX
1257 "[please extract dmidecode output]\n");
1258 printk(KERN_NOTICE PREFIX
1259 "Please send DMI info above to "
1260 "linux-acpi@vger.kernel.org\n");
1262 if (!osi_linux.known && !osi_linux.cmdline) {
1263 printk(KERN_NOTICE PREFIX
1264 "If \"acpi_osi=%sLinux\" works better, "
1265 "please notify linux-acpi@vger.kernel.org\n",
1266 osi_linux.enable ? "!" : "");
1269 if (osi_linux.enable)
1275 /******************************************************************************
1277 * FUNCTION: acpi_os_validate_address
1279 * PARAMETERS: space_id - ACPI space ID
1280 * address - Physical address
1281 * length - Address length
1283 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1284 * should return AE_AML_ILLEGAL_ADDRESS.
1286 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1287 * the addresses accessed by AML operation regions.
1289 *****************************************************************************/
1292 acpi_os_validate_address (
1294 acpi_physical_address address,