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