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 #define OSI_LINUX_ENABLED
81 #ifdef OSI_LINUX_ENABLED
82 int osi_linux
= 1; /* enable _OSI(Linux) by default */
84 int osi_linux
; /* disable _OSI(Linux) by default */
89 static struct __initdata dmi_system_id acpi_osl_dmi_table
[];
92 static void __init
acpi_request_region (struct acpi_generic_address
*addr
,
93 unsigned int length
, char *desc
)
97 if (!addr
->address
|| !length
)
100 if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_IO
)
101 res
= request_region(addr
->address
, length
, desc
);
102 else if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
)
103 res
= request_mem_region(addr
->address
, length
, desc
);
106 static int __init
acpi_reserve_resources(void)
108 acpi_request_region(&acpi_gbl_FADT
.xpm1a_event_block
, acpi_gbl_FADT
.pm1_event_length
,
109 "ACPI PM1a_EVT_BLK");
111 acpi_request_region(&acpi_gbl_FADT
.xpm1b_event_block
, acpi_gbl_FADT
.pm1_event_length
,
112 "ACPI PM1b_EVT_BLK");
114 acpi_request_region(&acpi_gbl_FADT
.xpm1a_control_block
, acpi_gbl_FADT
.pm1_control_length
,
115 "ACPI PM1a_CNT_BLK");
117 acpi_request_region(&acpi_gbl_FADT
.xpm1b_control_block
, acpi_gbl_FADT
.pm1_control_length
,
118 "ACPI PM1b_CNT_BLK");
120 if (acpi_gbl_FADT
.pm_timer_length
== 4)
121 acpi_request_region(&acpi_gbl_FADT
.xpm_timer_block
, 4, "ACPI PM_TMR");
123 acpi_request_region(&acpi_gbl_FADT
.xpm2_control_block
, acpi_gbl_FADT
.pm2_control_length
,
126 /* Length of GPE blocks must be a non-negative multiple of 2 */
128 if (!(acpi_gbl_FADT
.gpe0_block_length
& 0x1))
129 acpi_request_region(&acpi_gbl_FADT
.xgpe0_block
,
130 acpi_gbl_FADT
.gpe0_block_length
, "ACPI GPE0_BLK");
132 if (!(acpi_gbl_FADT
.gpe1_block_length
& 0x1))
133 acpi_request_region(&acpi_gbl_FADT
.xgpe1_block
,
134 acpi_gbl_FADT
.gpe1_block_length
, "ACPI GPE1_BLK");
138 device_initcall(acpi_reserve_resources
);
140 acpi_status __init
acpi_os_initialize(void)
142 dmi_check_system(acpi_osl_dmi_table
);
146 acpi_status
acpi_os_initialize1(void)
149 * Initialize PCI configuration space access, as we'll need to access
150 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
153 printk(KERN_ERR PREFIX
154 "Access to PCI configuration space unavailable\n");
155 return AE_NULL_ENTRY
;
157 kacpid_wq
= create_singlethread_workqueue("kacpid");
158 kacpi_notify_wq
= create_singlethread_workqueue("kacpi_notify");
160 BUG_ON(!kacpi_notify_wq
);
164 acpi_status
acpi_os_terminate(void)
166 if (acpi_irq_handler
) {
167 acpi_os_remove_interrupt_handler(acpi_irq_irq
,
171 destroy_workqueue(kacpid_wq
);
172 destroy_workqueue(kacpi_notify_wq
);
177 void acpi_os_printf(const char *fmt
, ...)
181 acpi_os_vprintf(fmt
, args
);
185 EXPORT_SYMBOL(acpi_os_printf
);
187 void acpi_os_vprintf(const char *fmt
, va_list args
)
189 static char buffer
[512];
191 vsprintf(buffer
, fmt
, args
);
193 #ifdef ENABLE_DEBUGGER
194 if (acpi_in_debugger
) {
195 kdb_printf("%s", buffer
);
197 printk("%s", buffer
);
200 printk("%s", buffer
);
204 acpi_physical_address __init
acpi_os_get_root_pointer(void)
207 if (efi
.acpi20
!= EFI_INVALID_TABLE_ADDR
)
209 else if (efi
.acpi
!= EFI_INVALID_TABLE_ADDR
)
212 printk(KERN_ERR PREFIX
213 "System description tables not found\n");
217 return acpi_find_rsdp();
220 void __iomem
*acpi_os_map_memory(acpi_physical_address phys
, acpi_size size
)
222 if (phys
> ULONG_MAX
) {
223 printk(KERN_ERR PREFIX
"Cannot map memory that high\n");
226 if (acpi_gbl_permanent_mmap
)
228 * ioremap checks to ensure this is in reserved space
230 return ioremap((unsigned long)phys
, size
);
232 return __acpi_map_table((unsigned long)phys
, size
);
234 EXPORT_SYMBOL_GPL(acpi_os_map_memory
);
236 void acpi_os_unmap_memory(void __iomem
* virt
, acpi_size size
)
238 if (acpi_gbl_permanent_mmap
) {
242 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory
);
244 #ifdef ACPI_FUTURE_USAGE
246 acpi_os_get_physical_address(void *virt
, acpi_physical_address
* phys
)
249 return AE_BAD_PARAMETER
;
251 *phys
= virt_to_phys(virt
);
257 #define ACPI_MAX_OVERRIDE_LEN 100
259 static char acpi_os_name
[ACPI_MAX_OVERRIDE_LEN
];
262 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
263 acpi_string
* new_val
)
265 if (!init_val
|| !new_val
)
266 return AE_BAD_PARAMETER
;
269 if (!memcmp(init_val
->name
, "_OS_", 4) && strlen(acpi_os_name
)) {
270 printk(KERN_INFO PREFIX
"Overriding _OS definition to '%s'\n",
272 *new_val
= acpi_os_name
;
279 acpi_os_table_override(struct acpi_table_header
* existing_table
,
280 struct acpi_table_header
** new_table
)
282 if (!existing_table
|| !new_table
)
283 return AE_BAD_PARAMETER
;
285 #ifdef CONFIG_ACPI_CUSTOM_DSDT
286 if (strncmp(existing_table
->signature
, "DSDT", 4) == 0)
287 *new_table
= (struct acpi_table_header
*)AmlCode
;
296 static irqreturn_t
acpi_irq(int irq
, void *dev_id
)
298 return (*acpi_irq_handler
) (acpi_irq_context
) ? IRQ_HANDLED
: IRQ_NONE
;
302 acpi_os_install_interrupt_handler(u32 gsi
, acpi_osd_handler handler
,
308 * Ignore the GSI from the core, and use the value in our copy of the
309 * FADT. It may not be the same if an interrupt source override exists
312 gsi
= acpi_gbl_FADT
.sci_interrupt
;
313 if (acpi_gsi_to_irq(gsi
, &irq
) < 0) {
314 printk(KERN_ERR PREFIX
"SCI (ACPI GSI %d) not registered\n",
319 acpi_irq_handler
= handler
;
320 acpi_irq_context
= context
;
321 if (request_irq(irq
, acpi_irq
, IRQF_SHARED
, "acpi", acpi_irq
)) {
322 printk(KERN_ERR PREFIX
"SCI (IRQ%d) allocation failed\n", irq
);
323 return AE_NOT_ACQUIRED
;
330 acpi_status
acpi_os_remove_interrupt_handler(u32 irq
, acpi_osd_handler handler
)
333 free_irq(irq
, acpi_irq
);
334 acpi_irq_handler
= NULL
;
342 * Running in interpreter thread context, safe to sleep
345 void acpi_os_sleep(acpi_integer ms
)
347 schedule_timeout_interruptible(msecs_to_jiffies(ms
));
350 EXPORT_SYMBOL(acpi_os_sleep
);
352 void acpi_os_stall(u32 us
)
360 touch_nmi_watchdog();
365 EXPORT_SYMBOL(acpi_os_stall
);
368 * Support ACPI 3.0 AML Timer operand
369 * Returns 64-bit free-running, monotonically increasing timer
370 * with 100ns granularity
372 u64
acpi_os_get_timer(void)
377 /* TBD: use HPET if available */
380 #ifdef CONFIG_X86_PM_TIMER
381 /* TBD: default to PM timer if HPET was not available */
384 printk(KERN_ERR PREFIX
"acpi_os_get_timer() TBD\n");
389 acpi_status
acpi_os_read_port(acpi_io_address port
, u32
* value
, u32 width
)
398 *(u8
*) value
= inb(port
);
401 *(u16
*) value
= inw(port
);
404 *(u32
*) value
= inl(port
);
413 EXPORT_SYMBOL(acpi_os_read_port
);
415 acpi_status
acpi_os_write_port(acpi_io_address port
, u32 value
, u32 width
)
434 EXPORT_SYMBOL(acpi_os_write_port
);
437 acpi_os_read_memory(acpi_physical_address phys_addr
, u32
* value
, u32 width
)
440 void __iomem
*virt_addr
;
442 virt_addr
= ioremap(phys_addr
, width
);
448 *(u8
*) value
= readb(virt_addr
);
451 *(u16
*) value
= readw(virt_addr
);
454 *(u32
*) value
= readl(virt_addr
);
466 acpi_os_write_memory(acpi_physical_address phys_addr
, u32 value
, u32 width
)
468 void __iomem
*virt_addr
;
470 virt_addr
= ioremap(phys_addr
, width
);
474 writeb(value
, virt_addr
);
477 writew(value
, virt_addr
);
480 writel(value
, virt_addr
);
492 acpi_os_read_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
493 void *value
, u32 width
)
498 return AE_BAD_PARAMETER
;
514 BUG_ON(!raw_pci_ops
);
516 result
= raw_pci_ops
->read(pci_id
->segment
, pci_id
->bus
,
517 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
520 return (result
? AE_ERROR
: AE_OK
);
523 EXPORT_SYMBOL(acpi_os_read_pci_configuration
);
526 acpi_os_write_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
527 acpi_integer value
, u32 width
)
545 BUG_ON(!raw_pci_ops
);
547 result
= raw_pci_ops
->write(pci_id
->segment
, pci_id
->bus
,
548 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
551 return (result
? AE_ERROR
: AE_OK
);
554 /* TODO: Change code to take advantage of driver model more */
555 static void acpi_os_derive_pci_id_2(acpi_handle rhandle
, /* upper bound */
556 acpi_handle chandle
, /* current node */
557 struct acpi_pci_id
**id
,
558 int *is_bridge
, u8
* bus_number
)
561 struct acpi_pci_id
*pci_id
= *id
;
564 acpi_object_type type
;
567 acpi_get_parent(chandle
, &handle
);
568 if (handle
!= rhandle
) {
569 acpi_os_derive_pci_id_2(rhandle
, handle
, &pci_id
, is_bridge
,
572 status
= acpi_get_type(handle
, &type
);
573 if ((ACPI_FAILURE(status
)) || (type
!= ACPI_TYPE_DEVICE
))
577 acpi_evaluate_integer(handle
, METHOD_NAME__ADR
, NULL
,
579 if (ACPI_SUCCESS(status
)) {
580 pci_id
->device
= ACPI_HIWORD(ACPI_LODWORD(temp
));
581 pci_id
->function
= ACPI_LOWORD(ACPI_LODWORD(temp
));
584 pci_id
->bus
= *bus_number
;
586 /* any nicer way to get bus number of bridge ? */
588 acpi_os_read_pci_configuration(pci_id
, 0x0e, &tu8
,
590 if (ACPI_SUCCESS(status
)
591 && ((tu8
& 0x7f) == 1 || (tu8
& 0x7f) == 2)) {
593 acpi_os_read_pci_configuration(pci_id
, 0x18,
595 if (!ACPI_SUCCESS(status
)) {
596 /* Certainly broken... FIX ME */
602 acpi_os_read_pci_configuration(pci_id
, 0x19,
604 if (ACPI_SUCCESS(status
)) {
613 void acpi_os_derive_pci_id(acpi_handle rhandle
, /* upper bound */
614 acpi_handle chandle
, /* current node */
615 struct acpi_pci_id
**id
)
618 u8 bus_number
= (*id
)->bus
;
620 acpi_os_derive_pci_id_2(rhandle
, chandle
, id
, &is_bridge
, &bus_number
);
623 static void acpi_os_execute_deferred(struct work_struct
*work
)
625 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
);
634 /* Yield cpu to notify thread */
640 static void acpi_os_execute_notify(struct work_struct
*work
)
642 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
645 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
649 dpc
->function(dpc
->context
);
656 /*******************************************************************************
658 * FUNCTION: acpi_os_execute
660 * PARAMETERS: Type - Type of the callback
661 * Function - Function to be executed
662 * Context - Function parameters
666 * DESCRIPTION: Depending on type, either queues function for deferred execution or
667 * immediately executes function on a separate thread.
669 ******************************************************************************/
671 acpi_status
acpi_os_execute(acpi_execute_type type
,
672 acpi_osd_exec_callback function
, void *context
)
674 acpi_status status
= AE_OK
;
675 struct acpi_os_dpc
*dpc
;
677 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
678 "Scheduling function [%p(%p)] for deferred execution.\n",
682 return AE_BAD_PARAMETER
;
685 * Allocate/initialize DPC structure. Note that this memory will be
686 * freed by the callee. The kernel handles the work_struct list in a
687 * way that allows us to also free its memory inside the callee.
688 * Because we may want to schedule several tasks with different
689 * parameters we can't use the approach some kernel code uses of
690 * having a static work_struct.
693 dpc
= kmalloc(sizeof(struct acpi_os_dpc
), GFP_ATOMIC
);
695 return_ACPI_STATUS(AE_NO_MEMORY
);
697 dpc
->function
= function
;
698 dpc
->context
= context
;
700 if (type
== OSL_NOTIFY_HANDLER
) {
701 INIT_WORK(&dpc
->work
, acpi_os_execute_notify
);
702 if (!queue_work(kacpi_notify_wq
, &dpc
->work
)) {
707 INIT_WORK(&dpc
->work
, acpi_os_execute_deferred
);
708 if (!queue_work(kacpid_wq
, &dpc
->work
)) {
709 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
710 "Call to queue_work() failed.\n"));
715 return_ACPI_STATUS(status
);
718 EXPORT_SYMBOL(acpi_os_execute
);
720 void acpi_os_wait_events_complete(void *context
)
722 flush_workqueue(kacpid_wq
);
725 EXPORT_SYMBOL(acpi_os_wait_events_complete
);
728 * Allocate the memory for a spinlock and initialize it.
730 acpi_status
acpi_os_create_lock(acpi_spinlock
* handle
)
732 spin_lock_init(*handle
);
738 * Deallocate the memory for a spinlock.
740 void acpi_os_delete_lock(acpi_spinlock handle
)
746 acpi_os_create_semaphore(u32 max_units
, u32 initial_units
, acpi_handle
* handle
)
748 struct semaphore
*sem
= NULL
;
751 sem
= acpi_os_allocate(sizeof(struct semaphore
));
754 memset(sem
, 0, sizeof(struct semaphore
));
756 sema_init(sem
, initial_units
);
758 *handle
= (acpi_handle
*) sem
;
760 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating semaphore[%p|%d].\n",
761 *handle
, initial_units
));
766 EXPORT_SYMBOL(acpi_os_create_semaphore
);
769 * TODO: A better way to delete semaphores? Linux doesn't have a
770 * 'delete_semaphore()' function -- may result in an invalid
771 * pointer dereference for non-synchronized consumers. Should
772 * we at least check for blocked threads and signal/cancel them?
775 acpi_status
acpi_os_delete_semaphore(acpi_handle handle
)
777 struct semaphore
*sem
= (struct semaphore
*)handle
;
781 return AE_BAD_PARAMETER
;
783 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting semaphore[%p].\n", handle
));
791 EXPORT_SYMBOL(acpi_os_delete_semaphore
);
794 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
795 * improvise. The process is to sleep for one scheduler quantum
796 * until the semaphore becomes available. Downside is that this
797 * may result in starvation for timeout-based waits when there's
798 * lots of semaphore activity.
800 * TODO: Support for units > 1?
802 acpi_status
acpi_os_wait_semaphore(acpi_handle handle
, u32 units
, u16 timeout
)
804 acpi_status status
= AE_OK
;
805 struct semaphore
*sem
= (struct semaphore
*)handle
;
809 if (!sem
|| (units
< 1))
810 return AE_BAD_PARAMETER
;
815 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Waiting for semaphore[%p|%d|%d]\n",
816 handle
, units
, timeout
));
819 * This can be called during resume with interrupts off.
820 * Like boot-time, we should be single threaded and will
821 * always get the lock if we try -- timeout or not.
822 * If this doesn't succeed, then we will oops courtesy of
823 * might_sleep() in down().
825 if (!down_trylock(sem
))
832 * A zero timeout value indicates that we shouldn't wait - just
833 * acquire the semaphore if available otherwise return AE_TIME
834 * (a.k.a. 'would block').
837 if (down_trylock(sem
))
845 case ACPI_WAIT_FOREVER
:
854 // TODO: A better timeout algorithm?
857 static const int quantum_ms
= 1000 / HZ
;
859 ret
= down_trylock(sem
);
860 for (i
= timeout
; (i
> 0 && ret
!= 0); i
-= quantum_ms
) {
861 schedule_timeout_interruptible(1);
862 ret
= down_trylock(sem
);
871 if (ACPI_FAILURE(status
)) {
872 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
873 "Failed to acquire semaphore[%p|%d|%d], %s",
874 handle
, units
, timeout
,
875 acpi_format_exception(status
)));
877 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
878 "Acquired semaphore[%p|%d|%d]", handle
,
885 EXPORT_SYMBOL(acpi_os_wait_semaphore
);
888 * TODO: Support for units > 1?
890 acpi_status
acpi_os_signal_semaphore(acpi_handle handle
, u32 units
)
892 struct semaphore
*sem
= (struct semaphore
*)handle
;
895 if (!sem
|| (units
< 1))
896 return AE_BAD_PARAMETER
;
901 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Signaling semaphore[%p|%d]\n", handle
,
909 EXPORT_SYMBOL(acpi_os_signal_semaphore
);
911 #ifdef ACPI_FUTURE_USAGE
912 u32
acpi_os_get_line(char *buffer
)
915 #ifdef ENABLE_DEBUGGER
916 if (acpi_in_debugger
) {
919 kdb_read(buffer
, sizeof(line_buf
));
921 /* remove the CR kdb includes */
922 chars
= strlen(buffer
) - 1;
923 buffer
[chars
] = '\0';
929 #endif /* ACPI_FUTURE_USAGE */
931 acpi_status
acpi_os_signal(u32 function
, void *info
)
934 case ACPI_SIGNAL_FATAL
:
935 printk(KERN_ERR PREFIX
"Fatal opcode executed\n");
937 case ACPI_SIGNAL_BREAKPOINT
:
940 * ACPI spec. says to treat it as a NOP unless
941 * you are debugging. So if/when we integrate
942 * AML debugger into the kernel debugger its
943 * hook will go here. But until then it is
944 * not useful to print anything on breakpoints.
954 EXPORT_SYMBOL(acpi_os_signal
);
956 static int __init
acpi_os_name_setup(char *str
)
958 char *p
= acpi_os_name
;
959 int count
= ACPI_MAX_OVERRIDE_LEN
- 1;
964 for (; count
-- && str
&& *str
; str
++) {
965 if (isalnum(*str
) || *str
== ' ' || *str
== ':')
967 else if (*str
== '\'' || *str
== '"')
978 __setup("acpi_os_name=", acpi_os_name_setup
);
980 static void enable_osi_linux(int enable
) {
982 if (osi_linux
!= enable
)
983 printk(KERN_INFO PREFIX
"%sabled _OSI(Linux)\n",
984 enable
? "En": "Dis");
991 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
993 * empty string disables _OSI
994 * string starting with '!' disables that string
995 * otherwise string is added to list, augmenting built-in strings
997 static int __init
acpi_osi_setup(char *str
)
999 if (str
== NULL
|| *str
== '\0') {
1000 printk(KERN_INFO PREFIX
"_OSI method disabled\n");
1001 acpi_gbl_create_osi_method
= FALSE
;
1002 } else if (*str
== '!') {
1003 if (acpi_osi_invalidate(++str
) == AE_OK
)
1004 printk(KERN_INFO PREFIX
"Deleted _OSI(%s)\n", str
);
1005 } else if (!strcmp("!Linux", str
)) {
1006 enable_osi_linux(0);
1007 } else if (!strcmp("Linux", str
)) {
1008 enable_osi_linux(1);
1009 } else if (*osi_additional_string
== '\0') {
1010 strncpy(osi_additional_string
, str
, OSI_STRING_LENGTH_MAX
);
1011 printk(KERN_INFO PREFIX
"Added _OSI(%s)\n", str
);
1017 __setup("acpi_osi=", acpi_osi_setup
);
1019 /* enable serialization to combat AE_ALREADY_EXISTS errors */
1020 static int __init
acpi_serialize_setup(char *str
)
1022 printk(KERN_INFO PREFIX
"serialize enabled\n");
1024 acpi_gbl_all_methods_serialized
= TRUE
;
1029 __setup("acpi_serialize", acpi_serialize_setup
);
1032 * Wake and Run-Time GPES are expected to be separate.
1033 * We disable wake-GPEs at run-time to prevent spurious
1036 * However, if a system exists that shares Wake and
1037 * Run-time events on the same GPE this flag is available
1038 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1040 static int __init
acpi_wake_gpes_always_on_setup(char *str
)
1042 printk(KERN_INFO PREFIX
"wake GPEs not disabled\n");
1044 acpi_gbl_leave_wake_gpes_disabled
= FALSE
;
1049 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup
);
1052 * max_cstate is defined in the base kernel so modules can
1053 * change it w/o depending on the state of the processor module.
1055 unsigned int max_cstate
= ACPI_PROCESSOR_MAX_POWER
;
1057 EXPORT_SYMBOL(max_cstate
);
1060 * Acquire a spinlock.
1062 * handle is a pointer to the spinlock_t.
1065 acpi_cpu_flags
acpi_os_acquire_lock(acpi_spinlock lockp
)
1067 acpi_cpu_flags flags
;
1068 spin_lock_irqsave(lockp
, flags
);
1073 * Release a spinlock. See above.
1076 void acpi_os_release_lock(acpi_spinlock lockp
, acpi_cpu_flags flags
)
1078 spin_unlock_irqrestore(lockp
, flags
);
1081 #ifndef ACPI_USE_LOCAL_CACHE
1083 /*******************************************************************************
1085 * FUNCTION: acpi_os_create_cache
1087 * PARAMETERS: name - Ascii name for the cache
1088 * size - Size of each cached object
1089 * depth - Maximum depth of the cache (in objects) <ignored>
1090 * cache - Where the new cache object is returned
1094 * DESCRIPTION: Create a cache object
1096 ******************************************************************************/
1099 acpi_os_create_cache(char *name
, u16 size
, u16 depth
, acpi_cache_t
** cache
)
1101 *cache
= kmem_cache_create(name
, size
, 0, 0, NULL
, NULL
);
1108 /*******************************************************************************
1110 * FUNCTION: acpi_os_purge_cache
1112 * PARAMETERS: Cache - Handle to cache object
1116 * DESCRIPTION: Free all objects within the requested cache.
1118 ******************************************************************************/
1120 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
)
1122 kmem_cache_shrink(cache
);
1126 /*******************************************************************************
1128 * FUNCTION: acpi_os_delete_cache
1130 * PARAMETERS: Cache - Handle to cache object
1134 * DESCRIPTION: Free all objects within the requested cache and delete the
1137 ******************************************************************************/
1139 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
)
1141 kmem_cache_destroy(cache
);
1145 /*******************************************************************************
1147 * FUNCTION: acpi_os_release_object
1149 * PARAMETERS: Cache - Handle to cache object
1150 * Object - The object to be released
1154 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1155 * the object is deleted.
1157 ******************************************************************************/
1159 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
)
1161 kmem_cache_free(cache
, object
);
1165 /******************************************************************************
1167 * FUNCTION: acpi_os_validate_interface
1169 * PARAMETERS: interface - Requested interface to be validated
1171 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1173 * DESCRIPTION: Match an interface string to the interfaces supported by the
1174 * host. Strings originate from an AML call to the _OSI method.
1176 *****************************************************************************/
1179 acpi_os_validate_interface (char *interface
)
1181 if (!strncmp(osi_additional_string
, interface
, OSI_STRING_LENGTH_MAX
))
1183 if (!strcmp("Linux", interface
)) {
1184 printk(KERN_WARNING PREFIX
1185 "System BIOS is requesting _OSI(Linux)\n");
1186 #ifdef OSI_LINUX_ENABLED
1187 printk(KERN_WARNING PREFIX
1188 "Please test with \"acpi_osi=!Linux\"\n"
1189 "Please send dmidecode "
1190 "to linux-acpi@vger.kernel.org\n");
1192 printk(KERN_WARNING PREFIX
1193 "If \"acpi_osi=Linux\" works better,\n"
1194 "Please send dmidecode "
1195 "to linux-acpi@vger.kernel.org\n");
1203 /******************************************************************************
1205 * FUNCTION: acpi_os_validate_address
1207 * PARAMETERS: space_id - ACPI space ID
1208 * address - Physical address
1209 * length - Address length
1211 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1212 * should return AE_AML_ILLEGAL_ADDRESS.
1214 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1215 * the addresses accessed by AML operation regions.
1217 *****************************************************************************/
1220 acpi_os_validate_address (
1222 acpi_physical_address address
,
1230 #ifdef OSI_LINUX_ENABLED
1231 static int dmi_osi_not_linux(struct dmi_system_id
*d
)
1233 printk(KERN_NOTICE
"%s detected: requires not _OSI(Linux)\n", d
->ident
);
1234 enable_osi_linux(0);
1238 static int dmi_osi_linux(struct dmi_system_id
*d
)
1240 printk(KERN_NOTICE
"%s detected: requires _OSI(Linux)\n", d
->ident
);
1241 enable_osi_linux(1);
1246 static struct dmi_system_id acpi_osl_dmi_table
[] __initdata
= {
1247 #ifdef OSI_LINUX_ENABLED
1249 * Boxes that need NOT _OSI(Linux)
1252 .callback
= dmi_osi_not_linux
,
1253 .ident
= "Toshiba Satellite P100",
1255 DMI_MATCH(DMI_BOARD_VENDOR
, "TOSHIBA"),
1256 DMI_MATCH(DMI_BOARD_NAME
, "Satellite P100"),
1261 * Boxes that need _OSI(Linux)
1264 .callback
= dmi_osi_linux
,
1265 .ident
= "Intel Napa CRB",
1267 DMI_MATCH(DMI_BOARD_VENDOR
, "Intel Corporation"),
1268 DMI_MATCH(DMI_BOARD_NAME
, "MPAD-MSAE Customer Reference Boards"),
1274 #endif /* CONFIG_DMI */