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 static void __init
acpi_request_region (struct acpi_generic_address
*addr
,
77 unsigned int length
, char *desc
)
81 if (!addr
->address
|| !length
)
84 if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_IO
)
85 res
= request_region(addr
->address
, length
, desc
);
86 else if (addr
->space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
)
87 res
= request_mem_region(addr
->address
, length
, desc
);
90 static int __init
acpi_reserve_resources(void)
92 acpi_request_region(&acpi_gbl_FADT
.xpm1a_event_block
, acpi_gbl_FADT
.pm1_event_length
,
95 acpi_request_region(&acpi_gbl_FADT
.xpm1b_event_block
, acpi_gbl_FADT
.pm1_event_length
,
98 acpi_request_region(&acpi_gbl_FADT
.xpm1a_control_block
, acpi_gbl_FADT
.pm1_control_length
,
101 acpi_request_region(&acpi_gbl_FADT
.xpm1b_control_block
, acpi_gbl_FADT
.pm1_control_length
,
102 "ACPI PM1b_CNT_BLK");
104 if (acpi_gbl_FADT
.pm_timer_length
== 4)
105 acpi_request_region(&acpi_gbl_FADT
.xpm_timer_block
, 4, "ACPI PM_TMR");
107 acpi_request_region(&acpi_gbl_FADT
.xpm2_control_block
, acpi_gbl_FADT
.pm2_control_length
,
110 /* Length of GPE blocks must be a non-negative multiple of 2 */
112 if (!(acpi_gbl_FADT
.gpe0_block_length
& 0x1))
113 acpi_request_region(&acpi_gbl_FADT
.xgpe0_block
,
114 acpi_gbl_FADT
.gpe0_block_length
, "ACPI GPE0_BLK");
116 if (!(acpi_gbl_FADT
.gpe1_block_length
& 0x1))
117 acpi_request_region(&acpi_gbl_FADT
.xgpe1_block
,
118 acpi_gbl_FADT
.gpe1_block_length
, "ACPI GPE1_BLK");
122 device_initcall(acpi_reserve_resources
);
124 acpi_status
acpi_os_initialize(void)
129 acpi_status
acpi_os_initialize1(void)
132 * Initialize PCI configuration space access, as we'll need to access
133 * it while walking the namespace (bus 0 and root bridges w/ _BBNs).
136 printk(KERN_ERR PREFIX
137 "Access to PCI configuration space unavailable\n");
138 return AE_NULL_ENTRY
;
140 kacpid_wq
= create_singlethread_workqueue("kacpid");
141 kacpi_notify_wq
= create_singlethread_workqueue("kacpi_notify");
143 BUG_ON(!kacpi_notify_wq
);
147 acpi_status
acpi_os_terminate(void)
149 if (acpi_irq_handler
) {
150 acpi_os_remove_interrupt_handler(acpi_irq_irq
,
154 destroy_workqueue(kacpid_wq
);
155 destroy_workqueue(kacpi_notify_wq
);
160 void acpi_os_printf(const char *fmt
, ...)
164 acpi_os_vprintf(fmt
, args
);
168 EXPORT_SYMBOL(acpi_os_printf
);
170 void acpi_os_vprintf(const char *fmt
, va_list args
)
172 static char buffer
[512];
174 vsprintf(buffer
, fmt
, args
);
176 #ifdef ENABLE_DEBUGGER
177 if (acpi_in_debugger
) {
178 kdb_printf("%s", buffer
);
180 printk("%s", buffer
);
183 printk("%s", buffer
);
187 acpi_physical_address __init
acpi_os_get_root_pointer(void)
190 if (efi
.acpi20
!= EFI_INVALID_TABLE_ADDR
)
192 else if (efi
.acpi
!= EFI_INVALID_TABLE_ADDR
)
195 printk(KERN_ERR PREFIX
196 "System description tables not found\n");
200 return acpi_find_rsdp();
203 void __iomem
*acpi_os_map_memory(acpi_physical_address phys
, acpi_size size
)
205 if (phys
> ULONG_MAX
) {
206 printk(KERN_ERR PREFIX
"Cannot map memory that high\n");
209 if (acpi_gbl_permanent_mmap
)
211 * ioremap checks to ensure this is in reserved space
213 return ioremap((unsigned long)phys
, size
);
215 return __acpi_map_table((unsigned long)phys
, size
);
217 EXPORT_SYMBOL_GPL(acpi_os_map_memory
);
219 void acpi_os_unmap_memory(void __iomem
* virt
, acpi_size size
)
221 if (acpi_gbl_permanent_mmap
) {
225 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory
);
227 #ifdef ACPI_FUTURE_USAGE
229 acpi_os_get_physical_address(void *virt
, acpi_physical_address
* phys
)
232 return AE_BAD_PARAMETER
;
234 *phys
= virt_to_phys(virt
);
240 #define ACPI_MAX_OVERRIDE_LEN 100
242 static char acpi_os_name
[ACPI_MAX_OVERRIDE_LEN
];
245 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
246 acpi_string
* new_val
)
248 if (!init_val
|| !new_val
)
249 return AE_BAD_PARAMETER
;
252 if (!memcmp(init_val
->name
, "_OS_", 4) && strlen(acpi_os_name
)) {
253 printk(KERN_INFO PREFIX
"Overriding _OS definition to '%s'\n",
255 *new_val
= acpi_os_name
;
262 acpi_os_table_override(struct acpi_table_header
* existing_table
,
263 struct acpi_table_header
** new_table
)
265 if (!existing_table
|| !new_table
)
266 return AE_BAD_PARAMETER
;
268 #ifdef CONFIG_ACPI_CUSTOM_DSDT
269 if (strncmp(existing_table
->signature
, "DSDT", 4) == 0)
270 *new_table
= (struct acpi_table_header
*)AmlCode
;
279 static irqreturn_t
acpi_irq(int irq
, void *dev_id
)
281 return (*acpi_irq_handler
) (acpi_irq_context
) ? IRQ_HANDLED
: IRQ_NONE
;
285 acpi_os_install_interrupt_handler(u32 gsi
, acpi_osd_handler handler
,
291 * Ignore the GSI from the core, and use the value in our copy of the
292 * FADT. It may not be the same if an interrupt source override exists
295 gsi
= acpi_gbl_FADT
.sci_interrupt
;
296 if (acpi_gsi_to_irq(gsi
, &irq
) < 0) {
297 printk(KERN_ERR PREFIX
"SCI (ACPI GSI %d) not registered\n",
302 acpi_irq_handler
= handler
;
303 acpi_irq_context
= context
;
304 if (request_irq(irq
, acpi_irq
, IRQF_SHARED
, "acpi", acpi_irq
)) {
305 printk(KERN_ERR PREFIX
"SCI (IRQ%d) allocation failed\n", irq
);
306 return AE_NOT_ACQUIRED
;
313 acpi_status
acpi_os_remove_interrupt_handler(u32 irq
, acpi_osd_handler handler
)
316 free_irq(irq
, acpi_irq
);
317 acpi_irq_handler
= NULL
;
325 * Running in interpreter thread context, safe to sleep
328 void acpi_os_sleep(acpi_integer ms
)
330 schedule_timeout_interruptible(msecs_to_jiffies(ms
));
333 EXPORT_SYMBOL(acpi_os_sleep
);
335 void acpi_os_stall(u32 us
)
343 touch_nmi_watchdog();
348 EXPORT_SYMBOL(acpi_os_stall
);
351 * Support ACPI 3.0 AML Timer operand
352 * Returns 64-bit free-running, monotonically increasing timer
353 * with 100ns granularity
355 u64
acpi_os_get_timer(void)
360 /* TBD: use HPET if available */
363 #ifdef CONFIG_X86_PM_TIMER
364 /* TBD: default to PM timer if HPET was not available */
367 printk(KERN_ERR PREFIX
"acpi_os_get_timer() TBD\n");
372 acpi_status
acpi_os_read_port(acpi_io_address port
, u32
* value
, u32 width
)
381 *(u8
*) value
= inb(port
);
384 *(u16
*) value
= inw(port
);
387 *(u32
*) value
= inl(port
);
396 EXPORT_SYMBOL(acpi_os_read_port
);
398 acpi_status
acpi_os_write_port(acpi_io_address port
, u32 value
, u32 width
)
417 EXPORT_SYMBOL(acpi_os_write_port
);
420 acpi_os_read_memory(acpi_physical_address phys_addr
, u32
* value
, u32 width
)
423 void __iomem
*virt_addr
;
425 virt_addr
= ioremap(phys_addr
, width
);
431 *(u8
*) value
= readb(virt_addr
);
434 *(u16
*) value
= readw(virt_addr
);
437 *(u32
*) value
= readl(virt_addr
);
449 acpi_os_write_memory(acpi_physical_address phys_addr
, u32 value
, u32 width
)
451 void __iomem
*virt_addr
;
453 virt_addr
= ioremap(phys_addr
, width
);
457 writeb(value
, virt_addr
);
460 writew(value
, virt_addr
);
463 writel(value
, virt_addr
);
475 acpi_os_read_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
476 void *value
, u32 width
)
481 return AE_BAD_PARAMETER
;
497 BUG_ON(!raw_pci_ops
);
499 result
= raw_pci_ops
->read(pci_id
->segment
, pci_id
->bus
,
500 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
503 return (result
? AE_ERROR
: AE_OK
);
506 EXPORT_SYMBOL(acpi_os_read_pci_configuration
);
509 acpi_os_write_pci_configuration(struct acpi_pci_id
* pci_id
, u32 reg
,
510 acpi_integer value
, u32 width
)
528 BUG_ON(!raw_pci_ops
);
530 result
= raw_pci_ops
->write(pci_id
->segment
, pci_id
->bus
,
531 PCI_DEVFN(pci_id
->device
, pci_id
->function
),
534 return (result
? AE_ERROR
: AE_OK
);
537 /* TODO: Change code to take advantage of driver model more */
538 static void acpi_os_derive_pci_id_2(acpi_handle rhandle
, /* upper bound */
539 acpi_handle chandle
, /* current node */
540 struct acpi_pci_id
**id
,
541 int *is_bridge
, u8
* bus_number
)
544 struct acpi_pci_id
*pci_id
= *id
;
547 acpi_object_type type
;
550 acpi_get_parent(chandle
, &handle
);
551 if (handle
!= rhandle
) {
552 acpi_os_derive_pci_id_2(rhandle
, handle
, &pci_id
, is_bridge
,
555 status
= acpi_get_type(handle
, &type
);
556 if ((ACPI_FAILURE(status
)) || (type
!= ACPI_TYPE_DEVICE
))
560 acpi_evaluate_integer(handle
, METHOD_NAME__ADR
, NULL
,
562 if (ACPI_SUCCESS(status
)) {
563 pci_id
->device
= ACPI_HIWORD(ACPI_LODWORD(temp
));
564 pci_id
->function
= ACPI_LOWORD(ACPI_LODWORD(temp
));
567 pci_id
->bus
= *bus_number
;
569 /* any nicer way to get bus number of bridge ? */
571 acpi_os_read_pci_configuration(pci_id
, 0x0e, &tu8
,
573 if (ACPI_SUCCESS(status
)
574 && ((tu8
& 0x7f) == 1 || (tu8
& 0x7f) == 2)) {
576 acpi_os_read_pci_configuration(pci_id
, 0x18,
578 if (!ACPI_SUCCESS(status
)) {
579 /* Certainly broken... FIX ME */
585 acpi_os_read_pci_configuration(pci_id
, 0x19,
587 if (ACPI_SUCCESS(status
)) {
596 void acpi_os_derive_pci_id(acpi_handle rhandle
, /* upper bound */
597 acpi_handle chandle
, /* current node */
598 struct acpi_pci_id
**id
)
601 u8 bus_number
= (*id
)->bus
;
603 acpi_os_derive_pci_id_2(rhandle
, chandle
, id
, &is_bridge
, &bus_number
);
606 static void acpi_os_execute_deferred(struct work_struct
*work
)
608 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
610 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
614 dpc
->function(dpc
->context
);
617 /* Yield cpu to notify thread */
623 static void acpi_os_execute_notify(struct work_struct
*work
)
625 struct acpi_os_dpc
*dpc
= container_of(work
, struct acpi_os_dpc
, work
);
628 printk(KERN_ERR PREFIX
"Invalid (NULL) context\n");
632 dpc
->function(dpc
->context
);
639 /*******************************************************************************
641 * FUNCTION: acpi_os_execute
643 * PARAMETERS: Type - Type of the callback
644 * Function - Function to be executed
645 * Context - Function parameters
649 * DESCRIPTION: Depending on type, either queues function for deferred execution or
650 * immediately executes function on a separate thread.
652 ******************************************************************************/
654 acpi_status
acpi_os_execute(acpi_execute_type type
,
655 acpi_osd_exec_callback function
, void *context
)
657 acpi_status status
= AE_OK
;
658 struct acpi_os_dpc
*dpc
;
660 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
661 "Scheduling function [%p(%p)] for deferred execution.\n",
665 return AE_BAD_PARAMETER
;
668 * Allocate/initialize DPC structure. Note that this memory will be
669 * freed by the callee. The kernel handles the work_struct list in a
670 * way that allows us to also free its memory inside the callee.
671 * Because we may want to schedule several tasks with different
672 * parameters we can't use the approach some kernel code uses of
673 * having a static work_struct.
676 dpc
= kmalloc(sizeof(struct acpi_os_dpc
), GFP_ATOMIC
);
678 return_ACPI_STATUS(AE_NO_MEMORY
);
680 dpc
->function
= function
;
681 dpc
->context
= context
;
683 if (type
== OSL_NOTIFY_HANDLER
) {
684 INIT_WORK(&dpc
->work
, acpi_os_execute_notify
);
685 if (!queue_work(kacpi_notify_wq
, &dpc
->work
)) {
690 INIT_WORK(&dpc
->work
, acpi_os_execute_deferred
);
691 if (!queue_work(kacpid_wq
, &dpc
->work
)) {
692 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
693 "Call to queue_work() failed.\n"));
698 return_ACPI_STATUS(status
);
701 EXPORT_SYMBOL(acpi_os_execute
);
703 void acpi_os_wait_events_complete(void *context
)
705 flush_workqueue(kacpid_wq
);
708 EXPORT_SYMBOL(acpi_os_wait_events_complete
);
711 * Allocate the memory for a spinlock and initialize it.
713 acpi_status
acpi_os_create_lock(acpi_spinlock
* handle
)
715 spin_lock_init(*handle
);
721 * Deallocate the memory for a spinlock.
723 void acpi_os_delete_lock(acpi_spinlock handle
)
729 acpi_os_create_semaphore(u32 max_units
, u32 initial_units
, acpi_handle
* handle
)
731 struct semaphore
*sem
= NULL
;
734 sem
= acpi_os_allocate(sizeof(struct semaphore
));
737 memset(sem
, 0, sizeof(struct semaphore
));
739 sema_init(sem
, initial_units
);
741 *handle
= (acpi_handle
*) sem
;
743 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Creating semaphore[%p|%d].\n",
744 *handle
, initial_units
));
749 EXPORT_SYMBOL(acpi_os_create_semaphore
);
752 * TODO: A better way to delete semaphores? Linux doesn't have a
753 * 'delete_semaphore()' function -- may result in an invalid
754 * pointer dereference for non-synchronized consumers. Should
755 * we at least check for blocked threads and signal/cancel them?
758 acpi_status
acpi_os_delete_semaphore(acpi_handle handle
)
760 struct semaphore
*sem
= (struct semaphore
*)handle
;
764 return AE_BAD_PARAMETER
;
766 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Deleting semaphore[%p].\n", handle
));
774 EXPORT_SYMBOL(acpi_os_delete_semaphore
);
777 * TODO: The kernel doesn't have a 'down_timeout' function -- had to
778 * improvise. The process is to sleep for one scheduler quantum
779 * until the semaphore becomes available. Downside is that this
780 * may result in starvation for timeout-based waits when there's
781 * lots of semaphore activity.
783 * TODO: Support for units > 1?
785 acpi_status
acpi_os_wait_semaphore(acpi_handle handle
, u32 units
, u16 timeout
)
787 acpi_status status
= AE_OK
;
788 struct semaphore
*sem
= (struct semaphore
*)handle
;
792 if (!sem
|| (units
< 1))
793 return AE_BAD_PARAMETER
;
798 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Waiting for semaphore[%p|%d|%d]\n",
799 handle
, units
, timeout
));
802 * This can be called during resume with interrupts off.
803 * Like boot-time, we should be single threaded and will
804 * always get the lock if we try -- timeout or not.
805 * If this doesn't succeed, then we will oops courtesy of
806 * might_sleep() in down().
808 if (!down_trylock(sem
))
815 * A zero timeout value indicates that we shouldn't wait - just
816 * acquire the semaphore if available otherwise return AE_TIME
817 * (a.k.a. 'would block').
820 if (down_trylock(sem
))
828 case ACPI_WAIT_FOREVER
:
837 // TODO: A better timeout algorithm?
840 static const int quantum_ms
= 1000 / HZ
;
842 ret
= down_trylock(sem
);
843 for (i
= timeout
; (i
> 0 && ret
!= 0); i
-= quantum_ms
) {
844 schedule_timeout_interruptible(1);
845 ret
= down_trylock(sem
);
854 if (ACPI_FAILURE(status
)) {
855 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
856 "Failed to acquire semaphore[%p|%d|%d], %s",
857 handle
, units
, timeout
,
858 acpi_format_exception(status
)));
860 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
,
861 "Acquired semaphore[%p|%d|%d]", handle
,
868 EXPORT_SYMBOL(acpi_os_wait_semaphore
);
871 * TODO: Support for units > 1?
873 acpi_status
acpi_os_signal_semaphore(acpi_handle handle
, u32 units
)
875 struct semaphore
*sem
= (struct semaphore
*)handle
;
878 if (!sem
|| (units
< 1))
879 return AE_BAD_PARAMETER
;
884 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX
, "Signaling semaphore[%p|%d]\n", handle
,
892 EXPORT_SYMBOL(acpi_os_signal_semaphore
);
894 #ifdef ACPI_FUTURE_USAGE
895 u32
acpi_os_get_line(char *buffer
)
898 #ifdef ENABLE_DEBUGGER
899 if (acpi_in_debugger
) {
902 kdb_read(buffer
, sizeof(line_buf
));
904 /* remove the CR kdb includes */
905 chars
= strlen(buffer
) - 1;
906 buffer
[chars
] = '\0';
912 #endif /* ACPI_FUTURE_USAGE */
914 acpi_status
acpi_os_signal(u32 function
, void *info
)
917 case ACPI_SIGNAL_FATAL
:
918 printk(KERN_ERR PREFIX
"Fatal opcode executed\n");
920 case ACPI_SIGNAL_BREAKPOINT
:
923 * ACPI spec. says to treat it as a NOP unless
924 * you are debugging. So if/when we integrate
925 * AML debugger into the kernel debugger its
926 * hook will go here. But until then it is
927 * not useful to print anything on breakpoints.
937 EXPORT_SYMBOL(acpi_os_signal
);
939 static int __init
acpi_os_name_setup(char *str
)
941 char *p
= acpi_os_name
;
942 int count
= ACPI_MAX_OVERRIDE_LEN
- 1;
947 for (; count
-- && str
&& *str
; str
++) {
948 if (isalnum(*str
) || *str
== ' ' || *str
== ':')
950 else if (*str
== '\'' || *str
== '"')
961 __setup("acpi_os_name=", acpi_os_name_setup
);
965 * empty string disables _OSI
966 * TBD additional string adds to _OSI
968 static int __init
acpi_osi_setup(char *str
)
970 if (str
== NULL
|| *str
== '\0') {
971 printk(KERN_INFO PREFIX
"_OSI method disabled\n");
972 acpi_gbl_create_osi_method
= FALSE
;
975 printk(KERN_ERR PREFIX
"_OSI additional string ignored -- %s\n",
982 __setup("acpi_osi=", acpi_osi_setup
);
984 /* enable serialization to combat AE_ALREADY_EXISTS errors */
985 static int __init
acpi_serialize_setup(char *str
)
987 printk(KERN_INFO PREFIX
"serialize enabled\n");
989 acpi_gbl_all_methods_serialized
= TRUE
;
994 __setup("acpi_serialize", acpi_serialize_setup
);
997 * Wake and Run-Time GPES are expected to be separate.
998 * We disable wake-GPEs at run-time to prevent spurious
1001 * However, if a system exists that shares Wake and
1002 * Run-time events on the same GPE this flag is available
1003 * to tell Linux to keep the wake-time GPEs enabled at run-time.
1005 static int __init
acpi_wake_gpes_always_on_setup(char *str
)
1007 printk(KERN_INFO PREFIX
"wake GPEs not disabled\n");
1009 acpi_gbl_leave_wake_gpes_disabled
= FALSE
;
1014 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup
);
1017 * max_cstate is defined in the base kernel so modules can
1018 * change it w/o depending on the state of the processor module.
1020 unsigned int max_cstate
= ACPI_PROCESSOR_MAX_POWER
;
1022 EXPORT_SYMBOL(max_cstate
);
1025 * Acquire a spinlock.
1027 * handle is a pointer to the spinlock_t.
1030 acpi_cpu_flags
acpi_os_acquire_lock(acpi_spinlock lockp
)
1032 acpi_cpu_flags flags
;
1033 spin_lock_irqsave(lockp
, flags
);
1038 * Release a spinlock. See above.
1041 void acpi_os_release_lock(acpi_spinlock lockp
, acpi_cpu_flags flags
)
1043 spin_unlock_irqrestore(lockp
, flags
);
1046 #ifndef ACPI_USE_LOCAL_CACHE
1048 /*******************************************************************************
1050 * FUNCTION: acpi_os_create_cache
1052 * PARAMETERS: name - Ascii name for the cache
1053 * size - Size of each cached object
1054 * depth - Maximum depth of the cache (in objects) <ignored>
1055 * cache - Where the new cache object is returned
1059 * DESCRIPTION: Create a cache object
1061 ******************************************************************************/
1064 acpi_os_create_cache(char *name
, u16 size
, u16 depth
, acpi_cache_t
** cache
)
1066 *cache
= kmem_cache_create(name
, size
, 0, 0, NULL
, NULL
);
1073 /*******************************************************************************
1075 * FUNCTION: acpi_os_purge_cache
1077 * PARAMETERS: Cache - Handle to cache object
1081 * DESCRIPTION: Free all objects within the requested cache.
1083 ******************************************************************************/
1085 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
)
1087 kmem_cache_shrink(cache
);
1091 /*******************************************************************************
1093 * FUNCTION: acpi_os_delete_cache
1095 * PARAMETERS: Cache - Handle to cache object
1099 * DESCRIPTION: Free all objects within the requested cache and delete the
1102 ******************************************************************************/
1104 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
)
1106 kmem_cache_destroy(cache
);
1110 /*******************************************************************************
1112 * FUNCTION: acpi_os_release_object
1114 * PARAMETERS: Cache - Handle to cache object
1115 * Object - The object to be released
1119 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1120 * the object is deleted.
1122 ******************************************************************************/
1124 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
)
1126 kmem_cache_free(cache
, object
);
1130 /******************************************************************************
1132 * FUNCTION: acpi_os_validate_interface
1134 * PARAMETERS: interface - Requested interface to be validated
1136 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1138 * DESCRIPTION: Match an interface string to the interfaces supported by the
1139 * host. Strings originate from an AML call to the _OSI method.
1141 *****************************************************************************/
1144 acpi_os_validate_interface (char *interface
)
1151 /******************************************************************************
1153 * FUNCTION: acpi_os_validate_address
1155 * PARAMETERS: space_id - ACPI space ID
1156 * address - Physical address
1157 * length - Address length
1159 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1160 * should return AE_AML_ILLEGAL_ADDRESS.
1162 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1163 * the addresses accessed by AML operation regions.
1165 *****************************************************************************/
1168 acpi_os_validate_address (
1170 acpi_physical_address address
,