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>
49 #define _COMPONENT ACPI_OS_SERVICES
50 ACPI_MODULE_NAME("osl");
53 acpi_osd_exec_callback function;
55 struct work_struct work;
58 #ifdef CONFIG_ACPI_CUSTOM_DSDT
59 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
62 #ifdef ENABLE_DEBUGGER
63 #include <linux/kdb.h>
65 /* stuff for debugger support */
67 EXPORT_SYMBOL(acpi_in_debugger);
69 extern char line_buf[80];
70 #endif /*ENABLE_DEBUGGER */
72 static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
74 static int (*__acpi_os_prepare_extended_sleep)(u8 sleep_state, u32 val_a,
77 static acpi_osd_handler acpi_irq_handler;
78 static void *acpi_irq_context;
79 static struct workqueue_struct *kacpid_wq;
80 static struct workqueue_struct *kacpi_notify_wq;
81 static struct workqueue_struct *kacpi_hotplug_wq;
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 acpi_reserve_region(addr, length, gas->space_id, 0, desc);
177 static void __init acpi_reserve_resources(void)
179 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
180 "ACPI PM1a_EVT_BLK");
182 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
183 "ACPI PM1b_EVT_BLK");
185 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
186 "ACPI PM1a_CNT_BLK");
188 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
189 "ACPI PM1b_CNT_BLK");
191 if (acpi_gbl_FADT.pm_timer_length == 4)
192 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
194 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
197 /* Length of GPE blocks must be a non-negative multiple of 2 */
199 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
200 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
201 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
203 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
204 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
205 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
208 void acpi_os_printf(const char *fmt, ...)
212 acpi_os_vprintf(fmt, args);
216 void acpi_os_vprintf(const char *fmt, va_list args)
218 static char buffer[512];
220 vsprintf(buffer, fmt, args);
222 #ifdef ENABLE_DEBUGGER
223 if (acpi_in_debugger) {
224 kdb_printf("%s", buffer);
226 printk(KERN_CONT "%s", buffer);
229 printk(KERN_CONT "%s", buffer);
234 static unsigned long acpi_rsdp;
235 static int __init setup_acpi_rsdp(char *arg)
237 if (kstrtoul(arg, 16, &acpi_rsdp))
241 early_param("acpi_rsdp", setup_acpi_rsdp);
244 acpi_physical_address __init acpi_os_get_root_pointer(void)
251 if (efi_enabled(EFI_CONFIG_TABLES)) {
252 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
254 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
257 printk(KERN_ERR PREFIX
258 "System description tables not found\n");
261 } else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) {
262 acpi_physical_address pa = 0;
264 acpi_find_root_pointer(&pa);
271 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
272 static struct acpi_ioremap *
273 acpi_map_lookup(acpi_physical_address phys, acpi_size size)
275 struct acpi_ioremap *map;
277 list_for_each_entry_rcu(map, &acpi_ioremaps, list)
278 if (map->phys <= phys &&
279 phys + size <= map->phys + map->size)
285 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
286 static void __iomem *
287 acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size)
289 struct acpi_ioremap *map;
291 map = acpi_map_lookup(phys, size);
293 return map->virt + (phys - map->phys);
298 void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size)
300 struct acpi_ioremap *map;
301 void __iomem *virt = NULL;
303 mutex_lock(&acpi_ioremap_lock);
304 map = acpi_map_lookup(phys, size);
306 virt = map->virt + (phys - map->phys);
309 mutex_unlock(&acpi_ioremap_lock);
312 EXPORT_SYMBOL_GPL(acpi_os_get_iomem);
314 /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
315 static struct acpi_ioremap *
316 acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
318 struct acpi_ioremap *map;
320 list_for_each_entry_rcu(map, &acpi_ioremaps, list)
321 if (map->virt <= virt &&
322 virt + size <= map->virt + map->size)
328 #if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
329 /* ioremap will take care of cache attributes */
330 #define should_use_kmap(pfn) 0
332 #define should_use_kmap(pfn) page_is_ram(pfn)
335 static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
339 pfn = pg_off >> PAGE_SHIFT;
340 if (should_use_kmap(pfn)) {
341 if (pg_sz > PAGE_SIZE)
343 return (void __iomem __force *)kmap(pfn_to_page(pfn));
345 return acpi_os_ioremap(pg_off, pg_sz);
348 static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
352 pfn = pg_off >> PAGE_SHIFT;
353 if (should_use_kmap(pfn))
354 kunmap(pfn_to_page(pfn));
359 void __iomem *__init_refok
360 acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
362 struct acpi_ioremap *map;
364 acpi_physical_address pg_off;
367 if (phys > ULONG_MAX) {
368 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
372 if (!acpi_gbl_permanent_mmap)
373 return __acpi_map_table((unsigned long)phys, size);
375 mutex_lock(&acpi_ioremap_lock);
376 /* Check if there's a suitable mapping already. */
377 map = acpi_map_lookup(phys, size);
383 map = kzalloc(sizeof(*map), GFP_KERNEL);
385 mutex_unlock(&acpi_ioremap_lock);
389 pg_off = round_down(phys, PAGE_SIZE);
390 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
391 virt = acpi_map(pg_off, pg_sz);
393 mutex_unlock(&acpi_ioremap_lock);
398 INIT_LIST_HEAD(&map->list);
404 list_add_tail_rcu(&map->list, &acpi_ioremaps);
407 mutex_unlock(&acpi_ioremap_lock);
408 return map->virt + (phys - map->phys);
410 EXPORT_SYMBOL_GPL(acpi_os_map_iomem);
413 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
415 return (void *)acpi_os_map_iomem(phys, size);
417 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
419 static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
421 if (!--map->refcount)
422 list_del_rcu(&map->list);
425 static void acpi_os_map_cleanup(struct acpi_ioremap *map)
427 if (!map->refcount) {
428 synchronize_rcu_expedited();
429 acpi_unmap(map->phys, map->virt);
434 void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
436 struct acpi_ioremap *map;
438 if (!acpi_gbl_permanent_mmap) {
439 __acpi_unmap_table(virt, size);
443 mutex_lock(&acpi_ioremap_lock);
444 map = acpi_map_lookup_virt(virt, size);
446 mutex_unlock(&acpi_ioremap_lock);
447 WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
450 acpi_os_drop_map_ref(map);
451 mutex_unlock(&acpi_ioremap_lock);
453 acpi_os_map_cleanup(map);
455 EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
457 void __ref acpi_os_unmap_memory(void *virt, acpi_size size)
459 return acpi_os_unmap_iomem((void __iomem *)virt, size);
461 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
463 void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
465 if (!acpi_gbl_permanent_mmap)
466 __acpi_unmap_table(virt, size);
469 int acpi_os_map_generic_address(struct acpi_generic_address *gas)
474 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
477 /* Handle possible alignment issues */
478 memcpy(&addr, &gas->address, sizeof(addr));
479 if (!addr || !gas->bit_width)
482 virt = acpi_os_map_iomem(addr, gas->bit_width / 8);
488 EXPORT_SYMBOL(acpi_os_map_generic_address);
490 void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
493 struct acpi_ioremap *map;
495 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
498 /* Handle possible alignment issues */
499 memcpy(&addr, &gas->address, sizeof(addr));
500 if (!addr || !gas->bit_width)
503 mutex_lock(&acpi_ioremap_lock);
504 map = acpi_map_lookup(addr, gas->bit_width / 8);
506 mutex_unlock(&acpi_ioremap_lock);
509 acpi_os_drop_map_ref(map);
510 mutex_unlock(&acpi_ioremap_lock);
512 acpi_os_map_cleanup(map);
514 EXPORT_SYMBOL(acpi_os_unmap_generic_address);
516 #ifdef ACPI_FUTURE_USAGE
518 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
521 return AE_BAD_PARAMETER;
523 *phys = virt_to_phys(virt);
529 #ifdef CONFIG_ACPI_REV_OVERRIDE_POSSIBLE
530 static bool acpi_rev_override;
532 int __init acpi_rev_override_setup(char *str)
534 acpi_rev_override = true;
537 __setup("acpi_rev_override", acpi_rev_override_setup);
539 #define acpi_rev_override false
542 #define ACPI_MAX_OVERRIDE_LEN 100
544 static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN];
547 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
550 if (!init_val || !new_val)
551 return AE_BAD_PARAMETER;
554 if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
555 printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
557 *new_val = acpi_os_name;
560 if (!memcmp(init_val->name, "_REV", 4) && acpi_rev_override) {
561 printk(KERN_INFO PREFIX "Overriding _REV return value to 5\n");
562 *new_val = (char *)5;
568 #ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
569 #include <linux/earlycpio.h>
570 #include <linux/memblock.h>
572 static u64 acpi_tables_addr;
573 static int all_tables_size;
575 /* Copied from acpica/tbutils.c:acpi_tb_checksum() */
576 static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
579 u8 *end = buffer + length;
582 sum = (u8) (sum + *(buffer++));
586 /* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
587 static const char * const table_sigs[] = {
588 ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ,
589 ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT,
590 ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF,
591 ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET,
592 ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI,
593 ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA,
594 ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT,
595 ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT,
596 ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL };
598 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
600 #define ACPI_OVERRIDE_TABLES 64
601 static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];
603 #define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT)
605 void __init acpi_initrd_override(void *data, size_t size)
607 int sig, no, table_nr = 0, total_offset = 0;
609 struct acpi_table_header *table;
610 char cpio_path[32] = "kernel/firmware/acpi/";
611 struct cpio_data file;
613 if (data == NULL || size == 0)
616 for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
617 file = find_cpio_data(cpio_path, data, size, &offset);
624 if (file.size < sizeof(struct acpi_table_header)) {
625 pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n",
626 cpio_path, file.name);
632 for (sig = 0; table_sigs[sig]; sig++)
633 if (!memcmp(table->signature, table_sigs[sig], 4))
636 if (!table_sigs[sig]) {
637 pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n",
638 cpio_path, file.name);
641 if (file.size != table->length) {
642 pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n",
643 cpio_path, file.name);
646 if (acpi_table_checksum(file.data, table->length)) {
647 pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n",
648 cpio_path, file.name);
652 pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n",
653 table->signature, cpio_path, file.name, table->length);
655 all_tables_size += table->length;
656 acpi_initrd_files[table_nr].data = file.data;
657 acpi_initrd_files[table_nr].size = file.size;
664 memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT,
665 all_tables_size, PAGE_SIZE);
666 if (!acpi_tables_addr) {
671 * Only calling e820_add_reserve does not work and the
672 * tables are invalid (memory got used) later.
673 * memblock_reserve works as expected and the tables won't get modified.
674 * But it's not enough on X86 because ioremap will
675 * complain later (used by acpi_os_map_memory) that the pages
676 * that should get mapped are not marked "reserved".
677 * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
680 memblock_reserve(acpi_tables_addr, all_tables_size);
681 arch_reserve_mem_area(acpi_tables_addr, all_tables_size);
684 * early_ioremap only can remap 256k one time. If we map all
685 * tables one time, we will hit the limit. Need to map chunks
686 * one by one during copying the same as that in relocate_initrd().
688 for (no = 0; no < table_nr; no++) {
689 unsigned char *src_p = acpi_initrd_files[no].data;
690 phys_addr_t size = acpi_initrd_files[no].size;
691 phys_addr_t dest_addr = acpi_tables_addr + total_offset;
692 phys_addr_t slop, clen;
695 total_offset += size;
698 slop = dest_addr & ~PAGE_MASK;
700 if (clen > MAP_CHUNK_SIZE - slop)
701 clen = MAP_CHUNK_SIZE - slop;
702 dest_p = early_ioremap(dest_addr & PAGE_MASK,
704 memcpy(dest_p + slop, src_p, clen);
705 early_iounmap(dest_p, clen + slop);
712 #endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */
714 static void acpi_table_taint(struct acpi_table_header *table)
717 "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
718 table->signature, table->oem_table_id);
719 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
724 acpi_os_table_override(struct acpi_table_header * existing_table,
725 struct acpi_table_header ** new_table)
727 if (!existing_table || !new_table)
728 return AE_BAD_PARAMETER;
732 #ifdef CONFIG_ACPI_CUSTOM_DSDT
733 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
734 *new_table = (struct acpi_table_header *)AmlCode;
736 if (*new_table != NULL)
737 acpi_table_taint(existing_table);
742 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
743 acpi_physical_address *address,
746 #ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
751 int table_offset = 0;
752 struct acpi_table_header *table;
757 if (!acpi_tables_addr)
761 if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
766 table = acpi_os_map_memory(acpi_tables_addr + table_offset,
769 if (table_offset + table->length > all_tables_size) {
770 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
775 table_offset += table->length;
777 if (memcmp(existing_table->signature, table->signature, 4)) {
778 acpi_os_unmap_memory(table,
783 /* Only override tables with matching oem id */
784 if (memcmp(table->oem_table_id, existing_table->oem_table_id,
785 ACPI_OEM_TABLE_ID_SIZE)) {
786 acpi_os_unmap_memory(table,
791 table_offset -= table->length;
792 *table_length = table->length;
793 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
794 *address = acpi_tables_addr + table_offset;
796 } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
799 acpi_table_taint(existing_table);
804 static irqreturn_t acpi_irq(int irq, void *dev_id)
808 handled = (*acpi_irq_handler) (acpi_irq_context);
814 acpi_irq_not_handled++;
820 acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
825 acpi_irq_stats_init();
828 * ACPI interrupts different from the SCI in our copy of the FADT are
831 if (gsi != acpi_gbl_FADT.sci_interrupt)
832 return AE_BAD_PARAMETER;
834 if (acpi_irq_handler)
835 return AE_ALREADY_ACQUIRED;
837 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
838 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
843 acpi_irq_handler = handler;
844 acpi_irq_context = context;
845 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
846 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
847 acpi_irq_handler = NULL;
848 return AE_NOT_ACQUIRED;
854 acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
856 if (irq != acpi_gbl_FADT.sci_interrupt)
857 return AE_BAD_PARAMETER;
859 free_irq(irq, acpi_irq);
860 acpi_irq_handler = NULL;
866 * Running in interpreter thread context, safe to sleep
869 void acpi_os_sleep(u64 ms)
874 void acpi_os_stall(u32 us)
882 touch_nmi_watchdog();
888 * Support ACPI 3.0 AML Timer operand
889 * Returns 64-bit free-running, monotonically increasing timer
890 * with 100ns granularity
892 u64 acpi_os_get_timer(void)
894 u64 time_ns = ktime_to_ns(ktime_get());
895 do_div(time_ns, 100);
899 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
908 *(u8 *) value = inb(port);
909 } else if (width <= 16) {
910 *(u16 *) value = inw(port);
911 } else if (width <= 32) {
912 *(u32 *) value = inl(port);
920 EXPORT_SYMBOL(acpi_os_read_port);
922 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
926 } else if (width <= 16) {
928 } else if (width <= 32) {
937 EXPORT_SYMBOL(acpi_os_write_port);
940 static inline u64 read64(const volatile void __iomem *addr)
945 static inline u64 read64(const volatile void __iomem *addr)
950 return l | (h << 32);
955 acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
957 void __iomem *virt_addr;
958 unsigned int size = width / 8;
963 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
966 virt_addr = acpi_os_ioremap(phys_addr, size);
968 return AE_BAD_ADDRESS;
977 *(u8 *) value = readb(virt_addr);
980 *(u16 *) value = readw(virt_addr);
983 *(u32 *) value = readl(virt_addr);
986 *(u64 *) value = read64(virt_addr);
1001 static inline void write64(u64 val, volatile void __iomem *addr)
1006 static inline void write64(u64 val, volatile void __iomem *addr)
1009 writel(val>>32, addr+4);
1014 acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
1016 void __iomem *virt_addr;
1017 unsigned int size = width / 8;
1021 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
1024 virt_addr = acpi_os_ioremap(phys_addr, size);
1026 return AE_BAD_ADDRESS;
1032 writeb(value, virt_addr);
1035 writew(value, virt_addr);
1038 writel(value, virt_addr);
1041 write64(value, virt_addr);
1056 acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
1057 u64 *value, u32 width)
1063 return AE_BAD_PARAMETER;
1079 result = raw_pci_read(pci_id->segment, pci_id->bus,
1080 PCI_DEVFN(pci_id->device, pci_id->function),
1081 reg, size, &value32);
1084 return (result ? AE_ERROR : AE_OK);
1088 acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
1089 u64 value, u32 width)
1107 result = raw_pci_write(pci_id->segment, pci_id->bus,
1108 PCI_DEVFN(pci_id->device, pci_id->function),
1111 return (result ? AE_ERROR : AE_OK);
1114 static void acpi_os_execute_deferred(struct work_struct *work)
1116 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
1118 dpc->function(dpc->context);
1122 /*******************************************************************************
1124 * FUNCTION: acpi_os_execute
1126 * PARAMETERS: Type - Type of the callback
1127 * Function - Function to be executed
1128 * Context - Function parameters
1132 * DESCRIPTION: Depending on type, either queues function for deferred execution or
1133 * immediately executes function on a separate thread.
1135 ******************************************************************************/
1137 acpi_status acpi_os_execute(acpi_execute_type type,
1138 acpi_osd_exec_callback function, void *context)
1140 acpi_status status = AE_OK;
1141 struct acpi_os_dpc *dpc;
1142 struct workqueue_struct *queue;
1144 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1145 "Scheduling function [%p(%p)] for deferred execution.\n",
1146 function, context));
1149 * Allocate/initialize DPC structure. Note that this memory will be
1150 * freed by the callee. The kernel handles the work_struct list in a
1151 * way that allows us to also free its memory inside the callee.
1152 * Because we may want to schedule several tasks with different
1153 * parameters we can't use the approach some kernel code uses of
1154 * having a static work_struct.
1157 dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
1159 return AE_NO_MEMORY;
1161 dpc->function = function;
1162 dpc->context = context;
1165 * To prevent lockdep from complaining unnecessarily, make sure that
1166 * there is a different static lockdep key for each workqueue by using
1167 * INIT_WORK() for each of them separately.
1169 if (type == OSL_NOTIFY_HANDLER) {
1170 queue = kacpi_notify_wq;
1171 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1174 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1178 * On some machines, a software-initiated SMI causes corruption unless
1179 * the SMI runs on CPU 0. An SMI can be initiated by any AML, but
1180 * typically it's done in GPE-related methods that are run via
1181 * workqueues, so we can avoid the known corruption cases by always
1182 * queueing on CPU 0.
1184 ret = queue_work_on(0, queue, &dpc->work);
1187 printk(KERN_ERR PREFIX
1188 "Call to queue_work() failed.\n");
1194 EXPORT_SYMBOL(acpi_os_execute);
1196 void acpi_os_wait_events_complete(void)
1199 * Make sure the GPE handler or the fixed event handler is not used
1200 * on another CPU after removal.
1202 if (acpi_irq_handler)
1203 synchronize_hardirq(acpi_gbl_FADT.sci_interrupt);
1204 flush_workqueue(kacpid_wq);
1205 flush_workqueue(kacpi_notify_wq);
1208 struct acpi_hp_work {
1209 struct work_struct work;
1210 struct acpi_device *adev;
1214 static void acpi_hotplug_work_fn(struct work_struct *work)
1216 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
1218 acpi_os_wait_events_complete();
1219 acpi_device_hotplug(hpw->adev, hpw->src);
1223 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src)
1225 struct acpi_hp_work *hpw;
1227 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1228 "Scheduling hotplug event (%p, %u) for deferred execution.\n",
1231 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
1233 return AE_NO_MEMORY;
1235 INIT_WORK(&hpw->work, acpi_hotplug_work_fn);
1239 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because
1240 * the hotplug code may call driver .remove() functions, which may
1241 * invoke flush_scheduled_work()/acpi_os_wait_events_complete() to flush
1244 if (!queue_work(kacpi_hotplug_wq, &hpw->work)) {
1251 bool acpi_queue_hotplug_work(struct work_struct *work)
1253 return queue_work(kacpi_hotplug_wq, work);
1257 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
1259 struct semaphore *sem = NULL;
1261 sem = acpi_os_allocate_zeroed(sizeof(struct semaphore));
1263 return AE_NO_MEMORY;
1265 sema_init(sem, initial_units);
1267 *handle = (acpi_handle *) sem;
1269 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
1270 *handle, initial_units));
1276 * TODO: A better way to delete semaphores? Linux doesn't have a
1277 * 'delete_semaphore()' function -- may result in an invalid
1278 * pointer dereference for non-synchronized consumers. Should
1279 * we at least check for blocked threads and signal/cancel them?
1282 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
1284 struct semaphore *sem = (struct semaphore *)handle;
1287 return AE_BAD_PARAMETER;
1289 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
1291 BUG_ON(!list_empty(&sem->wait_list));
1299 * TODO: Support for units > 1?
1301 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
1303 acpi_status status = AE_OK;
1304 struct semaphore *sem = (struct semaphore *)handle;
1308 if (!sem || (units < 1))
1309 return AE_BAD_PARAMETER;
1314 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
1315 handle, units, timeout));
1317 if (timeout == ACPI_WAIT_FOREVER)
1318 jiffies = MAX_SCHEDULE_TIMEOUT;
1320 jiffies = msecs_to_jiffies(timeout);
1322 ret = down_timeout(sem, jiffies);
1326 if (ACPI_FAILURE(status)) {
1327 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
1328 "Failed to acquire semaphore[%p|%d|%d], %s",
1329 handle, units, timeout,
1330 acpi_format_exception(status)));
1332 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
1333 "Acquired semaphore[%p|%d|%d]", handle,
1341 * TODO: Support for units > 1?
1343 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
1345 struct semaphore *sem = (struct semaphore *)handle;
1347 if (!sem || (units < 1))
1348 return AE_BAD_PARAMETER;
1353 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
1361 #ifdef ACPI_FUTURE_USAGE
1362 u32 acpi_os_get_line(char *buffer)
1365 #ifdef ENABLE_DEBUGGER
1366 if (acpi_in_debugger) {
1369 kdb_read(buffer, sizeof(line_buf));
1371 /* remove the CR kdb includes */
1372 chars = strlen(buffer) - 1;
1373 buffer[chars] = '\0';
1379 #endif /* ACPI_FUTURE_USAGE */
1381 acpi_status acpi_os_signal(u32 function, void *info)
1384 case ACPI_SIGNAL_FATAL:
1385 printk(KERN_ERR PREFIX "Fatal opcode executed\n");
1387 case ACPI_SIGNAL_BREAKPOINT:
1390 * ACPI spec. says to treat it as a NOP unless
1391 * you are debugging. So if/when we integrate
1392 * AML debugger into the kernel debugger its
1393 * hook will go here. But until then it is
1394 * not useful to print anything on breakpoints.
1404 static int __init acpi_os_name_setup(char *str)
1406 char *p = acpi_os_name;
1407 int count = ACPI_MAX_OVERRIDE_LEN - 1;
1412 for (; count-- && *str; str++) {
1413 if (isalnum(*str) || *str == ' ' || *str == ':')
1415 else if (*str == '\'' || *str == '"')
1426 __setup("acpi_os_name=", acpi_os_name_setup);
1428 #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
1429 #define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */
1431 struct osi_setup_entry {
1432 char string[OSI_STRING_LENGTH_MAX];
1436 static struct osi_setup_entry
1437 osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
1438 {"Module Device", true},
1439 {"Processor Device", true},
1440 {"3.0 _SCP Extensions", true},
1441 {"Processor Aggregator Device", true},
1444 void __init acpi_osi_setup(char *str)
1446 struct osi_setup_entry *osi;
1450 if (!acpi_gbl_create_osi_method)
1453 if (str == NULL || *str == '\0') {
1454 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1455 acpi_gbl_create_osi_method = FALSE;
1462 osi_linux.default_disabling = 1;
1464 } else if (*str == '*') {
1465 acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
1466 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1467 osi = &osi_setup_entries[i];
1468 osi->enable = false;
1475 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1476 osi = &osi_setup_entries[i];
1477 if (!strcmp(osi->string, str)) {
1478 osi->enable = enable;
1480 } else if (osi->string[0] == '\0') {
1481 osi->enable = enable;
1482 strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
1488 static void __init set_osi_linux(unsigned int enable)
1490 if (osi_linux.enable != enable)
1491 osi_linux.enable = enable;
1493 if (osi_linux.enable)
1494 acpi_osi_setup("Linux");
1496 acpi_osi_setup("!Linux");
1501 static void __init acpi_cmdline_osi_linux(unsigned int enable)
1503 osi_linux.cmdline = 1; /* cmdline set the default and override DMI */
1505 set_osi_linux(enable);
1510 void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1512 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
1517 osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
1518 set_osi_linux(enable);
1524 * Modify the list of "OS Interfaces" reported to BIOS via _OSI
1526 * empty string disables _OSI
1527 * string starting with '!' disables that string
1528 * otherwise string is added to list, augmenting built-in strings
1530 static void __init acpi_osi_setup_late(void)
1532 struct osi_setup_entry *osi;
1537 if (osi_linux.default_disabling) {
1538 status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
1540 if (ACPI_SUCCESS(status))
1541 printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
1544 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1545 osi = &osi_setup_entries[i];
1551 status = acpi_install_interface(str);
1553 if (ACPI_SUCCESS(status))
1554 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
1556 status = acpi_remove_interface(str);
1558 if (ACPI_SUCCESS(status))
1559 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
1564 static int __init osi_setup(char *str)
1566 if (str && !strcmp("Linux", str))
1567 acpi_cmdline_osi_linux(1);
1568 else if (str && !strcmp("!Linux", str))
1569 acpi_cmdline_osi_linux(0);
1571 acpi_osi_setup(str);
1576 __setup("acpi_osi=", osi_setup);
1579 * Disable the auto-serialization of named objects creation methods.
1581 * This feature is enabled by default. It marks the AML control methods
1582 * that contain the opcodes to create named objects as "Serialized".
1584 static int __init acpi_no_auto_serialize_setup(char *str)
1586 acpi_gbl_auto_serialize_methods = FALSE;
1587 pr_info("ACPI: auto-serialization disabled\n");
1592 __setup("acpi_no_auto_serialize", acpi_no_auto_serialize_setup);
1594 /* Check of resource interference between native drivers and ACPI
1595 * OperationRegions (SystemIO and System Memory only).
1596 * IO ports and memory declared in ACPI might be used by the ACPI subsystem
1597 * in arbitrary AML code and can interfere with legacy drivers.
1598 * acpi_enforce_resources= can be set to:
1600 * - strict (default) (2)
1601 * -> further driver trying to access the resources will not load
1603 * -> further driver trying to access the resources will load, but you
1604 * get a system message that something might go wrong...
1607 * -> ACPI Operation Region resources will not be registered
1610 #define ENFORCE_RESOURCES_STRICT 2
1611 #define ENFORCE_RESOURCES_LAX 1
1612 #define ENFORCE_RESOURCES_NO 0
1614 static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
1616 static int __init acpi_enforce_resources_setup(char *str)
1618 if (str == NULL || *str == '\0')
1621 if (!strcmp("strict", str))
1622 acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
1623 else if (!strcmp("lax", str))
1624 acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
1625 else if (!strcmp("no", str))
1626 acpi_enforce_resources = ENFORCE_RESOURCES_NO;
1631 __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
1633 /* Check for resource conflicts between ACPI OperationRegions and native
1635 int acpi_check_resource_conflict(const struct resource *res)
1637 acpi_adr_space_type space_id;
1642 if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
1644 if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM))
1647 if (res->flags & IORESOURCE_IO)
1648 space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1650 space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
1652 length = resource_size(res);
1653 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO)
1655 clash = acpi_check_address_range(space_id, res->start, length, warn);
1658 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
1659 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
1660 printk(KERN_NOTICE "ACPI: This conflict may"
1661 " cause random problems and system"
1663 printk(KERN_INFO "ACPI: If an ACPI driver is available"
1664 " for this device, you should use it instead of"
1665 " the native driver\n");
1667 if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT)
1672 EXPORT_SYMBOL(acpi_check_resource_conflict);
1674 int acpi_check_region(resource_size_t start, resource_size_t n,
1677 struct resource res = {
1679 .end = start + n - 1,
1681 .flags = IORESOURCE_IO,
1684 return acpi_check_resource_conflict(&res);
1686 EXPORT_SYMBOL(acpi_check_region);
1689 * Let drivers know whether the resource checks are effective
1691 int acpi_resources_are_enforced(void)
1693 return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT;
1695 EXPORT_SYMBOL(acpi_resources_are_enforced);
1697 bool acpi_osi_is_win8(void)
1699 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
1701 EXPORT_SYMBOL(acpi_osi_is_win8);
1704 * Deallocate the memory for a spinlock.
1706 void acpi_os_delete_lock(acpi_spinlock handle)
1712 * Acquire a spinlock.
1714 * handle is a pointer to the spinlock_t.
1717 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1719 acpi_cpu_flags flags;
1720 spin_lock_irqsave(lockp, flags);
1725 * Release a spinlock. See above.
1728 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1730 spin_unlock_irqrestore(lockp, flags);
1733 #ifndef ACPI_USE_LOCAL_CACHE
1735 /*******************************************************************************
1737 * FUNCTION: acpi_os_create_cache
1739 * PARAMETERS: name - Ascii name for the cache
1740 * size - Size of each cached object
1741 * depth - Maximum depth of the cache (in objects) <ignored>
1742 * cache - Where the new cache object is returned
1746 * DESCRIPTION: Create a cache object
1748 ******************************************************************************/
1751 acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
1753 *cache = kmem_cache_create(name, size, 0, 0, NULL);
1760 /*******************************************************************************
1762 * FUNCTION: acpi_os_purge_cache
1764 * PARAMETERS: Cache - Handle to cache object
1768 * DESCRIPTION: Free all objects within the requested cache.
1770 ******************************************************************************/
1772 acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1774 kmem_cache_shrink(cache);
1778 /*******************************************************************************
1780 * FUNCTION: acpi_os_delete_cache
1782 * PARAMETERS: Cache - Handle to cache object
1786 * DESCRIPTION: Free all objects within the requested cache and delete the
1789 ******************************************************************************/
1791 acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1793 kmem_cache_destroy(cache);
1797 /*******************************************************************************
1799 * FUNCTION: acpi_os_release_object
1801 * PARAMETERS: Cache - Handle to cache object
1802 * Object - The object to be released
1806 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1807 * the object is deleted.
1809 ******************************************************************************/
1811 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1813 kmem_cache_free(cache, object);
1818 static int __init acpi_no_static_ssdt_setup(char *s)
1820 acpi_gbl_disable_ssdt_table_install = TRUE;
1821 pr_info("ACPI: static SSDT installation disabled\n");
1826 early_param("acpi_no_static_ssdt", acpi_no_static_ssdt_setup);
1828 static int __init acpi_disable_return_repair(char *s)
1830 printk(KERN_NOTICE PREFIX
1831 "ACPI: Predefined validation mechanism disabled\n");
1832 acpi_gbl_disable_auto_repair = TRUE;
1837 __setup("acpica_no_return_repair", acpi_disable_return_repair);
1839 acpi_status __init acpi_os_initialize(void)
1841 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
1842 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
1843 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block);
1844 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block);
1845 if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) {
1847 * Use acpi_os_map_generic_address to pre-map the reset
1848 * register if it's in system memory.
1852 rv = acpi_os_map_generic_address(&acpi_gbl_FADT.reset_register);
1853 pr_debug(PREFIX "%s: map reset_reg status %d\n", __func__, rv);
1859 acpi_status __init acpi_os_initialize1(void)
1861 acpi_reserve_resources();
1862 kacpid_wq = alloc_workqueue("kacpid", 0, 1);
1863 kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
1864 kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
1866 BUG_ON(!kacpi_notify_wq);
1867 BUG_ON(!kacpi_hotplug_wq);
1868 acpi_install_interface_handler(acpi_osi_handler);
1869 acpi_osi_setup_late();
1873 acpi_status acpi_os_terminate(void)
1875 if (acpi_irq_handler) {
1876 acpi_os_remove_interrupt_handler(acpi_gbl_FADT.sci_interrupt,
1880 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe1_block);
1881 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block);
1882 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
1883 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
1884 if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)
1885 acpi_os_unmap_generic_address(&acpi_gbl_FADT.reset_register);
1887 destroy_workqueue(kacpid_wq);
1888 destroy_workqueue(kacpi_notify_wq);
1889 destroy_workqueue(kacpi_hotplug_wq);
1894 acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
1898 if (__acpi_os_prepare_sleep)
1899 rc = __acpi_os_prepare_sleep(sleep_state,
1900 pm1a_control, pm1b_control);
1904 return AE_CTRL_SKIP;
1909 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
1910 u32 pm1a_ctrl, u32 pm1b_ctrl))
1912 __acpi_os_prepare_sleep = func;
1915 acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
1919 if (__acpi_os_prepare_extended_sleep)
1920 rc = __acpi_os_prepare_extended_sleep(sleep_state,
1925 return AE_CTRL_SKIP;
1930 void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
1931 u32 val_a, u32 val_b))
1933 __acpi_os_prepare_extended_sleep = func;