diff options
Diffstat (limited to 'drivers/acpi/osl.c')
-rw-r--r-- | drivers/acpi/osl.c | 695 |
1 files changed, 351 insertions, 344 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 0d11d6e6abd6..d528c750a380 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -45,16 +45,12 @@ | |||
45 | 45 | ||
46 | #include <linux/efi.h> | 46 | #include <linux/efi.h> |
47 | 47 | ||
48 | |||
49 | #define _COMPONENT ACPI_OS_SERVICES | 48 | #define _COMPONENT ACPI_OS_SERVICES |
50 | ACPI_MODULE_NAME ("osl") | 49 | ACPI_MODULE_NAME("osl") |
51 | |||
52 | #define PREFIX "ACPI: " | 50 | #define PREFIX "ACPI: " |
53 | 51 | struct acpi_os_dpc { | |
54 | struct acpi_os_dpc | 52 | acpi_osd_exec_callback function; |
55 | { | 53 | void *context; |
56 | acpi_osd_exec_callback function; | ||
57 | void *context; | ||
58 | }; | 54 | }; |
59 | 55 | ||
60 | #ifdef CONFIG_ACPI_CUSTOM_DSDT | 56 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
@@ -69,7 +65,7 @@ int acpi_in_debugger; | |||
69 | EXPORT_SYMBOL(acpi_in_debugger); | 65 | EXPORT_SYMBOL(acpi_in_debugger); |
70 | 66 | ||
71 | extern char line_buf[80]; | 67 | extern char line_buf[80]; |
72 | #endif /*ENABLE_DEBUGGER*/ | 68 | #endif /*ENABLE_DEBUGGER */ |
73 | 69 | ||
74 | int acpi_specific_hotkey_enabled = TRUE; | 70 | int acpi_specific_hotkey_enabled = TRUE; |
75 | EXPORT_SYMBOL(acpi_specific_hotkey_enabled); | 71 | EXPORT_SYMBOL(acpi_specific_hotkey_enabled); |
@@ -79,33 +75,29 @@ static acpi_osd_handler acpi_irq_handler; | |||
79 | static void *acpi_irq_context; | 75 | static void *acpi_irq_context; |
80 | static struct workqueue_struct *kacpid_wq; | 76 | static struct workqueue_struct *kacpid_wq; |
81 | 77 | ||
82 | acpi_status | 78 | acpi_status acpi_os_initialize(void) |
83 | acpi_os_initialize(void) | ||
84 | { | 79 | { |
85 | return AE_OK; | 80 | return AE_OK; |
86 | } | 81 | } |
87 | 82 | ||
88 | acpi_status | 83 | acpi_status acpi_os_initialize1(void) |
89 | acpi_os_initialize1(void) | ||
90 | { | 84 | { |
91 | /* | 85 | /* |
92 | * Initialize PCI configuration space access, as we'll need to access | 86 | * Initialize PCI configuration space access, as we'll need to access |
93 | * it while walking the namespace (bus 0 and root bridges w/ _BBNs). | 87 | * it while walking the namespace (bus 0 and root bridges w/ _BBNs). |
94 | */ | 88 | */ |
95 | #ifdef CONFIG_ACPI_PCI | ||
96 | if (!raw_pci_ops) { | 89 | if (!raw_pci_ops) { |
97 | printk(KERN_ERR PREFIX "Access to PCI configuration space unavailable\n"); | 90 | printk(KERN_ERR PREFIX |
91 | "Access to PCI configuration space unavailable\n"); | ||
98 | return AE_NULL_ENTRY; | 92 | return AE_NULL_ENTRY; |
99 | } | 93 | } |
100 | #endif | ||
101 | kacpid_wq = create_singlethread_workqueue("kacpid"); | 94 | kacpid_wq = create_singlethread_workqueue("kacpid"); |
102 | BUG_ON(!kacpid_wq); | 95 | BUG_ON(!kacpid_wq); |
103 | 96 | ||
104 | return AE_OK; | 97 | return AE_OK; |
105 | } | 98 | } |
106 | 99 | ||
107 | acpi_status | 100 | acpi_status acpi_os_terminate(void) |
108 | acpi_os_terminate(void) | ||
109 | { | 101 | { |
110 | if (acpi_irq_handler) { | 102 | if (acpi_irq_handler) { |
111 | acpi_os_remove_interrupt_handler(acpi_irq_irq, | 103 | acpi_os_remove_interrupt_handler(acpi_irq_irq, |
@@ -117,21 +109,20 @@ acpi_os_terminate(void) | |||
117 | return AE_OK; | 109 | return AE_OK; |
118 | } | 110 | } |
119 | 111 | ||
120 | void | 112 | void acpi_os_printf(const char *fmt, ...) |
121 | acpi_os_printf(const char *fmt,...) | ||
122 | { | 113 | { |
123 | va_list args; | 114 | va_list args; |
124 | va_start(args, fmt); | 115 | va_start(args, fmt); |
125 | acpi_os_vprintf(fmt, args); | 116 | acpi_os_vprintf(fmt, args); |
126 | va_end(args); | 117 | va_end(args); |
127 | } | 118 | } |
119 | |||
128 | EXPORT_SYMBOL(acpi_os_printf); | 120 | EXPORT_SYMBOL(acpi_os_printf); |
129 | 121 | ||
130 | void | 122 | void acpi_os_vprintf(const char *fmt, va_list args) |
131 | acpi_os_vprintf(const char *fmt, va_list args) | ||
132 | { | 123 | { |
133 | static char buffer[512]; | 124 | static char buffer[512]; |
134 | 125 | ||
135 | vsprintf(buffer, fmt, args); | 126 | vsprintf(buffer, fmt, args); |
136 | 127 | ||
137 | #ifdef ENABLE_DEBUGGER | 128 | #ifdef ENABLE_DEBUGGER |
@@ -146,8 +137,7 @@ acpi_os_vprintf(const char *fmt, va_list args) | |||
146 | } | 137 | } |
147 | 138 | ||
148 | extern int acpi_in_resume; | 139 | extern int acpi_in_resume; |
149 | void * | 140 | void *acpi_os_allocate(acpi_size size) |
150 | acpi_os_allocate(acpi_size size) | ||
151 | { | 141 | { |
152 | if (acpi_in_resume) | 142 | if (acpi_in_resume) |
153 | return kmalloc(size, GFP_ATOMIC); | 143 | return kmalloc(size, GFP_ATOMIC); |
@@ -155,31 +145,32 @@ acpi_os_allocate(acpi_size size) | |||
155 | return kmalloc(size, GFP_KERNEL); | 145 | return kmalloc(size, GFP_KERNEL); |
156 | } | 146 | } |
157 | 147 | ||
158 | void | 148 | void acpi_os_free(void *ptr) |
159 | acpi_os_free(void *ptr) | ||
160 | { | 149 | { |
161 | kfree(ptr); | 150 | kfree(ptr); |
162 | } | 151 | } |
152 | |||
163 | EXPORT_SYMBOL(acpi_os_free); | 153 | EXPORT_SYMBOL(acpi_os_free); |
164 | 154 | ||
165 | acpi_status | 155 | acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) |
166 | acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) | ||
167 | { | 156 | { |
168 | if (efi_enabled) { | 157 | if (efi_enabled) { |
169 | addr->pointer_type = ACPI_PHYSICAL_POINTER; | 158 | addr->pointer_type = ACPI_PHYSICAL_POINTER; |
170 | if (efi.acpi20) | 159 | if (efi.acpi20) |
171 | addr->pointer.physical = | 160 | addr->pointer.physical = |
172 | (acpi_physical_address) virt_to_phys(efi.acpi20); | 161 | (acpi_physical_address) virt_to_phys(efi.acpi20); |
173 | else if (efi.acpi) | 162 | else if (efi.acpi) |
174 | addr->pointer.physical = | 163 | addr->pointer.physical = |
175 | (acpi_physical_address) virt_to_phys(efi.acpi); | 164 | (acpi_physical_address) virt_to_phys(efi.acpi); |
176 | else { | 165 | else { |
177 | printk(KERN_ERR PREFIX "System description tables not found\n"); | 166 | printk(KERN_ERR PREFIX |
167 | "System description tables not found\n"); | ||
178 | return AE_NOT_FOUND; | 168 | return AE_NOT_FOUND; |
179 | } | 169 | } |
180 | } else { | 170 | } else { |
181 | if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) { | 171 | if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) { |
182 | printk(KERN_ERR PREFIX "System description tables not found\n"); | 172 | printk(KERN_ERR PREFIX |
173 | "System description tables not found\n"); | ||
183 | return AE_NOT_FOUND; | 174 | return AE_NOT_FOUND; |
184 | } | 175 | } |
185 | } | 176 | } |
@@ -188,11 +179,12 @@ acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) | |||
188 | } | 179 | } |
189 | 180 | ||
190 | acpi_status | 181 | acpi_status |
191 | acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **virt) | 182 | acpi_os_map_memory(acpi_physical_address phys, acpi_size size, |
183 | void __iomem ** virt) | ||
192 | { | 184 | { |
193 | if (efi_enabled) { | 185 | if (efi_enabled) { |
194 | if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { | 186 | if (EFI_MEMORY_WB & efi_mem_attributes(phys)) { |
195 | *virt = (void __iomem *) phys_to_virt(phys); | 187 | *virt = (void __iomem *)phys_to_virt(phys); |
196 | } else { | 188 | } else { |
197 | *virt = ioremap(phys, size); | 189 | *virt = ioremap(phys, size); |
198 | } | 190 | } |
@@ -202,9 +194,9 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi | |||
202 | return AE_BAD_PARAMETER; | 194 | return AE_BAD_PARAMETER; |
203 | } | 195 | } |
204 | /* | 196 | /* |
205 | * ioremap checks to ensure this is in reserved space | 197 | * ioremap checks to ensure this is in reserved space |
206 | */ | 198 | */ |
207 | *virt = ioremap((unsigned long) phys, size); | 199 | *virt = ioremap((unsigned long)phys, size); |
208 | } | 200 | } |
209 | 201 | ||
210 | if (!*virt) | 202 | if (!*virt) |
@@ -213,17 +205,16 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size, void __iomem **vi | |||
213 | return AE_OK; | 205 | return AE_OK; |
214 | } | 206 | } |
215 | 207 | ||
216 | void | 208 | void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) |
217 | acpi_os_unmap_memory(void __iomem *virt, acpi_size size) | ||
218 | { | 209 | { |
219 | iounmap(virt); | 210 | iounmap(virt); |
220 | } | 211 | } |
221 | 212 | ||
222 | #ifdef ACPI_FUTURE_USAGE | 213 | #ifdef ACPI_FUTURE_USAGE |
223 | acpi_status | 214 | acpi_status |
224 | acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) | 215 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
225 | { | 216 | { |
226 | if(!phys || !virt) | 217 | if (!phys || !virt) |
227 | return AE_BAD_PARAMETER; | 218 | return AE_BAD_PARAMETER; |
228 | 219 | ||
229 | *phys = virt_to_phys(virt); | 220 | *phys = virt_to_phys(virt); |
@@ -237,16 +228,16 @@ acpi_os_get_physical_address(void *virt, acpi_physical_address *phys) | |||
237 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; | 228 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; |
238 | 229 | ||
239 | acpi_status | 230 | acpi_status |
240 | acpi_os_predefined_override (const struct acpi_predefined_names *init_val, | 231 | acpi_os_predefined_override(const struct acpi_predefined_names *init_val, |
241 | acpi_string *new_val) | 232 | acpi_string * new_val) |
242 | { | 233 | { |
243 | if (!init_val || !new_val) | 234 | if (!init_val || !new_val) |
244 | return AE_BAD_PARAMETER; | 235 | return AE_BAD_PARAMETER; |
245 | 236 | ||
246 | *new_val = NULL; | 237 | *new_val = NULL; |
247 | if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { | 238 | if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { |
248 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", | 239 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", |
249 | acpi_os_name); | 240 | acpi_os_name); |
250 | *new_val = acpi_os_name; | 241 | *new_val = acpi_os_name; |
251 | } | 242 | } |
252 | 243 | ||
@@ -254,15 +245,15 @@ acpi_os_predefined_override (const struct acpi_predefined_names *init_val, | |||
254 | } | 245 | } |
255 | 246 | ||
256 | acpi_status | 247 | acpi_status |
257 | acpi_os_table_override (struct acpi_table_header *existing_table, | 248 | acpi_os_table_override(struct acpi_table_header * existing_table, |
258 | struct acpi_table_header **new_table) | 249 | struct acpi_table_header ** new_table) |
259 | { | 250 | { |
260 | if (!existing_table || !new_table) | 251 | if (!existing_table || !new_table) |
261 | return AE_BAD_PARAMETER; | 252 | return AE_BAD_PARAMETER; |
262 | 253 | ||
263 | #ifdef CONFIG_ACPI_CUSTOM_DSDT | 254 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
264 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) | 255 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) |
265 | *new_table = (struct acpi_table_header*)AmlCode; | 256 | *new_table = (struct acpi_table_header *)AmlCode; |
266 | else | 257 | else |
267 | *new_table = NULL; | 258 | *new_table = NULL; |
268 | #else | 259 | #else |
@@ -271,14 +262,14 @@ acpi_os_table_override (struct acpi_table_header *existing_table, | |||
271 | return AE_OK; | 262 | return AE_OK; |
272 | } | 263 | } |
273 | 264 | ||
274 | static irqreturn_t | 265 | static irqreturn_t acpi_irq(int irq, void *dev_id, struct pt_regs *regs) |
275 | acpi_irq(int irq, void *dev_id, struct pt_regs *regs) | ||
276 | { | 266 | { |
277 | return (*acpi_irq_handler)(acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; | 267 | return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; |
278 | } | 268 | } |
279 | 269 | ||
280 | acpi_status | 270 | acpi_status |
281 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *context) | 271 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, |
272 | void *context) | ||
282 | { | 273 | { |
283 | unsigned int irq; | 274 | unsigned int irq; |
284 | 275 | ||
@@ -305,8 +296,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, void *conte | |||
305 | return AE_OK; | 296 | return AE_OK; |
306 | } | 297 | } |
307 | 298 | ||
308 | acpi_status | 299 | acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) |
309 | acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) | ||
310 | { | 300 | { |
311 | if (irq) { | 301 | if (irq) { |
312 | free_irq(irq, acpi_irq); | 302 | free_irq(irq, acpi_irq); |
@@ -321,16 +311,15 @@ acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) | |||
321 | * Running in interpreter thread context, safe to sleep | 311 | * Running in interpreter thread context, safe to sleep |
322 | */ | 312 | */ |
323 | 313 | ||
324 | void | 314 | void acpi_os_sleep(acpi_integer ms) |
325 | acpi_os_sleep(acpi_integer ms) | ||
326 | { | 315 | { |
327 | current->state = TASK_INTERRUPTIBLE; | 316 | current->state = TASK_INTERRUPTIBLE; |
328 | schedule_timeout(((signed long) ms * HZ) / 1000); | 317 | schedule_timeout(((signed long)ms * HZ) / 1000); |
329 | } | 318 | } |
319 | |||
330 | EXPORT_SYMBOL(acpi_os_sleep); | 320 | EXPORT_SYMBOL(acpi_os_sleep); |
331 | 321 | ||
332 | void | 322 | void acpi_os_stall(u32 us) |
333 | acpi_os_stall(u32 us) | ||
334 | { | 323 | { |
335 | while (us) { | 324 | while (us) { |
336 | u32 delay = 1000; | 325 | u32 delay = 1000; |
@@ -342,6 +331,7 @@ acpi_os_stall(u32 us) | |||
342 | us -= delay; | 331 | us -= delay; |
343 | } | 332 | } |
344 | } | 333 | } |
334 | |||
345 | EXPORT_SYMBOL(acpi_os_stall); | 335 | EXPORT_SYMBOL(acpi_os_stall); |
346 | 336 | ||
347 | /* | 337 | /* |
@@ -349,8 +339,7 @@ EXPORT_SYMBOL(acpi_os_stall); | |||
349 | * Returns 64-bit free-running, monotonically increasing timer | 339 | * Returns 64-bit free-running, monotonically increasing timer |
350 | * with 100ns granularity | 340 | * with 100ns granularity |
351 | */ | 341 | */ |
352 | u64 | 342 | u64 acpi_os_get_timer(void) |
353 | acpi_os_get_timer (void) | ||
354 | { | 343 | { |
355 | static u64 t; | 344 | static u64 t; |
356 | 345 | ||
@@ -367,27 +356,22 @@ acpi_os_get_timer (void) | |||
367 | return ++t; | 356 | return ++t; |
368 | } | 357 | } |
369 | 358 | ||
370 | acpi_status | 359 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
371 | acpi_os_read_port( | ||
372 | acpi_io_address port, | ||
373 | u32 *value, | ||
374 | u32 width) | ||
375 | { | 360 | { |
376 | u32 dummy; | 361 | u32 dummy; |
377 | 362 | ||
378 | if (!value) | 363 | if (!value) |
379 | value = &dummy; | 364 | value = &dummy; |
380 | 365 | ||
381 | switch (width) | 366 | switch (width) { |
382 | { | ||
383 | case 8: | 367 | case 8: |
384 | *(u8*) value = inb(port); | 368 | *(u8 *) value = inb(port); |
385 | break; | 369 | break; |
386 | case 16: | 370 | case 16: |
387 | *(u16*) value = inw(port); | 371 | *(u16 *) value = inw(port); |
388 | break; | 372 | break; |
389 | case 32: | 373 | case 32: |
390 | *(u32*) value = inl(port); | 374 | *(u32 *) value = inl(port); |
391 | break; | 375 | break; |
392 | default: | 376 | default: |
393 | BUG(); | 377 | BUG(); |
@@ -395,16 +379,12 @@ acpi_os_read_port( | |||
395 | 379 | ||
396 | return AE_OK; | 380 | return AE_OK; |
397 | } | 381 | } |
382 | |||
398 | EXPORT_SYMBOL(acpi_os_read_port); | 383 | EXPORT_SYMBOL(acpi_os_read_port); |
399 | 384 | ||
400 | acpi_status | 385 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
401 | acpi_os_write_port( | ||
402 | acpi_io_address port, | ||
403 | u32 value, | ||
404 | u32 width) | ||
405 | { | 386 | { |
406 | switch (width) | 387 | switch (width) { |
407 | { | ||
408 | case 8: | 388 | case 8: |
409 | outb(value, port); | 389 | outb(value, port); |
410 | break; | 390 | break; |
@@ -420,40 +400,38 @@ acpi_os_write_port( | |||
420 | 400 | ||
421 | return AE_OK; | 401 | return AE_OK; |
422 | } | 402 | } |
403 | |||
423 | EXPORT_SYMBOL(acpi_os_write_port); | 404 | EXPORT_SYMBOL(acpi_os_write_port); |
424 | 405 | ||
425 | acpi_status | 406 | acpi_status |
426 | acpi_os_read_memory( | 407 | acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) |
427 | acpi_physical_address phys_addr, | ||
428 | u32 *value, | ||
429 | u32 width) | ||
430 | { | 408 | { |
431 | u32 dummy; | 409 | u32 dummy; |
432 | void __iomem *virt_addr; | 410 | void __iomem *virt_addr; |
433 | int iomem = 0; | 411 | int iomem = 0; |
434 | 412 | ||
435 | if (efi_enabled) { | 413 | if (efi_enabled) { |
436 | if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { | 414 | if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { |
437 | /* HACK ALERT! We can use readb/w/l on real memory too.. */ | 415 | /* HACK ALERT! We can use readb/w/l on real memory too.. */ |
438 | virt_addr = (void __iomem *) phys_to_virt(phys_addr); | 416 | virt_addr = (void __iomem *)phys_to_virt(phys_addr); |
439 | } else { | 417 | } else { |
440 | iomem = 1; | 418 | iomem = 1; |
441 | virt_addr = ioremap(phys_addr, width); | 419 | virt_addr = ioremap(phys_addr, width); |
442 | } | 420 | } |
443 | } else | 421 | } else |
444 | virt_addr = (void __iomem *) phys_to_virt(phys_addr); | 422 | virt_addr = (void __iomem *)phys_to_virt(phys_addr); |
445 | if (!value) | 423 | if (!value) |
446 | value = &dummy; | 424 | value = &dummy; |
447 | 425 | ||
448 | switch (width) { | 426 | switch (width) { |
449 | case 8: | 427 | case 8: |
450 | *(u8*) value = readb(virt_addr); | 428 | *(u8 *) value = readb(virt_addr); |
451 | break; | 429 | break; |
452 | case 16: | 430 | case 16: |
453 | *(u16*) value = readw(virt_addr); | 431 | *(u16 *) value = readw(virt_addr); |
454 | break; | 432 | break; |
455 | case 32: | 433 | case 32: |
456 | *(u32*) value = readl(virt_addr); | 434 | *(u32 *) value = readl(virt_addr); |
457 | break; | 435 | break; |
458 | default: | 436 | default: |
459 | BUG(); | 437 | BUG(); |
@@ -468,24 +446,21 @@ acpi_os_read_memory( | |||
468 | } | 446 | } |
469 | 447 | ||
470 | acpi_status | 448 | acpi_status |
471 | acpi_os_write_memory( | 449 | acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) |
472 | acpi_physical_address phys_addr, | ||
473 | u32 value, | ||
474 | u32 width) | ||
475 | { | 450 | { |
476 | void __iomem *virt_addr; | 451 | void __iomem *virt_addr; |
477 | int iomem = 0; | 452 | int iomem = 0; |
478 | 453 | ||
479 | if (efi_enabled) { | 454 | if (efi_enabled) { |
480 | if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { | 455 | if (EFI_MEMORY_WB & efi_mem_attributes(phys_addr)) { |
481 | /* HACK ALERT! We can use writeb/w/l on real memory too */ | 456 | /* HACK ALERT! We can use writeb/w/l on real memory too */ |
482 | virt_addr = (void __iomem *) phys_to_virt(phys_addr); | 457 | virt_addr = (void __iomem *)phys_to_virt(phys_addr); |
483 | } else { | 458 | } else { |
484 | iomem = 1; | 459 | iomem = 1; |
485 | virt_addr = ioremap(phys_addr, width); | 460 | virt_addr = ioremap(phys_addr, width); |
486 | } | 461 | } |
487 | } else | 462 | } else |
488 | virt_addr = (void __iomem *) phys_to_virt(phys_addr); | 463 | virt_addr = (void __iomem *)phys_to_virt(phys_addr); |
489 | 464 | ||
490 | switch (width) { | 465 | switch (width) { |
491 | case 8: | 466 | case 8: |
@@ -507,10 +482,9 @@ acpi_os_write_memory( | |||
507 | return AE_OK; | 482 | return AE_OK; |
508 | } | 483 | } |
509 | 484 | ||
510 | #ifdef CONFIG_ACPI_PCI | ||
511 | |||
512 | acpi_status | 485 | acpi_status |
513 | acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value, u32 width) | 486 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
487 | void *value, u32 width) | ||
514 | { | 488 | { |
515 | int result, size; | 489 | int result, size; |
516 | 490 | ||
@@ -534,15 +508,17 @@ acpi_os_read_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, void *value | |||
534 | BUG_ON(!raw_pci_ops); | 508 | BUG_ON(!raw_pci_ops); |
535 | 509 | ||
536 | result = raw_pci_ops->read(pci_id->segment, pci_id->bus, | 510 | result = raw_pci_ops->read(pci_id->segment, pci_id->bus, |
537 | PCI_DEVFN(pci_id->device, pci_id->function), | 511 | PCI_DEVFN(pci_id->device, pci_id->function), |
538 | reg, size, value); | 512 | reg, size, value); |
539 | 513 | ||
540 | return (result ? AE_ERROR : AE_OK); | 514 | return (result ? AE_ERROR : AE_OK); |
541 | } | 515 | } |
516 | |||
542 | EXPORT_SYMBOL(acpi_os_read_pci_configuration); | 517 | EXPORT_SYMBOL(acpi_os_read_pci_configuration); |
543 | 518 | ||
544 | acpi_status | 519 | acpi_status |
545 | acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integer value, u32 width) | 520 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
521 | acpi_integer value, u32 width) | ||
546 | { | 522 | { |
547 | int result, size; | 523 | int result, size; |
548 | 524 | ||
@@ -563,56 +539,62 @@ acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integ | |||
563 | BUG_ON(!raw_pci_ops); | 539 | BUG_ON(!raw_pci_ops); |
564 | 540 | ||
565 | result = raw_pci_ops->write(pci_id->segment, pci_id->bus, | 541 | result = raw_pci_ops->write(pci_id->segment, pci_id->bus, |
566 | PCI_DEVFN(pci_id->device, pci_id->function), | 542 | PCI_DEVFN(pci_id->device, pci_id->function), |
567 | reg, size, value); | 543 | reg, size, value); |
568 | 544 | ||
569 | return (result ? AE_ERROR : AE_OK); | 545 | return (result ? AE_ERROR : AE_OK); |
570 | } | 546 | } |
571 | 547 | ||
572 | /* TODO: Change code to take advantage of driver model more */ | 548 | /* TODO: Change code to take advantage of driver model more */ |
573 | static void | 549 | static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ |
574 | acpi_os_derive_pci_id_2 ( | 550 | acpi_handle chandle, /* current node */ |
575 | acpi_handle rhandle, /* upper bound */ | 551 | struct acpi_pci_id **id, |
576 | acpi_handle chandle, /* current node */ | 552 | int *is_bridge, u8 * bus_number) |
577 | struct acpi_pci_id **id, | ||
578 | int *is_bridge, | ||
579 | u8 *bus_number) | ||
580 | { | 553 | { |
581 | acpi_handle handle; | 554 | acpi_handle handle; |
582 | struct acpi_pci_id *pci_id = *id; | 555 | struct acpi_pci_id *pci_id = *id; |
583 | acpi_status status; | 556 | acpi_status status; |
584 | unsigned long temp; | 557 | unsigned long temp; |
585 | acpi_object_type type; | 558 | acpi_object_type type; |
586 | u8 tu8; | 559 | u8 tu8; |
587 | 560 | ||
588 | acpi_get_parent(chandle, &handle); | 561 | acpi_get_parent(chandle, &handle); |
589 | if (handle != rhandle) { | 562 | if (handle != rhandle) { |
590 | acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, bus_number); | 563 | acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, |
564 | bus_number); | ||
591 | 565 | ||
592 | status = acpi_get_type(handle, &type); | 566 | status = acpi_get_type(handle, &type); |
593 | if ( (ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE) ) | 567 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) |
594 | return; | 568 | return; |
595 | 569 | ||
596 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &temp); | 570 | status = |
571 | acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, | ||
572 | &temp); | ||
597 | if (ACPI_SUCCESS(status)) { | 573 | if (ACPI_SUCCESS(status)) { |
598 | pci_id->device = ACPI_HIWORD (ACPI_LODWORD (temp)); | 574 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); |
599 | pci_id->function = ACPI_LOWORD (ACPI_LODWORD (temp)); | 575 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); |
600 | 576 | ||
601 | if (*is_bridge) | 577 | if (*is_bridge) |
602 | pci_id->bus = *bus_number; | 578 | pci_id->bus = *bus_number; |
603 | 579 | ||
604 | /* any nicer way to get bus number of bridge ? */ | 580 | /* any nicer way to get bus number of bridge ? */ |
605 | status = acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, 8); | 581 | status = |
606 | if (ACPI_SUCCESS(status) && | 582 | acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, |
607 | ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { | 583 | 8); |
608 | status = acpi_os_read_pci_configuration(pci_id, 0x18, &tu8, 8); | 584 | if (ACPI_SUCCESS(status) |
585 | && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { | ||
586 | status = | ||
587 | acpi_os_read_pci_configuration(pci_id, 0x18, | ||
588 | &tu8, 8); | ||
609 | if (!ACPI_SUCCESS(status)) { | 589 | if (!ACPI_SUCCESS(status)) { |
610 | /* Certainly broken... FIX ME */ | 590 | /* Certainly broken... FIX ME */ |
611 | return; | 591 | return; |
612 | } | 592 | } |
613 | *is_bridge = 1; | 593 | *is_bridge = 1; |
614 | pci_id->bus = tu8; | 594 | pci_id->bus = tu8; |
615 | status = acpi_os_read_pci_configuration(pci_id, 0x19, &tu8, 8); | 595 | status = |
596 | acpi_os_read_pci_configuration(pci_id, 0x19, | ||
597 | &tu8, 8); | ||
616 | if (ACPI_SUCCESS(status)) { | 598 | if (ACPI_SUCCESS(status)) { |
617 | *bus_number = tu8; | 599 | *bus_number = tu8; |
618 | } | 600 | } |
@@ -622,11 +604,9 @@ acpi_os_derive_pci_id_2 ( | |||
622 | } | 604 | } |
623 | } | 605 | } |
624 | 606 | ||
625 | void | 607 | void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ |
626 | acpi_os_derive_pci_id ( | 608 | acpi_handle chandle, /* current node */ |
627 | acpi_handle rhandle, /* upper bound */ | 609 | struct acpi_pci_id **id) |
628 | acpi_handle chandle, /* current node */ | ||
629 | struct acpi_pci_id **id) | ||
630 | { | 610 | { |
631 | int is_bridge = 1; | 611 | int is_bridge = 1; |
632 | u8 bus_number = (*id)->bus; | 612 | u8 bus_number = (*id)->bus; |
@@ -634,49 +614,15 @@ acpi_os_derive_pci_id ( | |||
634 | acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); | 614 | acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); |
635 | } | 615 | } |
636 | 616 | ||
637 | #else /*!CONFIG_ACPI_PCI*/ | 617 | static void acpi_os_execute_deferred(void *context) |
638 | |||
639 | acpi_status | ||
640 | acpi_os_write_pci_configuration ( | ||
641 | struct acpi_pci_id *pci_id, | ||
642 | u32 reg, | ||
643 | acpi_integer value, | ||
644 | u32 width) | ||
645 | { | ||
646 | return AE_SUPPORT; | ||
647 | } | ||
648 | |||
649 | acpi_status | ||
650 | acpi_os_read_pci_configuration ( | ||
651 | struct acpi_pci_id *pci_id, | ||
652 | u32 reg, | ||
653 | void *value, | ||
654 | u32 width) | ||
655 | { | ||
656 | return AE_SUPPORT; | ||
657 | } | ||
658 | |||
659 | void | ||
660 | acpi_os_derive_pci_id ( | ||
661 | acpi_handle rhandle, /* upper bound */ | ||
662 | acpi_handle chandle, /* current node */ | ||
663 | struct acpi_pci_id **id) | ||
664 | { | ||
665 | } | ||
666 | |||
667 | #endif /*CONFIG_ACPI_PCI*/ | ||
668 | |||
669 | static void | ||
670 | acpi_os_execute_deferred ( | ||
671 | void *context) | ||
672 | { | 618 | { |
673 | struct acpi_os_dpc *dpc = NULL; | 619 | struct acpi_os_dpc *dpc = NULL; |
674 | 620 | ||
675 | ACPI_FUNCTION_TRACE ("os_execute_deferred"); | 621 | ACPI_FUNCTION_TRACE("os_execute_deferred"); |
676 | 622 | ||
677 | dpc = (struct acpi_os_dpc *) context; | 623 | dpc = (struct acpi_os_dpc *)context; |
678 | if (!dpc) { | 624 | if (!dpc) { |
679 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); | 625 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); |
680 | return_VOID; | 626 | return_VOID; |
681 | } | 627 | } |
682 | 628 | ||
@@ -688,21 +634,21 @@ acpi_os_execute_deferred ( | |||
688 | } | 634 | } |
689 | 635 | ||
690 | acpi_status | 636 | acpi_status |
691 | acpi_os_queue_for_execution( | 637 | acpi_os_queue_for_execution(u32 priority, |
692 | u32 priority, | 638 | acpi_osd_exec_callback function, void *context) |
693 | acpi_osd_exec_callback function, | ||
694 | void *context) | ||
695 | { | 639 | { |
696 | acpi_status status = AE_OK; | 640 | acpi_status status = AE_OK; |
697 | struct acpi_os_dpc *dpc; | 641 | struct acpi_os_dpc *dpc; |
698 | struct work_struct *task; | 642 | struct work_struct *task; |
699 | 643 | ||
700 | ACPI_FUNCTION_TRACE ("os_queue_for_execution"); | 644 | ACPI_FUNCTION_TRACE("os_queue_for_execution"); |
701 | 645 | ||
702 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); | 646 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
647 | "Scheduling function [%p(%p)] for deferred execution.\n", | ||
648 | function, context)); | ||
703 | 649 | ||
704 | if (!function) | 650 | if (!function) |
705 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 651 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
706 | 652 | ||
707 | /* | 653 | /* |
708 | * Allocate/initialize DPC structure. Note that this memory will be | 654 | * Allocate/initialize DPC structure. Note that this memory will be |
@@ -715,146 +661,94 @@ acpi_os_queue_for_execution( | |||
715 | * from the same memory. | 661 | * from the same memory. |
716 | */ | 662 | */ |
717 | 663 | ||
718 | dpc = kmalloc(sizeof(struct acpi_os_dpc)+sizeof(struct work_struct), GFP_ATOMIC); | 664 | dpc = |
665 | kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct), | ||
666 | GFP_ATOMIC); | ||
719 | if (!dpc) | 667 | if (!dpc) |
720 | return_ACPI_STATUS (AE_NO_MEMORY); | 668 | return_ACPI_STATUS(AE_NO_MEMORY); |
721 | 669 | ||
722 | dpc->function = function; | 670 | dpc->function = function; |
723 | dpc->context = context; | 671 | dpc->context = context; |
724 | 672 | ||
725 | task = (void *)(dpc+1); | 673 | task = (void *)(dpc + 1); |
726 | INIT_WORK(task, acpi_os_execute_deferred, (void*)dpc); | 674 | INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); |
727 | 675 | ||
728 | if (!queue_work(kacpid_wq, task)) { | 676 | if (!queue_work(kacpid_wq, task)) { |
729 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to queue_work() failed.\n")); | 677 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
678 | "Call to queue_work() failed.\n")); | ||
730 | kfree(dpc); | 679 | kfree(dpc); |
731 | status = AE_ERROR; | 680 | status = AE_ERROR; |
732 | } | 681 | } |
733 | 682 | ||
734 | return_ACPI_STATUS (status); | 683 | return_ACPI_STATUS(status); |
735 | } | 684 | } |
685 | |||
736 | EXPORT_SYMBOL(acpi_os_queue_for_execution); | 686 | EXPORT_SYMBOL(acpi_os_queue_for_execution); |
737 | 687 | ||
738 | void | 688 | void acpi_os_wait_events_complete(void *context) |
739 | acpi_os_wait_events_complete( | ||
740 | void *context) | ||
741 | { | 689 | { |
742 | flush_workqueue(kacpid_wq); | 690 | flush_workqueue(kacpid_wq); |
743 | } | 691 | } |
692 | |||
744 | EXPORT_SYMBOL(acpi_os_wait_events_complete); | 693 | EXPORT_SYMBOL(acpi_os_wait_events_complete); |
745 | 694 | ||
746 | /* | 695 | /* |
747 | * Allocate the memory for a spinlock and initialize it. | 696 | * Allocate the memory for a spinlock and initialize it. |
748 | */ | 697 | */ |
749 | acpi_status | 698 | acpi_status acpi_os_create_lock(acpi_handle * out_handle) |
750 | acpi_os_create_lock ( | ||
751 | acpi_handle *out_handle) | ||
752 | { | 699 | { |
753 | spinlock_t *lock_ptr; | 700 | spinlock_t *lock_ptr; |
754 | 701 | ||
755 | ACPI_FUNCTION_TRACE ("os_create_lock"); | 702 | ACPI_FUNCTION_TRACE("os_create_lock"); |
756 | 703 | ||
757 | lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); | 704 | lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); |
758 | 705 | ||
759 | spin_lock_init(lock_ptr); | 706 | spin_lock_init(lock_ptr); |
760 | 707 | ||
761 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); | 708 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); |
762 | 709 | ||
763 | *out_handle = lock_ptr; | 710 | *out_handle = lock_ptr; |
764 | 711 | ||
765 | return_ACPI_STATUS (AE_OK); | 712 | return_ACPI_STATUS(AE_OK); |
766 | } | 713 | } |
767 | 714 | ||
768 | |||
769 | /* | 715 | /* |
770 | * Deallocate the memory for a spinlock. | 716 | * Deallocate the memory for a spinlock. |
771 | */ | 717 | */ |
772 | void | 718 | void acpi_os_delete_lock(acpi_handle handle) |
773 | acpi_os_delete_lock ( | ||
774 | acpi_handle handle) | ||
775 | { | 719 | { |
776 | ACPI_FUNCTION_TRACE ("os_create_lock"); | 720 | ACPI_FUNCTION_TRACE("os_create_lock"); |
777 | 721 | ||
778 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); | 722 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); |
779 | 723 | ||
780 | acpi_os_free(handle); | 724 | acpi_os_free(handle); |
781 | 725 | ||
782 | return_VOID; | 726 | return_VOID; |
783 | } | 727 | } |
784 | 728 | ||
785 | /* | ||
786 | * Acquire a spinlock. | ||
787 | * | ||
788 | * handle is a pointer to the spinlock_t. | ||
789 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
790 | * that indicates whether we are at interrupt level. | ||
791 | */ | ||
792 | void | ||
793 | acpi_os_acquire_lock ( | ||
794 | acpi_handle handle, | ||
795 | u32 flags) | ||
796 | { | ||
797 | ACPI_FUNCTION_TRACE ("os_acquire_lock"); | ||
798 | |||
799 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle, | ||
800 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
801 | |||
802 | if (flags & ACPI_NOT_ISR) | ||
803 | ACPI_DISABLE_IRQS(); | ||
804 | |||
805 | spin_lock((spinlock_t *)handle); | ||
806 | |||
807 | return_VOID; | ||
808 | } | ||
809 | |||
810 | |||
811 | /* | ||
812 | * Release a spinlock. See above. | ||
813 | */ | ||
814 | void | ||
815 | acpi_os_release_lock ( | ||
816 | acpi_handle handle, | ||
817 | u32 flags) | ||
818 | { | ||
819 | ACPI_FUNCTION_TRACE ("os_release_lock"); | ||
820 | |||
821 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle, | ||
822 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
823 | |||
824 | spin_unlock((spinlock_t *)handle); | ||
825 | |||
826 | if (flags & ACPI_NOT_ISR) | ||
827 | ACPI_ENABLE_IRQS(); | ||
828 | |||
829 | return_VOID; | ||
830 | } | ||
831 | |||
832 | |||
833 | acpi_status | 729 | acpi_status |
834 | acpi_os_create_semaphore( | 730 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
835 | u32 max_units, | ||
836 | u32 initial_units, | ||
837 | acpi_handle *handle) | ||
838 | { | 731 | { |
839 | struct semaphore *sem = NULL; | 732 | struct semaphore *sem = NULL; |
840 | 733 | ||
841 | ACPI_FUNCTION_TRACE ("os_create_semaphore"); | 734 | ACPI_FUNCTION_TRACE("os_create_semaphore"); |
842 | 735 | ||
843 | sem = acpi_os_allocate(sizeof(struct semaphore)); | 736 | sem = acpi_os_allocate(sizeof(struct semaphore)); |
844 | if (!sem) | 737 | if (!sem) |
845 | return_ACPI_STATUS (AE_NO_MEMORY); | 738 | return_ACPI_STATUS(AE_NO_MEMORY); |
846 | memset(sem, 0, sizeof(struct semaphore)); | 739 | memset(sem, 0, sizeof(struct semaphore)); |
847 | 740 | ||
848 | sema_init(sem, initial_units); | 741 | sema_init(sem, initial_units); |
849 | 742 | ||
850 | *handle = (acpi_handle*)sem; | 743 | *handle = (acpi_handle *) sem; |
851 | 744 | ||
852 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); | 745 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", |
746 | *handle, initial_units)); | ||
853 | 747 | ||
854 | return_ACPI_STATUS (AE_OK); | 748 | return_ACPI_STATUS(AE_OK); |
855 | } | 749 | } |
856 | EXPORT_SYMBOL(acpi_os_create_semaphore); | ||
857 | 750 | ||
751 | EXPORT_SYMBOL(acpi_os_create_semaphore); | ||
858 | 752 | ||
859 | /* | 753 | /* |
860 | * TODO: A better way to delete semaphores? Linux doesn't have a | 754 | * TODO: A better way to delete semaphores? Linux doesn't have a |
@@ -863,25 +757,24 @@ EXPORT_SYMBOL(acpi_os_create_semaphore); | |||
863 | * we at least check for blocked threads and signal/cancel them? | 757 | * we at least check for blocked threads and signal/cancel them? |
864 | */ | 758 | */ |
865 | 759 | ||
866 | acpi_status | 760 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) |
867 | acpi_os_delete_semaphore( | ||
868 | acpi_handle handle) | ||
869 | { | 761 | { |
870 | struct semaphore *sem = (struct semaphore*) handle; | 762 | struct semaphore *sem = (struct semaphore *)handle; |
871 | 763 | ||
872 | ACPI_FUNCTION_TRACE ("os_delete_semaphore"); | 764 | ACPI_FUNCTION_TRACE("os_delete_semaphore"); |
873 | 765 | ||
874 | if (!sem) | 766 | if (!sem) |
875 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 767 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
876 | 768 | ||
877 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); | 769 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); |
878 | 770 | ||
879 | acpi_os_free(sem); sem = NULL; | 771 | acpi_os_free(sem); |
772 | sem = NULL; | ||
880 | 773 | ||
881 | return_ACPI_STATUS (AE_OK); | 774 | return_ACPI_STATUS(AE_OK); |
882 | } | 775 | } |
883 | EXPORT_SYMBOL(acpi_os_delete_semaphore); | ||
884 | 776 | ||
777 | EXPORT_SYMBOL(acpi_os_delete_semaphore); | ||
885 | 778 | ||
886 | /* | 779 | /* |
887 | * TODO: The kernel doesn't have a 'down_timeout' function -- had to | 780 | * TODO: The kernel doesn't have a 'down_timeout' function -- had to |
@@ -892,31 +785,27 @@ EXPORT_SYMBOL(acpi_os_delete_semaphore); | |||
892 | * | 785 | * |
893 | * TODO: Support for units > 1? | 786 | * TODO: Support for units > 1? |
894 | */ | 787 | */ |
895 | acpi_status | 788 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) |
896 | acpi_os_wait_semaphore( | ||
897 | acpi_handle handle, | ||
898 | u32 units, | ||
899 | u16 timeout) | ||
900 | { | 789 | { |
901 | acpi_status status = AE_OK; | 790 | acpi_status status = AE_OK; |
902 | struct semaphore *sem = (struct semaphore*)handle; | 791 | struct semaphore *sem = (struct semaphore *)handle; |
903 | int ret = 0; | 792 | int ret = 0; |
904 | 793 | ||
905 | ACPI_FUNCTION_TRACE ("os_wait_semaphore"); | 794 | ACPI_FUNCTION_TRACE("os_wait_semaphore"); |
906 | 795 | ||
907 | if (!sem || (units < 1)) | 796 | if (!sem || (units < 1)) |
908 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 797 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
909 | 798 | ||
910 | if (units > 1) | 799 | if (units > 1) |
911 | return_ACPI_STATUS (AE_SUPPORT); | 800 | return_ACPI_STATUS(AE_SUPPORT); |
912 | 801 | ||
913 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); | 802 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", |
803 | handle, units, timeout)); | ||
914 | 804 | ||
915 | if (in_atomic()) | 805 | if (in_atomic()) |
916 | timeout = 0; | 806 | timeout = 0; |
917 | 807 | ||
918 | switch (timeout) | 808 | switch (timeout) { |
919 | { | ||
920 | /* | 809 | /* |
921 | * No Wait: | 810 | * No Wait: |
922 | * -------- | 811 | * -------- |
@@ -924,8 +813,8 @@ acpi_os_wait_semaphore( | |||
924 | * acquire the semaphore if available otherwise return AE_TIME | 813 | * acquire the semaphore if available otherwise return AE_TIME |
925 | * (a.k.a. 'would block'). | 814 | * (a.k.a. 'would block'). |
926 | */ | 815 | */ |
927 | case 0: | 816 | case 0: |
928 | if(down_trylock(sem)) | 817 | if (down_trylock(sem)) |
929 | status = AE_TIME; | 818 | status = AE_TIME; |
930 | break; | 819 | break; |
931 | 820 | ||
@@ -933,7 +822,7 @@ acpi_os_wait_semaphore( | |||
933 | * Wait Indefinitely: | 822 | * Wait Indefinitely: |
934 | * ------------------ | 823 | * ------------------ |
935 | */ | 824 | */ |
936 | case ACPI_WAIT_FOREVER: | 825 | case ACPI_WAIT_FOREVER: |
937 | down(sem); | 826 | down(sem); |
938 | break; | 827 | break; |
939 | 828 | ||
@@ -941,11 +830,11 @@ acpi_os_wait_semaphore( | |||
941 | * Wait w/ Timeout: | 830 | * Wait w/ Timeout: |
942 | * ---------------- | 831 | * ---------------- |
943 | */ | 832 | */ |
944 | default: | 833 | default: |
945 | // TODO: A better timeout algorithm? | 834 | // TODO: A better timeout algorithm? |
946 | { | 835 | { |
947 | int i = 0; | 836 | int i = 0; |
948 | static const int quantum_ms = 1000/HZ; | 837 | static const int quantum_ms = 1000 / HZ; |
949 | 838 | ||
950 | ret = down_trylock(sem); | 839 | ret = down_trylock(sem); |
951 | for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { | 840 | for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { |
@@ -953,7 +842,7 @@ acpi_os_wait_semaphore( | |||
953 | schedule_timeout(1); | 842 | schedule_timeout(1); |
954 | ret = down_trylock(sem); | 843 | ret = down_trylock(sem); |
955 | } | 844 | } |
956 | 845 | ||
957 | if (ret != 0) | 846 | if (ret != 0) |
958 | status = AE_TIME; | 847 | status = AE_TIME; |
959 | } | 848 | } |
@@ -961,47 +850,48 @@ acpi_os_wait_semaphore( | |||
961 | } | 850 | } |
962 | 851 | ||
963 | if (ACPI_FAILURE(status)) { | 852 | if (ACPI_FAILURE(status)) { |
964 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failed to acquire semaphore[%p|%d|%d], %s\n", | 853 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
965 | handle, units, timeout, acpi_format_exception(status))); | 854 | "Failed to acquire semaphore[%p|%d|%d], %s\n", |
966 | } | 855 | handle, units, timeout, |
967 | else { | 856 | acpi_format_exception(status))); |
968 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout)); | 857 | } else { |
858 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | ||
859 | "Acquired semaphore[%p|%d|%d]\n", handle, | ||
860 | units, timeout)); | ||
969 | } | 861 | } |
970 | 862 | ||
971 | return_ACPI_STATUS (status); | 863 | return_ACPI_STATUS(status); |
972 | } | 864 | } |
973 | EXPORT_SYMBOL(acpi_os_wait_semaphore); | ||
974 | 865 | ||
866 | EXPORT_SYMBOL(acpi_os_wait_semaphore); | ||
975 | 867 | ||
976 | /* | 868 | /* |
977 | * TODO: Support for units > 1? | 869 | * TODO: Support for units > 1? |
978 | */ | 870 | */ |
979 | acpi_status | 871 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) |
980 | acpi_os_signal_semaphore( | ||
981 | acpi_handle handle, | ||
982 | u32 units) | ||
983 | { | 872 | { |
984 | struct semaphore *sem = (struct semaphore *) handle; | 873 | struct semaphore *sem = (struct semaphore *)handle; |
985 | 874 | ||
986 | ACPI_FUNCTION_TRACE ("os_signal_semaphore"); | 875 | ACPI_FUNCTION_TRACE("os_signal_semaphore"); |
987 | 876 | ||
988 | if (!sem || (units < 1)) | 877 | if (!sem || (units < 1)) |
989 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 878 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
990 | 879 | ||
991 | if (units > 1) | 880 | if (units > 1) |
992 | return_ACPI_STATUS (AE_SUPPORT); | 881 | return_ACPI_STATUS(AE_SUPPORT); |
993 | 882 | ||
994 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); | 883 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, |
884 | units)); | ||
995 | 885 | ||
996 | up(sem); | 886 | up(sem); |
997 | 887 | ||
998 | return_ACPI_STATUS (AE_OK); | 888 | return_ACPI_STATUS(AE_OK); |
999 | } | 889 | } |
890 | |||
1000 | EXPORT_SYMBOL(acpi_os_signal_semaphore); | 891 | EXPORT_SYMBOL(acpi_os_signal_semaphore); |
1001 | 892 | ||
1002 | #ifdef ACPI_FUTURE_USAGE | 893 | #ifdef ACPI_FUTURE_USAGE |
1003 | u32 | 894 | u32 acpi_os_get_line(char *buffer) |
1004 | acpi_os_get_line(char *buffer) | ||
1005 | { | 895 | { |
1006 | 896 | ||
1007 | #ifdef ENABLE_DEBUGGER | 897 | #ifdef ENABLE_DEBUGGER |
@@ -1018,22 +908,21 @@ acpi_os_get_line(char *buffer) | |||
1018 | 908 | ||
1019 | return 0; | 909 | return 0; |
1020 | } | 910 | } |
1021 | #endif /* ACPI_FUTURE_USAGE */ | 911 | #endif /* ACPI_FUTURE_USAGE */ |
1022 | 912 | ||
1023 | /* Assumes no unreadable holes inbetween */ | 913 | /* Assumes no unreadable holes inbetween */ |
1024 | u8 | 914 | u8 acpi_os_readable(void *ptr, acpi_size len) |
1025 | acpi_os_readable(void *ptr, acpi_size len) | ||
1026 | { | 915 | { |
1027 | #if defined(__i386__) || defined(__x86_64__) | 916 | #if defined(__i386__) || defined(__x86_64__) |
1028 | char tmp; | 917 | char tmp; |
1029 | return !__get_user(tmp, (char __user *)ptr) && !__get_user(tmp, (char __user *)ptr + len - 1); | 918 | return !__get_user(tmp, (char __user *)ptr) |
919 | && !__get_user(tmp, (char __user *)ptr + len - 1); | ||
1030 | #endif | 920 | #endif |
1031 | return 1; | 921 | return 1; |
1032 | } | 922 | } |
1033 | 923 | ||
1034 | #ifdef ACPI_FUTURE_USAGE | 924 | #ifdef ACPI_FUTURE_USAGE |
1035 | u8 | 925 | u8 acpi_os_writable(void *ptr, acpi_size len) |
1036 | acpi_os_writable(void *ptr, acpi_size len) | ||
1037 | { | 926 | { |
1038 | /* could do dummy write (racy) or a kernel page table lookup. | 927 | /* could do dummy write (racy) or a kernel page table lookup. |
1039 | The later may be difficult at early boot when kmap doesn't work yet. */ | 928 | The later may be difficult at early boot when kmap doesn't work yet. */ |
@@ -1041,8 +930,7 @@ acpi_os_writable(void *ptr, acpi_size len) | |||
1041 | } | 930 | } |
1042 | #endif | 931 | #endif |
1043 | 932 | ||
1044 | u32 | 933 | u32 acpi_os_get_thread_id(void) |
1045 | acpi_os_get_thread_id (void) | ||
1046 | { | 934 | { |
1047 | if (!in_atomic()) | 935 | if (!in_atomic()) |
1048 | return current->pid; | 936 | return current->pid; |
@@ -1050,13 +938,9 @@ acpi_os_get_thread_id (void) | |||
1050 | return 0; | 938 | return 0; |
1051 | } | 939 | } |
1052 | 940 | ||
1053 | acpi_status | 941 | acpi_status acpi_os_signal(u32 function, void *info) |
1054 | acpi_os_signal ( | ||
1055 | u32 function, | ||
1056 | void *info) | ||
1057 | { | 942 | { |
1058 | switch (function) | 943 | switch (function) { |
1059 | { | ||
1060 | case ACPI_SIGNAL_FATAL: | 944 | case ACPI_SIGNAL_FATAL: |
1061 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); | 945 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); |
1062 | break; | 946 | break; |
@@ -1076,13 +960,13 @@ acpi_os_signal ( | |||
1076 | 960 | ||
1077 | return AE_OK; | 961 | return AE_OK; |
1078 | } | 962 | } |
963 | |||
1079 | EXPORT_SYMBOL(acpi_os_signal); | 964 | EXPORT_SYMBOL(acpi_os_signal); |
1080 | 965 | ||
1081 | static int __init | 966 | static int __init acpi_os_name_setup(char *str) |
1082 | acpi_os_name_setup(char *str) | ||
1083 | { | 967 | { |
1084 | char *p = acpi_os_name; | 968 | char *p = acpi_os_name; |
1085 | int count = ACPI_MAX_OVERRIDE_LEN-1; | 969 | int count = ACPI_MAX_OVERRIDE_LEN - 1; |
1086 | 970 | ||
1087 | if (!str || !*str) | 971 | if (!str || !*str) |
1088 | return 0; | 972 | return 0; |
@@ -1098,7 +982,7 @@ acpi_os_name_setup(char *str) | |||
1098 | *p = 0; | 982 | *p = 0; |
1099 | 983 | ||
1100 | return 1; | 984 | return 1; |
1101 | 985 | ||
1102 | } | 986 | } |
1103 | 987 | ||
1104 | __setup("acpi_os_name=", acpi_os_name_setup); | 988 | __setup("acpi_os_name=", acpi_os_name_setup); |
@@ -1108,16 +992,15 @@ __setup("acpi_os_name=", acpi_os_name_setup); | |||
1108 | * empty string disables _OSI | 992 | * empty string disables _OSI |
1109 | * TBD additional string adds to _OSI | 993 | * TBD additional string adds to _OSI |
1110 | */ | 994 | */ |
1111 | static int __init | 995 | static int __init acpi_osi_setup(char *str) |
1112 | acpi_osi_setup(char *str) | ||
1113 | { | 996 | { |
1114 | if (str == NULL || *str == '\0') { | 997 | if (str == NULL || *str == '\0') { |
1115 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); | 998 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); |
1116 | acpi_gbl_create_osi_method = FALSE; | 999 | acpi_gbl_create_osi_method = FALSE; |
1117 | } else | 1000 | } else { |
1118 | { | ||
1119 | /* TBD */ | 1001 | /* TBD */ |
1120 | printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", str); | 1002 | printk(KERN_ERR PREFIX "_OSI additional string ignored -- %s\n", |
1003 | str); | ||
1121 | } | 1004 | } |
1122 | 1005 | ||
1123 | return 1; | 1006 | return 1; |
@@ -1126,8 +1009,7 @@ acpi_osi_setup(char *str) | |||
1126 | __setup("acpi_osi=", acpi_osi_setup); | 1009 | __setup("acpi_osi=", acpi_osi_setup); |
1127 | 1010 | ||
1128 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ | 1011 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ |
1129 | static int __init | 1012 | static int __init acpi_serialize_setup(char *str) |
1130 | acpi_serialize_setup(char *str) | ||
1131 | { | 1013 | { |
1132 | printk(KERN_INFO PREFIX "serialize enabled\n"); | 1014 | printk(KERN_INFO PREFIX "serialize enabled\n"); |
1133 | 1015 | ||
@@ -1147,8 +1029,7 @@ __setup("acpi_serialize", acpi_serialize_setup); | |||
1147 | * Run-time events on the same GPE this flag is available | 1029 | * Run-time events on the same GPE this flag is available |
1148 | * to tell Linux to keep the wake-time GPEs enabled at run-time. | 1030 | * to tell Linux to keep the wake-time GPEs enabled at run-time. |
1149 | */ | 1031 | */ |
1150 | static int __init | 1032 | static int __init acpi_wake_gpes_always_on_setup(char *str) |
1151 | acpi_wake_gpes_always_on_setup(char *str) | ||
1152 | { | 1033 | { |
1153 | printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); | 1034 | printk(KERN_INFO PREFIX "wake GPEs not disabled\n"); |
1154 | 1035 | ||
@@ -1159,8 +1040,7 @@ acpi_wake_gpes_always_on_setup(char *str) | |||
1159 | 1040 | ||
1160 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); | 1041 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); |
1161 | 1042 | ||
1162 | int __init | 1043 | static int __init acpi_hotkey_setup(char *str) |
1163 | acpi_hotkey_setup(char *str) | ||
1164 | { | 1044 | { |
1165 | acpi_specific_hotkey_enabled = FALSE; | 1045 | acpi_specific_hotkey_enabled = FALSE; |
1166 | return 1; | 1046 | return 1; |
@@ -1174,5 +1054,132 @@ __setup("acpi_generic_hotkey", acpi_hotkey_setup); | |||
1174 | */ | 1054 | */ |
1175 | unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; | 1055 | unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; |
1176 | 1056 | ||
1177 | |||
1178 | EXPORT_SYMBOL(max_cstate); | 1057 | EXPORT_SYMBOL(max_cstate); |
1058 | |||
1059 | /* | ||
1060 | * Acquire a spinlock. | ||
1061 | * | ||
1062 | * handle is a pointer to the spinlock_t. | ||
1063 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
1064 | * that indicates whether we are at interrupt level. | ||
1065 | */ | ||
1066 | |||
1067 | unsigned long acpi_os_acquire_lock(acpi_handle handle) | ||
1068 | { | ||
1069 | unsigned long flags; | ||
1070 | spin_lock_irqsave((spinlock_t *) handle, flags); | ||
1071 | return flags; | ||
1072 | } | ||
1073 | |||
1074 | /* | ||
1075 | * Release a spinlock. See above. | ||
1076 | */ | ||
1077 | |||
1078 | void acpi_os_release_lock(acpi_handle handle, unsigned long flags) | ||
1079 | { | ||
1080 | spin_unlock_irqrestore((spinlock_t *) handle, flags); | ||
1081 | } | ||
1082 | |||
1083 | #ifndef ACPI_USE_LOCAL_CACHE | ||
1084 | |||
1085 | /******************************************************************************* | ||
1086 | * | ||
1087 | * FUNCTION: acpi_os_create_cache | ||
1088 | * | ||
1089 | * PARAMETERS: CacheName - Ascii name for the cache | ||
1090 | * ObjectSize - Size of each cached object | ||
1091 | * MaxDepth - Maximum depth of the cache (in objects) | ||
1092 | * ReturnCache - Where the new cache object is returned | ||
1093 | * | ||
1094 | * RETURN: Status | ||
1095 | * | ||
1096 | * DESCRIPTION: Create a cache object | ||
1097 | * | ||
1098 | ******************************************************************************/ | ||
1099 | |||
1100 | acpi_status | ||
1101 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) | ||
1102 | { | ||
1103 | *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); | ||
1104 | return AE_OK; | ||
1105 | } | ||
1106 | |||
1107 | /******************************************************************************* | ||
1108 | * | ||
1109 | * FUNCTION: acpi_os_purge_cache | ||
1110 | * | ||
1111 | * PARAMETERS: Cache - Handle to cache object | ||
1112 | * | ||
1113 | * RETURN: Status | ||
1114 | * | ||
1115 | * DESCRIPTION: Free all objects within the requested cache. | ||
1116 | * | ||
1117 | ******************************************************************************/ | ||
1118 | |||
1119 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) | ||
1120 | { | ||
1121 | (void)kmem_cache_shrink(cache); | ||
1122 | return (AE_OK); | ||
1123 | } | ||
1124 | |||
1125 | /******************************************************************************* | ||
1126 | * | ||
1127 | * FUNCTION: acpi_os_delete_cache | ||
1128 | * | ||
1129 | * PARAMETERS: Cache - Handle to cache object | ||
1130 | * | ||
1131 | * RETURN: Status | ||
1132 | * | ||
1133 | * DESCRIPTION: Free all objects within the requested cache and delete the | ||
1134 | * cache object. | ||
1135 | * | ||
1136 | ******************************************************************************/ | ||
1137 | |||
1138 | acpi_status acpi_os_delete_cache(acpi_cache_t * cache) | ||
1139 | { | ||
1140 | (void)kmem_cache_destroy(cache); | ||
1141 | return (AE_OK); | ||
1142 | } | ||
1143 | |||
1144 | /******************************************************************************* | ||
1145 | * | ||
1146 | * FUNCTION: acpi_os_release_object | ||
1147 | * | ||
1148 | * PARAMETERS: Cache - Handle to cache object | ||
1149 | * Object - The object to be released | ||
1150 | * | ||
1151 | * RETURN: None | ||
1152 | * | ||
1153 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
1154 | * the object is deleted. | ||
1155 | * | ||
1156 | ******************************************************************************/ | ||
1157 | |||
1158 | acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) | ||
1159 | { | ||
1160 | kmem_cache_free(cache, object); | ||
1161 | return (AE_OK); | ||
1162 | } | ||
1163 | |||
1164 | /******************************************************************************* | ||
1165 | * | ||
1166 | * FUNCTION: acpi_os_acquire_object | ||
1167 | * | ||
1168 | * PARAMETERS: Cache - Handle to cache object | ||
1169 | * ReturnObject - Where the object is returned | ||
1170 | * | ||
1171 | * RETURN: Status | ||
1172 | * | ||
1173 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | ||
1174 | * the object is allocated. | ||
1175 | * | ||
1176 | ******************************************************************************/ | ||
1177 | |||
1178 | void *acpi_os_acquire_object(acpi_cache_t * cache) | ||
1179 | { | ||
1180 | void *object = kmem_cache_alloc(cache, GFP_KERNEL); | ||
1181 | WARN_ON(!object); | ||
1182 | return object; | ||
1183 | } | ||
1184 | |||
1185 | #endif | ||