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/workqueue.h>
37 #include <linux/nmi.h>
38 #include <linux/acpi.h>
39 #include <acpi/acpi.h>
41 #include <acpi/acpi_bus.h>
42 #include <acpi/processor.h>
43 #include <asm/uaccess.h>
45 #include <linux/efi.h>
47 #define _COMPONENT ACPI_OS_SERVICES
48 ACPI_MODULE_NAME("osl");
49 #define PREFIX "ACPI: "
51 acpi_osd_exec_callback function
;
53 struct work_struct work
;
56 #ifdef CONFIG_ACPI_CUSTOM_DSDT
57 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
60 #ifdef ENABLE_DEBUGGER
61 #include <linux/kdb.h>
63 /* stuff for debugger support */
65 EXPORT_SYMBOL(acpi_in_debugger
);
67 extern char line_buf
[80];
68 #endif /*ENABLE_DEBUGGER */
70 static unsigned int acpi_irq_irq
;
71 static acpi_osd_handler acpi_irq_handler
;
72 static void *acpi_irq_context
;
73 static struct workqueue_struct
*kacpid_wq
;
74 static struct workqueue_struct
*kacpi_notify_wq
;
76 #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
77 static char osi_additional_string
[OSI_STRING_LENGTH_MAX
];
79 static void __init
acpi_request_region (struct acpi_generic_address
*addr
,
80 unsigned int length
, char *desc
)
84 if (!addr
->address
|| !length
)
87 if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_IO
)
88 res
= request_region(addr
->address
, length
, desc
);
89 else if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
)
90 res
= request_mem_region(addr
->address
, length
, desc
);
93 static int __init
acpi_reserve_resources(void)
95 acpi_request_region(&acpi_gbl_FADT
.xpm1a_event_block
, acpi_gbl_FADT
.pm1_event_length
,
98 acpi_request_region(&acpi_gbl_FADT
.xpm1b_event_block
, acpi_gbl_FADT
.pm1_event_length
,
101 acpi_request_region(&acpi_gbl_FADT
.xpm1a_control_block
, acpi_gbl_FADT
.pm1_control_length
,
102 "ACPI PM1a_CNT_BLK");
104 acpi_request_region(&acpi_gbl_FADT
.xpm1b_control_block
, acpi_gbl_FADT
.pm1_control_length
,
105 "ACPI PM1b_CNT_BLK");
107 if (acpi_gbl_FADT
.pm_timer_length
== 4)
108 acpi_request_region(&acpi_gbl_FADT
.xpm_timer_block
, 4, "ACPI PM_TMR");
110 acpi_request_region(&acpi_gbl_FADT
.xpm2_control_block
, acpi_gbl_FADT
.pm2_control_length
,
113 /* Length of GPE blocks must be a non-negative multiple of 2 */
115 if (!(acpi_gbl_FADT
.gpe0_block_length
& 0x1))
116 acpi_request_region(&acpi_gbl_FADT
.xgpe0_block
,
117 acpi_gbl_FADT
.gpe0_block_length
, "ACPI GPE0_BLK");
119 if (!(acpi_gbl_FADT
.gpe1_block_length
& 0x1))
120 acpi_request_region(&acpi_gbl_FADT
.xgpe1_block
,
121 acpi_gbl_FADT
.gpe1_block_length
, "ACPI GPE1_BLK");
125 device_initcall(acpi_reserve_resources
);
127 acpi_status
acpi_os_initialize(void)
132 acpi_status
acpi_os_initialize1(void)
135 * Initialize PCI configuration space access, as we'll need to access
136 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
139 printk(KERN_ERR PREFIX
140 "Access to PCI configuration space unavailable\n");
141 return AE_NULL_ENTRY
;
143 kacpid_wq
= create_singlethread_workqueue("kacpid");
144 kacpi_notify_wq
= create_singlethread_workqueue("kacpi_notify");
146 BUG_ON(!kacpi_notify_wq
);
150 acpi_status
acpi_os_terminate(void)
152 if (acpi_irq_handler
) {
153 acpi_os_remove_interrupt_handler(acpi_irq_irq
,
157 destroy_workqueue(kacpid_wq
);
158 destroy_workqueue(kacpi_notify_wq
);
163 void acpi_os_printf(const char *fmt
, ...)
167 acpi_os_vprintf(fmt
, args
);
171 EXPORT_SYMBOL(acpi_os_printf
);
173 void acpi_os_vprintf(const char *fmt
, va_list args
)
175 static char buffer
[512];
177 vsprintf(buffer
, fmt
, args
);
179 #ifdef ENABLE_DEBUGGER
180 if (acpi_in_debugger
) {
181 kdb_printf("%s", buffer
);
183 printk("%s", buffer
);
186 printk("%s", buffer
);
190 acpi_physical_address __init
acpi_os_get_root_pointer(void)
193 if (efi
.acpi20
!= EFI_INVALID_TABLE_ADDR
)
195 else if (efi
.acpi
!= EFI_INVALID_TABLE_ADDR
)
198 printk(KERN_ERR PREFIX
199 "System description tables not found\n");
203 return acpi_find_rsdp();
206 void __iomem
*acpi_os_map_memory(acpi_physical_address phys
, acpi_size size
)
208 if (phys
> ULONG_MAX
) {
209 printk(KERN_ERR PREFIX
"Cannot map memory that high\n");
212 if (acpi_gbl_permanent_mmap
)
214 * ioremap checks to ensure this is in reserved space
216 return ioremap((unsigned long)phys
, size
);
218 return __acpi_map_table((unsigned long)phys
, size
);
220 EXPORT_SYMBOL_GPL(acpi_os_map_memory
);
222 void acpi_os_unmap_memory(void __iomem
* virt
, acpi_size size
)
224 if (acpi_gbl_permanent_mmap
) {
228 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory
);
230 #ifdef ACPI_FUTURE_USAGE
232 acpi_os_get_physical_address(void *virt
, acpi_physical_address
* phys
)
235 return AE_BAD_PARAMETER
;
237 *phys
= virt_to_phys(virt
);
243 #define ACPI_MAX_OVERRIDE_LEN 100
245 static char acpi_os_name
[ACPI_MAX_OVERRIDE_LEN
];
248 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
249 acpi_string
* new_val
)
251 if (!init_val
|| !new_val
)
252 return AE_BAD_PARAMETER
;
255 if (!memcmp(init_val
->name
, "_OS_", 4) && strlen(acpi_os_name
)) {
256 printk(KERN_INFO PREFIX
"Overriding _OS definition to '%s'\n",
258 *new_val
= acpi_os_name
;
265 acpi_os_table_override(struct acpi_table_header
* existing_table
,
266 struct acpi_table_header
** new_table
)
268 if (!existing_table
|| !new_table
)
269 return AE_BAD_PARAMETER
;
271 #ifdef CONFIG_ACPI_CUSTOM_DSDT
272 if (strncmp(existing_table
->signature
, "DSDT", 4) == 0)
273 *new_table
= (struct acpi_table_header
*)AmlCode
;
282 static irqreturn_t
acpi_irq(int irq
, void *dev_id
)
284 return (*acpi_irq_handler
) (acpi_irq_context
) ? IRQ_HANDLED
: IRQ_NONE
;
288 acpi_os_install_interrupt_handler(u32 gsi
, acpi_osd_handler handler
,
294 * Ignore the GSI from the core, and use the value in our copy of the
295 * FADT. It may not be the same if an interrupt source override exists
298 gsi
= acpi_gbl_FADT
.sci_interrupt
;
299 if (acpi_gsi_to_irq(gsi
, &irq
) < 0) {
300 printk(KERN_ERR PREFIX
"SCI (ACPI GSI %d) not registered\n",
305 acpi_irq_handler
= handler
;
306 acpi_irq_context
= context
;
307 if (request_irq(irq
, acpi_irq
, IRQF_SHARED
, "acpi", acpi_irq
)) {
308 printk(KERN_ERR PREFIX
"SCI (IRQ%d) allocation failed\n", irq
);
309 return AE_NOT_ACQUIRED
;
316 acpi_status
acpi_os_remove_interrupt_handler(u32 irq
, acpi_osd_handler handler
)
319 free_irq(irq
, acpi_irq
);
320 acpi_irq_handler
= NULL
;
328 * Running in interpreter thread context, safe to sleep
331 void acpi_os_sleep(acpi_integer ms
)
333 schedule_timeout_interruptible(msecs_to_jiffies(ms
));
336 EXPORT_SYMBOL(acpi_os_sleep
);
338 void acpi_os_stall(u32 us
)
346 touch_nmi_watchdog();
351 EXPORT_SYMBOL(acpi_os_stall
);
354 * Support ACPI 3.0 AML Timer operand
355 * Returns 64-bit free-running, monotonically increasing timer
356 * with 100ns granularity
358 u64
acpi_os_get_timer(void)
363 /* TBD: use HPET if available */
366 #ifdef CONFIG_X86_PM_TIMER
367 /* TBD: default to PM timer if HPET was not available */
370 printk(KERN_ERR PREFIX
"acpi_os_get_timer() TBD\n");
375 acpi_status
acpi_os_read_port(acpi_io_address port
, u32
* value
, u32 width
)
384 *(u8
*) value
= inb(port
);
387 *(u16
*) value
= inw(port
);
390 *(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
)
420 EXPORT_SYMBOL(acpi_os_write_port
);
423 acpi_os_read_memory(acpi_physical_address phys_addr
, u32
* value
, u32 width
)
426 void __iomem
*virt_addr
;
428 virt_addr
= ioremap(phys_addr
, width
);
434 *(u8
*) value
= readb(virt_addr
);
437 *(u16
*) value
= readw(virt_addr
);
440 *(u32
*) value
= readl(virt_addr
);
452 acpi_os_write_memory(acpi_physical_address phys_addr
, u32 value
, u32 width
)
454 void __iomem
*virt_addr
;
456 virt_addr
= ioremap(phys_addr
, width
);
460 writeb(value
, virt_addr
);
463 writew(value
, virt_addr
);
466 writel(value
, virt_addr
);
478 acpi_os_read_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
479 void *value
, u32 width
)
484 return AE_BAD_PARAMETER
;
500 BUG_ON(!raw_pci_ops
);
502 result
= raw_pci_ops
->read(pci_id
->segment
, pci_id
->bus
,
503 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
506 return (result
? AE_ERROR
: AE_OK
);
509 EXPORT_SYMBOL(acpi_os_read_pci_configuration
);
512 acpi_os_write_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
513 acpi_integer value
, u32 width
)
531 BUG_ON(!raw_pci_ops
);
533 result
= raw_pci_ops
->write(pci_id
->segment
, pci_id
->bus
,
534 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
537 return (result
? AE_ERROR
: AE_OK
);
540 /* TODO: Change code to take advantage of driver model more */
541 static void acpi_os_derive_pci_id_2(acpi_handle rhandle
, /* upper bound */
542 acpi_handle chandle
, /* current node */
543 struct acpi_pci_id
**id
,
544 int *is_bridge
, u8
* bus_number
)
547 struct acpi_pci_id
*pci_id
= *id
;
550 acpi_object_type type
;
553 acpi_get_parent(chandle
, &handle
);
554 if (handle
!= rhandle
) {
555 acpi_os_derive_pci_id_2(rhandle
, handle
, &pci_id
, is_bridge
,
558 status
= acpi_get_type(handle
, &type
);
559 if ((ACPI_FAILURE(status
)) || (type
!= ACPI_TYPE_DEVICE
))
563 acpi_evaluate_integer(handle
, METHOD_NAME__ADR
, NULL
,
565 if (ACPI_SUCCESS(status
)) {
566 pci_id
->device
= ACPI_HIWORD(ACPI_LODWORD(temp
));
567 pci_id
->function
= ACPI_LOWORD(ACPI_LODWORD(temp
));
570 pci_id
->bus
= *bus_number
;
572 /* any nicer way to get bus number of bridge ? */
574 acpi_os_read_pci_configuration(pci_id
, 0x0e, &tu8
,
576 if (ACPI_SUCCESS(status
)
577 && ((tu8
& 0x7f) == 1 || (tu8
& 0x7f) == 2)) {
579 acpi_os_read_pci_configuration(pci_id
, 0x18,
581 if (!ACPI_SUCCESS(status
)) {
582 /* Certainly broken... FIX ME */
588 acpi_os_read_pci_configuration(pci_id
, 0x19,
590 if (ACPI_SUCCESS(status
)) {
599 void acpi_os_derive_pci_id(acpi_handle rhandle
, /* upper bound */
600 acpi_handle chandle
, /* current node */
601 struct acpi_pci_id
**id
)
604 u8 bus_number
= (*id
)->bus
;
606 acpi_os_derive_pci_id_2(rhandle
, chandle
, id
, &is_bridge
, &bus_number
);
609 static void acpi_os_execute_deferred(struct work_struct
*work
)
611 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
613 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
617 dpc
->function(dpc
->context
);
620 /* Yield cpu to notify thread */
626 static void acpi_os_execute_notify(struct work_struct
*work
)
628 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
631 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
635 dpc
->function(dpc
->context
);
642 /*******************************************************************************
644 * FUNCTION: acpi_os_execute
646 * PARAMETERS: Type - Type of the callback
647 * Function - Function to be executed
648 * Context - Function parameters
652 * DESCRIPTION: Depending on type, either queues function for deferred execution or
653 * immediately executes function on a separate thread.
655 ******************************************************************************/
657 acpi_status
acpi_os_execute(acpi_execute_type type
,
658 acpi_osd_exec_callback function
, void *context
)
660 acpi_status status
= AE_OK
;
661 struct acpi_os_dpc
*dpc
;
663 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
664 "Scheduling function [%p(%p)] for deferred execution.\n",
668 return AE_BAD_PARAMETER
;
671 * Allocate/initialize DPC structure. Note that this memory will be
672 * freed by the callee. The kernel handles the work_struct list in a
673 * way that allows us to also free its memory inside the callee.
674 * Because we may want to schedule several tasks with different
675 * parameters we can't use the approach some kernel code uses of
676 * having a static work_struct.
679 dpc
= kmalloc(sizeof(struct acpi_os_dpc
), GFP_ATOMIC
);
681 return_ACPI_STATUS(AE_NO_MEMORY
);
683 dpc
->function
= function
;
684 dpc
->context
= context
;
686 if (type
== OSL_NOTIFY_HANDLER
) {
687 INIT_WORK(&dpc
->work
, acpi_os_execute_notify
);
688 if (!queue_work(kacpi_notify_wq
, &dpc
->work
)) {
693 INIT_WORK(&dpc
->work
, acpi_os_execute_deferred
);
694 if (!queue_work(kacpid_wq
, &dpc
->work
)) {
695 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
696 "Call to queue_work() failed.\n"));
701 return_ACPI_STATUS(status
);
704 EXPORT_SYMBOL(acpi_os_execute
);
706 void acpi_os_wait_events_complete(void *context
)
708 flush_workqueue(kacpid_wq
);
711 EXPORT_SYMBOL(acpi_os_wait_events_complete
);
714 * Allocate the memory for a spinlock and initialize it.
716 acpi_status
acpi_os_create_lock(acpi_spinlock
* handle
)
718 spin_lock_init(*handle
);
724 * Deallocate the memory for a spinlock.
726 void acpi_os_delete_lock(acpi_spinlock handle
)
732 acpi_os_create_semaphore(u32 max_units
, u32 initial_units
, acpi_handle
* handle
)
734 struct semaphore
*sem
= NULL
;
737 sem
= acpi_os_allocate(sizeof(struct semaphore
));
740 memset(sem
, 0, sizeof(struct semaphore
));
742 sema_init(sem
, initial_units
);
744 *handle
= (acpi_handle
*) sem
;
746 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating semaphore[%p|%d].\n",
747 *handle
, initial_units
));
752 EXPORT_SYMBOL(acpi_os_create_semaphore
);
755 * TODO: A better way to delete semaphores? Linux doesn't have a
756 * 'delete_semaphore()' function -- may result in an invalid
757 * pointer dereference for non-synchronized consumers. Should
758 * we at least check for blocked threads and signal/cancel them?
761 acpi_status
acpi_os_delete_semaphore(acpi_handle handle
)
763 struct semaphore
*sem
= (struct semaphore
*)handle
;
767 return AE_BAD_PARAMETER
;
769 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting semaphore[%p].\n", handle
));
777 EXPORT_SYMBOL(acpi_os_delete_semaphore
);
780 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
781 * improvise. The process is to sleep for one scheduler quantum
782 * until the semaphore becomes available. Downside is that this
783 * may result in starvation for timeout-based waits when there's
784 * lots of semaphore activity.
786 * TODO: Support for units > 1?
788 acpi_status
acpi_os_wait_semaphore(acpi_handle handle
, u32 units
, u16 timeout
)
790 acpi_status status
= AE_OK
;
791 struct semaphore
*sem
= (struct semaphore
*)handle
;
795 if (!sem
|| (units
< 1))
796 return AE_BAD_PARAMETER
;
801 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Waiting for semaphore[%p|%d|%d]\n",
802 handle
, units
, timeout
));
805 * This can be called during resume with interrupts off.
806 * Like boot-time, we should be single threaded and will
807 * always get the lock if we try -- timeout or not.
808 * If this doesn't succeed, then we will oops courtesy of
809 * might_sleep() in down().
811 if (!down_trylock(sem
))
818 * A zero timeout value indicates that we shouldn't wait - just
819 * acquire the semaphore if available otherwise return AE_TIME
820 * (a.k.a. 'would block').
823 if (down_trylock(sem
))
831 case ACPI_WAIT_FOREVER
:
840 // TODO: A better timeout algorithm?
843 static const int quantum_ms
= 1000 / HZ
;
845 ret
= down_trylock(sem
);
846 for (i
= timeout
; (i
> 0 && ret
!= 0); i
-= quantum_ms
) {
847 schedule_timeout_interruptible(1);
848 ret
= down_trylock(sem
);
857 if (ACPI_FAILURE(status
)) {
858 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
859 "Failed to acquire semaphore[%p|%d|%d], %s",
860 handle
, units
, timeout
,
861 acpi_format_exception(status
)));
863 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
864 "Acquired semaphore[%p|%d|%d]", handle
,
871 EXPORT_SYMBOL(acpi_os_wait_semaphore
);
874 * TODO: Support for units > 1?
876 acpi_status
acpi_os_signal_semaphore(acpi_handle handle
, u32 units
)
878 struct semaphore
*sem
= (struct semaphore
*)handle
;
881 if (!sem
|| (units
< 1))
882 return AE_BAD_PARAMETER
;
887 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Signaling semaphore[%p|%d]\n", handle
,
895 EXPORT_SYMBOL(acpi_os_signal_semaphore
);
897 #ifdef ACPI_FUTURE_USAGE
898 u32
acpi_os_get_line(char *buffer
)
901 #ifdef ENABLE_DEBUGGER
902 if (acpi_in_debugger
) {
905 kdb_read(buffer
, sizeof(line_buf
));
907 /* remove the CR kdb includes */
908 chars
= strlen(buffer
) - 1;
909 buffer
[chars
] = '\0';
915 #endif /* ACPI_FUTURE_USAGE */
917 acpi_status
acpi_os_signal(u32 function
, void *info
)
920 case ACPI_SIGNAL_FATAL
:
921 printk(KERN_ERR PREFIX
"Fatal opcode executed\n");
923 case ACPI_SIGNAL_BREAKPOINT
:
926 * ACPI spec. says to treat it as a NOP unless
927 * you are debugging. So if/when we integrate
928 * AML debugger into the kernel debugger its
929 * hook will go here. But until then it is
930 * not useful to print anything on breakpoints.
940 EXPORT_SYMBOL(acpi_os_signal
);
942 static int __init
acpi_os_name_setup(char *str
)
944 char *p
= acpi_os_name
;
945 int count
= ACPI_MAX_OVERRIDE_LEN
- 1;
950 for (; count
-- && str
&& *str
; str
++) {
951 if (isalnum(*str
) || *str
== ' ' || *str
== ':')
953 else if (*str
== '\'' || *str
== '"')
964 __setup("acpi_os_name=", acpi_os_name_setup
);
967 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
969 * empty string disables _OSI
970 * string starting with '!' disables that string
971 * otherwise string is added to list, augmenting built-in strings
973 static int __init
acpi_osi_setup(char *str
)
975 if (str
== NULL
|| *str
== '\0') {
976 printk(KERN_INFO PREFIX
"_OSI method disabled\n");
977 acpi_gbl_create_osi_method
= FALSE
;
978 } else if (*str
== '!') {
979 if (acpi_osi_invalidate(++str
) == AE_OK
)
980 printk(KERN_INFO PREFIX
"Deleted _OSI(%s)\n", str
);
981 } else if (*osi_additional_string
== '\0') {
982 strncpy(osi_additional_string
, str
, OSI_STRING_LENGTH_MAX
);
983 printk(KERN_INFO PREFIX
"Added _OSI(%s)\n", str
);
989 __setup("acpi_osi=", acpi_osi_setup
);
991 /* enable serialization to combat AE_ALREADY_EXISTS errors */
992 static int __init
acpi_serialize_setup(char *str
)
994 printk(KERN_INFO PREFIX
"serialize enabled\n");
996 acpi_gbl_all_methods_serialized
= TRUE
;
1001 __setup("acpi_serialize", acpi_serialize_setup
);
1004 * Wake and Run-Time GPES are expected to be separate.
1005 * We disable wake-GPEs at run-time to prevent spurious
1008 * However, if a system exists that shares Wake and
1009 * Run-time events on the same GPE this flag is available
1010 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1012 static int __init
acpi_wake_gpes_always_on_setup(char *str
)
1014 printk(KERN_INFO PREFIX
"wake GPEs not disabled\n");
1016 acpi_gbl_leave_wake_gpes_disabled
= FALSE
;
1021 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup
);
1024 * max_cstate is defined in the base kernel so modules can
1025 * change it w/o depending on the state of the processor module.
1027 unsigned int max_cstate
= ACPI_PROCESSOR_MAX_POWER
;
1029 EXPORT_SYMBOL(max_cstate
);
1032 * Acquire a spinlock.
1034 * handle is a pointer to the spinlock_t.
1037 acpi_cpu_flags
acpi_os_acquire_lock(acpi_spinlock lockp
)
1039 acpi_cpu_flags flags
;
1040 spin_lock_irqsave(lockp
, flags
);
1045 * Release a spinlock. See above.
1048 void acpi_os_release_lock(acpi_spinlock lockp
, acpi_cpu_flags flags
)
1050 spin_unlock_irqrestore(lockp
, flags
);
1053 #ifndef ACPI_USE_LOCAL_CACHE
1055 /*******************************************************************************
1057 * FUNCTION: acpi_os_create_cache
1059 * PARAMETERS: name - Ascii name for the cache
1060 * size - Size of each cached object
1061 * depth - Maximum depth of the cache (in objects) <ignored>
1062 * cache - Where the new cache object is returned
1066 * DESCRIPTION: Create a cache object
1068 ******************************************************************************/
1071 acpi_os_create_cache(char *name
, u16 size
, u16 depth
, acpi_cache_t
** cache
)
1073 *cache
= kmem_cache_create(name
, size
, 0, 0, NULL
, NULL
);
1080 /*******************************************************************************
1082 * FUNCTION: acpi_os_purge_cache
1084 * PARAMETERS: Cache - Handle to cache object
1088 * DESCRIPTION: Free all objects within the requested cache.
1090 ******************************************************************************/
1092 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
)
1094 kmem_cache_shrink(cache
);
1098 /*******************************************************************************
1100 * FUNCTION: acpi_os_delete_cache
1102 * PARAMETERS: Cache - Handle to cache object
1106 * DESCRIPTION: Free all objects within the requested cache and delete the
1109 ******************************************************************************/
1111 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
)
1113 kmem_cache_destroy(cache
);
1117 /*******************************************************************************
1119 * FUNCTION: acpi_os_release_object
1121 * PARAMETERS: Cache - Handle to cache object
1122 * Object - The object to be released
1126 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1127 * the object is deleted.
1129 ******************************************************************************/
1131 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
)
1133 kmem_cache_free(cache
, object
);
1137 /******************************************************************************
1139 * FUNCTION: acpi_os_validate_interface
1141 * PARAMETERS: interface - Requested interface to be validated
1143 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1145 * DESCRIPTION: Match an interface string to the interfaces supported by the
1146 * host. Strings originate from an AML call to the _OSI method.
1148 *****************************************************************************/
1151 acpi_os_validate_interface (char *interface
)
1153 if (!strncmp(osi_additional_string
, interface
, OSI_STRING_LENGTH_MAX
))
1158 /******************************************************************************
1160 * FUNCTION: acpi_os_validate_address
1162 * PARAMETERS: space_id - ACPI space ID
1163 * address - Physical address
1164 * length - Address length
1166 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1167 * should return AE_AML_ILLEGAL_ADDRESS.
1169 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1170 * the addresses accessed by AML operation regions.
1172 *****************************************************************************/
1175 acpi_os_validate_address (
1177 acpi_physical_address address
,