Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * acpi_osl.c - OS-dependent functions ($Revision: 83 $) |
| 3 | * |
| 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> |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 7 | * Copyright (c) 2008 Intel Corporation |
| 8 | * Author: Matthew Wilcox <willy@linux.intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 11 | * |
| 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. |
| 16 | * |
| 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. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | * |
| 28 | */ |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/module.h> |
| 31 | #include <linux/kernel.h> |
| 32 | #include <linux/slab.h> |
| 33 | #include <linux/mm.h> |
| 34 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/interrupt.h> |
| 36 | #include <linux/kmod.h> |
| 37 | #include <linux/delay.h> |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 38 | #include <linux/dmi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/workqueue.h> |
| 40 | #include <linux/nmi.h> |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 41 | #include <linux/acpi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <linux/efi.h> |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 43 | #include <linux/ioport.h> |
| 44 | #include <linux/list.h> |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 45 | #include <linux/jiffies.h> |
| 46 | #include <linux/semaphore.h> |
| 47 | |
| 48 | #include <asm/io.h> |
| 49 | #include <asm/uaccess.h> |
| 50 | |
| 51 | #include <acpi/acpi.h> |
| 52 | #include <acpi/acpi_bus.h> |
| 53 | #include <acpi/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #define _COMPONENT ACPI_OS_SERVICES |
Len Brown | f52fd66 | 2007-02-12 22:42:12 -0500 | [diff] [blame] | 56 | ACPI_MODULE_NAME("osl"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #define PREFIX "ACPI: " |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 58 | struct acpi_os_dpc { |
| 59 | acpi_osd_exec_callback function; |
| 60 | void *context; |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 61 | struct work_struct work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
| 65 | #include CONFIG_ACPI_CUSTOM_DSDT_FILE |
| 66 | #endif |
| 67 | |
| 68 | #ifdef ENABLE_DEBUGGER |
| 69 | #include <linux/kdb.h> |
| 70 | |
| 71 | /* stuff for debugger support */ |
| 72 | int acpi_in_debugger; |
| 73 | EXPORT_SYMBOL(acpi_in_debugger); |
| 74 | |
| 75 | extern char line_buf[80]; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | #endif /*ENABLE_DEBUGGER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | static unsigned int acpi_irq_irq; |
| 79 | static acpi_osd_handler acpi_irq_handler; |
| 80 | static void *acpi_irq_context; |
| 81 | static struct workqueue_struct *kacpid_wq; |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 82 | static struct workqueue_struct *kacpi_notify_wq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 84 | struct acpi_res_list { |
| 85 | resource_size_t start; |
| 86 | resource_size_t end; |
| 87 | acpi_adr_space_type resource_type; /* IO port, System memory, ...*/ |
| 88 | char name[5]; /* only can have a length of 4 chars, make use of this |
| 89 | one instead of res->name, no need to kalloc then */ |
| 90 | struct list_head resource_list; |
| 91 | }; |
| 92 | |
| 93 | static LIST_HEAD(resource_list_head); |
| 94 | static DEFINE_SPINLOCK(acpi_res_lock); |
| 95 | |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 96 | #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ |
| 97 | static char osi_additional_string[OSI_STRING_LENGTH_MAX]; |
| 98 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 99 | /* |
| 100 | * "Ode to _OSI(Linux)" |
| 101 | * |
| 102 | * osi_linux -- Control response to BIOS _OSI(Linux) query. |
| 103 | * |
| 104 | * As Linux evolves, the features that it supports change. |
| 105 | * So an OSI string such as "Linux" is not specific enough |
| 106 | * to be useful across multiple versions of Linux. It |
| 107 | * doesn't identify any particular feature, interface, |
| 108 | * or even any particular version of Linux... |
| 109 | * |
| 110 | * Unfortunately, Linux-2.6.22 and earlier responded "yes" |
| 111 | * to a BIOS _OSI(Linux) query. When |
| 112 | * a reference mobile BIOS started using it, its use |
| 113 | * started to spread to many vendor platforms. |
| 114 | * As it is not supportable, we need to halt that spread. |
| 115 | * |
| 116 | * Today, most BIOS references to _OSI(Linux) are noise -- |
| 117 | * they have no functional effect and are just dead code |
| 118 | * carried over from the reference BIOS. |
| 119 | * |
| 120 | * The next most common case is that _OSI(Linux) harms Linux, |
| 121 | * usually by causing the BIOS to follow paths that are |
| 122 | * not tested during Windows validation. |
| 123 | * |
| 124 | * Finally, there is a short list of platforms |
| 125 | * where OSI(Linux) benefits Linux. |
| 126 | * |
| 127 | * In Linux-2.6.23, OSI(Linux) is first disabled by default. |
| 128 | * DMI is used to disable the dmesg warning about OSI(Linux) |
| 129 | * on platforms where it is known to have no effect. |
| 130 | * But a dmesg warning remains for systems where |
| 131 | * we do not know if OSI(Linux) is good or bad for the system. |
| 132 | * DMI is also used to enable OSI(Linux) for the machines |
| 133 | * that are known to need it. |
| 134 | * |
| 135 | * BIOS writers should NOT query _OSI(Linux) on future systems. |
| 136 | * It will be ignored by default, and to get Linux to |
| 137 | * not ignore it will require a kernel source update to |
| 138 | * add a DMI entry, or a boot-time "acpi_osi=Linux" invocation. |
| 139 | */ |
| 140 | #define OSI_LINUX_ENABLE 0 |
| 141 | |
Adrian Bunk | 1d15d84 | 2008-01-29 00:10:15 +0200 | [diff] [blame] | 142 | static struct osi_linux { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 143 | unsigned int enable:1; |
| 144 | unsigned int dmi:1; |
| 145 | unsigned int cmdline:1; |
| 146 | unsigned int known:1; |
| 147 | } osi_linux = { OSI_LINUX_ENABLE, 0, 0, 0}; |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 148 | |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 149 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
| 150 | unsigned int length, char *desc) |
| 151 | { |
| 152 | struct resource *res; |
| 153 | |
| 154 | if (!addr->address || !length) |
| 155 | return; |
| 156 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 157 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 158 | res = request_region(addr->address, length, desc); |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 159 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 160 | res = request_mem_region(addr->address, length, desc); |
| 161 | } |
| 162 | |
| 163 | static int __init acpi_reserve_resources(void) |
| 164 | { |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 165 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 166 | "ACPI PM1a_EVT_BLK"); |
| 167 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 168 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 169 | "ACPI PM1b_EVT_BLK"); |
| 170 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 171 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 172 | "ACPI PM1a_CNT_BLK"); |
| 173 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 174 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 175 | "ACPI PM1b_CNT_BLK"); |
| 176 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 177 | if (acpi_gbl_FADT.pm_timer_length == 4) |
| 178 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 179 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 180 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 181 | "ACPI PM2_CNT_BLK"); |
| 182 | |
| 183 | /* Length of GPE blocks must be a non-negative multiple of 2 */ |
| 184 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 185 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) |
| 186 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, |
| 187 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 188 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 189 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) |
| 190 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, |
| 191 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | device_initcall(acpi_reserve_resources); |
| 196 | |
Len Brown | dd272b5 | 2007-05-30 00:26:11 -0400 | [diff] [blame] | 197 | acpi_status __init acpi_os_initialize(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
| 199 | return AE_OK; |
| 200 | } |
| 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | acpi_status acpi_os_initialize1(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | kacpid_wq = create_singlethread_workqueue("kacpid"); |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 205 | kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | BUG_ON(!kacpid_wq); |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 207 | BUG_ON(!kacpi_notify_wq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | return AE_OK; |
| 209 | } |
| 210 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | acpi_status acpi_os_terminate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | { |
| 213 | if (acpi_irq_handler) { |
| 214 | acpi_os_remove_interrupt_handler(acpi_irq_irq, |
| 215 | acpi_irq_handler); |
| 216 | } |
| 217 | |
| 218 | destroy_workqueue(kacpid_wq); |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 219 | destroy_workqueue(kacpi_notify_wq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | return AE_OK; |
| 222 | } |
| 223 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 224 | void acpi_os_printf(const char *fmt, ...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | { |
| 226 | va_list args; |
| 227 | va_start(args, fmt); |
| 228 | acpi_os_vprintf(fmt, args); |
| 229 | va_end(args); |
| 230 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 231 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | void acpi_os_vprintf(const char *fmt, va_list args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
| 234 | static char buffer[512]; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | vsprintf(buffer, fmt, args); |
| 237 | |
| 238 | #ifdef ENABLE_DEBUGGER |
| 239 | if (acpi_in_debugger) { |
| 240 | kdb_printf("%s", buffer); |
| 241 | } else { |
| 242 | printk("%s", buffer); |
| 243 | } |
| 244 | #else |
| 245 | printk("%s", buffer); |
| 246 | #endif |
| 247 | } |
| 248 | |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 249 | acpi_physical_address __init acpi_os_get_root_pointer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | if (efi_enabled) { |
Bjorn Helgaas | b2c99e3 | 2006-03-26 01:37:08 -0800 | [diff] [blame] | 252 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 253 | return efi.acpi20; |
Bjorn Helgaas | b2c99e3 | 2006-03-26 01:37:08 -0800 | [diff] [blame] | 254 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 255 | return efi.acpi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | else { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | printk(KERN_ERR PREFIX |
| 258 | "System description tables not found\n"); |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 259 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
Len Brown | 239665a | 2007-11-23 20:08:02 -0500 | [diff] [blame] | 261 | } else { |
| 262 | acpi_physical_address pa = 0; |
| 263 | |
| 264 | acpi_find_root_pointer(&pa); |
| 265 | return pa; |
| 266 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Jan Beulich | 2fdf074 | 2007-12-13 08:33:59 +0000 | [diff] [blame] | 269 | void __iomem *__init_refok |
| 270 | acpi_os_map_memory(acpi_physical_address phys, acpi_size size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | { |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 272 | if (phys > ULONG_MAX) { |
| 273 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); |
Randy Dunlap | 70c0846 | 2007-02-13 16:11:36 -0800 | [diff] [blame] | 274 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 276 | if (acpi_gbl_permanent_mmap) |
| 277 | /* |
| 278 | * ioremap checks to ensure this is in reserved space |
| 279 | */ |
| 280 | return ioremap((unsigned long)phys, size); |
| 281 | else |
| 282 | return __acpi_map_table((unsigned long)phys, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
Kylene Jo Hall | 55a82ab | 2006-01-08 01:03:15 -0800 | [diff] [blame] | 284 | EXPORT_SYMBOL_GPL(acpi_os_map_memory); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 286 | void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
Alexey Starikovskiy | ad71860 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 288 | if (acpi_gbl_permanent_mmap) { |
| 289 | iounmap(virt); |
| 290 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
Kylene Jo Hall | 55a82ab | 2006-01-08 01:03:15 -0800 | [diff] [blame] | 292 | EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
| 294 | #ifdef ACPI_FUTURE_USAGE |
| 295 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 298 | if (!phys || !virt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | return AE_BAD_PARAMETER; |
| 300 | |
| 301 | *phys = virt_to_phys(virt); |
| 302 | |
| 303 | return AE_OK; |
| 304 | } |
| 305 | #endif |
| 306 | |
| 307 | #define ACPI_MAX_OVERRIDE_LEN 100 |
| 308 | |
| 309 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; |
| 310 | |
| 311 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 312 | acpi_os_predefined_override(const struct acpi_predefined_names *init_val, |
| 313 | acpi_string * new_val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | { |
| 315 | if (!init_val || !new_val) |
| 316 | return AE_BAD_PARAMETER; |
| 317 | |
| 318 | *new_val = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 321 | acpi_os_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | *new_val = acpi_os_name; |
| 323 | } |
| 324 | |
| 325 | return AE_OK; |
| 326 | } |
| 327 | |
| 328 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 329 | acpi_os_table_override(struct acpi_table_header * existing_table, |
| 330 | struct acpi_table_header ** new_table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | { |
| 332 | if (!existing_table || !new_table) |
| 333 | return AE_BAD_PARAMETER; |
| 334 | |
Markus Gaugusch | 71fc47a | 2008-02-05 00:04:06 +0100 | [diff] [blame] | 335 | *new_table = NULL; |
| 336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
| 338 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 339 | *new_table = (struct acpi_table_header *)AmlCode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | #endif |
Éric Piel | 6ed31e9 | 2008-02-05 00:04:50 +0100 | [diff] [blame] | 341 | if (*new_table != NULL) { |
| 342 | printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " |
| 343 | "this is unsafe: tainting kernel\n", |
| 344 | existing_table->signature, |
| 345 | existing_table->oem_table_id); |
| 346 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); |
| 347 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | return AE_OK; |
| 349 | } |
| 350 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 351 | static irqreturn_t acpi_irq(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 353 | u32 handled; |
| 354 | |
| 355 | handled = (*acpi_irq_handler) (acpi_irq_context); |
| 356 | |
| 357 | if (handled) { |
| 358 | acpi_irq_handled++; |
| 359 | return IRQ_HANDLED; |
| 360 | } else |
| 361 | return IRQ_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 365 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, |
| 366 | void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { |
| 368 | unsigned int irq; |
| 369 | |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 370 | acpi_irq_stats_init(); |
| 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | /* |
| 373 | * Ignore the GSI from the core, and use the value in our copy of the |
| 374 | * FADT. It may not be the same if an interrupt source override exists |
| 375 | * for the SCI. |
| 376 | */ |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 377 | gsi = acpi_gbl_FADT.sci_interrupt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | if (acpi_gsi_to_irq(gsi, &irq) < 0) { |
| 379 | printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", |
| 380 | gsi); |
| 381 | return AE_OK; |
| 382 | } |
| 383 | |
| 384 | acpi_irq_handler = handler; |
| 385 | acpi_irq_context = context; |
Thomas Gleixner | dace145 | 2006-07-01 19:29:38 -0700 | [diff] [blame] | 386 | if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); |
| 388 | return AE_NOT_ACQUIRED; |
| 389 | } |
| 390 | acpi_irq_irq = irq; |
| 391 | |
| 392 | return AE_OK; |
| 393 | } |
| 394 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 395 | acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | { |
| 397 | if (irq) { |
| 398 | free_irq(irq, acpi_irq); |
| 399 | acpi_irq_handler = NULL; |
| 400 | acpi_irq_irq = 0; |
| 401 | } |
| 402 | |
| 403 | return AE_OK; |
| 404 | } |
| 405 | |
| 406 | /* |
| 407 | * Running in interpreter thread context, safe to sleep |
| 408 | */ |
| 409 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 410 | void acpi_os_sleep(acpi_integer ms) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | { |
Nishanth Aravamudan | 01a527e | 2005-11-07 01:01:14 -0800 | [diff] [blame] | 412 | schedule_timeout_interruptible(msecs_to_jiffies(ms)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 414 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 415 | void acpi_os_stall(u32 us) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | { |
| 417 | while (us) { |
| 418 | u32 delay = 1000; |
| 419 | |
| 420 | if (delay > us) |
| 421 | delay = us; |
| 422 | udelay(delay); |
| 423 | touch_nmi_watchdog(); |
| 424 | us -= delay; |
| 425 | } |
| 426 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 427 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | /* |
| 429 | * Support ACPI 3.0 AML Timer operand |
| 430 | * Returns 64-bit free-running, monotonically increasing timer |
| 431 | * with 100ns granularity |
| 432 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | u64 acpi_os_get_timer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | { |
| 435 | static u64 t; |
| 436 | |
| 437 | #ifdef CONFIG_HPET |
| 438 | /* TBD: use HPET if available */ |
| 439 | #endif |
| 440 | |
| 441 | #ifdef CONFIG_X86_PM_TIMER |
| 442 | /* TBD: default to PM timer if HPET was not available */ |
| 443 | #endif |
| 444 | if (!t) |
| 445 | printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n"); |
| 446 | |
| 447 | return ++t; |
| 448 | } |
| 449 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 450 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | { |
| 452 | u32 dummy; |
| 453 | |
| 454 | if (!value) |
| 455 | value = &dummy; |
| 456 | |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 457 | *value = 0; |
| 458 | if (width <= 8) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 459 | *(u8 *) value = inb(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 460 | } else if (width <= 16) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 461 | *(u16 *) value = inw(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 462 | } else if (width <= 32) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 463 | *(u32 *) value = inl(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 464 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | BUG(); |
| 466 | } |
| 467 | |
| 468 | return AE_OK; |
| 469 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | EXPORT_SYMBOL(acpi_os_read_port); |
| 472 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 473 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | { |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 475 | if (width <= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | outb(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 477 | } else if (width <= 16) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | outw(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 479 | } else if (width <= 32) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | outl(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 481 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | BUG(); |
| 483 | } |
| 484 | |
| 485 | return AE_OK; |
| 486 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 487 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | EXPORT_SYMBOL(acpi_os_write_port); |
| 489 | |
| 490 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 493 | u32 dummy; |
| 494 | void __iomem *virt_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 496 | virt_addr = ioremap(phys_addr, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | if (!value) |
| 498 | value = &dummy; |
| 499 | |
| 500 | switch (width) { |
| 501 | case 8: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 502 | *(u8 *) value = readb(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | break; |
| 504 | case 16: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 505 | *(u16 *) value = readw(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | break; |
| 507 | case 32: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 508 | *(u32 *) value = readl(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | break; |
| 510 | default: |
| 511 | BUG(); |
| 512 | } |
| 513 | |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 514 | iounmap(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
| 516 | return AE_OK; |
| 517 | } |
| 518 | |
| 519 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 520 | acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 522 | void __iomem *virt_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 524 | virt_addr = ioremap(phys_addr, width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
| 526 | switch (width) { |
| 527 | case 8: |
| 528 | writeb(value, virt_addr); |
| 529 | break; |
| 530 | case 16: |
| 531 | writew(value, virt_addr); |
| 532 | break; |
| 533 | case 32: |
| 534 | writel(value, virt_addr); |
| 535 | break; |
| 536 | default: |
| 537 | BUG(); |
| 538 | } |
| 539 | |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 540 | iounmap(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | |
| 542 | return AE_OK; |
| 543 | } |
| 544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 546 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 547 | u32 *value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | { |
| 549 | int result, size; |
| 550 | |
| 551 | if (!value) |
| 552 | return AE_BAD_PARAMETER; |
| 553 | |
| 554 | switch (width) { |
| 555 | case 8: |
| 556 | size = 1; |
| 557 | break; |
| 558 | case 16: |
| 559 | size = 2; |
| 560 | break; |
| 561 | case 32: |
| 562 | size = 4; |
| 563 | break; |
| 564 | default: |
| 565 | return AE_ERROR; |
| 566 | } |
| 567 | |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 568 | result = raw_pci_read(pci_id->segment, pci_id->bus, |
| 569 | PCI_DEVFN(pci_id->device, pci_id->function), |
| 570 | reg, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
| 572 | return (result ? AE_ERROR : AE_OK); |
| 573 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 576 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
| 577 | acpi_integer value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | { |
| 579 | int result, size; |
| 580 | |
| 581 | switch (width) { |
| 582 | case 8: |
| 583 | size = 1; |
| 584 | break; |
| 585 | case 16: |
| 586 | size = 2; |
| 587 | break; |
| 588 | case 32: |
| 589 | size = 4; |
| 590 | break; |
| 591 | default: |
| 592 | return AE_ERROR; |
| 593 | } |
| 594 | |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 595 | result = raw_pci_write(pci_id->segment, pci_id->bus, |
| 596 | PCI_DEVFN(pci_id->device, pci_id->function), |
| 597 | reg, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
| 599 | return (result ? AE_ERROR : AE_OK); |
| 600 | } |
| 601 | |
| 602 | /* TODO: Change code to take advantage of driver model more */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 603 | static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ |
| 604 | acpi_handle chandle, /* current node */ |
| 605 | struct acpi_pci_id **id, |
| 606 | int *is_bridge, u8 * bus_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 608 | acpi_handle handle; |
| 609 | struct acpi_pci_id *pci_id = *id; |
| 610 | acpi_status status; |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 611 | unsigned long long temp; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 612 | acpi_object_type type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
| 614 | acpi_get_parent(chandle, &handle); |
| 615 | if (handle != rhandle) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 616 | acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, |
| 617 | bus_number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
| 619 | status = acpi_get_type(handle, &type); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | return; |
| 622 | |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 623 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 624 | &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 626 | u32 val; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 627 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); |
| 628 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | |
| 630 | if (*is_bridge) |
| 631 | pci_id->bus = *bus_number; |
| 632 | |
| 633 | /* any nicer way to get bus number of bridge ? */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 634 | status = |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 635 | acpi_os_read_pci_configuration(pci_id, 0x0e, &val, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 636 | 8); |
| 637 | if (ACPI_SUCCESS(status) |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 638 | && ((val & 0x7f) == 1 || (val & 0x7f) == 2)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 639 | status = |
| 640 | acpi_os_read_pci_configuration(pci_id, 0x18, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 641 | &val, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | if (!ACPI_SUCCESS(status)) { |
| 643 | /* Certainly broken... FIX ME */ |
| 644 | return; |
| 645 | } |
| 646 | *is_bridge = 1; |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 647 | pci_id->bus = val; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | status = |
| 649 | acpi_os_read_pci_configuration(pci_id, 0x19, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 650 | &val, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 652 | *bus_number = val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | } |
| 654 | } else |
| 655 | *is_bridge = 0; |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 660 | void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ |
| 661 | acpi_handle chandle, /* current node */ |
| 662 | struct acpi_pci_id **id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | { |
| 664 | int is_bridge = 1; |
| 665 | u8 bus_number = (*id)->bus; |
| 666 | |
| 667 | acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); |
| 668 | } |
| 669 | |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 670 | static void acpi_os_execute_deferred(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | { |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 672 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 673 | if (!dpc) { |
| 674 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
| 675 | return; |
| 676 | } |
| 677 | |
| 678 | dpc->function(dpc->context); |
| 679 | kfree(dpc); |
| 680 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 681 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 684 | static void acpi_os_execute_hp_deferred(struct work_struct *work) |
| 685 | { |
| 686 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
| 687 | if (!dpc) { |
| 688 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
| 689 | return; |
| 690 | } |
| 691 | |
| 692 | acpi_os_wait_events_complete(NULL); |
| 693 | |
| 694 | dpc->function(dpc->context); |
| 695 | kfree(dpc); |
| 696 | |
| 697 | return; |
| 698 | } |
| 699 | |
Alexey Starikovskiy | b8d3519 | 2006-05-05 03:23:00 -0400 | [diff] [blame] | 700 | /******************************************************************************* |
| 701 | * |
| 702 | * FUNCTION: acpi_os_execute |
| 703 | * |
| 704 | * PARAMETERS: Type - Type of the callback |
| 705 | * Function - Function to be executed |
| 706 | * Context - Function parameters |
| 707 | * |
| 708 | * RETURN: Status |
| 709 | * |
| 710 | * DESCRIPTION: Depending on type, either queues function for deferred execution or |
| 711 | * immediately executes function on a separate thread. |
| 712 | * |
| 713 | ******************************************************************************/ |
| 714 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 715 | static acpi_status __acpi_os_execute(acpi_execute_type type, |
| 716 | acpi_osd_exec_callback function, void *context, int hp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 718 | acpi_status status = AE_OK; |
| 719 | struct acpi_os_dpc *dpc; |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 720 | struct workqueue_struct *queue; |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 721 | int ret; |
Len Brown | 72945b2 | 2006-07-12 22:46:42 -0400 | [diff] [blame] | 722 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 723 | "Scheduling function [%p(%p)] for deferred execution.\n", |
| 724 | function, context)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
| 726 | if (!function) |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 727 | return AE_BAD_PARAMETER; |
Len Brown | 72945b2 | 2006-07-12 22:46:42 -0400 | [diff] [blame] | 728 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | /* |
| 730 | * Allocate/initialize DPC structure. Note that this memory will be |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 731 | * freed by the callee. The kernel handles the work_struct list in a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | * way that allows us to also free its memory inside the callee. |
| 733 | * Because we may want to schedule several tasks with different |
| 734 | * parameters we can't use the approach some kernel code uses of |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 735 | * having a static work_struct. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | */ |
Len Brown | 72945b2 | 2006-07-12 22:46:42 -0400 | [diff] [blame] | 737 | |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 738 | dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | if (!dpc) |
Linus Torvalds | b976fe1 | 2006-11-17 19:31:09 -0800 | [diff] [blame] | 740 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | dpc->function = function; |
| 743 | dpc->context = context; |
Linus Torvalds | b976fe1 | 2006-11-17 19:31:09 -0800 | [diff] [blame] | 744 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 745 | if (!hp) { |
| 746 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); |
| 747 | queue = (type == OSL_NOTIFY_HANDLER) ? |
| 748 | kacpi_notify_wq : kacpid_wq; |
| 749 | ret = queue_work(queue, &dpc->work); |
| 750 | } else { |
| 751 | INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred); |
| 752 | ret = schedule_work(&dpc->work); |
| 753 | } |
| 754 | |
| 755 | if (!ret) { |
Lin Ming | 55ac9a0 | 2008-09-28 14:51:56 +0800 | [diff] [blame] | 756 | printk(KERN_ERR PREFIX |
| 757 | "Call to queue_work() failed.\n"); |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 758 | status = AE_ERROR; |
| 759 | kfree(dpc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | } |
Linus Torvalds | b976fe1 | 2006-11-17 19:31:09 -0800 | [diff] [blame] | 761 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 763 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 764 | acpi_status acpi_os_execute(acpi_execute_type type, |
| 765 | acpi_osd_exec_callback function, void *context) |
| 766 | { |
| 767 | return __acpi_os_execute(type, function, context, 0); |
| 768 | } |
Alexey Starikovskiy | b8d3519 | 2006-05-05 03:23:00 -0400 | [diff] [blame] | 769 | EXPORT_SYMBOL(acpi_os_execute); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 771 | acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function, |
| 772 | void *context) |
| 773 | { |
| 774 | return __acpi_os_execute(0, function, context, 1); |
| 775 | } |
| 776 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 777 | void acpi_os_wait_events_complete(void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | { |
| 779 | flush_workqueue(kacpid_wq); |
Zhang Rui | 2f67a06 | 2008-04-29 02:34:42 -0400 | [diff] [blame] | 780 | flush_workqueue(kacpi_notify_wq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | EXPORT_SYMBOL(acpi_os_wait_events_complete); |
| 784 | |
| 785 | /* |
| 786 | * Allocate the memory for a spinlock and initialize it. |
| 787 | */ |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 788 | acpi_status acpi_os_create_lock(acpi_spinlock * handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | { |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 790 | spin_lock_init(*handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 792 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | } |
| 794 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | /* |
| 796 | * Deallocate the memory for a spinlock. |
| 797 | */ |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 798 | void acpi_os_delete_lock(acpi_spinlock handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | { |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 800 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | } |
| 802 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 804 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 806 | struct semaphore *sem = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | sem = acpi_os_allocate(sizeof(struct semaphore)); |
| 809 | if (!sem) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 810 | return AE_NO_MEMORY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | memset(sem, 0, sizeof(struct semaphore)); |
| 812 | |
| 813 | sema_init(sem, initial_units); |
| 814 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 815 | *handle = (acpi_handle *) sem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 817 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", |
| 818 | *handle, initial_units)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 820 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | /* |
| 824 | * TODO: A better way to delete semaphores? Linux doesn't have a |
| 825 | * 'delete_semaphore()' function -- may result in an invalid |
| 826 | * pointer dereference for non-synchronized consumers. Should |
| 827 | * we at least check for blocked threads and signal/cancel them? |
| 828 | */ |
| 829 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 830 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 832 | struct semaphore *sem = (struct semaphore *)handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | if (!sem) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 835 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 837 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 839 | BUG_ON(!list_empty(&sem->wait_list)); |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 840 | kfree(sem); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 841 | sem = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 843 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | * TODO: Support for units > 1? |
| 848 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 849 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 851 | acpi_status status = AE_OK; |
| 852 | struct semaphore *sem = (struct semaphore *)handle; |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 853 | long jiffies; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 854 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | if (!sem || (units < 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 857 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | |
| 859 | if (units > 1) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 860 | return AE_SUPPORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 862 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", |
| 863 | handle, units, timeout)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 865 | if (timeout == ACPI_WAIT_FOREVER) |
| 866 | jiffies = MAX_SCHEDULE_TIMEOUT; |
| 867 | else |
| 868 | jiffies = msecs_to_jiffies(timeout); |
| 869 | |
| 870 | ret = down_timeout(sem, jiffies); |
| 871 | if (ret) |
| 872 | status = AE_TIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | |
| 874 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | 9e7e2c0 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 875 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 876 | "Failed to acquire semaphore[%p|%d|%d], %s", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 877 | handle, units, timeout, |
| 878 | acpi_format_exception(status))); |
| 879 | } else { |
| 880 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 881 | "Acquired semaphore[%p|%d|%d]", handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 882 | units, timeout)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 885 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | /* |
| 889 | * TODO: Support for units > 1? |
| 890 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 891 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 893 | struct semaphore *sem = (struct semaphore *)handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | if (!sem || (units < 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 896 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
| 898 | if (units > 1) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 899 | return AE_SUPPORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 901 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, |
| 902 | units)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
| 904 | up(sem); |
| 905 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 906 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 908 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | #ifdef ACPI_FUTURE_USAGE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 910 | u32 acpi_os_get_line(char *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | { |
| 912 | |
| 913 | #ifdef ENABLE_DEBUGGER |
| 914 | if (acpi_in_debugger) { |
| 915 | u32 chars; |
| 916 | |
| 917 | kdb_read(buffer, sizeof(line_buf)); |
| 918 | |
| 919 | /* remove the CR kdb includes */ |
| 920 | chars = strlen(buffer) - 1; |
| 921 | buffer[chars] = '\0'; |
| 922 | } |
| 923 | #endif |
| 924 | |
| 925 | return 0; |
| 926 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 927 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 929 | acpi_status acpi_os_signal(u32 function, void *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 931 | switch (function) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | case ACPI_SIGNAL_FATAL: |
| 933 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); |
| 934 | break; |
| 935 | case ACPI_SIGNAL_BREAKPOINT: |
| 936 | /* |
| 937 | * AML Breakpoint |
| 938 | * ACPI spec. says to treat it as a NOP unless |
| 939 | * you are debugging. So if/when we integrate |
| 940 | * AML debugger into the kernel debugger its |
| 941 | * hook will go here. But until then it is |
| 942 | * not useful to print anything on breakpoints. |
| 943 | */ |
| 944 | break; |
| 945 | default: |
| 946 | break; |
| 947 | } |
| 948 | |
| 949 | return AE_OK; |
| 950 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 951 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 952 | static int __init acpi_os_name_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | { |
| 954 | char *p = acpi_os_name; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 955 | int count = ACPI_MAX_OVERRIDE_LEN - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | |
| 957 | if (!str || !*str) |
| 958 | return 0; |
| 959 | |
| 960 | for (; count-- && str && *str; str++) { |
| 961 | if (isalnum(*str) || *str == ' ' || *str == ':') |
| 962 | *p++ = *str; |
| 963 | else if (*str == '\'' || *str == '"') |
| 964 | continue; |
| 965 | else |
| 966 | break; |
| 967 | } |
| 968 | *p = 0; |
| 969 | |
| 970 | return 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 971 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | __setup("acpi_os_name=", acpi_os_name_setup); |
| 975 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 976 | static void __init set_osi_linux(unsigned int enable) |
| 977 | { |
| 978 | if (osi_linux.enable != enable) { |
| 979 | osi_linux.enable = enable; |
| 980 | printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n", |
| 981 | enable ? "Add": "Delet"); |
| 982 | } |
| 983 | return; |
| 984 | } |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 985 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 986 | static void __init acpi_cmdline_osi_linux(unsigned int enable) |
| 987 | { |
| 988 | osi_linux.cmdline = 1; /* cmdline set the default */ |
| 989 | set_osi_linux(enable); |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 990 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 991 | return; |
| 992 | } |
| 993 | |
| 994 | void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) |
| 995 | { |
| 996 | osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ |
| 997 | |
| 998 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); |
| 999 | |
| 1000 | if (enable == -1) |
| 1001 | return; |
| 1002 | |
| 1003 | osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */ |
| 1004 | |
| 1005 | set_osi_linux(enable); |
| 1006 | |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1007 | return; |
| 1008 | } |
| 1009 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | /* |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1011 | * Modify the list of "OS Interfaces" reported to BIOS via _OSI |
| 1012 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | * empty string disables _OSI |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1014 | * string starting with '!' disables that string |
| 1015 | * otherwise string is added to list, augmenting built-in strings |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | */ |
Len Brown | 46c1fbd | 2008-02-13 23:13:25 -0500 | [diff] [blame] | 1017 | int __init acpi_osi_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | { |
| 1019 | if (str == NULL || *str == '\0') { |
| 1020 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); |
| 1021 | acpi_gbl_create_osi_method = FALSE; |
Len Brown | aa2e09d | 2007-07-02 23:57:45 -0400 | [diff] [blame] | 1022 | } else if (!strcmp("!Linux", str)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1023 | acpi_cmdline_osi_linux(0); /* !enable */ |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1024 | } else if (*str == '!') { |
| 1025 | if (acpi_osi_invalidate(++str) == AE_OK) |
| 1026 | printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1027 | } else if (!strcmp("Linux", str)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1028 | acpi_cmdline_osi_linux(1); /* enable */ |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1029 | } else if (*osi_additional_string == '\0') { |
| 1030 | strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX); |
| 1031 | printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | return 1; |
| 1035 | } |
| 1036 | |
| 1037 | __setup("acpi_osi=", acpi_osi_setup); |
| 1038 | |
| 1039 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1040 | static int __init acpi_serialize_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | { |
| 1042 | printk(KERN_INFO PREFIX "serialize enabled\n"); |
| 1043 | |
| 1044 | acpi_gbl_all_methods_serialized = TRUE; |
| 1045 | |
| 1046 | return 1; |
| 1047 | } |
| 1048 | |
| 1049 | __setup("acpi_serialize", acpi_serialize_setup); |
| 1050 | |
| 1051 | /* |
| 1052 | * Wake and Run-Time GPES are expected to be separate. |
| 1053 | * We disable wake-GPEs at run-time to prevent spurious |
| 1054 | * interrupts. |
| 1055 | * |
| 1056 | * However, if a system exists that shares Wake and |
| 1057 | * Run-time events on the same GPE this flag is available |
| 1058 | * to tell Linux to keep the wake-time GPEs enabled at run-time. |
| 1059 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1060 | static int __init acpi_wake_gpes_always_on_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | { |
| 1062 | printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); |
| 1063 | |
| 1064 | acpi_gbl_leave_wake_gpes_disabled = FALSE; |
| 1065 | |
| 1066 | return 1; |
| 1067 | } |
| 1068 | |
| 1069 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); |
| 1070 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1071 | /* Check of resource interference between native drivers and ACPI |
| 1072 | * OperationRegions (SystemIO and System Memory only). |
| 1073 | * IO ports and memory declared in ACPI might be used by the ACPI subsystem |
| 1074 | * in arbitrary AML code and can interfere with legacy drivers. |
| 1075 | * acpi_enforce_resources= can be set to: |
| 1076 | * |
| 1077 | * - strict (2) |
| 1078 | * -> further driver trying to access the resources will not load |
| 1079 | * - lax (default) (1) |
| 1080 | * -> further driver trying to access the resources will load, but you |
| 1081 | * get a system message that something might go wrong... |
| 1082 | * |
| 1083 | * - no (0) |
| 1084 | * -> ACPI Operation Region resources will not be registered |
| 1085 | * |
| 1086 | */ |
| 1087 | #define ENFORCE_RESOURCES_STRICT 2 |
| 1088 | #define ENFORCE_RESOURCES_LAX 1 |
| 1089 | #define ENFORCE_RESOURCES_NO 0 |
| 1090 | |
| 1091 | static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX; |
| 1092 | |
| 1093 | static int __init acpi_enforce_resources_setup(char *str) |
| 1094 | { |
| 1095 | if (str == NULL || *str == '\0') |
| 1096 | return 0; |
| 1097 | |
| 1098 | if (!strcmp("strict", str)) |
| 1099 | acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; |
| 1100 | else if (!strcmp("lax", str)) |
| 1101 | acpi_enforce_resources = ENFORCE_RESOURCES_LAX; |
| 1102 | else if (!strcmp("no", str)) |
| 1103 | acpi_enforce_resources = ENFORCE_RESOURCES_NO; |
| 1104 | |
| 1105 | return 1; |
| 1106 | } |
| 1107 | |
| 1108 | __setup("acpi_enforce_resources=", acpi_enforce_resources_setup); |
| 1109 | |
| 1110 | /* Check for resource conflicts between ACPI OperationRegions and native |
| 1111 | * drivers */ |
Thomas Renninger | 443dea7 | 2008-02-04 23:31:23 -0800 | [diff] [blame] | 1112 | int acpi_check_resource_conflict(struct resource *res) |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1113 | { |
| 1114 | struct acpi_res_list *res_list_elem; |
| 1115 | int ioport; |
| 1116 | int clash = 0; |
| 1117 | |
| 1118 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) |
| 1119 | return 0; |
| 1120 | if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) |
| 1121 | return 0; |
| 1122 | |
| 1123 | ioport = res->flags & IORESOURCE_IO; |
| 1124 | |
| 1125 | spin_lock(&acpi_res_lock); |
| 1126 | list_for_each_entry(res_list_elem, &resource_list_head, |
| 1127 | resource_list) { |
| 1128 | if (ioport && (res_list_elem->resource_type |
| 1129 | != ACPI_ADR_SPACE_SYSTEM_IO)) |
| 1130 | continue; |
| 1131 | if (!ioport && (res_list_elem->resource_type |
| 1132 | != ACPI_ADR_SPACE_SYSTEM_MEMORY)) |
| 1133 | continue; |
| 1134 | |
| 1135 | if (res->end < res_list_elem->start |
| 1136 | || res_list_elem->end < res->start) |
| 1137 | continue; |
| 1138 | clash = 1; |
| 1139 | break; |
| 1140 | } |
| 1141 | spin_unlock(&acpi_res_lock); |
| 1142 | |
| 1143 | if (clash) { |
| 1144 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { |
Jean Delvare | bd12935 | 2008-02-27 20:56:01 +0100 | [diff] [blame] | 1145 | printk("%sACPI: %s resource %s [0x%llx-0x%llx]" |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1146 | " conflicts with ACPI region %s" |
| 1147 | " [0x%llx-0x%llx]\n", |
| 1148 | acpi_enforce_resources == ENFORCE_RESOURCES_LAX |
| 1149 | ? KERN_WARNING : KERN_ERR, |
| 1150 | ioport ? "I/O" : "Memory", res->name, |
| 1151 | (long long) res->start, (long long) res->end, |
| 1152 | res_list_elem->name, |
| 1153 | (long long) res_list_elem->start, |
| 1154 | (long long) res_list_elem->end); |
| 1155 | printk(KERN_INFO "ACPI: Device needs an ACPI driver\n"); |
| 1156 | } |
| 1157 | if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT) |
| 1158 | return -EBUSY; |
| 1159 | } |
| 1160 | return 0; |
| 1161 | } |
Thomas Renninger | 443dea7 | 2008-02-04 23:31:23 -0800 | [diff] [blame] | 1162 | EXPORT_SYMBOL(acpi_check_resource_conflict); |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1163 | |
| 1164 | int acpi_check_region(resource_size_t start, resource_size_t n, |
| 1165 | const char *name) |
| 1166 | { |
| 1167 | struct resource res = { |
| 1168 | .start = start, |
| 1169 | .end = start + n - 1, |
| 1170 | .name = name, |
| 1171 | .flags = IORESOURCE_IO, |
| 1172 | }; |
| 1173 | |
| 1174 | return acpi_check_resource_conflict(&res); |
| 1175 | } |
| 1176 | EXPORT_SYMBOL(acpi_check_region); |
| 1177 | |
| 1178 | int acpi_check_mem_region(resource_size_t start, resource_size_t n, |
| 1179 | const char *name) |
| 1180 | { |
| 1181 | struct resource res = { |
| 1182 | .start = start, |
| 1183 | .end = start + n - 1, |
| 1184 | .name = name, |
| 1185 | .flags = IORESOURCE_MEM, |
| 1186 | }; |
| 1187 | |
| 1188 | return acpi_check_resource_conflict(&res); |
| 1189 | |
| 1190 | } |
| 1191 | EXPORT_SYMBOL(acpi_check_mem_region); |
| 1192 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | /* |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1194 | * Acquire a spinlock. |
| 1195 | * |
| 1196 | * handle is a pointer to the spinlock_t. |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1197 | */ |
| 1198 | |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1199 | acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1200 | { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1201 | acpi_cpu_flags flags; |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1202 | spin_lock_irqsave(lockp, flags); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1203 | return flags; |
| 1204 | } |
| 1205 | |
| 1206 | /* |
| 1207 | * Release a spinlock. See above. |
| 1208 | */ |
| 1209 | |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1210 | void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1211 | { |
Bob Moore | 967440e | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1212 | spin_unlock_irqrestore(lockp, flags); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1213 | } |
| 1214 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1215 | #ifndef ACPI_USE_LOCAL_CACHE |
| 1216 | |
| 1217 | /******************************************************************************* |
| 1218 | * |
| 1219 | * FUNCTION: acpi_os_create_cache |
| 1220 | * |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1221 | * PARAMETERS: name - Ascii name for the cache |
| 1222 | * size - Size of each cached object |
| 1223 | * depth - Maximum depth of the cache (in objects) <ignored> |
| 1224 | * cache - Where the new cache object is returned |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1225 | * |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1226 | * RETURN: status |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1227 | * |
| 1228 | * DESCRIPTION: Create a cache object |
| 1229 | * |
| 1230 | ******************************************************************************/ |
| 1231 | |
| 1232 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1233 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1234 | { |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 1235 | *cache = kmem_cache_create(name, size, 0, 0, NULL); |
Adrian Bunk | a6fdbf9 | 2006-12-19 12:56:13 -0800 | [diff] [blame] | 1236 | if (*cache == NULL) |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1237 | return AE_ERROR; |
| 1238 | else |
| 1239 | return AE_OK; |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | /******************************************************************************* |
| 1243 | * |
| 1244 | * FUNCTION: acpi_os_purge_cache |
| 1245 | * |
| 1246 | * PARAMETERS: Cache - Handle to cache object |
| 1247 | * |
| 1248 | * RETURN: Status |
| 1249 | * |
| 1250 | * DESCRIPTION: Free all objects within the requested cache. |
| 1251 | * |
| 1252 | ******************************************************************************/ |
| 1253 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1254 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1255 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1256 | kmem_cache_shrink(cache); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1257 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | /******************************************************************************* |
| 1261 | * |
| 1262 | * FUNCTION: acpi_os_delete_cache |
| 1263 | * |
| 1264 | * PARAMETERS: Cache - Handle to cache object |
| 1265 | * |
| 1266 | * RETURN: Status |
| 1267 | * |
| 1268 | * DESCRIPTION: Free all objects within the requested cache and delete the |
| 1269 | * cache object. |
| 1270 | * |
| 1271 | ******************************************************************************/ |
| 1272 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1273 | acpi_status acpi_os_delete_cache(acpi_cache_t * cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1274 | { |
Alexey Dobriyan | 1a1d92c | 2006-09-27 01:49:40 -0700 | [diff] [blame] | 1275 | kmem_cache_destroy(cache); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1276 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1277 | } |
| 1278 | |
| 1279 | /******************************************************************************* |
| 1280 | * |
| 1281 | * FUNCTION: acpi_os_release_object |
| 1282 | * |
| 1283 | * PARAMETERS: Cache - Handle to cache object |
| 1284 | * Object - The object to be released |
| 1285 | * |
| 1286 | * RETURN: None |
| 1287 | * |
| 1288 | * DESCRIPTION: Release an object to the specified cache. If cache is full, |
| 1289 | * the object is deleted. |
| 1290 | * |
| 1291 | ******************************************************************************/ |
| 1292 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1293 | acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1294 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1295 | kmem_cache_free(cache, object); |
| 1296 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1297 | } |
| 1298 | |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1299 | /** |
| 1300 | * acpi_dmi_dump - dump DMI slots needed for blacklist entry |
| 1301 | * |
| 1302 | * Returns 0 on success |
| 1303 | */ |
Adrian Bunk | 12d3931 | 2008-01-29 00:10:12 +0200 | [diff] [blame] | 1304 | static int acpi_dmi_dump(void) |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1305 | { |
| 1306 | |
| 1307 | if (!dmi_available) |
| 1308 | return -1; |
| 1309 | |
| 1310 | printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1311 | dmi_get_system_info(DMI_SYS_VENDOR)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1312 | printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1313 | dmi_get_system_info(DMI_PRODUCT_NAME)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1314 | printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1315 | dmi_get_system_info(DMI_PRODUCT_VERSION)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1316 | printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1317 | dmi_get_system_info(DMI_BOARD_NAME)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1318 | printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1319 | dmi_get_system_info(DMI_BIOS_VENDOR)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1320 | printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n", |
Len Brown | e6298c6 | 2008-01-25 15:40:02 -0500 | [diff] [blame] | 1321 | dmi_get_system_info(DMI_BIOS_DATE)); |
Len Brown | 5a4e143 | 2008-01-23 20:01:22 -0500 | [diff] [blame] | 1322 | |
| 1323 | return 0; |
| 1324 | } |
| 1325 | |
| 1326 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1327 | /****************************************************************************** |
| 1328 | * |
| 1329 | * FUNCTION: acpi_os_validate_interface |
| 1330 | * |
| 1331 | * PARAMETERS: interface - Requested interface to be validated |
| 1332 | * |
| 1333 | * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise |
| 1334 | * |
| 1335 | * DESCRIPTION: Match an interface string to the interfaces supported by the |
| 1336 | * host. Strings originate from an AML call to the _OSI method. |
| 1337 | * |
| 1338 | *****************************************************************************/ |
| 1339 | |
| 1340 | acpi_status |
| 1341 | acpi_os_validate_interface (char *interface) |
| 1342 | { |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1343 | if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX)) |
| 1344 | return AE_OK; |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1345 | if (!strcmp("Linux", interface)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1346 | |
| 1347 | printk(KERN_NOTICE PREFIX |
| 1348 | "BIOS _OSI(Linux) query %s%s\n", |
| 1349 | osi_linux.enable ? "honored" : "ignored", |
| 1350 | osi_linux.cmdline ? " via cmdline" : |
| 1351 | osi_linux.dmi ? " via DMI" : ""); |
| 1352 | |
| 1353 | if (!osi_linux.dmi) { |
| 1354 | if (acpi_dmi_dump()) |
| 1355 | printk(KERN_NOTICE PREFIX |
| 1356 | "[please extract dmidecode output]\n"); |
Len Brown | f40cd6f | 2008-01-23 20:04:28 -0500 | [diff] [blame] | 1357 | printk(KERN_NOTICE PREFIX |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1358 | "Please send DMI info above to " |
| 1359 | "linux-acpi@vger.kernel.org\n"); |
| 1360 | } |
| 1361 | if (!osi_linux.known && !osi_linux.cmdline) { |
| 1362 | printk(KERN_NOTICE PREFIX |
| 1363 | "If \"acpi_osi=%sLinux\" works better, " |
| 1364 | "please notify linux-acpi@vger.kernel.org\n", |
| 1365 | osi_linux.enable ? "!" : ""); |
| 1366 | } |
| 1367 | |
| 1368 | if (osi_linux.enable) |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1369 | return AE_OK; |
| 1370 | } |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1371 | return AE_SUPPORT; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1372 | } |
| 1373 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1374 | /****************************************************************************** |
| 1375 | * |
| 1376 | * FUNCTION: acpi_os_validate_address |
| 1377 | * |
| 1378 | * PARAMETERS: space_id - ACPI space ID |
| 1379 | * address - Physical address |
| 1380 | * length - Address length |
| 1381 | * |
| 1382 | * RETURN: AE_OK if address/length is valid for the space_id. Otherwise, |
| 1383 | * should return AE_AML_ILLEGAL_ADDRESS. |
| 1384 | * |
| 1385 | * DESCRIPTION: Validate a system address via the host OS. Used to validate |
| 1386 | * the addresses accessed by AML operation regions. |
| 1387 | * |
| 1388 | *****************************************************************************/ |
| 1389 | |
| 1390 | acpi_status |
| 1391 | acpi_os_validate_address ( |
| 1392 | u8 space_id, |
| 1393 | acpi_physical_address address, |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1394 | acpi_size length, |
| 1395 | char *name) |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1396 | { |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1397 | struct acpi_res_list *res; |
| 1398 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) |
| 1399 | return AE_OK; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1400 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1401 | switch (space_id) { |
| 1402 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 1403 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
| 1404 | /* Only interference checks against SystemIO and SytemMemory |
| 1405 | are needed */ |
| 1406 | res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL); |
| 1407 | if (!res) |
| 1408 | return AE_OK; |
| 1409 | /* ACPI names are fixed to 4 bytes, still better use strlcpy */ |
| 1410 | strlcpy(res->name, name, 5); |
| 1411 | res->start = address; |
| 1412 | res->end = address + length - 1; |
| 1413 | res->resource_type = space_id; |
| 1414 | spin_lock(&acpi_res_lock); |
| 1415 | list_add(&res->resource_list, &resource_list_head); |
| 1416 | spin_unlock(&acpi_res_lock); |
| 1417 | pr_debug("Added %s resource: start: 0x%llx, end: 0x%llx, " |
| 1418 | "name: %s\n", (space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
| 1419 | ? "SystemIO" : "System Memory", |
| 1420 | (unsigned long long)res->start, |
| 1421 | (unsigned long long)res->end, |
| 1422 | res->name); |
| 1423 | break; |
| 1424 | case ACPI_ADR_SPACE_PCI_CONFIG: |
| 1425 | case ACPI_ADR_SPACE_EC: |
| 1426 | case ACPI_ADR_SPACE_SMBUS: |
| 1427 | case ACPI_ADR_SPACE_CMOS: |
| 1428 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
| 1429 | case ACPI_ADR_SPACE_DATA_TABLE: |
| 1430 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
| 1431 | break; |
| 1432 | } |
| 1433 | return AE_OK; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1434 | } |
| 1435 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1436 | #endif |