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>
7 * Copyright (c) 2008 Intel Corporation
8 * Author: Matthew Wilcox <willy@linux.intel.com>
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/slab.h>
30 #include <linux/highmem.h>
31 #include <linux/pci.h>
32 #include <linux/interrupt.h>
33 #include <linux/kmod.h>
34 #include <linux/delay.h>
35 #include <linux/workqueue.h>
36 #include <linux/nmi.h>
37 #include <linux/acpi.h>
38 #include <linux/efi.h>
39 #include <linux/ioport.h>
40 #include <linux/list.h>
41 #include <linux/jiffies.h>
42 #include <linux/semaphore.h>
45 #include <asm/uaccess.h>
46 #include <asm-generic/io-64-nonatomic-lo-hi.h>
50 #define _COMPONENT ACPI_OS_SERVICES
51 ACPI_MODULE_NAME("osl");
54 acpi_osd_exec_callback function;
56 struct work_struct work;
59 #ifdef CONFIG_ACPI_CUSTOM_DSDT
60 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
63 #ifdef ENABLE_DEBUGGER
64 #include <linux/kdb.h>
66 /* stuff for debugger support */
68 EXPORT_SYMBOL(acpi_in_debugger);
69 #endif /*ENABLE_DEBUGGER */
71 static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
73 static int (*__acpi_os_prepare_extended_sleep)(u8 sleep_state, u32 val_a,
76 static acpi_osd_handler acpi_irq_handler;
77 static void *acpi_irq_context;
78 static struct workqueue_struct *kacpid_wq;
79 static struct workqueue_struct *kacpi_notify_wq;
80 static struct workqueue_struct *kacpi_hotplug_wq;
81 static bool acpi_os_initialized;
84 * This list of permanent mappings is for memory that may be accessed from
85 * interrupt context, where we can't do the ioremap().
88 struct list_head list;
90 acpi_physical_address phys;
92 unsigned long refcount;
95 static LIST_HEAD(acpi_ioremaps);
96 static DEFINE_MUTEX(acpi_ioremap_lock);
98 static void __init acpi_osi_setup_late(void);
101 * The story of _OSI(Linux)
103 * From pre-history through Linux-2.6.22,
104 * Linux responded TRUE upon a BIOS OSI(Linux) query.
106 * Unfortunately, reference BIOS writers got wind of this
107 * and put OSI(Linux) in their example code, quickly exposing
108 * this string as ill-conceived and opening the door to
109 * an un-bounded number of BIOS incompatibilities.
111 * For example, OSI(Linux) was used on resume to re-POST a
112 * video card on one system, because Linux at that time
113 * could not do a speedy restore in its native driver.
114 * But then upon gaining quick native restore capability,
115 * Linux has no way to tell the BIOS to skip the time-consuming
116 * POST -- putting Linux at a permanent performance disadvantage.
117 * On another system, the BIOS writer used OSI(Linux)
118 * to infer native OS support for IPMI! On other systems,
119 * OSI(Linux) simply got in the way of Linux claiming to
120 * be compatible with other operating systems, exposing
121 * BIOS issues such as skipped device initialization.
123 * So "Linux" turned out to be a really poor chose of
124 * OSI string, and from Linux-2.6.23 onward we respond FALSE.
126 * BIOS writers should NOT query _OSI(Linux) on future systems.
127 * Linux will complain on the console when it sees it, and return FALSE.
128 * To get Linux to return TRUE for your system will require
129 * a kernel source update to add a DMI entry,
130 * or boot with "acpi_osi=Linux"
133 static struct osi_linux {
134 unsigned int enable:1;
136 unsigned int cmdline:1;
137 unsigned int default_disabling:1;
138 } osi_linux = {0, 0, 0, 0};
140 static u32 acpi_osi_handler(acpi_string interface, u32 supported)
142 if (!strcmp("Linux", interface)) {
144 printk_once(KERN_NOTICE FW_BUG PREFIX
145 "BIOS _OSI(Linux) query %s%s\n",
146 osi_linux.enable ? "honored" : "ignored",
147 osi_linux.cmdline ? " via cmdline" :
148 osi_linux.dmi ? " via DMI" : "");
151 if (!strcmp("Darwin", interface)) {
153 * Apple firmware will behave poorly if it receives positive
154 * answers to "Darwin" and any other OS. Respond positively
155 * to Darwin and then disable all other vendor strings.
157 acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
158 supported = ACPI_UINT32_MAX;
164 static void __init acpi_request_region (struct acpi_generic_address *gas,
165 unsigned int length, char *desc)
169 /* Handle possible alignment issues */
170 memcpy(&addr, &gas->address, sizeof(addr));
171 if (!addr || !length)
174 /* Resources are never freed */
175 if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
176 request_region(addr, length, desc);
177 else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
178 request_mem_region(addr, length, desc);
181 static int __init acpi_reserve_resources(void)
183 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
184 "ACPI PM1a_EVT_BLK");
186 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
187 "ACPI PM1b_EVT_BLK");
189 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
190 "ACPI PM1a_CNT_BLK");
192 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
193 "ACPI PM1b_CNT_BLK");
195 if (acpi_gbl_FADT.pm_timer_length == 4)
196 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
198 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
201 /* Length of GPE blocks must be a non-negative multiple of 2 */
203 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
204 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
205 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
207 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
208 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
209 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
213 fs_initcall_sync(acpi_reserve_resources);
215 void acpi_os_printf(const char *fmt, ...)
219 acpi_os_vprintf(fmt, args);
223 void acpi_os_vprintf(const char *fmt, va_list args)
225 static char buffer[512];
227 vsprintf(buffer, fmt, args);
229 #ifdef ENABLE_DEBUGGER
230 if (acpi_in_debugger) {
231 kdb_printf("%s", buffer);
233 printk(KERN_CONT "%s", buffer);
236 printk(KERN_CONT "%s", buffer);
241 static unsigned long acpi_rsdp;
242 static int __init setup_acpi_rsdp(char *arg)
244 if (kstrtoul(arg, 16, &acpi_rsdp))
248 early_param("acpi_rsdp", setup_acpi_rsdp);
251 acpi_physical_address __init acpi_os_get_root_pointer(void)
258 if (efi_enabled(EFI_CONFIG_TABLES)) {
259 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
261 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
264 printk(KERN_ERR PREFIX
265 "System description tables not found\n");
268 } else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) {
269 acpi_physical_address pa = 0;
271 acpi_find_root_pointer(&pa);
278 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
279 static struct acpi_ioremap *
280 acpi_map_lookup(acpi_physical_address phys, acpi_size size)
282 struct acpi_ioremap *map;
284 list_for_each_entry_rcu(map, &acpi_ioremaps, list)
285 if (map->phys <= phys &&
286 phys + size <= map->phys + map->size)
292 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
293 static void __iomem *
294 acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size)
296 struct acpi_ioremap *map;
298 map = acpi_map_lookup(phys, size);
300 return map->virt + (phys - map->phys);
305 void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size)
307 struct acpi_ioremap *map;
308 void __iomem *virt = NULL;
310 mutex_lock(&acpi_ioremap_lock);
311 map = acpi_map_lookup(phys, size);
313 virt = map->virt + (phys - map->phys);
316 mutex_unlock(&acpi_ioremap_lock);
319 EXPORT_SYMBOL_GPL(acpi_os_get_iomem);
321 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
322 static struct acpi_ioremap *
323 acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
325 struct acpi_ioremap *map;
327 list_for_each_entry_rcu(map, &acpi_ioremaps, list)
328 if (map->virt <= virt &&
329 virt + size <= map->virt + map->size)
335 #if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
336 /* ioremap will take care of cache attributes */
337 #define should_use_kmap(pfn) 0
339 #define should_use_kmap(pfn) page_is_ram(pfn)
342 static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
346 pfn = pg_off >> PAGE_SHIFT;
347 if (should_use_kmap(pfn)) {
348 if (pg_sz > PAGE_SIZE)
350 return (void __iomem __force *)kmap(pfn_to_page(pfn));
352 return acpi_os_ioremap(pg_off, pg_sz);
355 static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
359 pfn = pg_off >> PAGE_SHIFT;
360 if (should_use_kmap(pfn))
361 kunmap(pfn_to_page(pfn));
366 void __iomem *__init_refok
367 acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
369 struct acpi_ioremap *map;
371 acpi_physical_address pg_off;
374 if (phys > ULONG_MAX) {
375 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
379 if (!acpi_gbl_permanent_mmap)
380 return __acpi_map_table((unsigned long)phys, size);
382 mutex_lock(&acpi_ioremap_lock);
383 /* Check if there's a suitable mapping already. */
384 map = acpi_map_lookup(phys, size);
390 map = kzalloc(sizeof(*map), GFP_KERNEL);
392 mutex_unlock(&acpi_ioremap_lock);
396 pg_off = round_down(phys, PAGE_SIZE);
397 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
398 virt = acpi_map(pg_off, pg_sz);
400 mutex_unlock(&acpi_ioremap_lock);
405 INIT_LIST_HEAD(&map->list);
411 list_add_tail_rcu(&map->list, &acpi_ioremaps);
414 mutex_unlock(&acpi_ioremap_lock);
415 return map->virt + (phys - map->phys);
417 EXPORT_SYMBOL_GPL(acpi_os_map_iomem);
420 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
422 return (void *)acpi_os_map_iomem(phys, size);
424 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
426 static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
428 if (!--map->refcount)
429 list_del_rcu(&map->list);
432 static void acpi_os_map_cleanup(struct acpi_ioremap *map)
434 if (!map->refcount) {
435 synchronize_rcu_expedited();
436 acpi_unmap(map->phys, map->virt);
441 void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
443 struct acpi_ioremap *map;
445 if (!acpi_gbl_permanent_mmap) {
446 __acpi_unmap_table(virt, size);
450 mutex_lock(&acpi_ioremap_lock);
451 map = acpi_map_lookup_virt(virt, size);
453 mutex_unlock(&acpi_ioremap_lock);
454 WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
457 acpi_os_drop_map_ref(map);
458 mutex_unlock(&acpi_ioremap_lock);
460 acpi_os_map_cleanup(map);
462 EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
464 void __ref acpi_os_unmap_memory(void *virt, acpi_size size)
466 return acpi_os_unmap_iomem((void __iomem *)virt, size);
468 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
470 void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
472 if (!acpi_gbl_permanent_mmap)
473 __acpi_unmap_table(virt, size);
476 int acpi_os_map_generic_address(struct acpi_generic_address *gas)
481 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
484 /* Handle possible alignment issues */
485 memcpy(&addr, &gas->address, sizeof(addr));
486 if (!addr || !gas->bit_width)
489 virt = acpi_os_map_iomem(addr, gas->bit_width / 8);
495 EXPORT_SYMBOL(acpi_os_map_generic_address);
497 void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
500 struct acpi_ioremap *map;
502 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
505 /* Handle possible alignment issues */
506 memcpy(&addr, &gas->address, sizeof(addr));
507 if (!addr || !gas->bit_width)
510 mutex_lock(&acpi_ioremap_lock);
511 map = acpi_map_lookup(addr, gas->bit_width / 8);
513 mutex_unlock(&acpi_ioremap_lock);
516 acpi_os_drop_map_ref(map);
517 mutex_unlock(&acpi_ioremap_lock);
519 acpi_os_map_cleanup(map);
521 EXPORT_SYMBOL(acpi_os_unmap_generic_address);
523 #ifdef ACPI_FUTURE_USAGE
525 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
528 return AE_BAD_PARAMETER;
530 *phys = virt_to_phys(virt);
536 #ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE
537 static bool acpi_rev_override;
539 int __init acpi_rev_override_setup(char *str)
541 acpi_rev_override = true;
544 __setup("acpi_rev_override", acpi_rev_override_setup);
546 #define acpi_rev_override false
549 #define ACPI_MAX_OVERRIDE_LEN 100
551 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
554 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
557 if (!init_val || !new_val)
558 return AE_BAD_PARAMETER;
561 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
562 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
564 *new_val = acpi_os_name;
567 if (!memcmp(init_val->name, "_REV", 4) && acpi_rev_override) {
568 printk(KERN_INFO PREFIX "Overriding _REV return value to 5\n");
569 *new_val = (char *)5;
575 #ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
576 #include <linux/earlycpio.h>
577 #include <linux/memblock.h>
579 static u64 acpi_tables_addr;
580 static int all_tables_size;
582 /* Copied from acpica/tbutils.c:acpi_tb_checksum() */
583 static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
586 u8 *end = buffer + length;
589 sum = (u8) (sum + *(buffer++));
593 /* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
594 static const char * const table_sigs[] = {
595 ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ,
596 ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT,
597 ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF,
598 ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET,
599 ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI,
600 ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA,
601 ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT,
602 ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT,
603 ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL };
605 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
607 #define ACPI_OVERRIDE_TABLES 64
608 static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];
610 #define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT)
612 void __init acpi_initrd_override(void *data, size_t size)
614 int sig, no, table_nr = 0, total_offset = 0;
616 struct acpi_table_header *table;
617 char cpio_path[32] = "kernel/firmware/acpi/";
618 struct cpio_data file;
620 if (data == NULL || size == 0)
623 for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
624 file = find_cpio_data(cpio_path, data, size, &offset);
631 if (file.size < sizeof(struct acpi_table_header)) {
632 pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n",
633 cpio_path, file.name);
639 for (sig = 0; table_sigs[sig]; sig++)
640 if (!memcmp(table->signature, table_sigs[sig], 4))
643 if (!table_sigs[sig]) {
644 pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n",
645 cpio_path, file.name);
648 if (file.size != table->length) {
649 pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n",
650 cpio_path, file.name);
653 if (acpi_table_checksum(file.data, table->length)) {
654 pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n",
655 cpio_path, file.name);
659 pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n",
660 table->signature, cpio_path, file.name, table->length);
662 all_tables_size += table->length;
663 acpi_initrd_files[table_nr].data = file.data;
664 acpi_initrd_files[table_nr].size = file.size;
671 memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT,
672 all_tables_size, PAGE_SIZE);
673 if (!acpi_tables_addr) {
678 * Only calling e820_add_reserve does not work and the
679 * tables are invalid (memory got used) later.
680 * memblock_reserve works as expected and the tables won't get modified.
681 * But it's not enough on X86 because ioremap will
682 * complain later (used by acpi_os_map_memory) that the pages
683 * that should get mapped are not marked "reserved".
684 * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
687 memblock_reserve(acpi_tables_addr, all_tables_size);
688 arch_reserve_mem_area(acpi_tables_addr, all_tables_size);
691 * early_ioremap only can remap 256k one time. If we map all
692 * tables one time, we will hit the limit. Need to map chunks
693 * one by one during copying the same as that in relocate_initrd().
695 for (no = 0; no < table_nr; no++) {
696 unsigned char *src_p = acpi_initrd_files[no].data;
697 phys_addr_t size = acpi_initrd_files[no].size;
698 phys_addr_t dest_addr = acpi_tables_addr + total_offset;
699 phys_addr_t slop, clen;
702 total_offset += size;
705 slop = dest_addr & ~PAGE_MASK;
707 if (clen > MAP_CHUNK_SIZE - slop)
708 clen = MAP_CHUNK_SIZE - slop;
709 dest_p = early_ioremap(dest_addr & PAGE_MASK,
711 memcpy(dest_p + slop, src_p, clen);
712 early_iounmap(dest_p, clen + slop);
719 #endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */
721 static void acpi_table_taint(struct acpi_table_header *table)
724 "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
725 table->signature, table->oem_table_id);
726 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
731 acpi_os_table_override(struct acpi_table_header * existing_table,
732 struct acpi_table_header ** new_table)
734 if (!existing_table || !new_table)
735 return AE_BAD_PARAMETER;
739 #ifdef CONFIG_ACPI_CUSTOM_DSDT
740 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
741 *new_table = (struct acpi_table_header *)AmlCode;
743 if (*new_table != NULL)
744 acpi_table_taint(existing_table);
749 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
750 acpi_physical_address *address,
753 #ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
758 int table_offset = 0;
759 struct acpi_table_header *table;
764 if (!acpi_tables_addr)
768 if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
773 table = acpi_os_map_memory(acpi_tables_addr + table_offset,
776 if (table_offset + table->length > all_tables_size) {
777 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
782 table_offset += table->length;
784 if (memcmp(existing_table->signature, table->signature, 4)) {
785 acpi_os_unmap_memory(table,
790 /* Only override tables with matching oem id */
791 if (memcmp(table->oem_table_id, existing_table->oem_table_id,
792 ACPI_OEM_TABLE_ID_SIZE)) {
793 acpi_os_unmap_memory(table,
798 table_offset -= table->length;
799 *table_length = table->length;
800 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
801 *address = acpi_tables_addr + table_offset;
803 } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
806 acpi_table_taint(existing_table);
811 static irqreturn_t acpi_irq(int irq, void *dev_id)
815 handled = (*acpi_irq_handler) (acpi_irq_context);
821 acpi_irq_not_handled++;
827 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
832 acpi_irq_stats_init();
835 * ACPI interrupts different from the SCI in our copy of the FADT are
838 if (gsi != acpi_gbl_FADT.sci_interrupt)
839 return AE_BAD_PARAMETER;
841 if (acpi_irq_handler)
842 return AE_ALREADY_ACQUIRED;
844 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
845 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
850 acpi_irq_handler = handler;
851 acpi_irq_context = context;
852 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
853 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
854 acpi_irq_handler = NULL;
855 return AE_NOT_ACQUIRED;
861 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
863 if (irq != acpi_gbl_FADT.sci_interrupt)
864 return AE_BAD_PARAMETER;
866 free_irq(irq, acpi_irq);
867 acpi_irq_handler = NULL;
873 * Running in interpreter thread context, safe to sleep
876 void acpi_os_sleep(u64 ms)
881 void acpi_os_stall(u32 us)
889 touch_nmi_watchdog();
895 * Support ACPI 3.0 AML Timer operand
896 * Returns 64-bit free-running, monotonically increasing timer
897 * with 100ns granularity
899 u64 acpi_os_get_timer(void)
901 u64 time_ns = ktime_to_ns(ktime_get());
902 do_div(time_ns, 100);
906 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
915 *(u8 *) value = inb(port);
916 } else if (width <= 16) {
917 *(u16 *) value = inw(port);
918 } else if (width <= 32) {
919 *(u32 *) value = inl(port);
927 EXPORT_SYMBOL(acpi_os_read_port);
929 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
933 } else if (width <= 16) {
935 } else if (width <= 32) {
944 EXPORT_SYMBOL(acpi_os_write_port);
947 acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
949 void __iomem *virt_addr;
950 unsigned int size = width / 8;
955 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
958 virt_addr = acpi_os_ioremap(phys_addr, size);
960 return AE_BAD_ADDRESS;
969 *(u8 *) value = readb(virt_addr);
972 *(u16 *) value = readw(virt_addr);
975 *(u32 *) value = readl(virt_addr);
978 *(u64 *) value = readq(virt_addr);
993 acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
995 void __iomem *virt_addr;
996 unsigned int size = width / 8;
1000 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
1003 virt_addr = acpi_os_ioremap(phys_addr, size);
1005 return AE_BAD_ADDRESS;
1011 writeb(value, virt_addr);
1014 writew(value, virt_addr);
1017 writel(value, virt_addr);
1020 writeq(value, virt_addr);
1035 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
1036 u64 *value, u32 width)
1042 return AE_BAD_PARAMETER;
1058 result = raw_pci_read(pci_id->segment, pci_id->bus,
1059 PCI_DEVFN(pci_id->device, pci_id->function),
1060 reg, size, &value32);
1063 return (result ? AE_ERROR : AE_OK);
1067 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
1068 u64 value, u32 width)
1086 result = raw_pci_write(pci_id->segment, pci_id->bus,
1087 PCI_DEVFN(pci_id->device, pci_id->function),
1090 return (result ? AE_ERROR : AE_OK);
1093 static void acpi_os_execute_deferred(struct work_struct *work)
1095 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
1097 dpc->function(dpc->context);
1101 /*******************************************************************************
1103 * FUNCTION: acpi_os_execute
1105 * PARAMETERS: Type - Type of the callback
1106 * Function - Function to be executed
1107 * Context - Function parameters
1111 * DESCRIPTION: Depending on type, either queues function for deferred execution or
1112 * immediately executes function on a separate thread.
1114 ******************************************************************************/
1116 acpi_status acpi_os_execute(acpi_execute_type type,
1117 acpi_osd_exec_callback function, void *context)
1119 acpi_status status = AE_OK;
1120 struct acpi_os_dpc *dpc;
1121 struct workqueue_struct *queue;
1123 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1124 "Scheduling function [%p(%p)] for deferred execution.\n",
1125 function, context));
1128 * Allocate/initialize DPC structure. Note that this memory will be
1129 * freed by the callee. The kernel handles the work_struct list in a
1130 * way that allows us to also free its memory inside the callee.
1131 * Because we may want to schedule several tasks with different
1132 * parameters we can't use the approach some kernel code uses of
1133 * having a static work_struct.
1136 dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
1138 return AE_NO_MEMORY;
1140 dpc->function = function;
1141 dpc->context = context;
1144 * To prevent lockdep from complaining unnecessarily, make sure that
1145 * there is a different static lockdep key for each workqueue by using
1146 * INIT_WORK() for each of them separately.
1148 if (type == OSL_NOTIFY_HANDLER) {
1149 queue = kacpi_notify_wq;
1150 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1153 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1157 * On some machines, a software-initiated SMI causes corruption unless
1158 * the SMI runs on CPU 0. An SMI can be initiated by any AML, but
1159 * typically it's done in GPE-related methods that are run via
1160 * workqueues, so we can avoid the known corruption cases by always
1161 * queueing on CPU 0.
1163 ret = queue_work_on(0, queue, &dpc->work);
1166 printk(KERN_ERR PREFIX
1167 "Call to queue_work() failed.\n");
1173 EXPORT_SYMBOL(acpi_os_execute);
1175 void acpi_os_wait_events_complete(void)
1178 * Make sure the GPE handler or the fixed event handler is not used
1179 * on another CPU after removal.
1181 if (acpi_irq_handler)
1182 synchronize_hardirq(acpi_gbl_FADT.sci_interrupt);
1183 flush_workqueue(kacpid_wq);
1184 flush_workqueue(kacpi_notify_wq);
1187 struct acpi_hp_work {
1188 struct work_struct work;
1189 struct acpi_device *adev;
1193 static void acpi_hotplug_work_fn(struct work_struct *work)
1195 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
1197 acpi_os_wait_events_complete();
1198 acpi_device_hotplug(hpw->adev, hpw->src);
1202 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src)
1204 struct acpi_hp_work *hpw;
1206 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1207 "Scheduling hotplug event (%p, %u) for deferred execution.\n",
1210 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
1212 return AE_NO_MEMORY;
1214 INIT_WORK(&hpw->work, acpi_hotplug_work_fn);
1218 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because
1219 * the hotplug code may call driver .remove() functions, which may
1220 * invoke flush_scheduled_work()/acpi_os_wait_events_complete() to flush
1223 if (!queue_work(kacpi_hotplug_wq, &hpw->work)) {
1230 bool acpi_queue_hotplug_work(struct work_struct *work)
1232 return queue_work(kacpi_hotplug_wq, work);
1236 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
1238 struct semaphore *sem = NULL;
1240 sem = acpi_os_allocate_zeroed(sizeof(struct semaphore));
1242 return AE_NO_MEMORY;
1244 sema_init(sem, initial_units);
1246 *handle = (acpi_handle *) sem;
1248 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
1249 *handle, initial_units));
1255 * TODO: A better way to delete semaphores? Linux doesn't have a
1256 * 'delete_semaphore()' function -- may result in an invalid
1257 * pointer dereference for non-synchronized consumers. Should
1258 * we at least check for blocked threads and signal/cancel them?
1261 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
1263 struct semaphore *sem = (struct semaphore *)handle;
1266 return AE_BAD_PARAMETER;
1268 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
1270 BUG_ON(!list_empty(&sem->wait_list));
1278 * TODO: Support for units > 1?
1280 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
1282 acpi_status status = AE_OK;
1283 struct semaphore *sem = (struct semaphore *)handle;
1287 if (!acpi_os_initialized)
1290 if (!sem || (units < 1))
1291 return AE_BAD_PARAMETER;
1296 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
1297 handle, units, timeout));
1299 if (timeout == ACPI_WAIT_FOREVER)
1300 jiffies = MAX_SCHEDULE_TIMEOUT;
1302 jiffies = msecs_to_jiffies(timeout);
1304 ret = down_timeout(sem, jiffies);
1308 if (ACPI_FAILURE(status)) {
1309 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
1310 "Failed to acquire semaphore[%p|%d|%d], %s",
1311 handle, units, timeout,
1312 acpi_format_exception(status)));
1314 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
1315 "Acquired semaphore[%p|%d|%d]", handle,
1323 * TODO: Support for units > 1?
1325 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
1327 struct semaphore *sem = (struct semaphore *)handle;
1329 if (!acpi_os_initialized)
1332 if (!sem || (units < 1))
1333 return AE_BAD_PARAMETER;
1338 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
1346 acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read)
1348 #ifdef ENABLE_DEBUGGER
1349 if (acpi_in_debugger) {
1352 kdb_read(buffer, buffer_length);
1354 /* remove the CR kdb includes */
1355 chars = strlen(buffer) - 1;
1356 buffer[chars] = '\0';
1363 acpi_status acpi_os_signal(u32 function, void *info)
1366 case ACPI_SIGNAL_FATAL:
1367 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
1369 case ACPI_SIGNAL_BREAKPOINT:
1372 * ACPI spec. says to treat it as a NOP unless
1373 * you are debugging. So if/when we integrate
1374 * AML debugger into the kernel debugger its
1375 * hook will go here. But until then it is
1376 * not useful to print anything on breakpoints.
1386 static int __init acpi_os_name_setup(char *str)
1388 char *p = acpi_os_name;
1389 int count = ACPI_MAX_OVERRIDE_LEN - 1;
1394 for (; count-- && *str; str++) {
1395 if (isalnum(*str) || *str == ' ' || *str == ':')
1397 else if (*str == '\'' || *str == '"')
1408 __setup("acpi_os_name=", acpi_os_name_setup);
1410 #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
1411 #define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */
1413 struct osi_setup_entry {
1414 char string[OSI_STRING_LENGTH_MAX];
1418 static struct osi_setup_entry
1419 osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
1420 {"Module Device", true},
1421 {"Processor Device", true},
1422 {"3.0 _SCP Extensions", true},
1423 {"Processor Aggregator Device", true},
1426 void __init acpi_osi_setup(char *str)
1428 struct osi_setup_entry *osi;
1432 if (!acpi_gbl_create_osi_method)
1435 if (str == NULL || *str == '\0') {
1436 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1437 acpi_gbl_create_osi_method = FALSE;
1444 osi_linux.default_disabling = 1;
1446 } else if (*str == '*') {
1447 acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
1448 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1449 osi = &osi_setup_entries[i];
1450 osi->enable = false;
1457 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1458 osi = &osi_setup_entries[i];
1459 if (!strcmp(osi->string, str)) {
1460 osi->enable = enable;
1462 } else if (osi->string[0] == '\0') {
1463 osi->enable = enable;
1464 strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
1470 static void __init set_osi_linux(unsigned int enable)
1472 if (osi_linux.enable != enable)
1473 osi_linux.enable = enable;
1475 if (osi_linux.enable)
1476 acpi_osi_setup("Linux");
1478 acpi_osi_setup("!Linux");
1483 static void __init acpi_cmdline_osi_linux(unsigned int enable)
1485 osi_linux.cmdline = 1; /* cmdline set the default and override DMI */
1487 set_osi_linux(enable);
1492 void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1494 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
1499 osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
1500 set_osi_linux(enable);
1506 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
1508 * empty string disables _OSI
1509 * string starting with '!' disables that string
1510 * otherwise string is added to list, augmenting built-in strings
1512 static void __init acpi_osi_setup_late(void)
1514 struct osi_setup_entry *osi;
1519 if (osi_linux.default_disabling) {
1520 status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
1522 if (ACPI_SUCCESS(status))
1523 printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
1526 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1527 osi = &osi_setup_entries[i];
1533 status = acpi_install_interface(str);
1535 if (ACPI_SUCCESS(status))
1536 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
1538 status = acpi_remove_interface(str);
1540 if (ACPI_SUCCESS(status))
1541 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
1546 static int __init osi_setup(char *str)
1548 if (str && !strcmp("Linux", str))
1549 acpi_cmdline_osi_linux(1);
1550 else if (str && !strcmp("!Linux", str))
1551 acpi_cmdline_osi_linux(0);
1553 acpi_osi_setup(str);
1558 __setup("acpi_osi=", osi_setup);
1561 * Disable the auto-serialization of named objects creation methods.
1563 * This feature is enabled by default. It marks the AML control methods
1564 * that contain the opcodes to create named objects as "Serialized".
1566 static int __init acpi_no_auto_serialize_setup(char *str)
1568 acpi_gbl_auto_serialize_methods = FALSE;
1569 pr_info("ACPI: auto-serialization disabled\n");
1574 __setup("acpi_no_auto_serialize", acpi_no_auto_serialize_setup);
1576 /* Check of resource interference between native drivers and ACPI
1577 * OperationRegions (SystemIO and System Memory only).
1578 * IO ports and memory declared in ACPI might be used by the ACPI subsystem
1579 * in arbitrary AML code and can interfere with legacy drivers.
1580 * acpi_enforce_resources= can be set to:
1582 * - strict (default) (2)
1583 * -> further driver trying to access the resources will not load
1585 * -> further driver trying to access the resources will load, but you
1586 * get a system message that something might go wrong...
1589 * -> ACPI Operation Region resources will not be registered
1592 #define ENFORCE_RESOURCES_STRICT 2
1593 #define ENFORCE_RESOURCES_LAX 1
1594 #define ENFORCE_RESOURCES_NO 0
1596 static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
1598 static int __init acpi_enforce_resources_setup(char *str)
1600 if (str == NULL || *str == '\0')
1603 if (!strcmp("strict", str))
1604 acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
1605 else if (!strcmp("lax", str))
1606 acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
1607 else if (!strcmp("no", str))
1608 acpi_enforce_resources = ENFORCE_RESOURCES_NO;
1613 __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
1615 /* Check for resource conflicts between ACPI OperationRegions and native
1617 int acpi_check_resource_conflict(const struct resource *res)
1619 acpi_adr_space_type space_id;
1624 if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
1626 if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM))
1629 if (res->flags & IORESOURCE_IO)
1630 space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1632 space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
1634 length = resource_size(res);
1635 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO)
1637 clash = acpi_check_address_range(space_id, res->start, length, warn);
1640 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
1641 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
1642 printk(KERN_NOTICE "ACPI: This conflict may"
1643 " cause random problems and system"
1645 printk(KERN_INFO "ACPI: If an ACPI driver is available"
1646 " for this device, you should use it instead of"
1647 " the native driver\n");
1649 if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT)
1654 EXPORT_SYMBOL(acpi_check_resource_conflict);
1656 int acpi_check_region(resource_size_t start, resource_size_t n,
1659 struct resource res = {
1661 .end = start + n - 1,
1663 .flags = IORESOURCE_IO,
1666 return acpi_check_resource_conflict(&res);
1668 EXPORT_SYMBOL(acpi_check_region);
1671 * Let drivers know whether the resource checks are effective
1673 int acpi_resources_are_enforced(void)
1675 return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT;
1677 EXPORT_SYMBOL(acpi_resources_are_enforced);
1679 bool acpi_osi_is_win8(void)
1681 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
1683 EXPORT_SYMBOL(acpi_osi_is_win8);
1686 * Deallocate the memory for a spinlock.
1688 void acpi_os_delete_lock(acpi_spinlock handle)
1694 * Acquire a spinlock.
1696 * handle is a pointer to the spinlock_t.
1699 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1701 acpi_cpu_flags flags;
1702 spin_lock_irqsave(lockp, flags);
1707 * Release a spinlock. See above.
1710 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1712 spin_unlock_irqrestore(lockp, flags);
1715 #ifndef ACPI_USE_LOCAL_CACHE
1717 /*******************************************************************************
1719 * FUNCTION: acpi_os_create_cache
1721 * PARAMETERS: name - Ascii name for the cache
1722 * size - Size of each cached object
1723 * depth - Maximum depth of the cache (in objects) <ignored>
1724 * cache - Where the new cache object is returned
1728 * DESCRIPTION: Create a cache object
1730 ******************************************************************************/
1733 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1735 *cache = kmem_cache_create(name, size, 0, 0, NULL);
1742 /*******************************************************************************
1744 * FUNCTION: acpi_os_purge_cache
1746 * PARAMETERS: Cache - Handle to cache object
1750 * DESCRIPTION: Free all objects within the requested cache.
1752 ******************************************************************************/
1754 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1756 kmem_cache_shrink(cache);
1760 /*******************************************************************************
1762 * FUNCTION: acpi_os_delete_cache
1764 * PARAMETERS: Cache - Handle to cache object
1768 * DESCRIPTION: Free all objects within the requested cache and delete the
1771 ******************************************************************************/
1773 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1775 kmem_cache_destroy(cache);
1779 /*******************************************************************************
1781 * FUNCTION: acpi_os_release_object
1783 * PARAMETERS: Cache - Handle to cache object
1784 * Object - The object to be released
1788 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1789 * the object is deleted.
1791 ******************************************************************************/
1793 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1795 kmem_cache_free(cache, object);
1800 static int __init acpi_no_static_ssdt_setup(char *s)
1802 acpi_gbl_disable_ssdt_table_install = TRUE;
1803 pr_info("ACPI: static SSDT installation disabled\n");
1808 early_param("acpi_no_static_ssdt", acpi_no_static_ssdt_setup);
1810 static int __init acpi_disable_return_repair(char *s)
1812 printk(KERN_NOTICE PREFIX
1813 "ACPI: Predefined validation mechanism disabled\n");
1814 acpi_gbl_disable_auto_repair = TRUE;
1819 __setup("acpica_no_return_repair", acpi_disable_return_repair);
1821 acpi_status __init acpi_os_initialize(void)
1823 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
1824 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
1825 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block);
1826 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block);
1827 if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) {
1829 * Use acpi_os_map_generic_address to pre-map the reset
1830 * register if it's in system memory.
1834 rv = acpi_os_map_generic_address(&acpi_gbl_FADT.reset_register);
1835 pr_debug(PREFIX "%s: map reset_reg status %d\n", __func__, rv);
1837 acpi_os_initialized = true;
1842 acpi_status __init acpi_os_initialize1(void)
1844 kacpid_wq = alloc_workqueue("kacpid", 0, 1);
1845 kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
1846 kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
1848 BUG_ON(!kacpi_notify_wq);
1849 BUG_ON(!kacpi_hotplug_wq);
1850 acpi_install_interface_handler(acpi_osi_handler);
1851 acpi_osi_setup_late();
1855 acpi_status acpi_os_terminate(void)
1857 if (acpi_irq_handler) {
1858 acpi_os_remove_interrupt_handler(acpi_gbl_FADT.sci_interrupt,
1862 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe1_block);
1863 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block);
1864 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
1865 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
1866 if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)
1867 acpi_os_unmap_generic_address(&acpi_gbl_FADT.reset_register);
1869 destroy_workqueue(kacpid_wq);
1870 destroy_workqueue(kacpi_notify_wq);
1871 destroy_workqueue(kacpi_hotplug_wq);
1876 acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
1880 if (__acpi_os_prepare_sleep)
1881 rc = __acpi_os_prepare_sleep(sleep_state,
1882 pm1a_control, pm1b_control);
1886 return AE_CTRL_SKIP;
1891 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
1892 u32 pm1a_ctrl, u32 pm1b_ctrl))
1894 __acpi_os_prepare_sleep = func;
1897 acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
1901 if (__acpi_os_prepare_extended_sleep)
1902 rc = __acpi_os_prepare_extended_sleep(sleep_state,
1907 return AE_CTRL_SKIP;
1912 void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
1913 u32 val_a, u32 val_b))
1915 __acpi_os_prepare_extended_sleep = func;