aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig109
-rw-r--r--drivers/acpi/Makefile33
-rw-r--r--drivers/acpi/ac.c3
-rw-r--r--drivers/acpi/acpi_memhotplug.c3
-rw-r--r--drivers/acpi/acpica/Makefile44
-rw-r--r--drivers/acpi/acpica/accommon.h63
-rw-r--r--drivers/acpi/acpica/acconfig.h217
-rw-r--r--drivers/acpi/acpica/acdebug.h231
-rw-r--r--drivers/acpi/acpica/acdispat.h345
-rw-r--r--drivers/acpi/acpica/acevents.h218
-rw-r--r--drivers/acpi/acpica/acglobal.h394
-rw-r--r--drivers/acpi/acpica/achware.h119
-rw-r--r--drivers/acpi/acpica/acinterp.h529
-rw-r--r--drivers/acpi/acpica/aclocal.h990
-rw-r--r--drivers/acpi/acpica/acmacros.h577
-rw-r--r--drivers/acpi/acpica/acnamesp.h324
-rw-r--r--drivers/acpi/acpica/acobject.h446
-rw-r--r--drivers/acpi/acpica/acopcode.h323
-rw-r--r--drivers/acpi/acpica/acparser.h234
-rw-r--r--drivers/acpi/acpica/acpredef.h371
-rw-r--r--drivers/acpi/acpica/acresrc.h336
-rw-r--r--drivers/acpi/acpica/acstruct.h228
-rw-r--r--drivers/acpi/acpica/actables.h117
-rw-r--r--drivers/acpi/acpica/acutils.h549
-rw-r--r--drivers/acpi/acpica/amlcode.h494
-rw-r--r--drivers/acpi/acpica/amlresrc.h311
-rw-r--r--drivers/acpi/acpica/dsfield.c (renamed from drivers/acpi/dispatcher/dsfield.c)11
-rw-r--r--drivers/acpi/acpica/dsinit.c (renamed from drivers/acpi/dispatcher/dsinit.c)7
-rw-r--r--drivers/acpi/acpica/dsmethod.c (renamed from drivers/acpi/dispatcher/dsmethod.c)14
-rw-r--r--drivers/acpi/acpica/dsmthdat.c (renamed from drivers/acpi/dispatcher/dsmthdat.c)7
-rw-r--r--drivers/acpi/acpica/dsobject.c (renamed from drivers/acpi/dispatcher/dsobject.c)11
-rw-r--r--drivers/acpi/acpica/dsopcode.c (renamed from drivers/acpi/dispatcher/dsopcode.c)66
-rw-r--r--drivers/acpi/acpica/dsutils.c (renamed from drivers/acpi/dispatcher/dsutils.c)13
-rw-r--r--drivers/acpi/acpica/dswexec.c (renamed from drivers/acpi/dispatcher/dswexec.c)13
-rw-r--r--drivers/acpi/acpica/dswload.c (renamed from drivers/acpi/dispatcher/dswload.c)13
-rw-r--r--drivers/acpi/acpica/dswscope.c (renamed from drivers/acpi/dispatcher/dswscope.c)3
-rw-r--r--drivers/acpi/acpica/dswstate.c (renamed from drivers/acpi/dispatcher/dswstate.c)7
-rw-r--r--drivers/acpi/acpica/evevent.c (renamed from drivers/acpi/events/evevent.c)17
-rw-r--r--drivers/acpi/acpica/evgpe.c (renamed from drivers/acpi/events/evgpe.c)55
-rw-r--r--drivers/acpi/acpica/evgpeblk.c (renamed from drivers/acpi/events/evgpeblk.c)82
-rw-r--r--drivers/acpi/acpica/evmisc.c (renamed from drivers/acpi/events/evmisc.c)62
-rw-r--r--drivers/acpi/acpica/evregion.c (renamed from drivers/acpi/events/evregion.c)140
-rw-r--r--drivers/acpi/acpica/evrgnini.c (renamed from drivers/acpi/events/evrgnini.c)46
-rw-r--r--drivers/acpi/acpica/evsci.c (renamed from drivers/acpi/events/evsci.c)13
-rw-r--r--drivers/acpi/acpica/evxface.c (renamed from drivers/acpi/events/evxface.c)9
-rw-r--r--drivers/acpi/acpica/evxfevnt.c (renamed from drivers/acpi/events/evxfevnt.c)211
-rw-r--r--drivers/acpi/acpica/evxfregn.c (renamed from drivers/acpi/events/evxfregn.c)5
-rw-r--r--drivers/acpi/acpica/exconfig.c (renamed from drivers/acpi/executer/exconfig.c)9
-rw-r--r--drivers/acpi/acpica/exconvrt.c (renamed from drivers/acpi/executer/exconvrt.c)5
-rw-r--r--drivers/acpi/acpica/excreate.c (renamed from drivers/acpi/executer/excreate.c)7
-rw-r--r--drivers/acpi/acpica/exdump.c (renamed from drivers/acpi/executer/exdump.c)7
-rw-r--r--drivers/acpi/acpica/exfield.c (renamed from drivers/acpi/executer/exfield.c)5
-rw-r--r--drivers/acpi/acpica/exfldio.c (renamed from drivers/acpi/executer/exfldio.c)20
-rw-r--r--drivers/acpi/acpica/exmisc.c (renamed from drivers/acpi/executer/exmisc.c)7
-rw-r--r--drivers/acpi/acpica/exmutex.c (renamed from drivers/acpi/executer/exmutex.c)5
-rw-r--r--drivers/acpi/acpica/exnames.c (renamed from drivers/acpi/executer/exnames.c)5
-rw-r--r--drivers/acpi/acpica/exoparg1.c (renamed from drivers/acpi/executer/exoparg1.c)11
-rw-r--r--drivers/acpi/acpica/exoparg2.c (renamed from drivers/acpi/executer/exoparg2.c)9
-rw-r--r--drivers/acpi/acpica/exoparg3.c (renamed from drivers/acpi/executer/exoparg3.c)7
-rw-r--r--drivers/acpi/acpica/exoparg6.c (renamed from drivers/acpi/executer/exoparg6.c)7
-rw-r--r--drivers/acpi/acpica/exprep.c (renamed from drivers/acpi/executer/exprep.c)9
-rw-r--r--drivers/acpi/acpica/exregion.c (renamed from drivers/acpi/executer/exregion.c)3
-rw-r--r--drivers/acpi/acpica/exresnte.c (renamed from drivers/acpi/executer/exresnte.c)7
-rw-r--r--drivers/acpi/acpica/exresolv.c (renamed from drivers/acpi/executer/exresolv.c)11
-rw-r--r--drivers/acpi/acpica/exresop.c (renamed from drivers/acpi/executer/exresop.c)9
-rw-r--r--drivers/acpi/acpica/exstore.c (renamed from drivers/acpi/executer/exstore.c)11
-rw-r--r--drivers/acpi/acpica/exstoren.c (renamed from drivers/acpi/executer/exstoren.c)5
-rw-r--r--drivers/acpi/acpica/exstorob.c (renamed from drivers/acpi/executer/exstorob.c)3
-rw-r--r--drivers/acpi/acpica/exsystem.c (renamed from drivers/acpi/executer/exsystem.c)3
-rw-r--r--drivers/acpi/acpica/exutils.c (renamed from drivers/acpi/executer/exutils.c)5
-rw-r--r--drivers/acpi/acpica/hwacpi.c (renamed from drivers/acpi/hardware/hwacpi.c)1
-rw-r--r--drivers/acpi/acpica/hwgpe.c (renamed from drivers/acpi/hardware/hwgpe.c)78
-rw-r--r--drivers/acpi/acpica/hwregs.c353
-rw-r--r--drivers/acpi/acpica/hwsleep.c (renamed from drivers/acpi/hardware/hwsleep.c)76
-rw-r--r--drivers/acpi/acpica/hwtimer.c (renamed from drivers/acpi/hardware/hwtimer.c)1
-rw-r--r--drivers/acpi/acpica/hwxface.c (renamed from drivers/acpi/hardware/hwregs.c)744
-rw-r--r--drivers/acpi/acpica/nsaccess.c (renamed from drivers/acpi/namespace/nsaccess.c)18
-rw-r--r--drivers/acpi/acpica/nsalloc.c (renamed from drivers/acpi/namespace/nsalloc.c)3
-rw-r--r--drivers/acpi/acpica/nsdump.c (renamed from drivers/acpi/namespace/nsdump.c)3
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c (renamed from drivers/acpi/namespace/nsdumpdv.c)3
-rw-r--r--drivers/acpi/acpica/nseval.c (renamed from drivers/acpi/namespace/nseval.c)77
-rw-r--r--drivers/acpi/acpica/nsinit.c (renamed from drivers/acpi/namespace/nsinit.c)7
-rw-r--r--drivers/acpi/acpica/nsload.c (renamed from drivers/acpi/namespace/nsload.c)7
-rw-r--r--drivers/acpi/acpica/nsnames.c (renamed from drivers/acpi/namespace/nsnames.c)5
-rw-r--r--drivers/acpi/acpica/nsobject.c (renamed from drivers/acpi/namespace/nsobject.c)3
-rw-r--r--drivers/acpi/acpica/nsparse.c (renamed from drivers/acpi/namespace/nsparse.c)9
-rw-r--r--drivers/acpi/acpica/nspredef.c (renamed from drivers/acpi/namespace/nspredef.c)261
-rw-r--r--drivers/acpi/acpica/nssearch.c (renamed from drivers/acpi/namespace/nssearch.c)3
-rw-r--r--drivers/acpi/acpica/nsutils.c (renamed from drivers/acpi/namespace/nsutils.c)15
-rw-r--r--drivers/acpi/acpica/nswalk.c (renamed from drivers/acpi/namespace/nswalk.c)3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c (renamed from drivers/acpi/namespace/nsxfeval.c)5
-rw-r--r--drivers/acpi/acpica/nsxfname.c (renamed from drivers/acpi/namespace/nsxfname.c)3
-rw-r--r--drivers/acpi/acpica/nsxfobj.c (renamed from drivers/acpi/namespace/nsxfobj.c)3
-rw-r--r--drivers/acpi/acpica/psargs.c (renamed from drivers/acpi/parser/psargs.c)9
-rw-r--r--drivers/acpi/acpica/psloop.c (renamed from drivers/acpi/parser/psloop.c)7
-rw-r--r--drivers/acpi/acpica/psopcode.c (renamed from drivers/acpi/parser/psopcode.c)7
-rw-r--r--drivers/acpi/acpica/psparse.c (renamed from drivers/acpi/parser/psparse.c)23
-rw-r--r--drivers/acpi/acpica/psscope.c (renamed from drivers/acpi/parser/psscope.c)3
-rw-r--r--drivers/acpi/acpica/pstree.c (renamed from drivers/acpi/parser/pstree.c)5
-rw-r--r--drivers/acpi/acpica/psutils.c (renamed from drivers/acpi/parser/psutils.c)5
-rw-r--r--drivers/acpi/acpica/pswalk.c (renamed from drivers/acpi/parser/pswalk.c)3
-rw-r--r--drivers/acpi/acpica/psxface.c (renamed from drivers/acpi/parser/psxface.c)40
-rw-r--r--drivers/acpi/acpica/rsaddr.c (renamed from drivers/acpi/resources/rsaddr.c)3
-rw-r--r--drivers/acpi/acpica/rscalc.c (renamed from drivers/acpi/resources/rscalc.c)5
-rw-r--r--drivers/acpi/acpica/rscreate.c (renamed from drivers/acpi/resources/rscreate.c)7
-rw-r--r--drivers/acpi/acpica/rsdump.c (renamed from drivers/acpi/resources/rsdump.c)3
-rw-r--r--drivers/acpi/acpica/rsinfo.c (renamed from drivers/acpi/resources/rsinfo.c)3
-rw-r--r--drivers/acpi/acpica/rsio.c (renamed from drivers/acpi/resources/rsio.c)3
-rw-r--r--drivers/acpi/acpica/rsirq.c (renamed from drivers/acpi/resources/rsirq.c)3
-rw-r--r--drivers/acpi/acpica/rslist.c (renamed from drivers/acpi/resources/rslist.c)3
-rw-r--r--drivers/acpi/acpica/rsmemory.c (renamed from drivers/acpi/resources/rsmemory.c)3
-rw-r--r--drivers/acpi/acpica/rsmisc.c (renamed from drivers/acpi/resources/rsmisc.c)3
-rw-r--r--drivers/acpi/acpica/rsutils.c (renamed from drivers/acpi/resources/rsutils.c)5
-rw-r--r--drivers/acpi/acpica/rsxface.c (renamed from drivers/acpi/resources/rsxface.c)5
-rw-r--r--drivers/acpi/acpica/tbfadt.c (renamed from drivers/acpi/tables/tbfadt.c)254
-rw-r--r--drivers/acpi/acpica/tbfind.c (renamed from drivers/acpi/tables/tbfind.c)3
-rw-r--r--drivers/acpi/acpica/tbinstal.c (renamed from drivers/acpi/tables/tbinstal.c)5
-rw-r--r--drivers/acpi/acpica/tbutils.c (renamed from drivers/acpi/tables/tbutils.c)37
-rw-r--r--drivers/acpi/acpica/tbxface.c (renamed from drivers/acpi/tables/tbxface.c)22
-rw-r--r--drivers/acpi/acpica/tbxfroot.c (renamed from drivers/acpi/tables/tbxfroot.c)3
-rw-r--r--drivers/acpi/acpica/utalloc.c (renamed from drivers/acpi/utilities/utalloc.c)3
-rw-r--r--drivers/acpi/acpica/utcopy.c (renamed from drivers/acpi/utilities/utcopy.c)3
-rw-r--r--drivers/acpi/acpica/utdebug.c (renamed from drivers/acpi/utilities/utdebug.c)95
-rw-r--r--drivers/acpi/acpica/utdelete.c (renamed from drivers/acpi/utilities/utdelete.c)7
-rw-r--r--drivers/acpi/acpica/uteval.c (renamed from drivers/acpi/utilities/uteval.c)28
-rw-r--r--drivers/acpi/acpica/utglobal.c (renamed from drivers/acpi/utilities/utglobal.c)14
-rw-r--r--drivers/acpi/acpica/utinit.c (renamed from drivers/acpi/utilities/utinit.c)7
-rw-r--r--drivers/acpi/acpica/utmath.c (renamed from drivers/acpi/utilities/utmath.c)1
-rw-r--r--drivers/acpi/acpica/utmisc.c (renamed from drivers/acpi/utilities/utmisc.c)23
-rw-r--r--drivers/acpi/acpica/utmutex.c (renamed from drivers/acpi/utilities/utmutex.c)1
-rw-r--r--drivers/acpi/acpica/utobject.c (renamed from drivers/acpi/utilities/utobject.c)7
-rw-r--r--drivers/acpi/acpica/utresrc.c (renamed from drivers/acpi/utilities/utresrc.c)3
-rw-r--r--drivers/acpi/acpica/utstate.c (renamed from drivers/acpi/utilities/utstate.c)1
-rw-r--r--drivers/acpi/acpica/utxface.c (renamed from drivers/acpi/utilities/utxface.c)18
-rw-r--r--drivers/acpi/asus_acpi.c1460
-rw-r--r--drivers/acpi/battery.c8
-rw-r--r--drivers/acpi/blacklist.c401
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/button.c3
-rw-r--r--drivers/acpi/cm_sbs.c10
-rw-r--r--drivers/acpi/container.c6
-rw-r--r--drivers/acpi/debug.c16
-rw-r--r--drivers/acpi/dispatcher/Makefile9
-rw-r--r--drivers/acpi/dock.c14
-rw-r--r--drivers/acpi/ec.c204
-rw-r--r--drivers/acpi/events/Makefile9
-rw-r--r--drivers/acpi/executer/Makefile10
-rw-r--r--drivers/acpi/fan.c1
-rw-r--r--drivers/acpi/glue.c48
-rw-r--r--drivers/acpi/hardware/Makefile9
-rw-r--r--drivers/acpi/namespace/Makefile12
-rw-r--r--drivers/acpi/numa.c1
-rw-r--r--drivers/acpi/osl.c173
-rw-r--r--drivers/acpi/parser/Makefile8
-rw-r--r--drivers/acpi/pci_bind.c90
-rw-r--r--drivers/acpi/pci_irq.c416
-rw-r--r--drivers/acpi/pci_link.c19
-rw-r--r--drivers/acpi/pci_root.c26
-rw-r--r--drivers/acpi/power.c15
-rw-r--r--drivers/acpi/proc.c (renamed from drivers/acpi/sleep/proc.c)67
-rw-r--r--drivers/acpi/processor_core.c107
-rw-r--r--drivers/acpi/processor_idle.c675
-rw-r--r--drivers/acpi/processor_perflib.c135
-rw-r--r--drivers/acpi/processor_thermal.c1
-rw-r--r--drivers/acpi/processor_throttling.c82
-rw-r--r--drivers/acpi/reboot.c27
-rw-r--r--drivers/acpi/resources/Makefile10
-rw-r--r--drivers/acpi/sbshc.c1
-rw-r--r--drivers/acpi/scan.c53
-rw-r--r--drivers/acpi/sleep.c (renamed from drivers/acpi/sleep/main.c)122
-rw-r--r--drivers/acpi/sleep.h (renamed from drivers/acpi/sleep/sleep.h)0
-rw-r--r--drivers/acpi/sleep/Makefile5
-rw-r--r--drivers/acpi/system.c111
-rw-r--r--drivers/acpi/tables.c27
-rw-r--r--drivers/acpi/tables/Makefile7
-rw-r--r--drivers/acpi/thermal.c25
-rw-r--r--drivers/acpi/toshiba_acpi.c861
-rw-r--r--drivers/acpi/utilities/Makefile9
-rw-r--r--drivers/acpi/utilities/utcache.c314
-rw-r--r--drivers/acpi/utils.c16
-rw-r--r--drivers/acpi/video.c78
-rw-r--r--drivers/acpi/video_detect.c267
-rw-r--r--drivers/acpi/wakeup.c (renamed from drivers/acpi/sleep/wakeup.c)14
-rw-r--r--drivers/acpi/wmi.c747
184 files changed, 10683 insertions, 6996 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f4f632917509..a7799a99f2d9 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -9,6 +9,7 @@ menuconfig ACPI
9 depends on PCI 9 depends on PCI
10 depends on PM 10 depends on PM
11 select PNP 11 select PNP
12 select CPU_IDLE
12 default y 13 default y
13 ---help--- 14 ---help---
14 Advanced Configuration and Power Interface (ACPI) support for 15 Advanced Configuration and Power Interface (ACPI) support for
@@ -196,90 +197,6 @@ config ACPI_NUMA
196 depends on (X86 || IA64) 197 depends on (X86 || IA64)
197 default y if IA64_GENERIC || IA64_SGI_SN2 198 default y if IA64_GENERIC || IA64_SGI_SN2
198 199
199config ACPI_WMI
200 tristate "WMI (EXPERIMENTAL)"
201 depends on X86
202 depends on EXPERIMENTAL
203 help
204 This driver adds support for the ACPI-WMI (Windows Management
205 Instrumentation) mapper device (PNP0C14) found on some systems.
206
207 ACPI-WMI is a proprietary extension to ACPI to expose parts of the
208 ACPI firmware to userspace - this is done through various vendor
209 defined methods and data blocks in a PNP0C14 device, which are then
210 made available for userspace to call.
211
212 The implementation of this in Linux currently only exposes this to
213 other kernel space drivers.
214
215 This driver is a required dependency to build the firmware specific
216 drivers needed on many machines, including Acer and HP laptops.
217
218 It is safe to enable this driver even if your DSDT doesn't define
219 any ACPI-WMI devices.
220
221config ACPI_ASUS
222 tristate "ASUS/Medion Laptop Extras"
223 depends on X86
224 select BACKLIGHT_CLASS_DEVICE
225 ---help---
226 This driver provides support for extra features of ACPI-compatible
227 ASUS laptops. As some of Medion laptops are made by ASUS, it may also
228 support some Medion laptops (such as 9675 for example). It makes all
229 the extra buttons generate standard ACPI events that go through
230 /proc/acpi/events, and (on some models) adds support for changing the
231 display brightness and output, switching the LCD backlight on and off,
232 and most importantly, allows you to blink those fancy LEDs intended
233 for reporting mail and wireless status.
234
235 Note: display switching code is currently considered EXPERIMENTAL,
236 toying with these values may even lock your machine.
237
238 All settings are changed via /proc/acpi/asus directory entries. Owner
239 and group for these entries can be set with asus_uid and asus_gid
240 parameters.
241
242 More information and a userspace daemon for handling the extra buttons
243 at <http://sourceforge.net/projects/acpi4asus/>.
244
245 If you have an ACPI-compatible ASUS laptop, say Y or M here. This
246 driver is still under development, so if your laptop is unsupported or
247 something works not quite as expected, please use the mailing list
248 available on the above page (acpi4asus-user@lists.sourceforge.net).
249
250 NOTE: This driver is deprecated and will probably be removed soon,
251 use asus-laptop instead.
252
253config ACPI_TOSHIBA
254 tristate "Toshiba Laptop Extras"
255 depends on X86 && INPUT
256 select INPUT_POLLDEV
257 select NET
258 select RFKILL
259 select BACKLIGHT_CLASS_DEVICE
260 ---help---
261 This driver adds support for access to certain system settings
262 on "legacy free" Toshiba laptops. These laptops can be recognized by
263 their lack of a BIOS setup menu and APM support.
264
265 On these machines, all system configuration is handled through the
266 ACPI. This driver is required for access to controls not covered
267 by the general ACPI drivers, such as LCD brightness, video output,
268 etc.
269
270 This driver differs from the non-ACPI Toshiba laptop driver (located
271 under "Processor type and features") in several aspects.
272 Configuration is accessed by reading and writing text files in the
273 /proc tree instead of by program interface to /dev. Furthermore, no
274 power management functions are exposed, as those are handled by the
275 general ACPI drivers.
276
277 More information about this driver is available at
278 <http://memebeam.org/toys/ToshibaAcpiDriver>.
279
280 If you have a legacy free Toshiba laptop (such as the Libretto L1
281 series), say Y.
282
283config ACPI_CUSTOM_DSDT_FILE 200config ACPI_CUSTOM_DSDT_FILE
284 string "Custom DSDT Table file to include" 201 string "Custom DSDT Table file to include"
285 default "" 202 default ""
@@ -312,9 +229,13 @@ config ACPI_DEBUG
312 bool "Debug Statements" 229 bool "Debug Statements"
313 default n 230 default n
314 help 231 help
315 The ACPI driver can optionally report errors with a great deal 232 The ACPI subsystem can produce debug output. Saying Y enables this
316 of verbosity. Saying Y enables these statements. This will increase 233 output and increases the kernel size by around 50K.
317 your kernel size by around 50K. 234
235 Use the acpi.debug_layer and acpi.debug_level kernel command-line
236 parameters documented in Documentation/acpi/debug.txt and
237 Documentation/kernel-parameters.txt to control the type and
238 amount of debug output.
318 239
319config ACPI_DEBUG_FUNC_TRACE 240config ACPI_DEBUG_FUNC_TRACE
320 bool "Additionally enable ACPI function tracing" 241 bool "Additionally enable ACPI function tracing"
@@ -324,14 +245,6 @@ config ACPI_DEBUG_FUNC_TRACE
324 ACPI Debug Statements slow down ACPI processing. Function trace 245 ACPI Debug Statements slow down ACPI processing. Function trace
325 is about half of the penalty and is rarely useful. 246 is about half of the penalty and is rarely useful.
326 247
327config ACPI_EC
328 bool
329 default y
330 help
331 This driver is required on some systems for the proper operation of
332 the battery and thermal drivers. If you are compiling for a
333 mobile system, say Y.
334
335config ACPI_PCI_SLOT 248config ACPI_PCI_SLOT
336 tristate "PCI slot detection driver" 249 tristate "PCI slot detection driver"
337 default n 250 default n
@@ -341,10 +254,6 @@ config ACPI_PCI_SLOT
341 help you correlate PCI bus addresses with the physical geography 254 help you correlate PCI bus addresses with the physical geography
342 of your slots. If you are unsure, say N. 255 of your slots. If you are unsure, say N.
343 256
344config ACPI_POWER
345 bool
346 default y
347
348config ACPI_SYSTEM 257config ACPI_SYSTEM
349 bool 258 bool
350 default y 259 default y
@@ -379,7 +288,7 @@ config ACPI_CONTAINER
379 support physical cpu/memory hot-plug. 288 support physical cpu/memory hot-plug.
380 289
381 If one selects "m", this driver can be loaded with 290 If one selects "m", this driver can be loaded with
382 "modprobe acpi_container". 291 "modprobe container".
383 292
384config ACPI_HOTPLUG_MEMORY 293config ACPI_HOTPLUG_MEMORY
385 tristate "Memory Hotplug" 294 tristate "Memory Hotplug"
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d91c027ece8f..65d90c720b5a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -2,15 +2,8 @@
2# Makefile for the Linux ACPI interpreter 2# Makefile for the Linux ACPI interpreter
3# 3#
4 4
5export ACPI_CFLAGS 5ccflags-y := -Os
6 6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
7ACPI_CFLAGS := -Os
8
9ifdef CONFIG_ACPI_DEBUG
10 ACPI_CFLAGS += -DACPI_DEBUG_OUTPUT
11endif
12
13EXTRA_CFLAGS += $(ACPI_CFLAGS)
14 7
15# 8#
16# ACPI Boot-Time Table Parsing 9# ACPI Boot-Time Table Parsing
@@ -22,9 +15,13 @@ obj-$(CONFIG_X86) += blacklist.o
22# ACPI Core Subsystem (Interpreter) 15# ACPI Core Subsystem (Interpreter)
23# 16#
24obj-y += osl.o utils.o reboot.o\ 17obj-y += osl.o utils.o reboot.o\
25 dispatcher/ events/ executer/ hardware/ \ 18 acpica/
26 namespace/ parser/ resources/ tables/ \ 19
27 utilities/ 20# sleep related files
21obj-y += wakeup.o
22obj-y += sleep.o
23obj-$(CONFIG_ACPI_SLEEP) += proc.o
24
28 25
29# 26#
30# ACPI Bus and Device Drivers 27# ACPI Bus and Device Drivers
@@ -35,29 +32,29 @@ ifdef CONFIG_CPU_FREQ
35processor-objs += processor_perflib.o 32processor-objs += processor_perflib.o
36endif 33endif
37 34
38obj-y += sleep/
39obj-y += bus.o glue.o 35obj-y += bus.o glue.o
40obj-y += scan.o 36obj-y += scan.o
41# Keep EC driver first. Initialization of others depend on it. 37# Keep EC driver first. Initialization of others depend on it.
42obj-$(CONFIG_ACPI_EC) += ec.o 38obj-y += ec.o
43obj-$(CONFIG_ACPI_AC) += ac.o 39obj-$(CONFIG_ACPI_AC) += ac.o
44obj-$(CONFIG_ACPI_BATTERY) += battery.o 40obj-$(CONFIG_ACPI_BATTERY) += battery.o
45obj-$(CONFIG_ACPI_BUTTON) += button.o 41obj-$(CONFIG_ACPI_BUTTON) += button.o
46obj-$(CONFIG_ACPI_FAN) += fan.o 42obj-$(CONFIG_ACPI_FAN) += fan.o
47obj-$(CONFIG_ACPI_DOCK) += dock.o 43obj-$(CONFIG_ACPI_DOCK) += dock.o
48obj-$(CONFIG_ACPI_VIDEO) += video.o 44obj-$(CONFIG_ACPI_VIDEO) += video.o
45ifdef CONFIG_ACPI_VIDEO
46obj-y += video_detect.o
47endif
48
49obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 49obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
50obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o 50obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o
51obj-$(CONFIG_ACPI_PROCESSOR) += processor.o 51obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
52obj-$(CONFIG_ACPI_CONTAINER) += container.o 52obj-$(CONFIG_ACPI_CONTAINER) += container.o
53obj-$(CONFIG_ACPI_THERMAL) += thermal.o 53obj-$(CONFIG_ACPI_THERMAL) += thermal.o
54obj-$(CONFIG_ACPI_POWER) += power.o 54obj-y += power.o
55obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o 55obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o
56obj-$(CONFIG_ACPI_DEBUG) += debug.o 56obj-$(CONFIG_ACPI_DEBUG) += debug.o
57obj-$(CONFIG_ACPI_NUMA) += numa.o 57obj-$(CONFIG_ACPI_NUMA) += numa.o
58obj-$(CONFIG_ACPI_WMI) += wmi.o
59obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
60obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
61obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o 58obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
62obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 59obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
63obj-$(CONFIG_ACPI_SBS) += sbshc.o 60obj-$(CONFIG_ACPI_SBS) += sbshc.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index d72a1b6c8a94..9b917dac7732 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -37,7 +37,6 @@
37#include <acpi/acpi_bus.h> 37#include <acpi/acpi_bus.h>
38#include <acpi/acpi_drivers.h> 38#include <acpi/acpi_drivers.h>
39 39
40#define ACPI_AC_COMPONENT 0x00020000
41#define ACPI_AC_CLASS "ac_adapter" 40#define ACPI_AC_CLASS "ac_adapter"
42#define ACPI_AC_DEVICE_NAME "AC Adapter" 41#define ACPI_AC_DEVICE_NAME "AC Adapter"
43#define ACPI_AC_FILE_STATE "state" 42#define ACPI_AC_FILE_STATE "state"
@@ -242,7 +241,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
242 acpi_ac_get_state(ac); 241 acpi_ac_get_state(ac);
243 acpi_bus_generate_proc_event(device, event, (u32) ac->state); 242 acpi_bus_generate_proc_event(device, event, (u32) ac->state);
244 acpi_bus_generate_netlink_event(device->pnp.device_class, 243 acpi_bus_generate_netlink_event(device->pnp.device_class,
245 device->dev.bus_id, event, 244 dev_name(&device->dev), event,
246 (u32) ac->state); 245 (u32) ac->state);
247#ifdef CONFIG_ACPI_SYSFS_POWER 246#ifdef CONFIG_ACPI_SYSFS_POWER
248 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 247 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 71d21c51c45f..7a0f4aa4fa1e 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -20,7 +20,7 @@
20 * 20 *
21 * 21 *
22 * ACPI based HotPlug driver that supports Memory Hotplug 22 * ACPI based HotPlug driver that supports Memory Hotplug
23 * This driver fields notifications from firmare for memory add 23 * This driver fields notifications from firmware for memory add
24 * and remove operations and alerts the VM of the affected memory 24 * and remove operations and alerts the VM of the affected memory
25 * ranges. 25 * ranges.
26 */ 26 */
@@ -32,7 +32,6 @@
32#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
33#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
34 34
35#define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL
36#define ACPI_MEMORY_DEVICE_CLASS "memory" 35#define ACPI_MEMORY_DEVICE_CLASS "memory"
37#define ACPI_MEMORY_DEVICE_HID "PNP0C80" 36#define ACPI_MEMORY_DEVICE_HID "PNP0C80"
38#define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" 37#define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device"
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
new file mode 100644
index 000000000000..3f23298ee3fd
--- /dev/null
+++ b/drivers/acpi/acpica/Makefile
@@ -0,0 +1,44 @@
1#
2# Makefile for ACPICA Core interpreter
3#
4
5ccflags-y := -Os
6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
7
8obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
9 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
10 dsinit.o
11
12obj-y += evevent.o evregion.o evsci.o evxfevnt.o \
13 evmisc.o evrgnini.o evxface.o evxfregn.o \
14 evgpe.o evgpeblk.o
15
16obj-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
17 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
18 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
19 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o
20
21obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o
22
23obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
24
25obj-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \
26 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
27 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
28 nsparse.o nspredef.o
29
30obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
31
32obj-y += psargs.o psparse.o psloop.o pstree.o pswalk.o \
33 psopcode.o psscope.o psutils.o psxface.o
34
35obj-y += rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
36 rscalc.o rsirq.o rsmemory.o rsutils.o
37
38obj-$(ACPI_FUTURE_USAGE) += rsdump.o
39
40obj-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
41
42obj-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
43 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
44 utstate.o utmutex.o utobject.o utresrc.o
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
new file mode 100644
index 000000000000..3b20786cbb0d
--- /dev/null
+++ b/drivers/acpi/acpica/accommon.h
@@ -0,0 +1,63 @@
1/******************************************************************************
2 *
3 * Name: accommon.h - Common include files for generation of ACPICA source
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACCOMMON_H__
45#define __ACCOMMON_H__
46
47/*
48 * Common set of includes for all ACPICA source files.
49 * We put them here because we don't want to duplicate them
50 * in the the source code again and again.
51 *
52 * Note: The order of these include files is important.
53 */
54#include "acconfig.h" /* Global configuration constants */
55#include "acmacros.h" /* C macros */
56#include "aclocal.h" /* Internal data types */
57#include "acobject.h" /* ACPI internal object */
58#include "acstruct.h" /* Common structures */
59#include "acglobal.h" /* All global variables */
60#include "achware.h" /* Hardware defines and interfaces */
61#include "acutils.h" /* Utility interfaces */
62
63#endif /* __ACCOMMON_H__ */
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
new file mode 100644
index 000000000000..e6777fb883d2
--- /dev/null
+++ b/drivers/acpi/acpica/acconfig.h
@@ -0,0 +1,217 @@
1/******************************************************************************
2 *
3 * Name: acconfig.h - Global configuration constants
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACCONFIG_H
45#define _ACCONFIG_H
46
47/******************************************************************************
48 *
49 * Configuration options
50 *
51 *****************************************************************************/
52
53/*
54 * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the
55 * ACPI subsystem. This includes the DEBUG_PRINT output
56 * statements. When disabled, all DEBUG_PRINT
57 * statements are compiled out.
58 *
59 * ACPI_APPLICATION - Use this switch if the subsystem is going to be run
60 * at the application level.
61 *
62 */
63
64/*
65 * OS name, used for the _OS object. The _OS object is essentially obsolete,
66 * but there is a large base of ASL/AML code in existing machines that check
67 * for the string below. The use of this string usually guarantees that
68 * the ASL will execute down the most tested code path. Also, there is some
69 * code that will not execute the _OSI method unless _OS matches the string
70 * below. Therefore, change this string at your own risk.
71 */
72#define ACPI_OS_NAME "Microsoft Windows NT"
73
74/* Maximum objects in the various object caches */
75
76#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */
77#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
78#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
79#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
80#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */
81
82/*
83 * Should the subsystem abort the loading of an ACPI table if the
84 * table checksum is incorrect?
85 */
86#define ACPI_CHECKSUM_ABORT FALSE
87
88/******************************************************************************
89 *
90 * Subsystem Constants
91 *
92 *****************************************************************************/
93
94/* Version of ACPI supported */
95
96#define ACPI_CA_SUPPORT_LEVEL 3
97
98/* Maximum count for a semaphore object */
99
100#define ACPI_MAX_SEMAPHORE_COUNT 256
101
102/* Maximum object reference count (detects object deletion issues) */
103
104#define ACPI_MAX_REFERENCE_COUNT 0x1000
105
106/* Size of cached memory mapping for system memory operation region */
107
108#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
109
110/* owner_id tracking. 8 entries allows for 255 owner_ids */
111
112#define ACPI_NUM_OWNERID_MASKS 8
113
114/* Size of the root table array is increased by this increment */
115
116#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4
117
118/* Maximum number of While() loop iterations before forced abort */
119
120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF
121
122/******************************************************************************
123 *
124 * ACPI Specification constants (Do not change unless the specification changes)
125 *
126 *****************************************************************************/
127
128/* Number of distinct GPE register blocks and register width */
129
130#define ACPI_MAX_GPE_BLOCKS 2
131#define ACPI_GPE_REGISTER_WIDTH 8
132
133/* Method info (in WALK_STATE), containing local variables and argumetns */
134
135#define ACPI_METHOD_NUM_LOCALS 8
136#define ACPI_METHOD_MAX_LOCAL 7
137
138#define ACPI_METHOD_NUM_ARGS 7
139#define ACPI_METHOD_MAX_ARG 6
140
141/* Length of _HID, _UID, _CID, and UUID values */
142
143#define ACPI_DEVICE_ID_LENGTH 0x09
144#define ACPI_MAX_CID_LENGTH 48
145#define ACPI_UUID_LENGTH 16
146
147/*
148 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
149 */
150#define ACPI_OBJ_NUM_OPERANDS 8
151#define ACPI_OBJ_MAX_OPERAND 7
152
153/* Number of elements in the Result Stack frame, can be an arbitrary value */
154
155#define ACPI_RESULTS_FRAME_OBJ_NUM 8
156
157/*
158 * Maximal number of elements the Result Stack can contain,
159 * it may be an arbitray value not exceeding the types of
160 * result_size and result_count (now u8).
161 */
162#define ACPI_RESULTS_OBJ_NUM_MAX 255
163
164/* Names within the namespace are 4 bytes long */
165
166#define ACPI_NAME_SIZE 4
167#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
168#define ACPI_PATH_SEPARATOR '.'
169
170/* Sizes for ACPI table headers */
171
172#define ACPI_OEM_ID_SIZE 6
173#define ACPI_OEM_TABLE_ID_SIZE 8
174
175/* Constants used in searching for the RSDP in low memory */
176
177#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
178#define ACPI_EBDA_PTR_LENGTH 2
179#define ACPI_EBDA_WINDOW_SIZE 1024
180#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */
181#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000
182#define ACPI_RSDP_SCAN_STEP 16
183
184/* Operation regions */
185
186#define ACPI_NUM_PREDEFINED_REGIONS 8
187#define ACPI_USER_REGION_BEGIN 0x80
188
189/* Maximum space_ids for Operation Regions */
190
191#define ACPI_MAX_ADDRESS_SPACE 255
192
193/* Array sizes. Used for range checking also */
194
195#define ACPI_MAX_MATCH_OPCODE 5
196
197/* RSDP checksums */
198
199#define ACPI_RSDP_CHECKSUM_LENGTH 20
200#define ACPI_RSDP_XCHECKSUM_LENGTH 36
201
202/* SMBus bidirectional buffer size */
203
204#define ACPI_SMBUS_BUFFER_SIZE 34
205
206/******************************************************************************
207 *
208 * ACPI AML Debugger
209 *
210 *****************************************************************************/
211
212#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */
213
214#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
215#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
216
217#endif /* _ACCONFIG_H */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
new file mode 100644
index 000000000000..62c59df3b86c
--- /dev/null
+++ b/drivers/acpi/acpica/acdebug.h
@@ -0,0 +1,231 @@
1/******************************************************************************
2 *
3 * Name: acdebug.h - ACPI/AML debugger
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACDEBUG_H__
45#define __ACDEBUG_H__
46
47#define ACPI_DEBUG_BUFFER_SIZE 4196
48
49struct command_info {
50 char *name; /* Command Name */
51 u8 min_args; /* Minimum arguments required */
52};
53
54struct argument_info {
55 char *name; /* Argument Name */
56};
57
58#define PARAM_LIST(pl) pl
59#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose)
60#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
61 acpi_os_printf PARAM_LIST(fp);}
62
63#define EX_NO_SINGLE_STEP 1
64#define EX_SINGLE_STEP 2
65
66/*
67 * dbxface - external debugger interfaces
68 */
69acpi_status acpi_db_initialize(void);
70
71void acpi_db_terminate(void);
72
73acpi_status
74acpi_db_single_step(struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op, u32 op_type);
76
77/*
78 * dbcmds - debug commands and output routines
79 */
80acpi_status acpi_db_disassemble_method(char *name);
81
82void acpi_db_display_table_info(char *table_arg);
83
84void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg);
85
86void
87acpi_db_set_method_breakpoint(char *location,
88 struct acpi_walk_state *walk_state,
89 union acpi_parse_object *op);
90
91void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
92
93void acpi_db_get_bus_info(void);
94
95void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
96
97void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
98
99void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
100
101void acpi_db_send_notify(char *name, u32 value);
102
103void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
104
105acpi_status
106acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
107
108acpi_status acpi_db_find_name_in_namespace(char *name_arg);
109
110void acpi_db_set_scope(char *name);
111
112acpi_status acpi_db_sleep(char *object_arg);
113
114void acpi_db_find_references(char *object_arg);
115
116void acpi_db_display_locks(void);
117
118void acpi_db_display_resources(char *object_arg);
119
120void acpi_db_display_gpes(void);
121
122void acpi_db_check_integrity(void);
123
124void acpi_db_generate_gpe(char *gpe_arg, char *block_arg);
125
126void acpi_db_check_predefined_names(void);
127
128void acpi_db_batch_execute(void);
129
130/*
131 * dbdisply - debug display commands
132 */
133void acpi_db_display_method_info(union acpi_parse_object *op);
134
135void acpi_db_decode_and_display_object(char *target, char *output_type);
136
137void
138acpi_db_display_result_object(union acpi_operand_object *obj_desc,
139 struct acpi_walk_state *walk_state);
140
141acpi_status acpi_db_display_all_methods(char *display_count_arg);
142
143void acpi_db_display_arguments(void);
144
145void acpi_db_display_locals(void);
146
147void acpi_db_display_results(void);
148
149void acpi_db_display_calling_tree(void);
150
151void acpi_db_display_object_type(char *object_arg);
152
153void
154acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
155 struct acpi_walk_state *walk_state);
156
157void acpi_db_check_predefined_names(void);
158
159void acpi_db_batch_execute(void);
160
161/*
162 * dbexec - debugger control method execution
163 */
164void acpi_db_execute(char *name, char **args, u32 flags);
165
166void
167acpi_db_create_execution_threads(char *num_threads_arg,
168 char *num_loops_arg, char *method_name_arg);
169
170#ifdef ACPI_DBG_TRACK_ALLOCATIONS
171u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
172#endif
173
174/*
175 * dbfileio - Debugger file I/O commands
176 */
177acpi_object_type
178acpi_db_match_argument(char *user_argument, struct argument_info *arguments);
179
180void acpi_db_close_debug_file(void);
181
182void acpi_db_open_debug_file(char *name);
183
184acpi_status acpi_db_load_acpi_table(char *filename);
185
186acpi_status
187acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
188
189acpi_status
190acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
191
192/*
193 * dbhistry - debugger HISTORY command
194 */
195void acpi_db_add_to_history(char *command_line);
196
197void acpi_db_display_history(void);
198
199char *acpi_db_get_from_history(char *command_num_arg);
200
201/*
202 * dbinput - user front-end to the AML debugger
203 */
204acpi_status
205acpi_db_command_dispatch(char *input_buffer,
206 struct acpi_walk_state *walk_state,
207 union acpi_parse_object *op);
208
209void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
210
211/*
212 * dbstats - Generation and display of ACPI table statistics
213 */
214void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method);
215
216acpi_status acpi_db_display_statistics(char *type_arg);
217
218/*
219 * dbutils - AML debugger utilities
220 */
221void acpi_db_set_output_destination(u32 where);
222
223void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level);
224
225void acpi_db_prep_namestring(char *name);
226
227struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name);
228
229void acpi_db_uint32_to_hex_string(u32 value, char *buffer);
230
231#endif /* __ACDEBUG_H__ */
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
new file mode 100644
index 000000000000..6291904be01e
--- /dev/null
+++ b/drivers/acpi/acpica/acdispat.h
@@ -0,0 +1,345 @@
1/******************************************************************************
2 *
3 * Name: acdispat.h - dispatcher (parser to interpreter interface)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACDISPAT_H_
45#define _ACDISPAT_H_
46
47#define NAMEOF_LOCAL_NTE "__L0"
48#define NAMEOF_ARG_NTE "__A0"
49
50/*
51 * dsopcode - support for late evaluation
52 */
53acpi_status
54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
55
56acpi_status
57acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc);
58
59acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc);
60
61acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
62
63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
64
65acpi_status
66acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
67 union acpi_parse_object *op);
68
69acpi_status
70acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
71 union acpi_parse_object *op);
72
73acpi_status
74acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op);
76
77acpi_status
78acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
79 union acpi_parse_object *op,
80 union acpi_operand_object *obj_desc);
81
82acpi_status
83acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
84 union acpi_parse_object *op);
85
86acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
87
88/*
89 * dsctrl - Parser/Interpreter interface, control stack routines
90 */
91acpi_status
92acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
93 union acpi_parse_object *op);
94
95acpi_status
96acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
97 union acpi_parse_object *op);
98
99/*
100 * dsexec - Parser/Interpreter interface, method execution callbacks
101 */
102acpi_status
103acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
104 union acpi_operand_object *result_obj);
105
106acpi_status
107acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
108 union acpi_parse_object **out_op);
109
110acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *state);
111
112/*
113 * dsfield - Parser/Interpreter interface for AML fields
114 */
115acpi_status
116acpi_ds_create_field(union acpi_parse_object *op,
117 struct acpi_namespace_node *region_node,
118 struct acpi_walk_state *walk_state);
119
120acpi_status
121acpi_ds_create_bank_field(union acpi_parse_object *op,
122 struct acpi_namespace_node *region_node,
123 struct acpi_walk_state *walk_state);
124
125acpi_status
126acpi_ds_create_index_field(union acpi_parse_object *op,
127 struct acpi_namespace_node *region_node,
128 struct acpi_walk_state *walk_state);
129
130acpi_status
131acpi_ds_create_buffer_field(union acpi_parse_object *op,
132 struct acpi_walk_state *walk_state);
133
134acpi_status
135acpi_ds_init_field_objects(union acpi_parse_object *op,
136 struct acpi_walk_state *walk_state);
137
138/*
139 * dsload - Parser/Interpreter interface, namespace load callbacks
140 */
141acpi_status
142acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
143 union acpi_parse_object **out_op);
144
145acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
146
147acpi_status
148acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
149 union acpi_parse_object **out_op);
150
151acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state);
152
153acpi_status
154acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
155
156/*
157 * dsmthdat - method data (locals/args)
158 */
159acpi_status
160acpi_ds_store_object_to_local(u8 type,
161 u32 index,
162 union acpi_operand_object *src_desc,
163 struct acpi_walk_state *walk_state);
164
165acpi_status
166acpi_ds_method_data_get_entry(u16 opcode,
167 u32 index,
168 struct acpi_walk_state *walk_state,
169 union acpi_operand_object ***node);
170
171void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state);
172
173u8 acpi_ds_is_method_value(union acpi_operand_object *obj_desc);
174
175acpi_status
176acpi_ds_method_data_get_value(u8 type,
177 u32 index,
178 struct acpi_walk_state *walk_state,
179 union acpi_operand_object **dest_desc);
180
181acpi_status
182acpi_ds_method_data_init_args(union acpi_operand_object **params,
183 u32 max_param_count,
184 struct acpi_walk_state *walk_state);
185
186acpi_status
187acpi_ds_method_data_get_node(u8 type,
188 u32 index,
189 struct acpi_walk_state *walk_state,
190 struct acpi_namespace_node **node);
191
192void acpi_ds_method_data_init(struct acpi_walk_state *walk_state);
193
194/*
195 * dsmethod - Parser/Interpreter interface - control method parsing
196 */
197acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node);
198
199acpi_status
200acpi_ds_call_control_method(struct acpi_thread_state *thread,
201 struct acpi_walk_state *walk_state,
202 union acpi_parse_object *op);
203
204acpi_status
205acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
206 union acpi_operand_object *return_desc);
207
208void
209acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
210 struct acpi_walk_state *walk_state);
211
212acpi_status
213acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
214 union acpi_operand_object *obj_desc,
215 struct acpi_walk_state *walk_state);
216
217acpi_status
218acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state);
219
220/*
221 * dsinit
222 */
223acpi_status
224acpi_ds_initialize_objects(u32 table_index,
225 struct acpi_namespace_node *start_node);
226
227/*
228 * dsobject - Parser/Interpreter interface - object initialization and conversion
229 */
230acpi_status
231acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
232 union acpi_parse_object *op,
233 u32 buffer_length,
234 union acpi_operand_object **obj_desc_ptr);
235
236acpi_status
237acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
238 union acpi_parse_object *op,
239 u32 package_length,
240 union acpi_operand_object **obj_desc);
241
242acpi_status
243acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
244 union acpi_parse_object *op,
245 u16 opcode, union acpi_operand_object **obj_desc);
246
247acpi_status
248acpi_ds_create_node(struct acpi_walk_state *walk_state,
249 struct acpi_namespace_node *node,
250 union acpi_parse_object *op);
251
252/*
253 * dsutils - Parser/Interpreter interface utility routines
254 */
255void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state);
256
257u8
258acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
259 struct acpi_walk_state *walk_state,
260 u8 add_reference);
261
262u8
263acpi_ds_is_result_used(union acpi_parse_object *op,
264 struct acpi_walk_state *walk_state);
265
266void
267acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
268 union acpi_operand_object *result_obj,
269 struct acpi_walk_state *walk_state);
270
271acpi_status
272acpi_ds_create_operand(struct acpi_walk_state *walk_state,
273 union acpi_parse_object *arg, u32 args_remaining);
274
275acpi_status
276acpi_ds_create_operands(struct acpi_walk_state *walk_state,
277 union acpi_parse_object *first_arg);
278
279acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state);
280
281void acpi_ds_clear_operands(struct acpi_walk_state *walk_state);
282
283acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state);
284
285/*
286 * dswscope - Scope Stack manipulation
287 */
288acpi_status
289acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
290 acpi_object_type type,
291 struct acpi_walk_state *walk_state);
292
293acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state);
294
295void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state);
296
297/*
298 * dswstate - parser WALK_STATE management routines
299 */
300acpi_status
301acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state);
302
303acpi_status
304acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state);
305
306struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object
307 *origin, union acpi_operand_object
308 *mth_desc, struct acpi_thread_state
309 *thread);
310
311acpi_status
312acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
313 union acpi_parse_object *op,
314 struct acpi_namespace_node *method_node,
315 u8 * aml_start,
316 u32 aml_length,
317 struct acpi_evaluate_info *info, u8 pass_number);
318
319void
320acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
321 struct acpi_walk_state *walk_state);
322
323void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state);
324
325struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state
326 *thread);
327
328void
329acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
330 struct acpi_thread_state *thread);
331
332acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state);
333
334struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
335 *thread);
336
337acpi_status
338acpi_ds_result_pop(union acpi_operand_object **object,
339 struct acpi_walk_state *walk_state);
340
341acpi_status
342acpi_ds_result_push(union acpi_operand_object *object,
343 struct acpi_walk_state *walk_state);
344
345#endif /* _ACDISPAT_H_ */
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
new file mode 100644
index 000000000000..07e20135f01b
--- /dev/null
+++ b/drivers/acpi/acpica/acevents.h
@@ -0,0 +1,218 @@
1/******************************************************************************
2 *
3 * Name: acevents.h - Event subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACEVENTS_H__
45#define __ACEVENTS_H__
46
47/*
48 * evevent
49 */
50acpi_status acpi_ev_initialize_events(void);
51
52acpi_status acpi_ev_install_xrupt_handlers(void);
53
54acpi_status acpi_ev_install_fadt_gpes(void);
55
56u32 acpi_ev_fixed_event_detect(void);
57
58/*
59 * evmisc
60 */
61u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node);
62
63acpi_status acpi_ev_acquire_global_lock(u16 timeout);
64
65acpi_status acpi_ev_release_global_lock(void);
66
67acpi_status acpi_ev_init_global_lock_handler(void);
68
69u32 acpi_ev_get_gpe_number_index(u32 gpe_number);
70
71acpi_status
72acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
73 u32 notify_value);
74
75/*
76 * evgpe - GPE handling and dispatch
77 */
78acpi_status
79acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
80 u8 type);
81
82acpi_status
83acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
84 u8 write_to_hardware);
85
86acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
87
88struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
89 u32 gpe_number);
90
91/*
92 * evgpeblk
93 */
94u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info);
95
96acpi_status
97acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context);
98
99acpi_status
100acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
101 struct acpi_gpe_block_info *gpe_block,
102 void *context);
103
104acpi_status
105acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
106 struct acpi_generic_address *gpe_block_address,
107 u32 register_count,
108 u8 gpe_block_base_number,
109 u32 interrupt_number,
110 struct acpi_gpe_block_info **return_gpe_block);
111
112acpi_status
113acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
114 struct acpi_gpe_block_info *gpe_block);
115
116acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
117
118u32
119acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info,
120 u32 gpe_number);
121
122u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
123
124acpi_status
125acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type);
126
127acpi_status
128acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info);
129
130acpi_status acpi_ev_gpe_initialize(void);
131
132/*
133 * evregion - Address Space handling
134 */
135acpi_status acpi_ev_install_region_handlers(void);
136
137acpi_status acpi_ev_initialize_op_regions(void);
138
139acpi_status
140acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
141 u32 function,
142 acpi_physical_address address,
143 u32 bit_width, acpi_integer * value);
144
145acpi_status
146acpi_ev_attach_region(union acpi_operand_object *handler_obj,
147 union acpi_operand_object *region_obj,
148 u8 acpi_ns_is_locked);
149
150void
151acpi_ev_detach_region(union acpi_operand_object *region_obj,
152 u8 acpi_ns_is_locked);
153
154acpi_status
155acpi_ev_install_space_handler(struct acpi_namespace_node *node,
156 acpi_adr_space_type space_id,
157 acpi_adr_space_handler handler,
158 acpi_adr_space_setup setup, void *context);
159
160acpi_status
161acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
162 acpi_adr_space_type space_id);
163
164acpi_status
165acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function);
166
167/*
168 * evregini - Region initialization and setup
169 */
170acpi_status
171acpi_ev_system_memory_region_setup(acpi_handle handle,
172 u32 function,
173 void *handler_context,
174 void **region_context);
175
176acpi_status
177acpi_ev_io_space_region_setup(acpi_handle handle,
178 u32 function,
179 void *handler_context, void **region_context);
180
181acpi_status
182acpi_ev_pci_config_region_setup(acpi_handle handle,
183 u32 function,
184 void *handler_context, void **region_context);
185
186acpi_status
187acpi_ev_cmos_region_setup(acpi_handle handle,
188 u32 function,
189 void *handler_context, void **region_context);
190
191acpi_status
192acpi_ev_pci_bar_region_setup(acpi_handle handle,
193 u32 function,
194 void *handler_context, void **region_context);
195
196acpi_status
197acpi_ev_default_region_setup(acpi_handle handle,
198 u32 function,
199 void *handler_context, void **region_context);
200
201acpi_status
202acpi_ev_initialize_region(union acpi_operand_object *region_obj,
203 u8 acpi_ns_locked);
204
205/*
206 * evsci - SCI (System Control Interrupt) handling/dispatch
207 */
208u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context);
209
210u32 acpi_ev_install_sci_handler(void);
211
212acpi_status acpi_ev_remove_sci_handler(void);
213
214u32 acpi_ev_initialize_sCI(u32 program_sCI);
215
216void acpi_ev_terminate(void);
217
218#endif /* __ACEVENTS_H__ */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
new file mode 100644
index 000000000000..ddb40f5c68fc
--- /dev/null
+++ b/drivers/acpi/acpica/acglobal.h
@@ -0,0 +1,394 @@
1/******************************************************************************
2 *
3 * Name: acglobal.h - Declarations for global variables
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACGLOBAL_H__
45#define __ACGLOBAL_H__
46
47/*
48 * Ensure that the globals are actually defined and initialized only once.
49 *
50 * The use of these macros allows a single list of globals (here) in order
51 * to simplify maintenance of the code.
52 */
53#ifdef DEFINE_ACPI_GLOBALS
54#define ACPI_EXTERN
55#define ACPI_INIT_GLOBAL(a,b) a=b
56#else
57#define ACPI_EXTERN extern
58#define ACPI_INIT_GLOBAL(a,b) a
59#endif
60
61/*****************************************************************************
62 *
63 * Runtime configuration (static defaults that can be overriden at runtime)
64 *
65 ****************************************************************************/
66
67/*
68 * Enable "slack" in the AML interpreter? Default is FALSE, and the
69 * interpreter strictly follows the ACPI specification. Setting to TRUE
70 * allows the interpreter to ignore certain errors and/or bad AML constructs.
71 *
72 * Currently, these features are enabled by this flag:
73 *
74 * 1) Allow "implicit return" of last value in a control method
75 * 2) Allow access beyond the end of an operation region
76 * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
77 * 4) Allow ANY object type to be a source operand for the Store() operator
78 * 5) Allow unresolved references (invalid target name) in package objects
79 * 6) Enable warning messages for behavior that is not ACPI spec compliant
80 */
81ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
82
83/*
84 * Automatically serialize ALL control methods? Default is FALSE, meaning
85 * to use the Serialized/not_serialized method flags on a per method basis.
86 * Only change this if the ASL code is poorly written and cannot handle
87 * reentrancy even though methods are marked "NotSerialized".
88 */
89ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
90
91/*
92 * Create the predefined _OSI method in the namespace? Default is TRUE
93 * because ACPI CA is fully compatible with other ACPI implementations.
94 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
95 */
96ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
97
98/*
99 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
100 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
101 * be enabled just before going to sleep.
102 */
103ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
104
105/*
106 * Optionally use default values for the ACPI register widths. Set this to
107 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
108 */
109ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
110
111/*****************************************************************************
112 *
113 * Debug support
114 *
115 ****************************************************************************/
116
117/* Runtime configuration of debug print levels */
118
119extern u32 acpi_dbg_level;
120extern u32 acpi_dbg_layer;
121
122/* Procedure nesting level for debug output */
123
124extern u32 acpi_gbl_nesting_level;
125
126/* Support for dynamic control method tracing mechanism */
127
128ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
129ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
130ACPI_EXTERN acpi_name acpi_gbl_trace_method_name;
131ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
132ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
133ACPI_EXTERN u32 acpi_gbl_trace_flags;
134
135/*****************************************************************************
136 *
137 * ACPI Table globals
138 *
139 ****************************************************************************/
140
141/*
142 * acpi_gbl_root_table_list is the master list of ACPI tables found in the
143 * RSDT/XSDT.
144 *
145 * acpi_gbl_FADT is a local copy of the FADT, converted to a common format.
146 */
147ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
150
151/* These addresses are calculated from FADT address values */
152
153ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable;
154ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
155
156/*
157 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is
158 * determined by the revision of the DSDT: If the DSDT revision is less than
159 * 2, use only the lower 32 bits of the internal 64-bit Integer.
160 */
161ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
162ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
163ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
164
165/*****************************************************************************
166 *
167 * Mutual exlusion within ACPICA subsystem
168 *
169 ****************************************************************************/
170
171/*
172 * Predefined mutex objects. This array contains the
173 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
174 * (The table maps local handles to the real OS handles)
175 */
176ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
177
178/*
179 * Global lock mutex is an actual AML mutex object
180 * Global lock semaphore works in conjunction with the HW global lock
181 */
182ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex;
183ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
184ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
185ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
186ACPI_EXTERN u8 acpi_gbl_global_lock_present;
187
188/*
189 * Spinlocks are used for interfaces that can be possibly called at
190 * interrupt level
191 */
192ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */
193ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
194#define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock
195#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock
196
197/*****************************************************************************
198 *
199 * Miscellaneous globals
200 *
201 ****************************************************************************/
202
203#ifdef ACPI_DBG_TRACK_ALLOCATIONS
204
205/* Lists for tracking memory allocations */
206
207ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
208ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
209ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
210#endif
211
212/* Object caches */
213
214ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache;
215ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache;
216ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache;
217ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache;
218ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
219
220/* Global handlers */
221
222ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
223ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
224ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
225ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
226ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler;
227ACPI_EXTERN void *acpi_gbl_table_handler_context;
228ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
229
230/* Owner ID support */
231
232ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
233ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
234ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
235
236/* Misc */
237
238ACPI_EXTERN u32 acpi_gbl_original_mode;
239ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
240ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
241ACPI_EXTERN u32 acpi_gbl_ps_find_count;
242ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
243ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
244ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
245ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
246ACPI_EXTERN u8 acpi_gbl_events_initialized;
247ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
248
249#ifndef DEFINE_ACPI_GLOBALS
250
251/* Other miscellaneous */
252
253extern u8 acpi_gbl_shutdown;
254extern u32 acpi_gbl_startup_flags;
255extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
256extern const char *acpi_gbl_highest_dstate_names[4];
257extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
258extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
259
260#endif
261
262/* Exception codes */
263
264extern char const *acpi_gbl_exception_names_env[];
265extern char const *acpi_gbl_exception_names_pgm[];
266extern char const *acpi_gbl_exception_names_tbl[];
267extern char const *acpi_gbl_exception_names_aml[];
268extern char const *acpi_gbl_exception_names_ctrl[];
269
270/*****************************************************************************
271 *
272 * Namespace globals
273 *
274 ****************************************************************************/
275
276#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
277#define NUM_PREDEFINED_NAMES 10
278#else
279#define NUM_PREDEFINED_NAMES 9
280#endif
281
282ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
283ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
284ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
285
286extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
287extern const struct acpi_predefined_names
288 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
289
290#ifdef ACPI_DEBUG_OUTPUT
291ACPI_EXTERN u32 acpi_gbl_current_node_count;
292ACPI_EXTERN u32 acpi_gbl_current_node_size;
293ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
294ACPI_EXTERN acpi_size *acpi_gbl_entry_stack_pointer;
295ACPI_EXTERN acpi_size *acpi_gbl_lowest_stack_pointer;
296ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
297#endif
298
299/*****************************************************************************
300 *
301 * Interpreter globals
302 *
303 ****************************************************************************/
304
305ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
306
307/* Control method single step flag */
308
309ACPI_EXTERN u8 acpi_gbl_cm_single_step;
310
311/*****************************************************************************
312 *
313 * Hardware globals
314 *
315 ****************************************************************************/
316
317extern struct acpi_bit_register_info
318 acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
319ACPI_EXTERN u8 acpi_gbl_sleep_type_a;
320ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
321
322/*****************************************************************************
323 *
324 * Event and GPE globals
325 *
326 ****************************************************************************/
327
328extern struct acpi_fixed_event_info
329 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
330ACPI_EXTERN struct acpi_fixed_event_handler
331 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
332ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
333ACPI_EXTERN struct acpi_gpe_block_info
334*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
335ACPI_EXTERN u32 acpi_current_gpe_count;
336
337/*****************************************************************************
338 *
339 * Debugger globals
340 *
341 ****************************************************************************/
342
343ACPI_EXTERN u8 acpi_gbl_db_output_flags;
344
345#ifdef ACPI_DISASSEMBLER
346
347ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
348ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
349#endif
350
351#ifdef ACPI_DEBUGGER
352
353extern u8 acpi_gbl_method_executing;
354extern u8 acpi_gbl_abort_method;
355extern u8 acpi_gbl_db_terminate_threads;
356
357ACPI_EXTERN int optind;
358ACPI_EXTERN char *optarg;
359
360ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
361ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
362ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
363
364ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
365ACPI_EXTERN char acpi_gbl_db_line_buf[80];
366ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
367ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
368ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
369ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
370ACPI_EXTERN char *acpi_gbl_db_buffer;
371ACPI_EXTERN char *acpi_gbl_db_filename;
372ACPI_EXTERN u32 acpi_gbl_db_debug_level;
373ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
374ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr;
375ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
376
377/*
378 * Statistic globals
379 */
380ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
381ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
382ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc;
383ACPI_EXTERN u16 acpi_gbl_node_type_count_misc;
384ACPI_EXTERN u32 acpi_gbl_num_nodes;
385ACPI_EXTERN u32 acpi_gbl_num_objects;
386
387ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree;
388ACPI_EXTERN u32 acpi_gbl_size_of_method_trees;
389ACPI_EXTERN u32 acpi_gbl_size_of_node_entries;
390ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
391
392#endif /* ACPI_DEBUGGER */
393
394#endif /* __ACGLOBAL_H__ */
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
new file mode 100644
index 000000000000..58c69dc49ab4
--- /dev/null
+++ b/drivers/acpi/acpica/achware.h
@@ -0,0 +1,119 @@
1/******************************************************************************
2 *
3 * Name: achware.h -- hardware specific interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACHWARE_H__
45#define __ACHWARE_H__
46
47/* Values for the _SST predefined method */
48
49#define ACPI_SST_INDICATOR_OFF 0
50#define ACPI_SST_WORKING 1
51#define ACPI_SST_WAKING 2
52#define ACPI_SST_SLEEPING 3
53#define ACPI_SST_SLEEP_CONTEXT 4
54
55/*
56 * hwacpi - high level functions
57 */
58acpi_status acpi_hw_set_mode(u32 mode);
59
60u32 acpi_hw_get_mode(void);
61
62/*
63 * hwregs - ACPI Register I/O
64 */
65struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
66
67acpi_status
68acpi_hw_register_read(u32 register_id, u32 * return_value);
69
70acpi_status acpi_hw_register_write(u32 register_id, u32 value);
71
72acpi_status acpi_hw_clear_acpi_status(void);
73
74/*
75 * hwgpe - GPE support
76 */
77acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
78
79acpi_status
80acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
81
82acpi_status
83acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
84 struct acpi_gpe_block_info *gpe_block, void *context);
85
86acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info);
87
88acpi_status
89acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
90 struct acpi_gpe_block_info *gpe_block, void *context);
91
92acpi_status
93acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
94 acpi_event_status * event_status);
95
96acpi_status acpi_hw_disable_all_gpes(void);
97
98acpi_status acpi_hw_enable_all_runtime_gpes(void);
99
100acpi_status acpi_hw_enable_all_wakeup_gpes(void);
101
102acpi_status
103acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
104 struct acpi_gpe_block_info *gpe_block,
105 void *context);
106
107#ifdef ACPI_FUTURE_USAGE
108/*
109 * hwtimer - ACPI Timer prototypes
110 */
111acpi_status acpi_get_timer_resolution(u32 * resolution);
112
113acpi_status acpi_get_timer(u32 * ticks);
114
115acpi_status
116acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed);
117#endif /* ACPI_FUTURE_USAGE */
118
119#endif /* __ACHWARE_H__ */
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
new file mode 100644
index 000000000000..e8db7a3143a5
--- /dev/null
+++ b/drivers/acpi/acpica/acinterp.h
@@ -0,0 +1,529 @@
1/******************************************************************************
2 *
3 * Name: acinterp.h - Interpreter subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACINTERP_H__
45#define __ACINTERP_H__
46
47#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
48
49/* Macros for tables used for debug output */
50
51#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f)
52#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f)
53#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info))
54
55/*
56 * If possible, pack the following structures to byte alignment, since we
57 * don't care about performance for debug output. Two cases where we cannot
58 * pack the structures:
59 *
60 * 1) Hardware does not support misaligned memory transfers
61 * 2) Compiler does not support pointers within packed structures
62 */
63#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
64#pragma pack(1)
65#endif
66
67typedef const struct acpi_exdump_info {
68 u8 opcode;
69 u8 offset;
70 char *name;
71
72} acpi_exdump_info;
73
74/* Values for the Opcode field above */
75
76#define ACPI_EXD_INIT 0
77#define ACPI_EXD_TYPE 1
78#define ACPI_EXD_UINT8 2
79#define ACPI_EXD_UINT16 3
80#define ACPI_EXD_UINT32 4
81#define ACPI_EXD_UINT64 5
82#define ACPI_EXD_LITERAL 6
83#define ACPI_EXD_POINTER 7
84#define ACPI_EXD_ADDRESS 8
85#define ACPI_EXD_STRING 9
86#define ACPI_EXD_BUFFER 10
87#define ACPI_EXD_PACKAGE 11
88#define ACPI_EXD_FIELD 12
89#define ACPI_EXD_REFERENCE 13
90
91/* restore default alignment */
92
93#pragma pack()
94
95/*
96 * exconvrt - object conversion
97 */
98acpi_status
99acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
100 union acpi_operand_object **result_desc, u32 flags);
101
102acpi_status
103acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
104 union acpi_operand_object **result_desc);
105
106acpi_status
107acpi_ex_convert_to_string(union acpi_operand_object *obj_desc,
108 union acpi_operand_object **result_desc, u32 type);
109
110/* Types for ->String conversion */
111
112#define ACPI_EXPLICIT_BYTE_COPY 0x00000000
113#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001
114#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002
115#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003
116
117acpi_status
118acpi_ex_convert_to_target_type(acpi_object_type destination_type,
119 union acpi_operand_object *source_desc,
120 union acpi_operand_object **result_desc,
121 struct acpi_walk_state *walk_state);
122
123/*
124 * exfield - ACPI AML (p-code) execution - field manipulation
125 */
126acpi_status
127acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
128 u32 buffer_length, u32 * datum_count);
129
130acpi_status
131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
132 acpi_integer mask,
133 acpi_integer field_value,
134 u32 field_datum_byte_offset);
135
136void
137acpi_ex_get_buffer_datum(acpi_integer * datum,
138 void *buffer,
139 u32 buffer_length,
140 u32 byte_granularity, u32 buffer_offset);
141
142void
143acpi_ex_set_buffer_datum(acpi_integer merged_datum,
144 void *buffer,
145 u32 buffer_length,
146 u32 byte_granularity, u32 buffer_offset);
147
148acpi_status
149acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
150 union acpi_operand_object *obj_desc,
151 union acpi_operand_object **ret_buffer_desc);
152
153acpi_status
154acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
155 union acpi_operand_object *obj_desc,
156 union acpi_operand_object **result_desc);
157
158/*
159 * exfldio - low level field I/O
160 */
161acpi_status
162acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
163 void *buffer, u32 buffer_length);
164
165acpi_status
166acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
167 void *buffer, u32 buffer_length);
168
169acpi_status
170acpi_ex_access_region(union acpi_operand_object *obj_desc,
171 u32 field_datum_byte_offset,
172 acpi_integer * value, u32 read_write);
173
174/*
175 * exmisc - misc support routines
176 */
177acpi_status
178acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
179 union acpi_operand_object **return_desc,
180 struct acpi_walk_state *walk_state);
181
182acpi_status
183acpi_ex_concat_template(union acpi_operand_object *obj_desc,
184 union acpi_operand_object *obj_desc2,
185 union acpi_operand_object **actual_return_desc,
186 struct acpi_walk_state *walk_state);
187
188acpi_status
189acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
190 union acpi_operand_object *obj_desc2,
191 union acpi_operand_object **actual_return_desc,
192 struct acpi_walk_state *walk_state);
193
194acpi_status
195acpi_ex_do_logical_numeric_op(u16 opcode,
196 acpi_integer integer0,
197 acpi_integer integer1, u8 * logical_result);
198
199acpi_status
200acpi_ex_do_logical_op(u16 opcode,
201 union acpi_operand_object *operand0,
202 union acpi_operand_object *operand1, u8 * logical_result);
203
204acpi_integer
205acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
206
207acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
208
209acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state);
210
211acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state);
212
213acpi_status
214acpi_ex_create_region(u8 * aml_start,
215 u32 aml_length,
216 u8 region_space, struct acpi_walk_state *walk_state);
217
218acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
219
220acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
221
222acpi_status
223acpi_ex_create_method(u8 * aml_start,
224 u32 aml_length, struct acpi_walk_state *walk_state);
225
226/*
227 * exconfig - dynamic table load/unload
228 */
229acpi_status
230acpi_ex_load_op(union acpi_operand_object *obj_desc,
231 union acpi_operand_object *target,
232 struct acpi_walk_state *walk_state);
233
234acpi_status
235acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
236 union acpi_operand_object **return_desc);
237
238acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle);
239
240/*
241 * exmutex - mutex support
242 */
243acpi_status
244acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
245 union acpi_operand_object *obj_desc,
246 struct acpi_walk_state *walk_state);
247
248acpi_status
249acpi_ex_acquire_mutex_object(u16 timeout,
250 union acpi_operand_object *obj_desc,
251 acpi_thread_id thread_id);
252
253acpi_status
254acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
255 struct acpi_walk_state *walk_state);
256
257acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc);
258
259void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
260
261void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
262
263/*
264 * exprep - ACPI AML execution - prep utilities
265 */
266acpi_status
267acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
268 u8 field_flags,
269 u8 field_attribute,
270 u32 field_bit_position, u32 field_bit_length);
271
272acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info);
273
274/*
275 * exsystem - Interface to OS services
276 */
277acpi_status
278acpi_ex_system_do_notify_op(union acpi_operand_object *value,
279 union acpi_operand_object *obj_desc);
280
281acpi_status acpi_ex_system_do_suspend(acpi_integer time);
282
283acpi_status acpi_ex_system_do_stall(u32 time);
284
285acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc);
286
287acpi_status
288acpi_ex_system_wait_event(union acpi_operand_object *time,
289 union acpi_operand_object *obj_desc);
290
291acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
292
293acpi_status
294acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
295
296acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
297
298/*
299 * exoparg1 - ACPI AML execution, 1 operand
300 */
301acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state);
302
303acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state);
304
305acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state);
306
307acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state);
308
309acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state);
310
311/*
312 * exoparg2 - ACPI AML execution, 2 operands
313 */
314acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state);
315
316acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state);
317
318acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state);
319
320acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state);
321
322/*
323 * exoparg3 - ACPI AML execution, 3 operands
324 */
325acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state);
326
327acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state);
328
329/*
330 * exoparg6 - ACPI AML execution, 6 operands
331 */
332acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state);
333
334/*
335 * exresolv - Object resolution and get value functions
336 */
337acpi_status
338acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
339 struct acpi_walk_state *walk_state);
340
341acpi_status
342acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
343 union acpi_operand_object *operand,
344 acpi_object_type * return_type,
345 union acpi_operand_object **return_desc);
346
347/*
348 * exresnte - resolve namespace node
349 */
350acpi_status
351acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr,
352 struct acpi_walk_state *walk_state);
353
354/*
355 * exresop - resolve operand to value
356 */
357acpi_status
358acpi_ex_resolve_operands(u16 opcode,
359 union acpi_operand_object **stack_ptr,
360 struct acpi_walk_state *walk_state);
361
362/*
363 * exdump - Interpreter debug output routines
364 */
365void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth);
366
367void
368acpi_ex_dump_operands(union acpi_operand_object **operands,
369 const char *opcode_name, u32 num_opcodes);
370
371#ifdef ACPI_FUTURE_USAGE
372void
373acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
374
375void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
376#endif /* ACPI_FUTURE_USAGE */
377
378/*
379 * exnames - AML namestring support
380 */
381acpi_status
382acpi_ex_get_name_string(acpi_object_type data_type,
383 u8 * in_aml_address,
384 char **out_name_string, u32 * out_name_length);
385
386/*
387 * exstore - Object store support
388 */
389acpi_status
390acpi_ex_store(union acpi_operand_object *val_desc,
391 union acpi_operand_object *dest_desc,
392 struct acpi_walk_state *walk_state);
393
394acpi_status
395acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
396 struct acpi_namespace_node *node,
397 struct acpi_walk_state *walk_state,
398 u8 implicit_conversion);
399
400#define ACPI_IMPLICIT_CONVERSION TRUE
401#define ACPI_NO_IMPLICIT_CONVERSION FALSE
402
403/*
404 * exstoren - resolve/store object
405 */
406acpi_status
407acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
408 acpi_object_type target_type,
409 struct acpi_walk_state *walk_state);
410
411acpi_status
412acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
413 union acpi_operand_object *dest_desc,
414 union acpi_operand_object **new_desc,
415 struct acpi_walk_state *walk_state);
416
417/*
418 * exstorob - store object - buffer/string
419 */
420acpi_status
421acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
422 union acpi_operand_object *target_desc);
423
424acpi_status
425acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
426 union acpi_operand_object *target_desc);
427
428/*
429 * excopy - object copy
430 */
431acpi_status
432acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc,
433 union acpi_operand_object *target_desc);
434
435acpi_status
436acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc,
437 union acpi_operand_object *target_desc);
438
439acpi_status
440acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc,
441 struct acpi_namespace_node *node);
442
443acpi_status
444acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc,
445 union acpi_operand_object *target_desc);
446
447/*
448 * exutils - interpreter/scanner utilities
449 */
450void acpi_ex_enter_interpreter(void);
451
452void acpi_ex_exit_interpreter(void);
453
454void acpi_ex_reacquire_interpreter(void);
455
456void acpi_ex_relinquish_interpreter(void);
457
458void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
459
460void acpi_ex_acquire_global_lock(u32 rule);
461
462void acpi_ex_release_global_lock(u32 rule);
463
464void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string);
465
466void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string);
467
468/*
469 * exregion - default op_region handlers
470 */
471acpi_status
472acpi_ex_system_memory_space_handler(u32 function,
473 acpi_physical_address address,
474 u32 bit_width,
475 acpi_integer * value,
476 void *handler_context,
477 void *region_context);
478
479acpi_status
480acpi_ex_system_io_space_handler(u32 function,
481 acpi_physical_address address,
482 u32 bit_width,
483 acpi_integer * value,
484 void *handler_context, void *region_context);
485
486acpi_status
487acpi_ex_pci_config_space_handler(u32 function,
488 acpi_physical_address address,
489 u32 bit_width,
490 acpi_integer * value,
491 void *handler_context, void *region_context);
492
493acpi_status
494acpi_ex_cmos_space_handler(u32 function,
495 acpi_physical_address address,
496 u32 bit_width,
497 acpi_integer * value,
498 void *handler_context, void *region_context);
499
500acpi_status
501acpi_ex_pci_bar_space_handler(u32 function,
502 acpi_physical_address address,
503 u32 bit_width,
504 acpi_integer * value,
505 void *handler_context, void *region_context);
506
507acpi_status
508acpi_ex_embedded_controller_space_handler(u32 function,
509 acpi_physical_address address,
510 u32 bit_width,
511 acpi_integer * value,
512 void *handler_context,
513 void *region_context);
514
515acpi_status
516acpi_ex_sm_bus_space_handler(u32 function,
517 acpi_physical_address address,
518 u32 bit_width,
519 acpi_integer * value,
520 void *handler_context, void *region_context);
521
522acpi_status
523acpi_ex_data_table_space_handler(u32 function,
524 acpi_physical_address address,
525 u32 bit_width,
526 acpi_integer * value,
527 void *handler_context, void *region_context);
528
529#endif /* __INTERP_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
new file mode 100644
index 000000000000..492d02761bb7
--- /dev/null
+++ b/drivers/acpi/acpica/aclocal.h
@@ -0,0 +1,990 @@
1/******************************************************************************
2 *
3 * Name: aclocal.h - Internal data types used across the ACPI subsystem
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACLOCAL_H__
45#define __ACLOCAL_H__
46
47/* acpisrc:struct_defs -- for acpisrc conversion */
48
49#define ACPI_SERIALIZED 0xFF
50
51typedef u32 acpi_mutex_handle;
52#define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1)
53
54/* Total number of aml opcodes defined */
55
56#define AML_NUM_OPCODES 0x7F
57
58/* Forward declarations */
59
60struct acpi_walk_state;
61struct acpi_obj_mutex;
62union acpi_parse_object;
63
64/*****************************************************************************
65 *
66 * Mutex typedefs and structs
67 *
68 ****************************************************************************/
69
70/*
71 * Predefined handles for the mutex objects used within the subsystem
72 * All mutex objects are automatically created by acpi_ut_mutex_initialize.
73 *
74 * The acquire/release ordering protocol is implied via this list. Mutexes
75 * with a lower value must be acquired before mutexes with a higher value.
76 *
77 * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names
78 * table below also!
79 */
80#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */
81#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */
82#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */
83#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */
84#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */
85#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */
86#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */
87#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */
88
89#define ACPI_MAX_MUTEX 7
90#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
91
92#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
93#ifdef DEFINE_ACPI_GLOBALS
94
95/* Debug names for the mutexes above */
96
97static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
98 "ACPI_MTX_Interpreter",
99 "ACPI_MTX_Namespace",
100 "ACPI_MTX_Tables",
101 "ACPI_MTX_Events",
102 "ACPI_MTX_Caches",
103 "ACPI_MTX_Memory",
104 "ACPI_MTX_CommandComplete",
105 "ACPI_MTX_CommandReady"
106};
107
108#endif
109#endif
110
111/*
112 * Predefined handles for spinlocks used within the subsystem.
113 * These spinlocks are created by acpi_ut_mutex_initialize
114 */
115#define ACPI_LOCK_GPES 0
116#define ACPI_LOCK_HARDWARE 1
117
118#define ACPI_MAX_LOCK 1
119#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1
120
121/* This Thread ID means that the mutex is not in use (unlocked) */
122
123#define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
124
125/* Table for the global mutexes */
126
127struct acpi_mutex_info {
128 acpi_mutex mutex;
129 u32 use_count;
130 acpi_thread_id thread_id;
131};
132
133/* Lock flag parameter for various interfaces */
134
135#define ACPI_MTX_DO_NOT_LOCK 0
136#define ACPI_MTX_LOCK 1
137
138/* Field access granularities */
139
140#define ACPI_FIELD_BYTE_GRANULARITY 1
141#define ACPI_FIELD_WORD_GRANULARITY 2
142#define ACPI_FIELD_DWORD_GRANULARITY 4
143#define ACPI_FIELD_QWORD_GRANULARITY 8
144
145#define ACPI_ENTRY_NOT_FOUND NULL
146
147/*****************************************************************************
148 *
149 * Namespace typedefs and structs
150 *
151 ****************************************************************************/
152
153/* Operational modes of the AML interpreter/scanner */
154
155typedef enum {
156 ACPI_IMODE_LOAD_PASS1 = 0x01,
157 ACPI_IMODE_LOAD_PASS2 = 0x02,
158 ACPI_IMODE_EXECUTE = 0x03
159} acpi_interpreter_mode;
160
161/*
162 * The Namespace Node describes a named object that appears in the AML.
163 * descriptor_type is used to differentiate between internal descriptors.
164 *
165 * The node is optimized for both 32-bit and 64-bit platforms:
166 * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
167 *
168 * Note: The descriptor_type and Type fields must appear in the identical
169 * position in both the struct acpi_namespace_node and union acpi_operand_object
170 * structures.
171 */
172struct acpi_namespace_node {
173 union acpi_operand_object *object; /* Interpreter object */
174 u8 descriptor_type; /* Differentiate object descriptor types */
175 u8 type; /* ACPI Type associated with this name */
176 u8 flags; /* Miscellaneous flags */
177 acpi_owner_id owner_id; /* Node creator */
178 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
179 struct acpi_namespace_node *child; /* First child */
180 struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */
181
182 /*
183 * The following fields are used by the ASL compiler and disassembler only
184 */
185#ifdef ACPI_LARGE_NAMESPACE_NODE
186 union acpi_parse_object *op;
187 u32 value;
188 u32 length;
189#endif
190};
191
192/* Namespace Node flags */
193
194#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */
195#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */
196#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
197#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
198#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
199#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
200
201#define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */
202#define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */
203#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */
204#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */
205#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
206
207/* One internal RSDT for table management */
208
209struct acpi_internal_rsdt {
210 struct acpi_table_desc *tables;
211 u32 count;
212 u32 size;
213 u8 flags;
214};
215
216/* Flags for above */
217
218#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */
219#define ACPI_ROOT_ORIGIN_ALLOCATED (1)
220#define ACPI_ROOT_ALLOW_RESIZE (2)
221
222/* Predefined (fixed) table indexes */
223
224#define ACPI_TABLE_INDEX_DSDT (0)
225#define ACPI_TABLE_INDEX_FACS (1)
226
227struct acpi_find_context {
228 char *search_for;
229 acpi_handle *list;
230 u32 *count;
231};
232
233struct acpi_ns_search_data {
234 struct acpi_namespace_node *node;
235};
236
237/* Object types used during package copies */
238
239#define ACPI_COPY_TYPE_SIMPLE 0
240#define ACPI_COPY_TYPE_PACKAGE 1
241
242/* Info structure used to convert external<->internal namestrings */
243
244struct acpi_namestring_info {
245 const char *external_name;
246 const char *next_external_char;
247 char *internal_name;
248 u32 length;
249 u32 num_segments;
250 u32 num_carats;
251 u8 fully_qualified;
252};
253
254/* Field creation info */
255
256struct acpi_create_field_info {
257 struct acpi_namespace_node *region_node;
258 struct acpi_namespace_node *field_node;
259 struct acpi_namespace_node *register_node;
260 struct acpi_namespace_node *data_register_node;
261 u32 bank_value;
262 u32 field_bit_position;
263 u32 field_bit_length;
264 u8 field_flags;
265 u8 attribute;
266 u8 field_type;
267};
268
269typedef
270acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
271
272/*
273 * Bitmapped ACPI types. Used internally only
274 */
275#define ACPI_BTYPE_ANY 0x00000000
276#define ACPI_BTYPE_INTEGER 0x00000001
277#define ACPI_BTYPE_STRING 0x00000002
278#define ACPI_BTYPE_BUFFER 0x00000004
279#define ACPI_BTYPE_PACKAGE 0x00000008
280#define ACPI_BTYPE_FIELD_UNIT 0x00000010
281#define ACPI_BTYPE_DEVICE 0x00000020
282#define ACPI_BTYPE_EVENT 0x00000040
283#define ACPI_BTYPE_METHOD 0x00000080
284#define ACPI_BTYPE_MUTEX 0x00000100
285#define ACPI_BTYPE_REGION 0x00000200
286#define ACPI_BTYPE_POWER 0x00000400
287#define ACPI_BTYPE_PROCESSOR 0x00000800
288#define ACPI_BTYPE_THERMAL 0x00001000
289#define ACPI_BTYPE_BUFFER_FIELD 0x00002000
290#define ACPI_BTYPE_DDB_HANDLE 0x00004000
291#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
292#define ACPI_BTYPE_REFERENCE 0x00010000
293#define ACPI_BTYPE_RESOURCE 0x00020000
294
295#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
296
297#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
298#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
299#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
300#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
301#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
302
303/*
304 * Information structure for ACPI predefined names.
305 * Each entry in the table contains the following items:
306 *
307 * Name - The ACPI reserved name
308 * param_count - Number of arguments to the method
309 * expected_return_btypes - Allowed type(s) for the return value
310 */
311struct acpi_name_info {
312 char name[ACPI_NAME_SIZE];
313 u8 param_count;
314 u8 expected_btypes;
315};
316
317/*
318 * Secondary information structures for ACPI predefined objects that return
319 * package objects. This structure appears as the next entry in the table
320 * after the NAME_INFO structure above.
321 *
322 * The reason for this is to minimize the size of the predefined name table.
323 */
324
325/*
326 * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
327 * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
328 */
329struct acpi_package_info {
330 u8 type;
331 u8 object_type1;
332 u8 count1;
333 u8 object_type2;
334 u8 count2;
335 u8 reserved;
336};
337
338/* Used for ACPI_PTYPE2_FIXED */
339
340struct acpi_package_info2 {
341 u8 type;
342 u8 count;
343 u8 object_type[4];
344};
345
346/* Used for ACPI_PTYPE1_OPTION */
347
348struct acpi_package_info3 {
349 u8 type;
350 u8 count;
351 u8 object_type[2];
352 u8 tail_object_type;
353 u8 reserved;
354};
355
356union acpi_predefined_info {
357 struct acpi_name_info info;
358 struct acpi_package_info ret_info;
359 struct acpi_package_info2 ret_info2;
360 struct acpi_package_info3 ret_info3;
361};
362
363/*
364 * Bitmapped return value types
365 * Note: the actual data types must be contiguous, a loop in nspredef.c
366 * depends on this.
367 */
368#define ACPI_RTYPE_ANY 0x00
369#define ACPI_RTYPE_NONE 0x01
370#define ACPI_RTYPE_INTEGER 0x02
371#define ACPI_RTYPE_STRING 0x04
372#define ACPI_RTYPE_BUFFER 0x08
373#define ACPI_RTYPE_PACKAGE 0x10
374#define ACPI_RTYPE_REFERENCE 0x20
375#define ACPI_RTYPE_ALL 0x3F
376
377#define ACPI_NUM_RTYPES 5 /* Number of actual object types */
378
379/*****************************************************************************
380 *
381 * Event typedefs and structs
382 *
383 ****************************************************************************/
384
385/* Dispatch info for each GPE -- either a method or handler, cannot be both */
386
387struct acpi_handler_info {
388 acpi_event_handler address; /* Address of handler, if any */
389 void *context; /* Context to be passed to handler */
390 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
391};
392
393union acpi_gpe_dispatch_info {
394 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
395 struct acpi_handler_info *handler;
396};
397
398/*
399 * Information about a GPE, one per each GPE in an array.
400 * NOTE: Important to keep this struct as small as possible.
401 */
402struct acpi_gpe_event_info {
403 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
404 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
405 u8 flags; /* Misc info about this GPE */
406 u8 gpe_number; /* This GPE */
407};
408
409/* Information about a GPE register pair, one per each status/enable pair in an array */
410
411struct acpi_gpe_register_info {
412 struct acpi_generic_address status_address; /* Address of status reg */
413 struct acpi_generic_address enable_address; /* Address of enable reg */
414 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
415 u8 enable_for_run; /* GPEs to keep enabled when running */
416 u8 base_gpe_number; /* Base GPE number for this register */
417};
418
419/*
420 * Information about a GPE register block, one per each installed block --
421 * GPE0, GPE1, and one per each installed GPE Block Device.
422 */
423struct acpi_gpe_block_info {
424 struct acpi_namespace_node *node;
425 struct acpi_gpe_block_info *previous;
426 struct acpi_gpe_block_info *next;
427 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
428 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
429 struct acpi_gpe_event_info *event_info; /* One for each GPE */
430 struct acpi_generic_address block_address; /* Base address of the block */
431 u32 register_count; /* Number of register pairs in block */
432 u8 block_base_number; /* Base GPE number for this block */
433};
434
435/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
436
437struct acpi_gpe_xrupt_info {
438 struct acpi_gpe_xrupt_info *previous;
439 struct acpi_gpe_xrupt_info *next;
440 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
441 u32 interrupt_number; /* System interrupt number */
442};
443
444struct acpi_gpe_walk_info {
445 struct acpi_namespace_node *gpe_device;
446 struct acpi_gpe_block_info *gpe_block;
447};
448
449struct acpi_gpe_device_info {
450 u32 index;
451 u32 next_block_base_index;
452 acpi_status status;
453 struct acpi_namespace_node *gpe_device;
454};
455
456typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info,
457 struct acpi_gpe_block_info *gpe_block, void *context);
458
459/* Information about each particular fixed event */
460
461struct acpi_fixed_event_handler {
462 acpi_event_handler handler; /* Address of handler. */
463 void *context; /* Context to be passed to handler */
464};
465
466struct acpi_fixed_event_info {
467 u8 status_register_id;
468 u8 enable_register_id;
469 u16 status_bit_mask;
470 u16 enable_bit_mask;
471};
472
473/* Information used during field processing */
474
475struct acpi_field_info {
476 u8 skip_field;
477 u8 field_flag;
478 u32 pkg_length;
479};
480
481/*****************************************************************************
482 *
483 * Generic "state" object for stacks
484 *
485 ****************************************************************************/
486
487#define ACPI_CONTROL_NORMAL 0xC0
488#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
489#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
490#define ACPI_CONTROL_PREDICATE_FALSE 0xC3
491#define ACPI_CONTROL_PREDICATE_TRUE 0xC4
492
493#define ACPI_STATE_COMMON \
494 void *next; \
495 u8 descriptor_type; /* To differentiate various internal objs */\
496 u8 flags; \
497 u16 value; \
498 u16 state;
499
500 /* There are 2 bytes available here until the next natural alignment boundary */
501
502struct acpi_common_state {
503ACPI_STATE_COMMON};
504
505/*
506 * Update state - used to traverse complex objects such as packages
507 */
508struct acpi_update_state {
509 ACPI_STATE_COMMON union acpi_operand_object *object;
510};
511
512/*
513 * Pkg state - used to traverse nested package structures
514 */
515struct acpi_pkg_state {
516 ACPI_STATE_COMMON u16 index;
517 union acpi_operand_object *source_object;
518 union acpi_operand_object *dest_object;
519 struct acpi_walk_state *walk_state;
520 void *this_target_obj;
521 u32 num_packages;
522};
523
524/*
525 * Control state - one per if/else and while constructs.
526 * Allows nesting of these constructs
527 */
528struct acpi_control_state {
529 ACPI_STATE_COMMON u16 opcode;
530 union acpi_parse_object *predicate_op;
531 u8 *aml_predicate_start; /* Start of if/while predicate */
532 u8 *package_end; /* End of if/while block */
533 u32 loop_count; /* While() loop counter */
534};
535
536/*
537 * Scope state - current scope during namespace lookups
538 */
539struct acpi_scope_state {
540 ACPI_STATE_COMMON struct acpi_namespace_node *node;
541};
542
543struct acpi_pscope_state {
544 ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */
545 union acpi_parse_object *op; /* Current op being parsed */
546 u8 *arg_end; /* Current argument end */
547 u8 *pkg_end; /* Current package end */
548 u32 arg_list; /* Next argument to parse */
549};
550
551/*
552 * Thread state - one per thread across multiple walk states. Multiple walk
553 * states are created when there are nested control methods executing.
554 */
555struct acpi_thread_state {
556 ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */
557 struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
558 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
559 acpi_thread_id thread_id; /* Running thread ID */
560};
561
562/*
563 * Result values - used to accumulate the results of nested
564 * AML arguments
565 */
566struct acpi_result_values {
567 ACPI_STATE_COMMON
568 union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM];
569};
570
571typedef
572acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
573 union acpi_parse_object ** out_op);
574
575typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
576
577/*
578 * Notify info - used to pass info to the deferred notify
579 * handler/dispatcher.
580 */
581struct acpi_notify_info {
582 ACPI_STATE_COMMON struct acpi_namespace_node *node;
583 union acpi_operand_object *handler_obj;
584};
585
586/* Generic state is union of structs above */
587
588union acpi_generic_state {
589 struct acpi_common_state common;
590 struct acpi_control_state control;
591 struct acpi_update_state update;
592 struct acpi_scope_state scope;
593 struct acpi_pscope_state parse_scope;
594 struct acpi_pkg_state pkg;
595 struct acpi_thread_state thread;
596 struct acpi_result_values results;
597 struct acpi_notify_info notify;
598};
599
600/*****************************************************************************
601 *
602 * Interpreter typedefs and structs
603 *
604 ****************************************************************************/
605
606typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
607
608/*****************************************************************************
609 *
610 * Parser typedefs and structs
611 *
612 ****************************************************************************/
613
614/*
615 * AML opcode, name, and argument layout
616 */
617struct acpi_opcode_info {
618#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
619 char *name; /* Opcode name (disassembler/debug only) */
620#endif
621 u32 parse_args; /* Grammar/Parse time arguments */
622 u32 runtime_args; /* Interpret time arguments */
623 u16 flags; /* Misc flags */
624 u8 object_type; /* Corresponding internal object type */
625 u8 class; /* Opcode class */
626 u8 type; /* Opcode type */
627};
628
629union acpi_parse_value {
630 acpi_integer integer; /* Integer constant (Up to 64 bits) */
631 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
632 u32 size; /* bytelist or field size */
633 char *string; /* NULL terminated string */
634 u8 *buffer; /* buffer or string */
635 char *name; /* NULL terminated string */
636 union acpi_parse_object *arg; /* arguments and contained ops */
637};
638
639#ifdef ACPI_DISASSEMBLER
640#define ACPI_DISASM_ONLY_MEMBERS(a) a;
641#else
642#define ACPI_DISASM_ONLY_MEMBERS(a)
643#endif
644
645#define ACPI_PARSE_COMMON \
646 union acpi_parse_object *parent; /* Parent op */\
647 u8 descriptor_type; /* To differentiate various internal objs */\
648 u8 flags; /* Type of Op */\
649 u16 aml_opcode; /* AML opcode */\
650 u32 aml_offset; /* Offset of declaration in AML */\
651 union acpi_parse_object *next; /* Next op */\
652 struct acpi_namespace_node *node; /* For use by interpreter */\
653 union acpi_parse_value value; /* Value or args associated with the opcode */\
654 u8 arg_list_length; /* Number of elements in the arg list */\
655 ACPI_DISASM_ONLY_MEMBERS (\
656 u8 disasm_flags; /* Used during AML disassembly */\
657 u8 disasm_opcode; /* Subtype used for disassembly */\
658 char aml_op_name[16]) /* Op name (debug only) */
659
660#define ACPI_DASM_BUFFER 0x00
661#define ACPI_DASM_RESOURCE 0x01
662#define ACPI_DASM_STRING 0x02
663#define ACPI_DASM_UNICODE 0x03
664#define ACPI_DASM_EISAID 0x04
665#define ACPI_DASM_MATCHOP 0x05
666#define ACPI_DASM_LNOT_PREFIX 0x06
667#define ACPI_DASM_LNOT_SUFFIX 0x07
668#define ACPI_DASM_IGNORE 0x08
669
670/*
671 * Generic operation (for example: If, While, Store)
672 */
673struct acpi_parse_obj_common {
674ACPI_PARSE_COMMON};
675
676/*
677 * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
678 * and bytelists.
679 */
680struct acpi_parse_obj_named {
681 ACPI_PARSE_COMMON u8 *path;
682 u8 *data; /* AML body or bytelist data */
683 u32 length; /* AML length */
684 u32 name; /* 4-byte name or zero if no name */
685};
686
687/* This version is used by the i_aSL compiler only */
688
689#define ACPI_MAX_PARSEOP_NAME 20
690
691struct acpi_parse_obj_asl {
692 ACPI_PARSE_COMMON union acpi_parse_object *child;
693 union acpi_parse_object *parent_method;
694 char *filename;
695 char *external_name;
696 char *namepath;
697 char name_seg[4];
698 u32 extra_value;
699 u32 column;
700 u32 line_number;
701 u32 logical_line_number;
702 u32 logical_byte_offset;
703 u32 end_line;
704 u32 end_logical_line;
705 u32 acpi_btype;
706 u32 aml_length;
707 u32 aml_subtree_length;
708 u32 final_aml_length;
709 u32 final_aml_offset;
710 u32 compile_flags;
711 u16 parse_opcode;
712 u8 aml_opcode_length;
713 u8 aml_pkg_len_bytes;
714 u8 extra;
715 char parse_op_name[ACPI_MAX_PARSEOP_NAME];
716};
717
718union acpi_parse_object {
719 struct acpi_parse_obj_common common;
720 struct acpi_parse_obj_named named;
721 struct acpi_parse_obj_asl asl;
722};
723
724/*
725 * Parse state - one state per parser invocation and each control
726 * method.
727 */
728struct acpi_parse_state {
729 u8 *aml_start; /* First AML byte */
730 u8 *aml; /* Next AML byte */
731 u8 *aml_end; /* (last + 1) AML byte */
732 u8 *pkg_start; /* Current package begin */
733 u8 *pkg_end; /* Current package end */
734 union acpi_parse_object *start_op; /* Root of parse tree */
735 struct acpi_namespace_node *start_node;
736 union acpi_generic_state *scope; /* Current scope */
737 union acpi_parse_object *start_scope;
738 u32 aml_size;
739};
740
741/* Parse object flags */
742
743#define ACPI_PARSEOP_GENERIC 0x01
744#define ACPI_PARSEOP_NAMED 0x02
745#define ACPI_PARSEOP_DEFERRED 0x04
746#define ACPI_PARSEOP_BYTELIST 0x08
747#define ACPI_PARSEOP_IN_STACK 0x10
748#define ACPI_PARSEOP_TARGET 0x20
749#define ACPI_PARSEOP_IN_CACHE 0x80
750
751/* Parse object disasm_flags */
752
753#define ACPI_PARSEOP_IGNORE 0x01
754#define ACPI_PARSEOP_PARAMLIST 0x02
755#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
756#define ACPI_PARSEOP_SPECIAL 0x10
757
758/*****************************************************************************
759 *
760 * Hardware (ACPI registers) and PNP
761 *
762 ****************************************************************************/
763
764struct acpi_bit_register_info {
765 u8 parent_register;
766 u8 bit_position;
767 u16 access_bit_mask;
768};
769
770/*
771 * Some ACPI registers have bits that must be ignored -- meaning that they
772 * must be preserved.
773 */
774#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
775#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0200 /* Bit 9 (whatever) */
776
777/*
778 * Register IDs
779 * These are the full ACPI registers
780 */
781#define ACPI_REGISTER_PM1_STATUS 0x01
782#define ACPI_REGISTER_PM1_ENABLE 0x02
783#define ACPI_REGISTER_PM1_CONTROL 0x03
784#define ACPI_REGISTER_PM1A_CONTROL 0x04
785#define ACPI_REGISTER_PM1B_CONTROL 0x05
786#define ACPI_REGISTER_PM2_CONTROL 0x06
787#define ACPI_REGISTER_PM_TIMER 0x07
788#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
789#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
790
791/* Masks used to access the bit_registers */
792
793#define ACPI_BITMASK_TIMER_STATUS 0x0001
794#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
795#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
796#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
797#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
798#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
799#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
800#define ACPI_BITMASK_WAKE_STATUS 0x8000
801
802#define ACPI_BITMASK_ALL_FIXED_STATUS (\
803 ACPI_BITMASK_TIMER_STATUS | \
804 ACPI_BITMASK_BUS_MASTER_STATUS | \
805 ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
806 ACPI_BITMASK_POWER_BUTTON_STATUS | \
807 ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
808 ACPI_BITMASK_RT_CLOCK_STATUS | \
809 ACPI_BITMASK_WAKE_STATUS)
810
811#define ACPI_BITMASK_TIMER_ENABLE 0x0001
812#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
813#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
814#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
815#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
816#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
817
818#define ACPI_BITMASK_SCI_ENABLE 0x0001
819#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
820#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
821#define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00
822#define ACPI_BITMASK_SLEEP_ENABLE 0x2000
823
824#define ACPI_BITMASK_ARB_DISABLE 0x0001
825
826/* Raw bit position of each bit_register */
827
828#define ACPI_BITPOSITION_TIMER_STATUS 0x00
829#define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04
830#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05
831#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
832#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
833#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
834#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
835#define ACPI_BITPOSITION_WAKE_STATUS 0x0F
836
837#define ACPI_BITPOSITION_TIMER_ENABLE 0x00
838#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05
839#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
840#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
841#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
842#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
843
844#define ACPI_BITPOSITION_SCI_ENABLE 0x00
845#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
846#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
847#define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A
848#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
849
850#define ACPI_BITPOSITION_ARB_DISABLE 0x00
851
852/*****************************************************************************
853 *
854 * Resource descriptors
855 *
856 ****************************************************************************/
857
858/* resource_type values */
859
860#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0
861#define ACPI_ADDRESS_TYPE_IO_RANGE 1
862#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2
863
864/* Resource descriptor types and masks */
865
866#define ACPI_RESOURCE_NAME_LARGE 0x80
867#define ACPI_RESOURCE_NAME_SMALL 0x00
868
869#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */
870#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */
871#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */
872
873/*
874 * Small resource descriptor "names" as defined by the ACPI specification.
875 * Note: Bits 2:0 are used for the descriptor length
876 */
877#define ACPI_RESOURCE_NAME_IRQ 0x20
878#define ACPI_RESOURCE_NAME_DMA 0x28
879#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30
880#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
881#define ACPI_RESOURCE_NAME_IO 0x40
882#define ACPI_RESOURCE_NAME_FIXED_IO 0x48
883#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
884#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
885#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
886#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
887#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70
888#define ACPI_RESOURCE_NAME_END_TAG 0x78
889
890/*
891 * Large resource descriptor "names" as defined by the ACPI specification.
892 * Note: includes the Large Descriptor bit in bit[7]
893 */
894#define ACPI_RESOURCE_NAME_MEMORY24 0x81
895#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82
896#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83
897#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84
898#define ACPI_RESOURCE_NAME_MEMORY32 0x85
899#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86
900#define ACPI_RESOURCE_NAME_ADDRESS32 0x87
901#define ACPI_RESOURCE_NAME_ADDRESS16 0x88
902#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
903#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
904#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
905#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
906
907/*****************************************************************************
908 *
909 * Miscellaneous
910 *
911 ****************************************************************************/
912
913#define ACPI_ASCII_ZERO 0x30
914
915/*****************************************************************************
916 *
917 * Debugger
918 *
919 ****************************************************************************/
920
921struct acpi_db_method_info {
922 acpi_handle main_thread_gate;
923 acpi_handle thread_complete_gate;
924 u32 *threads;
925 u32 num_threads;
926 u32 num_created;
927 u32 num_completed;
928
929 char *name;
930 u32 flags;
931 u32 num_loops;
932 char pathname[128];
933 char **args;
934
935 /*
936 * Arguments to be passed to method for the command
937 * Threads -
938 * the Number of threads, ID of current thread and
939 * Index of current thread inside all them created.
940 */
941 char init_args;
942 char *arguments[4];
943 char num_threads_str[11];
944 char id_of_thread_str[11];
945 char index_of_thread_str[11];
946};
947
948struct acpi_integrity_info {
949 u32 nodes;
950 u32 objects;
951};
952
953#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
954#define ACPI_DB_CONSOLE_OUTPUT 0x02
955#define ACPI_DB_DUPLICATE_OUTPUT 0x03
956
957/*****************************************************************************
958 *
959 * Debug
960 *
961 ****************************************************************************/
962
963/* Entry for a memory allocation (debug only) */
964
965#define ACPI_MEM_MALLOC 0
966#define ACPI_MEM_CALLOC 1
967#define ACPI_MAX_MODULE_NAME 16
968
969#define ACPI_COMMON_DEBUG_MEM_HEADER \
970 struct acpi_debug_mem_block *previous; \
971 struct acpi_debug_mem_block *next; \
972 u32 size; \
973 u32 component; \
974 u32 line; \
975 char module[ACPI_MAX_MODULE_NAME]; \
976 u8 alloc_type;
977
978struct acpi_debug_mem_header {
979ACPI_COMMON_DEBUG_MEM_HEADER};
980
981struct acpi_debug_mem_block {
982 ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
983};
984
985#define ACPI_MEM_LIST_GLOBAL 0
986#define ACPI_MEM_LIST_NSNODE 1
987#define ACPI_MEM_LIST_MAX 1
988#define ACPI_NUM_MEM_LISTS 2
989
990#endif /* __ACLOCAL_H__ */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
new file mode 100644
index 000000000000..9c127e8e2d6d
--- /dev/null
+++ b/drivers/acpi/acpica/acmacros.h
@@ -0,0 +1,577 @@
1/******************************************************************************
2 *
3 * Name: acmacros.h - C macros for the entire subsystem.
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACMACROS_H__
45#define __ACMACROS_H__
46
47/*
48 * Extract data using a pointer. Any more than a byte and we
49 * get into potential aligment issues -- see the STORE macros below.
50 * Use with care.
51 */
52#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr)
53#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr)
54#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr)
55#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr)
56#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr)
57#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr)
58#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr)
59#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr)
60
61/*
62 * printf() format helpers
63 */
64
65/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
66
67#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
68
69#if ACPI_MACHINE_WIDTH == 64
70#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
71#else
72#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i)
73#endif
74
75/*
76 * Macros for moving data around to/from buffers that are possibly unaligned.
77 * If the hardware supports the transfer of unaligned data, just do the store.
78 * Otherwise, we have to move one byte at a time.
79 */
80#ifdef ACPI_BIG_ENDIAN
81/*
82 * Macros for big-endian machines
83 */
84
85/* These macros reverse the bytes during the move, converting little-endian to big endian */
86
87 /* Big Endian <== Little Endian */
88 /* Hi...Lo Lo...Hi */
89/* 16-bit source, 16/32/64 destination */
90
91#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
92 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
93
94#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\
95 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
96 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
97
98#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
99 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
100 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
101
102/* 32-bit source, 16/32/64 destination */
103
104#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
105
106#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
107 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
108 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
109 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
110
111#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
112 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
113 ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
114 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
115 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
116
117/* 64-bit source, 16/32/64 destination */
118
119#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
120
121#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
122
123#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
124 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
125 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\
126 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\
127 (( u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
128 (( u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
129 (( u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
130 (( u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
131#else
132/*
133 * Macros for little-endian machines
134 */
135
136#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
137
138/* The hardware supports unaligned transfers, just do the little-endian move */
139
140/* 16-bit source, 16/32/64 destination */
141
142#define ACPI_MOVE_16_TO_16(d, s) *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
143#define ACPI_MOVE_16_TO_32(d, s) *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
144#define ACPI_MOVE_16_TO_64(d, s) *(u64 *)(void *)(d) = *(u16 *)(void *)(s)
145
146/* 32-bit source, 16/32/64 destination */
147
148#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
149#define ACPI_MOVE_32_TO_32(d, s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
150#define ACPI_MOVE_32_TO_64(d, s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
151
152/* 64-bit source, 16/32/64 destination */
153
154#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
155#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
156#define ACPI_MOVE_64_TO_64(d, s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
157
158#else
159/*
160 * The hardware does not support unaligned transfers. We must move the
161 * data one byte at a time. These macros work whether the source or
162 * the destination (or both) is/are unaligned. (Little-endian move)
163 */
164
165/* 16-bit source, 16/32/64 destination */
166
167#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
168 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
169
170#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
171#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
172
173/* 32-bit source, 16/32/64 destination */
174
175#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
176
177#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
178 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
179 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
180 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
181
182#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);}
183
184/* 64-bit source, 16/32/64 destination */
185
186#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
187#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
188#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
189 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
190 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
191 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
192 (( u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4];\
193 (( u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5];\
194 (( u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6];\
195 (( u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7];}
196#endif
197#endif
198
199/* Macros based on machine integer width */
200
201#if ACPI_MACHINE_WIDTH == 32
202#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_32_TO_16(d, s)
203
204#elif ACPI_MACHINE_WIDTH == 64
205#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_64_TO_16(d, s)
206
207#else
208#error unknown ACPI_MACHINE_WIDTH
209#endif
210
211/*
212 * Fast power-of-two math macros for non-optimized compilers
213 */
214#define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2)))
215#define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2)))
216#define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1)))
217
218#define ACPI_DIV_2(a) _ACPI_DIV(a, 1)
219#define ACPI_MUL_2(a) _ACPI_MUL(a, 1)
220#define ACPI_MOD_2(a) _ACPI_MOD(a, 2)
221
222#define ACPI_DIV_4(a) _ACPI_DIV(a, 2)
223#define ACPI_MUL_4(a) _ACPI_MUL(a, 2)
224#define ACPI_MOD_4(a) _ACPI_MOD(a, 4)
225
226#define ACPI_DIV_8(a) _ACPI_DIV(a, 3)
227#define ACPI_MUL_8(a) _ACPI_MUL(a, 3)
228#define ACPI_MOD_8(a) _ACPI_MOD(a, 8)
229
230#define ACPI_DIV_16(a) _ACPI_DIV(a, 4)
231#define ACPI_MUL_16(a) _ACPI_MUL(a, 4)
232#define ACPI_MOD_16(a) _ACPI_MOD(a, 16)
233
234#define ACPI_DIV_32(a) _ACPI_DIV(a, 5)
235#define ACPI_MUL_32(a) _ACPI_MUL(a, 5)
236#define ACPI_MOD_32(a) _ACPI_MOD(a, 32)
237
238/*
239 * Rounding macros (Power of two boundaries only)
240 */
241#define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \
242 (~(((acpi_size) boundary)-1)))
243
244#define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \
245 (((acpi_size) boundary)-1)) & \
246 (~(((acpi_size) boundary)-1)))
247
248/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */
249
250#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4)
251#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8)
252#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(acpi_size))
253
254#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4)
255#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8)
256#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(acpi_size))
257
258#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
259#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
260
261#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10)
262
263/* Generic (non-power-of-two) rounding */
264
265#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary))
266
267#define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1))
268
269/*
270 * Bitmask creation
271 * Bit positions start at zero.
272 * MASK_BITS_ABOVE creates a mask starting AT the position and above
273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
274 */
275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position))))
276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position)))
277
278/* Bitfields within ACPI registers */
279
280#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
281#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
282
283#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
284
285/*
286 * A struct acpi_namespace_node can appear in some contexts
287 * where a pointer to a union acpi_operand_object can also
288 * appear. This macro is used to distinguish them.
289 *
290 * The "Descriptor" field is the first field in both structures.
291 */
292#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
293#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
294
295/* Macro to test the object type */
296
297#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type)
298
299/*
300 * Macros for the master AML opcode table
301 */
302#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
303#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
304 {name, (u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
305#else
306#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
307 {(u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
308#endif
309
310#define ARG_TYPE_WIDTH 5
311#define ARG_1(x) ((u32)(x))
312#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH))
313#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH))
314#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH))
315#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH))
316#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH))
317
318#define ARGI_LIST1(a) (ARG_1(a))
319#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a))
320#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a))
321#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
322#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
323#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
324
325#define ARGP_LIST1(a) (ARG_1(a))
326#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b))
327#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c))
328#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
329#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
330#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
331
332#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
333#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
334
335/*
336 * Ascii error messages can be configured out
337 */
338#ifndef ACPI_NO_ERROR_MESSAGES
339
340/*
341 * Error reporting. Callers module and line number are inserted by AE_INFO,
342 * the plist contains a set of parens to allow variable-length lists.
343 * These macros are used for both the debug and non-debug versions of the code.
344 */
345#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
346#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
347
348#else
349
350/* No error messages */
351
352#define ACPI_ERROR_NAMESPACE(s, e)
353#define ACPI_ERROR_METHOD(s, n, p, e)
354#endif /* ACPI_NO_ERROR_MESSAGES */
355
356/*
357 * Debug macros that are conditionally compiled
358 */
359#ifdef ACPI_DEBUG_OUTPUT
360
361/*
362 * Function entry tracing
363 */
364#ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE
365
366#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
367 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
368#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \
369 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS, (void *)b)
370#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \
371 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b)
372#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \
373 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b)
374
375#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
376
377/*
378 * Function exit tracing.
379 * WARNING: These macros include a return statement. This is usually considered
380 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
381 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
382 * so that "_AcpiFunctionName" is defined.
383 *
384 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
385 * about these constructs.
386 */
387#ifdef ACPI_USE_DO_WHILE_0
388#define ACPI_DO_WHILE0(a) do a while(0)
389#else
390#define ACPI_DO_WHILE0(a) a
391#endif
392
393#define return_VOID ACPI_DO_WHILE0 ({ \
394 acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
395 return;})
396/*
397 * There are two versions of most of the return macros. The default version is
398 * safer, since it avoids side-effects by guaranteeing that the argument will
399 * not be evaluated twice.
400 *
401 * A less-safe version of the macros is provided for optional use if the
402 * compiler uses excessive CPU stack (for example, this may happen in the
403 * debug case if code optimzation is disabled.)
404 */
405#ifndef ACPI_SIMPLE_RETURN_MACROS
406
407#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
408 register acpi_status _s = (s); \
409 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \
410 return (_s); })
411#define return_PTR(s) ACPI_DO_WHILE0 ({ \
412 register void *_s = (void *) (s); \
413 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
414 return (_s); })
415#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
416 register acpi_integer _s = (s); \
417 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
418 return (_s); })
419#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
420 register u8 _s = (u8) (s); \
421 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
422 return (_s); })
423#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
424 register u32 _s = (u32) (s); \
425 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
426 return (_s); })
427#else /* Use original less-safe macros */
428
429#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
430 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \
431 return((s)); })
432#define return_PTR(s) ACPI_DO_WHILE0 ({ \
433 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
434 return((s)); })
435#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
436 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \
437 return((s)); })
438#define return_UINT8(s) return_VALUE(s)
439#define return_UINT32(s) return_VALUE(s)
440
441#endif /* ACPI_SIMPLE_RETURN_MACROS */
442
443#else /* !CONFIG_ACPI_DEBUG_FUNC_TRACE */
444
445#define ACPI_FUNCTION_TRACE(a)
446#define ACPI_FUNCTION_TRACE_PTR(a,b)
447#define ACPI_FUNCTION_TRACE_U32(a,b)
448#define ACPI_FUNCTION_TRACE_STR(a,b)
449#define ACPI_FUNCTION_EXIT
450#define ACPI_FUNCTION_STATUS_EXIT(s)
451#define ACPI_FUNCTION_VALUE_EXIT(s)
452#define ACPI_FUNCTION_TRACE(a)
453#define ACPI_FUNCTION_ENTRY()
454
455#define return_VOID return
456#define return_ACPI_STATUS(s) return(s)
457#define return_VALUE(s) return(s)
458#define return_UINT8(s) return(s)
459#define return_UINT32(s) return(s)
460#define return_PTR(s) return(s)
461
462#endif /* CONFIG_ACPI_DEBUG_FUNC_TRACE */
463
464/* Conditional execution */
465
466#define ACPI_DEBUG_EXEC(a) a
467#define ACPI_NORMAL_EXEC(a)
468
469#define ACPI_DEBUG_DEFINE(a) a;
470#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
471#define _VERBOSE_STRUCTURES
472
473/* Stack and buffer dumping */
474
475#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
476#define ACPI_DUMP_OPERANDS(a, b, c) acpi_ex_dump_operands(a, b, c)
477
478#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
479#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
480#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
481#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
482
483#else
484/*
485 * This is the non-debug case -- make everything go away,
486 * leaving no executable debug code!
487 */
488#define ACPI_DEBUG_EXEC(a)
489#define ACPI_NORMAL_EXEC(a) a;
490
491#define ACPI_DEBUG_DEFINE(a) do { } while(0)
492#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
493#define ACPI_FUNCTION_TRACE(a) do { } while(0)
494#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0)
495#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0)
496#define ACPI_FUNCTION_TRACE_STR(a, b) do { } while(0)
497#define ACPI_FUNCTION_EXIT do { } while(0)
498#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0)
499#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0)
500#define ACPI_FUNCTION_ENTRY() do { } while(0)
501#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0)
502#define ACPI_DUMP_OPERANDS(a, b, c) do { } while(0)
503#define ACPI_DUMP_ENTRY(a, b) do { } while(0)
504#define ACPI_DUMP_TABLES(a, b) do { } while(0)
505#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0)
506#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
507#define ACPI_DUMP_BUFFER(a, b) do { } while(0)
508
509#define return_VOID return
510#define return_ACPI_STATUS(s) return(s)
511#define return_VALUE(s) return(s)
512#define return_UINT8(s) return(s)
513#define return_UINT32(s) return(s)
514#define return_PTR(s) return(s)
515
516#endif /* ACPI_DEBUG_OUTPUT */
517
518/*
519 * Some code only gets executed when the debugger is built in.
520 * Note that this is entirely independent of whether the
521 * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
522 */
523#ifdef ACPI_DEBUGGER
524#define ACPI_DEBUGGER_EXEC(a) a
525#else
526#define ACPI_DEBUGGER_EXEC(a)
527#endif
528
529#ifdef ACPI_DEBUG_OUTPUT
530/*
531 * 1) Set name to blanks
532 * 2) Copy the object name
533 */
534#define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\
535 ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
536#else
537
538#define ACPI_ADD_OBJECT_NAME(a,b)
539#endif
540
541/*
542 * Memory allocation tracking (DEBUG ONLY)
543 */
544#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__
545
546#ifndef ACPI_DBG_TRACK_ALLOCATIONS
547
548/* Memory allocation */
549
550#ifndef ACPI_ALLOCATE
551#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a), ACPI_MEM_PARAMETERS)
552#endif
553#ifndef ACPI_ALLOCATE_ZEROED
554#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), ACPI_MEM_PARAMETERS)
555#endif
556#ifndef ACPI_FREE
557#define ACPI_FREE(a) acpio_os_free(a)
558#endif
559#define ACPI_MEM_TRACKING(a)
560
561#else
562
563/* Memory allocation */
564
565#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
566#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
567#define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS)
568#define ACPI_MEM_TRACKING(a) a
569
570#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
571
572/* Preemption point */
573#ifndef ACPI_PREEMPTION_POINT
574#define ACPI_PREEMPTION_POINT() /* no preemption */
575#endif
576
577#endif /* ACMACROS_H */
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
new file mode 100644
index 000000000000..46cb5b46d280
--- /dev/null
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -0,0 +1,324 @@
1/******************************************************************************
2 *
3 * Name: acnamesp.h - Namespace subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACNAMESP_H__
45#define __ACNAMESP_H__
46
47/* To search the entire name space, pass this as search_base */
48
49#define ACPI_NS_ALL ((acpi_handle)0)
50
51/*
52 * Elements of acpi_ns_properties are bit significant
53 * and should be one-to-one with values of acpi_object_type
54 */
55#define ACPI_NS_NORMAL 0
56#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */
57#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */
58
59/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
60
61#define ACPI_NS_NO_UPSEARCH 0
62#define ACPI_NS_SEARCH_PARENT 0x01
63#define ACPI_NS_DONT_OPEN_SCOPE 0x02
64#define ACPI_NS_NO_PEER_SEARCH 0x04
65#define ACPI_NS_ERROR_IF_FOUND 0x08
66#define ACPI_NS_PREFIX_IS_SCOPE 0x10
67#define ACPI_NS_EXTERNAL 0x20
68#define ACPI_NS_TEMPORARY 0x40
69
70/* Flags for acpi_ns_walk_namespace */
71
72#define ACPI_NS_WALK_NO_UNLOCK 0
73#define ACPI_NS_WALK_UNLOCK 0x01
74#define ACPI_NS_WALK_TEMP_NODES 0x02
75
76/*
77 * nsinit - Namespace initialization
78 */
79acpi_status acpi_ns_initialize_objects(void);
80
81acpi_status acpi_ns_initialize_devices(void);
82
83/*
84 * nsload - Namespace loading
85 */
86acpi_status acpi_ns_load_namespace(void);
87
88acpi_status
89acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node);
90
91/*
92 * nswalk - walk the namespace
93 */
94acpi_status
95acpi_ns_walk_namespace(acpi_object_type type,
96 acpi_handle start_object,
97 u32 max_depth,
98 u32 flags,
99 acpi_walk_callback user_function,
100 void *context, void **return_value);
101
102struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node
103 *parent, struct acpi_namespace_node
104 *child);
105
106/*
107 * nsparse - table parsing
108 */
109acpi_status
110acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node);
111
112acpi_status
113acpi_ns_one_complete_parse(u32 pass_number,
114 u32 table_index,
115 struct acpi_namespace_node *start_node);
116
117/*
118 * nsaccess - Top-level namespace access
119 */
120acpi_status acpi_ns_root_initialize(void);
121
122acpi_status
123acpi_ns_lookup(union acpi_generic_state *scope_info,
124 char *name,
125 acpi_object_type type,
126 acpi_interpreter_mode interpreter_mode,
127 u32 flags,
128 struct acpi_walk_state *walk_state,
129 struct acpi_namespace_node **ret_node);
130
131/*
132 * nsalloc - Named object allocation/deallocation
133 */
134struct acpi_namespace_node *acpi_ns_create_node(u32 name);
135
136void acpi_ns_delete_node(struct acpi_namespace_node *node);
137
138void
139acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
140
141void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id);
142
143void acpi_ns_detach_object(struct acpi_namespace_node *node);
144
145void acpi_ns_delete_children(struct acpi_namespace_node *parent);
146
147int acpi_ns_compare_names(char *name1, char *name2);
148
149/*
150 * nsdump - Namespace dump/print utilities
151 */
152#ifdef ACPI_FUTURE_USAGE
153void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth);
154#endif /* ACPI_FUTURE_USAGE */
155
156void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level);
157
158void
159acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component);
160
161void acpi_ns_print_pathname(u32 num_segments, char *pathname);
162
163acpi_status
164acpi_ns_dump_one_object(acpi_handle obj_handle,
165 u32 level, void *context, void **return_value);
166
167#ifdef ACPI_FUTURE_USAGE
168void
169acpi_ns_dump_objects(acpi_object_type type,
170 u8 display_type,
171 u32 max_depth,
172 acpi_owner_id owner_id, acpi_handle start_handle);
173#endif /* ACPI_FUTURE_USAGE */
174
175/*
176 * nseval - Namespace evaluation functions
177 */
178acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
179
180/*
181 * nspredef - Support for predefined/reserved names
182 */
183acpi_status
184acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
185 u32 user_param_count,
186 acpi_status return_status,
187 union acpi_operand_object **return_object);
188
189const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
190 acpi_namespace_node
191 *node);
192
193void
194acpi_ns_check_parameter_count(char *pathname,
195 struct acpi_namespace_node *node,
196 u32 user_param_count,
197 const union acpi_predefined_info *info);
198
199/*
200 * nsnames - Name and Scope manipulation
201 */
202u32 acpi_ns_opens_scope(acpi_object_type type);
203
204acpi_status
205acpi_ns_build_external_path(struct acpi_namespace_node *node,
206 acpi_size size, char *name_buffer);
207
208char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node);
209
210char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
211
212acpi_status
213acpi_ns_handle_to_pathname(acpi_handle target_handle,
214 struct acpi_buffer *buffer);
215
216u8
217acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);
218
219acpi_status
220acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
221 const char *external_pathname,
222 u32 flags, struct acpi_namespace_node **out_node);
223
224acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node);
225
226/*
227 * nsobject - Object management for namespace nodes
228 */
229acpi_status
230acpi_ns_attach_object(struct acpi_namespace_node *node,
231 union acpi_operand_object *object, acpi_object_type type);
232
233union acpi_operand_object *acpi_ns_get_attached_object(struct
234 acpi_namespace_node
235 *node);
236
237union acpi_operand_object *acpi_ns_get_secondary_object(union
238 acpi_operand_object
239 *obj_desc);
240
241acpi_status
242acpi_ns_attach_data(struct acpi_namespace_node *node,
243 acpi_object_handler handler, void *data);
244
245acpi_status
246acpi_ns_detach_data(struct acpi_namespace_node *node,
247 acpi_object_handler handler);
248
249acpi_status
250acpi_ns_get_attached_data(struct acpi_namespace_node *node,
251 acpi_object_handler handler, void **data);
252
253/*
254 * nssearch - Namespace searching and entry
255 */
256acpi_status
257acpi_ns_search_and_enter(u32 entry_name,
258 struct acpi_walk_state *walk_state,
259 struct acpi_namespace_node *node,
260 acpi_interpreter_mode interpreter_mode,
261 acpi_object_type type,
262 u32 flags, struct acpi_namespace_node **ret_node);
263
264acpi_status
265acpi_ns_search_one_scope(u32 entry_name,
266 struct acpi_namespace_node *node,
267 acpi_object_type type,
268 struct acpi_namespace_node **ret_node);
269
270void
271acpi_ns_install_node(struct acpi_walk_state *walk_state,
272 struct acpi_namespace_node *parent_node,
273 struct acpi_namespace_node *node, acpi_object_type type);
274
275/*
276 * nsutils - Utility functions
277 */
278u8 acpi_ns_valid_root_prefix(char prefix);
279
280acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
281
282u32 acpi_ns_local(acpi_object_type type);
283
284void
285acpi_ns_report_error(const char *module_name,
286 u32 line_number,
287 const char *internal_name, acpi_status lookup_status);
288
289void
290acpi_ns_report_method_error(const char *module_name,
291 u32 line_number,
292 const char *message,
293 struct acpi_namespace_node *node,
294 const char *path, acpi_status lookup_status);
295
296void
297acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *msg);
298
299acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info);
300
301void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info);
302
303acpi_status
304acpi_ns_internalize_name(const char *dotted_name, char **converted_name);
305
306acpi_status
307acpi_ns_externalize_name(u32 internal_name_length,
308 const char *internal_name,
309 u32 * converted_name_length, char **converted_name);
310
311struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle);
312
313acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
314
315void acpi_ns_terminate(void);
316
317struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
318 *node);
319
320struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
321 acpi_namespace_node
322 *node);
323
324#endif /* __ACNAMESP_H__ */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
new file mode 100644
index 000000000000..eb6f038b03d9
--- /dev/null
+++ b/drivers/acpi/acpica/acobject.h
@@ -0,0 +1,446 @@
1
2/******************************************************************************
3 *
4 * Name: acobject.h - Definition of union acpi_operand_object (Internal object only)
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#ifndef _ACOBJECT_H
46#define _ACOBJECT_H
47
48/* acpisrc:struct_defs -- for acpisrc conversion */
49
50/*
51 * The union acpi_operand_object is used to pass AML operands from the dispatcher
52 * to the interpreter, and to keep track of the various handlers such as
53 * address space handlers and notify handlers. The object is a constant
54 * size in order to allow it to be cached and reused.
55 *
56 * Note: The object is optimized to be aligned and will not work if it is
57 * byte-packed.
58 */
59#if ACPI_MACHINE_WIDTH == 64
60#pragma pack(8)
61#else
62#pragma pack(4)
63#endif
64
65/*******************************************************************************
66 *
67 * Common Descriptors
68 *
69 ******************************************************************************/
70
71/*
72 * Common area for all objects.
73 *
74 * descriptor_type is used to differentiate between internal descriptors, and
75 * must be in the same place across all descriptors
76 *
77 * Note: The descriptor_type and Type fields must appear in the identical
78 * position in both the struct acpi_namespace_node and union acpi_operand_object
79 * structures.
80 */
81#define ACPI_OBJECT_COMMON_HEADER \
82 union acpi_operand_object *next_object; /* Objects linked to parent NS node */\
83 u8 descriptor_type; /* To differentiate various internal objs */\
84 u8 type; /* acpi_object_type */\
85 u16 reference_count; /* For object deletion management */\
86 u8 flags;
87 /*
88 * Note: There are 3 bytes available here before the
89 * next natural alignment boundary (for both 32/64 cases)
90 */
91
92/* Values for Flag byte above */
93
94#define AOPOBJ_AML_CONSTANT 0x01
95#define AOPOBJ_STATIC_POINTER 0x02
96#define AOPOBJ_DATA_VALID 0x04
97#define AOPOBJ_OBJECT_INITIALIZED 0x08
98#define AOPOBJ_SETUP_COMPLETE 0x10
99#define AOPOBJ_SINGLE_DATUM 0x20
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */
101
102/******************************************************************************
103 *
104 * Basic data types
105 *
106 *****************************************************************************/
107
108struct acpi_object_common {
109ACPI_OBJECT_COMMON_HEADER};
110
111struct acpi_object_integer {
112 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */
113 acpi_integer value;
114};
115
116/*
117 * Note: The String and Buffer object must be identical through the Pointer
118 * and length elements. There is code that depends on this.
119 *
120 * Fields common to both Strings and Buffers
121 */
122#define ACPI_COMMON_BUFFER_INFO(_type) \
123 _type *pointer; \
124 u32 length;
125
126struct acpi_object_string { /* Null terminated, ASCII characters only */
127 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(char) /* String in AML stream or allocated string */
128};
129
130struct acpi_object_buffer {
131 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(u8) /* Buffer in AML stream or allocated buffer */
132 u32 aml_length;
133 u8 *aml_start;
134 struct acpi_namespace_node *node; /* Link back to parent node */
135};
136
137struct acpi_object_package {
138 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Link back to parent node */
139 union acpi_operand_object **elements; /* Array of pointers to acpi_objects */
140 u8 *aml_start;
141 u32 aml_length;
142 u32 count; /* # of elements in package */
143};
144
145/******************************************************************************
146 *
147 * Complex data types
148 *
149 *****************************************************************************/
150
151struct acpi_object_event {
152 ACPI_OBJECT_COMMON_HEADER acpi_semaphore os_semaphore; /* Actual OS synchronization object */
153};
154
155struct acpi_object_mutex {
156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
158 acpi_mutex os_mutex; /* Actual OS synchronization object */
159 acpi_thread_id thread_id; /* Current owner of the mutex */
160 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
161 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
162 union acpi_operand_object *next; /* Link for list of acquired mutexes */
163 struct acpi_namespace_node *node; /* Containing namespace node */
164 u8 original_sync_level; /* Owner's original sync level (0-15) */
165};
166
167struct acpi_object_region {
168 ACPI_OBJECT_COMMON_HEADER u8 space_id;
169 struct acpi_namespace_node *node; /* Containing namespace node */
170 union acpi_operand_object *handler; /* Handler for region access */
171 union acpi_operand_object *next;
172 acpi_physical_address address;
173 u32 length;
174};
175
176struct acpi_object_method {
177 ACPI_OBJECT_COMMON_HEADER u8 method_flags;
178 u8 param_count;
179 u8 sync_level;
180 union acpi_operand_object *mutex;
181 u8 *aml_start;
182 ACPI_INTERNAL_METHOD implementation;
183 u32 aml_length;
184 u8 thread_count;
185 acpi_owner_id owner_id;
186};
187
188/******************************************************************************
189 *
190 * Objects that can be notified. All share a common notify_info area.
191 *
192 *****************************************************************************/
193
194/*
195 * Common fields for objects that support ASL notifications
196 */
197#define ACPI_COMMON_NOTIFY_INFO \
198 union acpi_operand_object *system_notify; /* Handler for system notifies */\
199 union acpi_operand_object *device_notify; /* Handler for driver notifies */\
200 union acpi_operand_object *handler; /* Handler for Address space */
201
202struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
203ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
204
205struct acpi_object_device {
206 ACPI_OBJECT_COMMON_HEADER
207 ACPI_COMMON_NOTIFY_INFO struct acpi_gpe_block_info *gpe_block;
208};
209
210struct acpi_object_power_resource {
211 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 system_level;
212 u32 resource_order;
213};
214
215struct acpi_object_processor {
216 ACPI_OBJECT_COMMON_HEADER
217 /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */
218 u8 proc_id;
219 u8 length;
220 ACPI_COMMON_NOTIFY_INFO acpi_io_address address;
221};
222
223struct acpi_object_thermal_zone {
224ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
225
226/******************************************************************************
227 *
228 * Fields. All share a common header/info field.
229 *
230 *****************************************************************************/
231
232/*
233 * Common bitfield for the field objects
234 * "Field Datum" -- a datum from the actual field object
235 * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field
236 */
237#define ACPI_COMMON_FIELD_INFO \
238 u8 field_flags; /* Access, update, and lock bits */\
239 u8 attribute; /* From access_as keyword */\
240 u8 access_byte_width; /* Read/Write size in bytes */\
241 struct acpi_namespace_node *node; /* Link back to parent node */\
242 u32 bit_length; /* Length of field in bits */\
243 u32 base_byte_offset; /* Byte offset within containing object */\
244 u32 value; /* Value to store into the Bank or Index register */\
245 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
246 u8 access_bit_width; /* Read/Write size in bits (8-64) */
247
248struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
249 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Parent Operation Region object (REGION/BANK fields only) */
250};
251
252struct acpi_object_region_field {
253 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
254};
255
256struct acpi_object_bank_field {
257 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
258 union acpi_operand_object *bank_obj; /* bank_select Register object */
259};
260
261struct acpi_object_index_field {
262 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO
263 /*
264 * No "RegionObj" pointer needed since the Index and Data registers
265 * are each field definitions unto themselves.
266 */
267 union acpi_operand_object *index_obj; /* Index register */
268 union acpi_operand_object *data_obj; /* Data register */
269};
270
271/* The buffer_field is different in that it is part of a Buffer, not an op_region */
272
273struct acpi_object_buffer_field {
274 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *buffer_obj; /* Containing Buffer object */
275};
276
277/******************************************************************************
278 *
279 * Objects for handlers
280 *
281 *****************************************************************************/
282
283struct acpi_object_notify_handler {
284 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */
285 acpi_notify_handler handler;
286 void *context;
287};
288
289struct acpi_object_addr_handler {
290 ACPI_OBJECT_COMMON_HEADER u8 space_id;
291 u8 handler_flags;
292 acpi_adr_space_handler handler;
293 struct acpi_namespace_node *node; /* Parent device */
294 void *context;
295 acpi_adr_space_setup setup;
296 union acpi_operand_object *region_list; /* regions using this handler */
297 union acpi_operand_object *next;
298};
299
300/* Flags for address handler (handler_flags) */
301
302#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01
303
304/******************************************************************************
305 *
306 * Special internal objects
307 *
308 *****************************************************************************/
309
310/*
311 * The Reference object is used for these opcodes:
312 * Arg[0-6], Local[0-7], index_op, name_op, ref_of_op, load_op, load_table_op, debug_op
313 * The Reference.Class differentiates these types.
314 */
315struct acpi_object_reference {
316 ACPI_OBJECT_COMMON_HEADER u8 class; /* Reference Class */
317 u8 target_type; /* Used for Index Op */
318 u8 reserved;
319 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */
320 struct acpi_namespace_node *node; /* ref_of or Namepath */
321 union acpi_operand_object **where; /* Target of Index */
322 u32 value; /* Used for Local/Arg/Index/ddb_handle */
323};
324
325/* Values for Reference.Class above */
326
327typedef enum {
328 ACPI_REFCLASS_LOCAL = 0, /* Method local */
329 ACPI_REFCLASS_ARG = 1, /* Method argument */
330 ACPI_REFCLASS_REFOF = 2, /* Result of ref_of() TBD: Split to Ref/Node and Ref/operand_obj? */
331 ACPI_REFCLASS_INDEX = 3, /* Result of Index() */
332 ACPI_REFCLASS_TABLE = 4, /* ddb_handle - Load(), load_table() */
333 ACPI_REFCLASS_NAME = 5, /* Reference to a named object */
334 ACPI_REFCLASS_DEBUG = 6, /* Debug object */
335
336 ACPI_REFCLASS_MAX = 6
337} ACPI_REFERENCE_CLASSES;
338
339/*
340 * Extra object is used as additional storage for types that
341 * have AML code in their declarations (term_args) that must be
342 * evaluated at run time.
343 *
344 * Currently: Region and field_unit types
345 */
346struct acpi_object_extra {
347 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */
348 void *region_context; /* Region-specific data */
349 u8 *aml_start;
350 u32 aml_length;
351};
352
353/* Additional data that can be attached to namespace nodes */
354
355struct acpi_object_data {
356 ACPI_OBJECT_COMMON_HEADER acpi_object_handler handler;
357 void *pointer;
358};
359
360/* Structure used when objects are cached for reuse */
361
362struct acpi_object_cache_list {
363 ACPI_OBJECT_COMMON_HEADER union acpi_operand_object *next; /* Link for object cache and internal lists */
364};
365
366/******************************************************************************
367 *
368 * union acpi_operand_object Descriptor - a giant union of all of the above
369 *
370 *****************************************************************************/
371
372union acpi_operand_object {
373 struct acpi_object_common common;
374 struct acpi_object_integer integer;
375 struct acpi_object_string string;
376 struct acpi_object_buffer buffer;
377 struct acpi_object_package package;
378 struct acpi_object_event event;
379 struct acpi_object_method method;
380 struct acpi_object_mutex mutex;
381 struct acpi_object_region region;
382 struct acpi_object_notify_common common_notify;
383 struct acpi_object_device device;
384 struct acpi_object_power_resource power_resource;
385 struct acpi_object_processor processor;
386 struct acpi_object_thermal_zone thermal_zone;
387 struct acpi_object_field_common common_field;
388 struct acpi_object_region_field field;
389 struct acpi_object_buffer_field buffer_field;
390 struct acpi_object_bank_field bank_field;
391 struct acpi_object_index_field index_field;
392 struct acpi_object_notify_handler notify;
393 struct acpi_object_addr_handler address_space;
394 struct acpi_object_reference reference;
395 struct acpi_object_extra extra;
396 struct acpi_object_data data;
397 struct acpi_object_cache_list cache;
398
399 /*
400 * Add namespace node to union in order to simplify code that accepts both
401 * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share
402 * a common descriptor_type field in order to differentiate them.
403 */
404 struct acpi_namespace_node node;
405};
406
407/******************************************************************************
408 *
409 * union acpi_descriptor - objects that share a common descriptor identifier
410 *
411 *****************************************************************************/
412
413/* Object descriptor types */
414
415#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */
416#define ACPI_DESC_TYPE_STATE 0x02
417#define ACPI_DESC_TYPE_STATE_UPDATE 0x03
418#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04
419#define ACPI_DESC_TYPE_STATE_CONTROL 0x05
420#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06
421#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07
422#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08
423#define ACPI_DESC_TYPE_STATE_RESULT 0x09
424#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A
425#define ACPI_DESC_TYPE_STATE_THREAD 0x0B
426#define ACPI_DESC_TYPE_WALK 0x0C
427#define ACPI_DESC_TYPE_PARSER 0x0D
428#define ACPI_DESC_TYPE_OPERAND 0x0E
429#define ACPI_DESC_TYPE_NAMED 0x0F
430#define ACPI_DESC_TYPE_MAX 0x0F
431
432struct acpi_common_descriptor {
433 void *common_pointer;
434 u8 descriptor_type; /* To differentiate various internal objs */
435};
436
437union acpi_descriptor {
438 struct acpi_common_descriptor common;
439 union acpi_operand_object object;
440 struct acpi_namespace_node node;
441 union acpi_parse_object op;
442};
443
444#pragma pack()
445
446#endif /* _ACOBJECT_H */
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
new file mode 100644
index 000000000000..dfdf63327885
--- /dev/null
+++ b/drivers/acpi/acpica/acopcode.h
@@ -0,0 +1,323 @@
1/******************************************************************************
2 *
3 * Name: acopcode.h - AML opcode information for the AML parser and interpreter
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACOPCODE_H__
45#define __ACOPCODE_H__
46
47#define MAX_EXTENDED_OPCODE 0x88
48#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
49#define MAX_INTERNAL_OPCODE
50#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
51
52/* Used for non-assigned opcodes */
53
54#define _UNK 0x6B
55
56/*
57 * Reserved ASCII characters. Do not use any of these for
58 * internal opcodes, since they are used to differentiate
59 * name strings from AML opcodes
60 */
61#define _ASC 0x6C
62#define _NAM 0x6C
63#define _PFX 0x6D
64
65/*
66 * All AML opcodes and the parse-time arguments for each. Used by the AML
67 * parser Each list is compressed into a 32-bit number and stored in the
68 * master opcode table (in psopcode.c).
69 */
70#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
71#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
72#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
73#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
74#define ARGP_ARG0 ARG_NONE
75#define ARGP_ARG1 ARG_NONE
76#define ARGP_ARG2 ARG_NONE
77#define ARGP_ARG3 ARG_NONE
78#define ARGP_ARG4 ARG_NONE
79#define ARGP_ARG5 ARG_NONE
80#define ARGP_ARG6 ARG_NONE
81#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
82#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
83#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
84#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
85#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
86#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
87#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
88#define ARGP_BREAK_OP ARG_NONE
89#define ARGP_BREAK_POINT_OP ARG_NONE
90#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
91#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
92#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
93#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
94#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
95#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
96#define ARGP_CONTINUE_OP ARG_NONE
97#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME)
98#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
99#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
100#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
101#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
102#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
103#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
104#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
105#define ARGP_DEBUG_OP ARG_NONE
106#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
107#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
108#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
109#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
110#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
111#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
112#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
113#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
114#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
115#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
116#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
117#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
118#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
119#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
120#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
121#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
122#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
123#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
124#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
125#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
126#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
127#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
128#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
129#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
130#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
131#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
132#define ARGP_LOCAL0 ARG_NONE
133#define ARGP_LOCAL1 ARG_NONE
134#define ARGP_LOCAL2 ARG_NONE
135#define ARGP_LOCAL3 ARG_NONE
136#define ARGP_LOCAL4 ARG_NONE
137#define ARGP_LOCAL5 ARG_NONE
138#define ARGP_LOCAL6 ARG_NONE
139#define ARGP_LOCAL7 ARG_NONE
140#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
141#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
142#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
143#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
144#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
145#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
146#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
147#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
148#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
149#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
150#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
151#define ARGP_NOOP_OP ARG_NONE
152#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
153#define ARGP_ONE_OP ARG_NONE
154#define ARGP_ONES_OP ARG_NONE
155#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
156#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
157#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
158#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
159#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
160#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
161#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
162#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
163#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
164#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
165#define ARGP_REVISION_OP ARG_NONE
166#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
167#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
168#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
169#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
170#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
171#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
172#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
173#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
174#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
175#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
176#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
177#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
178#define ARGP_TIMER_OP ARG_NONE
179#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
180#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
181#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
182#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
183#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
184#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
185#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
186#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
187#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
188#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
189#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
190#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
191#define ARGP_ZERO_OP ARG_NONE
192
193/*
194 * All AML opcodes and the runtime arguments for each. Used by the AML
195 * interpreter Each list is compressed into a 32-bit number and stored
196 * in the master opcode table (in psopcode.c).
197 *
198 * (Used by prep_operands procedure and the ASL Compiler)
199 */
200#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
201#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
202#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
203#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
204#define ARGI_ARG0 ARG_NONE
205#define ARGI_ARG1 ARG_NONE
206#define ARGI_ARG2 ARG_NONE
207#define ARGI_ARG3 ARG_NONE
208#define ARGI_ARG4 ARG_NONE
209#define ARGI_ARG5 ARG_NONE
210#define ARGI_ARG6 ARG_NONE
211#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
212#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
213#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
214#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
215#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
216#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
217#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
218#define ARGI_BREAK_OP ARG_NONE
219#define ARGI_BREAK_POINT_OP ARG_NONE
220#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
221#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
222#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
223#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
224#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
225#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
226#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
227#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
228#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
229#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
230#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
231#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
232#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
233#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
234#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
235#define ARGI_DEBUG_OP ARG_NONE
236#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
237#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
238#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
239#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
240#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
241#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
242#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
243#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
244#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
245#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
246#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
247#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
248#define ARGI_IF_OP ARGI_INVALID_OPCODE
249#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
250#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
251#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
252#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
253#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
254#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
255#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
256#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
257#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
258#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
259#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
260#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF)
261#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
262#define ARGI_LOCAL0 ARG_NONE
263#define ARGI_LOCAL1 ARG_NONE
264#define ARGI_LOCAL2 ARG_NONE
265#define ARGI_LOCAL3 ARG_NONE
266#define ARGI_LOCAL4 ARG_NONE
267#define ARGI_LOCAL5 ARG_NONE
268#define ARGI_LOCAL6 ARG_NONE
269#define ARGI_LOCAL7 ARG_NONE
270#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
271#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
272#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
273#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
274#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
275#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
276#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
277#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
278#define ARGI_NAME_OP ARGI_INVALID_OPCODE
279#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
280#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
281#define ARGI_NOOP_OP ARG_NONE
282#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
283#define ARGI_ONE_OP ARG_NONE
284#define ARGI_ONES_OP ARG_NONE
285#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
286#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
287#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
288#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
289#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
290#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
291#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
292#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
293#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
294#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
295#define ARGI_REVISION_OP ARG_NONE
296#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
297#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
298#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
299#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
300#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
301#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
302#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
303#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
304#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
305#define ARGI_STRING_OP ARGI_INVALID_OPCODE
306#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
307#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
308#define ARGI_TIMER_OP ARG_NONE
309#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
310#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
311#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
312#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
313#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
314#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
315#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
316#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
317#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
318#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
319#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
320#define ARGI_WORD_OP ARGI_INVALID_OPCODE
321#define ARGI_ZERO_OP ARG_NONE
322
323#endif /* __ACOPCODE_H__ */
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
new file mode 100644
index 000000000000..23ee0fbf5619
--- /dev/null
+++ b/drivers/acpi/acpica/acparser.h
@@ -0,0 +1,234 @@
1/******************************************************************************
2 *
3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACPARSER_H__
45#define __ACPARSER_H__
46
47#define OP_HAS_RETURN_VALUE 1
48
49/* Variable number of arguments. This field must be 32 bits */
50
51#define ACPI_VAR_ARGS ACPI_UINT32_MAX
52
53#define ACPI_PARSE_DELETE_TREE 0x0001
54#define ACPI_PARSE_NO_TREE_DELETE 0x0000
55#define ACPI_PARSE_TREE_MASK 0x0001
56
57#define ACPI_PARSE_LOAD_PASS1 0x0010
58#define ACPI_PARSE_LOAD_PASS2 0x0020
59#define ACPI_PARSE_EXECUTE 0x0030
60#define ACPI_PARSE_MODE_MASK 0x0030
61
62#define ACPI_PARSE_DEFERRED_OP 0x0100
63#define ACPI_PARSE_DISASSEMBLE 0x0200
64
65/******************************************************************************
66 *
67 * Parser interfaces
68 *
69 *****************************************************************************/
70
71/*
72 * psxface - Parser external interfaces
73 */
74acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info);
75
76/*
77 * psargs - Parse AML opcode arguments
78 */
79u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
80
81char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
82
83void
84acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
85 u32 arg_type, union acpi_parse_object *arg);
86
87acpi_status
88acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
89 struct acpi_parse_state *parser_state,
90 union acpi_parse_object *arg, u8 method_call);
91
92acpi_status
93acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
94 struct acpi_parse_state *parser_state,
95 u32 arg_type, union acpi_parse_object **return_arg);
96
97/*
98 * psfind
99 */
100union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
101 u32 name, u32 opcode);
102
103union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
104
105/*
106 * psopcode - AML Opcode information
107 */
108const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
109
110char *acpi_ps_get_opcode_name(u16 opcode);
111
112u8 acpi_ps_get_argument_count(u32 op_type);
113
114/*
115 * psparse - top level parsing routines
116 */
117acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
118
119u32 acpi_ps_get_opcode_size(u32 opcode);
120
121u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
122
123acpi_status
124acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
125 union acpi_parse_object *op);
126
127acpi_status
128acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
129 union acpi_parse_object *op,
130 acpi_status callback_status);
131
132/*
133 * psloop - main parse loop
134 */
135acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
136
137/*
138 * psscope - Scope stack management routines
139 */
140acpi_status
141acpi_ps_init_scope(struct acpi_parse_state *parser_state,
142 union acpi_parse_object *root);
143
144union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
145 *state);
146
147u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
148
149void
150acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
151 union acpi_parse_object **op,
152 u32 * arg_list, u32 * arg_count);
153
154acpi_status
155acpi_ps_push_scope(struct acpi_parse_state *parser_state,
156 union acpi_parse_object *op,
157 u32 remaining_args, u32 arg_count);
158
159void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
160
161/*
162 * pstree - parse tree manipulation routines
163 */
164void
165acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
166
167union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
168 char *path, u16 opcode, u32 create);
169
170union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
171
172#ifdef ACPI_FUTURE_USAGE
173union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
174 union acpi_parse_object *op);
175#endif /* ACPI_FUTURE_USAGE */
176
177/*
178 * pswalk - parse tree walk routines
179 */
180acpi_status
181acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
182 union acpi_parse_object *end_op,
183 union acpi_operand_object *mth_desc,
184 struct acpi_namespace_node *start_node,
185 union acpi_operand_object **params,
186 union acpi_operand_object **caller_return_desc,
187 acpi_owner_id owner_id,
188 acpi_parse_downwards descending_callback,
189 acpi_parse_upwards ascending_callback);
190
191acpi_status
192acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
193 union acpi_parse_object *op,
194 acpi_parse_upwards ascending_callback);
195
196acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
197
198void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
199
200/*
201 * psutils - parser utilities
202 */
203union acpi_parse_object *acpi_ps_create_scope_op(void);
204
205void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
206
207union acpi_parse_object *acpi_ps_alloc_op(u16 opcode);
208
209void acpi_ps_free_op(union acpi_parse_object *op);
210
211u8 acpi_ps_is_leading_char(u32 c);
212
213u8 acpi_ps_is_prefix_char(u32 c);
214
215#ifdef ACPI_FUTURE_USAGE
216u32 acpi_ps_get_name(union acpi_parse_object *op);
217#endif /* ACPI_FUTURE_USAGE */
218
219void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
220
221/*
222 * psdump - display parser tree
223 */
224u32
225acpi_ps_sprint_path(char *buffer_start,
226 u32 buffer_size, union acpi_parse_object *op);
227
228u32
229acpi_ps_sprint_op(char *buffer_start,
230 u32 buffer_size, union acpi_parse_object *op);
231
232void acpi_ps_show(union acpi_parse_object *op);
233
234#endif /* __ACPARSER_H__ */
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
new file mode 100644
index 000000000000..16a9ca9a66e4
--- /dev/null
+++ b/drivers/acpi/acpica/acpredef.h
@@ -0,0 +1,371 @@
1/******************************************************************************
2 *
3 * Name: acpredef - Information table for ACPI predefined methods and objects
4 * $Revision: 1.1 $
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#ifndef __ACPREDEF_H__
46#define __ACPREDEF_H__
47
48/******************************************************************************
49 *
50 * Return Package types
51 *
52 * 1) PTYPE1 packages do not contain sub-packages.
53 *
54 * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types:
55 * object type
56 * count
57 * object type
58 * count
59 *
60 * ACPI_PTYPE1_VAR: Variable length:
61 * object type (Int/Buf/Ref)
62 *
63 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements:
64 * Used for _PRW
65 *
66 *
67 * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the
68 * different types describe the contents of each of the sub-packages.
69 *
70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types:
71 * object type
72 * count
73 * object type
74 * count
75 *
76 * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element:
77 * object type
78 *
79 * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types:
80 * object type
81 * count
82 * object type
83 * count
84 *
85 * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length:
86 * Used for _PRT
87 *
88 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length
89 * Used for _HPX
90 *
91 *****************************************************************************/
92
93enum acpi_return_package_types {
94 ACPI_PTYPE1_FIXED = 1,
95 ACPI_PTYPE1_VAR = 2,
96 ACPI_PTYPE1_OPTION = 3,
97 ACPI_PTYPE2 = 4,
98 ACPI_PTYPE2_COUNT = 5,
99 ACPI_PTYPE2_PKG_COUNT = 6,
100 ACPI_PTYPE2_FIXED = 7,
101 ACPI_PTYPE2_MIN = 8
102};
103
104/*
105 * Predefined method/object information table.
106 *
107 * These are the names that can actually be evaluated via acpi_evaluate_object.
108 * Not present in this table are the following:
109 *
110 * 1) Predefined/Reserved names that are never evaluated via acpi_evaluate_object:
111 * _Lxx and _Exx GPE methods
112 * _Qxx EC methods
113 * _T_x compiler temporary variables
114 *
115 * 2) Predefined names that never actually exist within the AML code:
116 * Predefined resource descriptor field names
117 *
118 * 3) Predefined names that are implemented within ACPICA:
119 * _OSI
120 *
121 * 4) Some predefined names that are not documented within the ACPI spec.
122 * _WDG, _WED
123 *
124 * The main entries in the table each contain the following items:
125 *
126 * Name - The ACPI reserved name
127 * param_count - Number of arguments to the method
128 * expected_btypes - Allowed type(s) for the return value.
129 * 0 means that no return value is expected.
130 *
131 * For methods that return packages, the next entry in the table contains
132 * information about the expected structure of the package. This information
133 * is saved here (rather than in a separate table) in order to minimize the
134 * overall size of the stored data.
135 */
136static const union acpi_predefined_info predefined_names[] = {
137 {.info = {"_AC0", 0, ACPI_RTYPE_INTEGER}},
138 {.info = {"_AC1", 0, ACPI_RTYPE_INTEGER}},
139 {.info = {"_AC2", 0, ACPI_RTYPE_INTEGER}},
140 {.info = {"_AC3", 0, ACPI_RTYPE_INTEGER}},
141 {.info = {"_AC4", 0, ACPI_RTYPE_INTEGER}},
142 {.info = {"_AC5", 0, ACPI_RTYPE_INTEGER}},
143 {.info = {"_AC6", 0, ACPI_RTYPE_INTEGER}},
144 {.info = {"_AC7", 0, ACPI_RTYPE_INTEGER}},
145 {.info = {"_AC8", 0, ACPI_RTYPE_INTEGER}},
146 {.info = {"_AC9", 0, ACPI_RTYPE_INTEGER}},
147 {.info = {"_ADR", 0, ACPI_RTYPE_INTEGER}},
148 {.info = {"_AL0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
149 {.info = {"_AL1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
150 {.info = {"_AL2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
151 {.info = {"_AL3", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
152 {.info = {"_AL4", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
153 {.info = {"_AL5", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
154 {.info = {"_AL6", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
155 {.info = {"_AL7", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
156 {.info = {"_AL8", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
157 {.info = {"_AL9", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
158 {.info = {"_ALC", 0, ACPI_RTYPE_INTEGER}},
159 {.info = {"_ALI", 0, ACPI_RTYPE_INTEGER}},
160 {.info = {"_ALP", 0, ACPI_RTYPE_INTEGER}},
161 {.info = {"_ALR", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* variable (Pkgs) each 2 (Ints) */
162 {.info = {"_ALT", 0, ACPI_RTYPE_INTEGER}},
163 {.info = {"_BBN", 0, ACPI_RTYPE_INTEGER}},
164 {.info = {"_BCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
165 {.info = {"_BCM", 1, 0}},
166 {.info = {"_BDN", 0, ACPI_RTYPE_INTEGER}},
167 {.info = {"_BFS", 1, 0}},
168 {.info = {"_BIF", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER,
169 9,
170 ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, 4, 0}}, /* fixed (9 Int),(4 Str) */
171 {.info = {"_BLT", 3, 0}},
172 {.info = {"_BMC", 1, 0}},
173 {.info = {"_BMD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* fixed (5 Int) */
174 {.info = {"_BQC", 0, ACPI_RTYPE_INTEGER}},
175 {.info = {"_BST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
176 {.info = {"_BTM", 1, ACPI_RTYPE_INTEGER}},
177 {.info = {"_BTP", 1, 0}},
178 {.info = {"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* see PCI firmware spec 3.0 */
179 {.info = {"_CID", 0,
180 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}},
181 {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, 0, 0, 0}}, /* variable (Ints/Strs) */
182 {.info = {"_CRS", 0, ACPI_RTYPE_BUFFER}},
183 {.info = {"_CRT", 0, ACPI_RTYPE_INTEGER}},
184 {.info = {"_CSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (1 Int(n), n-1 Int) */
185 {.info = {"_CST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_PKG_COUNT,
186 ACPI_RTYPE_BUFFER, 1,
187 ACPI_RTYPE_INTEGER, 3, 0}}, /* variable (1 Int(n), n Pkg (1 Buf/3 Int) */
188 {.info = {"_DCK", 1, ACPI_RTYPE_INTEGER}},
189 {.info = {"_DCS", 0, ACPI_RTYPE_INTEGER}},
190 {.info = {"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}},
191 {.info = {"_DDN", 0, ACPI_RTYPE_STRING}},
192 {.info = {"_DGS", 0, ACPI_RTYPE_INTEGER}},
193 {.info = {"_DIS", 0, 0}},
194 {.info = {"_DMA", 0, ACPI_RTYPE_BUFFER}},
195 {.info = {"_DOD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
196 {.info = {"_DOS", 1, 0}},
197 {.info = {"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */
198 {.info = {"_DSS", 1, 0}},
199 {.info = {"_DSW", 3, 0}},
200 {.info = {"_EC_", 0, ACPI_RTYPE_INTEGER}},
201 {.info = {"_EDL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
202 {.info = {"_EJ0", 1, 0}},
203 {.info = {"_EJ1", 1, 0}},
204 {.info = {"_EJ2", 1, 0}},
205 {.info = {"_EJ3", 1, 0}},
206 {.info = {"_EJ4", 1, 0}},
207 {.info = {"_EJD", 0, ACPI_RTYPE_STRING}},
208 {.info = {"_FDE", 0, ACPI_RTYPE_BUFFER}},
209 {.info = {"_FDI", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, 0, 0, 0}}, /* fixed (16 Int) */
210 {.info = {"_FDM", 1, 0}},
211 {.info = {"_FIX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
212 {.info = {"_GLK", 0, ACPI_RTYPE_INTEGER}},
213 {.info = {"_GPD", 0, ACPI_RTYPE_INTEGER}},
214 {.info = {"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */
215 {.info = {"_GSB", 0, ACPI_RTYPE_INTEGER}},
216 {.info = {"_GTF", 0, ACPI_RTYPE_BUFFER}},
217 {.info = {"_GTM", 0, ACPI_RTYPE_BUFFER}},
218 {.info = {"_GTS", 1, 0}},
219 {.info = {"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
220 {.info = {"_HOT", 0, ACPI_RTYPE_INTEGER}},
221 {.info = {"_HPP", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
222
223 /*
224 * For _HPX, a single package is returned, containing a variable number of sub-packages.
225 * Each sub-package contains a PCI record setting. There are several different type of
226 * record settings, of different lengths, but all elements of all settings are Integers.
227 */
228 {.info = {"_HPX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each (var Ints) */
229 {.info = {"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */
230 {.info = {"_INI", 0, 0}},
231 {.info = {"_IRC", 0, 0}},
232 {.info = {"_LCK", 1, 0}},
233 {.info = {"_LID", 0, ACPI_RTYPE_INTEGER}},
234 {.info = {"_MAT", 0, ACPI_RTYPE_BUFFER}},
235 {.info = {"_MLS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_STRING, 2, 0, 0, 0}}, /* variable (Pkgs) each (2 Str) */
236 {.info = {"_MSG", 1, 0}},
237 {.info = {"_OFF", 0, 0}},
238 {.info = {"_ON_", 0, 0}},
239 {.info = {"_OS_", 0, ACPI_RTYPE_STRING}},
240 {.info = {"_OSC", 4, ACPI_RTYPE_BUFFER}},
241 {.info = {"_OST", 3, 0}},
242 {.info = {"_PCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
243 {.info = {"_PCT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */
244 {.info = {"_PDC", 1, 0}},
245 {.info = {"_PIC", 1, 0}},
246 {.info = {"_PLD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0, 0, 0, 0}}, /* variable (Bufs) */
247 {.info = {"_PPC", 0, ACPI_RTYPE_INTEGER}},
248 {.info = {"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* see dig64 spec */
249 {.info = {"_PR0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
250 {.info = {"_PR1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
251 {.info = {"_PR2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
252 {.info = {"_PRS", 0, ACPI_RTYPE_BUFFER}},
253
254 /*
255 * For _PRT, many BIOSs reverse the 2nd and 3rd Package elements. This bug is so prevalent that there
256 * is code in the ACPICA Resource Manager to detect this and switch them back. For now, do not allow
257 * and issue a warning. To allow this and eliminate the warning, add the ACPI_RTYPE_REFERENCE
258 * type to the 2nd element (index 1) in the statement below.
259 */
260 {.info = {"_PRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_FIXED, 4,
261 ACPI_RTYPE_INTEGER,
262 ACPI_RTYPE_INTEGER,
263 ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, ACPI_RTYPE_INTEGER}}, /* variable (Pkgs) each (4): Int,Int,Int/Ref,Int */
264
265 {.info = {"_PRW", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_OPTION, 2,
266 ACPI_RTYPE_INTEGER |
267 ACPI_RTYPE_PACKAGE,
268 ACPI_RTYPE_INTEGER, ACPI_RTYPE_REFERENCE, 0}}, /* variable (Pkgs) each: Pkg/Int,Int,[variable Refs] (Pkg is Ref/Int) */
269
270 {.info = {"_PS0", 0, 0}},
271 {.info = {"_PS1", 0, 0}},
272 {.info = {"_PS2", 0, 0}},
273 {.info = {"_PS3", 0, 0}},
274 {.info = {"_PSC", 0, ACPI_RTYPE_INTEGER}},
275 {.info = {"_PSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Pkgs) each (5 Int) with count */
276 {.info = {"_PSL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
277 {.info = {"_PSR", 0, ACPI_RTYPE_INTEGER}},
278 {.info = {"_PSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6, 0, 0, 0}}, /* variable (Pkgs) each (6 Int) */
279 {.info = {"_PSV", 0, ACPI_RTYPE_INTEGER}},
280 {.info = {"_PSW", 1, 0}},
281 {.info = {"_PTC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */
282 {.info = {"_PTS", 1, 0}},
283 {.info = {"_PXM", 0, ACPI_RTYPE_INTEGER}},
284 {.info = {"_REG", 2, 0}},
285 {.info = {"_REV", 0, ACPI_RTYPE_INTEGER}},
286 {.info = {"_RMV", 0, ACPI_RTYPE_INTEGER}},
287 {.info = {"_ROM", 2, ACPI_RTYPE_BUFFER}},
288 {.info = {"_RTV", 0, ACPI_RTYPE_INTEGER}},
289
290 /*
291 * For _S0_ through _S5_, the ACPI spec defines a return Package containing 1 Integer,
292 * but most DSDTs have it wrong - 2,3, or 4 integers. Allow this by making the objects "variable length",
293 * but all elements must be Integers.
294 */
295 {.info = {"_S0_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
296 {.info = {"_S1_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
297 {.info = {"_S2_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
298 {.info = {"_S3_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
299 {.info = {"_S4_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
300 {.info = {"_S5_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
301
302 {.info = {"_S1D", 0, ACPI_RTYPE_INTEGER}},
303 {.info = {"_S2D", 0, ACPI_RTYPE_INTEGER}},
304 {.info = {"_S3D", 0, ACPI_RTYPE_INTEGER}},
305 {.info = {"_S4D", 0, ACPI_RTYPE_INTEGER}},
306 {.info = {"_S0W", 0, ACPI_RTYPE_INTEGER}},
307 {.info = {"_S1W", 0, ACPI_RTYPE_INTEGER}},
308 {.info = {"_S2W", 0, ACPI_RTYPE_INTEGER}},
309 {.info = {"_S3W", 0, ACPI_RTYPE_INTEGER}},
310 {.info = {"_S4W", 0, ACPI_RTYPE_INTEGER}},
311 {.info = {"_SBS", 0, ACPI_RTYPE_INTEGER}},
312 {.info = {"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */
313 /* Note: the 3-arg definition may be removed for ACPI 4.0 */
314 {.info = {"_SDD", 1, 0}},
315 {.info = {"_SEG", 0, ACPI_RTYPE_INTEGER}},
316 {.info = {"_SLI", 0, ACPI_RTYPE_BUFFER}},
317 {.info = {"_SPD", 1, ACPI_RTYPE_INTEGER}},
318 {.info = {"_SRS", 1, 0}},
319 {.info = {"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */
320 {.info = {"_SST", 1, 0}},
321 {.info = {"_STA", 0, ACPI_RTYPE_INTEGER}},
322 {.info = {"_STM", 3, 0}},
323 {.info = {"_STR", 0, ACPI_RTYPE_BUFFER}},
324 {.info = {"_SUN", 0, ACPI_RTYPE_INTEGER}},
325 {.info = {"_SWS", 0, ACPI_RTYPE_INTEGER}},
326 {.info = {"_TC1", 0, ACPI_RTYPE_INTEGER}},
327 {.info = {"_TC2", 0, ACPI_RTYPE_INTEGER}},
328 {.info = {"_TMP", 0, ACPI_RTYPE_INTEGER}},
329 {.info = {"_TPC", 0, ACPI_RTYPE_INTEGER}},
330 {.info = {"_TPT", 1, 0}},
331 {.info = {"_TRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2,
332 ACPI_RTYPE_INTEGER, 6, 0}}, /* variable (Pkgs) each 2_ref/6_int */
333 {.info = {"_TSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int with count */
334 {.info = {"_TSP", 0, ACPI_RTYPE_INTEGER}},
335 {.info = {"_TSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int */
336 {.info = {"_TST", 0, ACPI_RTYPE_INTEGER}},
337 {.info = {"_TTS", 1, 0}},
338 {.info = {"_TZD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
339 {.info = {"_TZM", 0, ACPI_RTYPE_REFERENCE}},
340 {.info = {"_TZP", 0, ACPI_RTYPE_INTEGER}},
341 {.info = {"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
342 {.info = {"_UPC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
343 {.info = {"_UPD", 0, ACPI_RTYPE_INTEGER}},
344 {.info = {"_UPP", 0, ACPI_RTYPE_INTEGER}},
345 {.info = {"_VPO", 0, ACPI_RTYPE_INTEGER}},
346
347 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */
348
349 {.info = {"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
350 {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* fixed (2 Int), but is optional */
351 {.ret_info = {0, 0, 0, 0, 0, 0}} /* Table terminator */
352};
353
354#if 0
355 /* Not implemented */
356
357{
358"_WDG", 0, ACPI_RTYPE_BUFFER}, /* MS Extension */
359
360{
361"_WED", 1, ACPI_RTYPE_PACKAGE}, /* MS Extension */
362
363 /* This is an internally implemented control method, no need to check */
364{
365"_OSI", 1, ACPI_RTYPE_INTEGER},
366
367 /* TBD: */
368 _PRT - currently ignore reversed entries.attempt to fix here ?
369 think about code that attempts to fix package elements like _BIF, etc.
370#endif
371#endif
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
new file mode 100644
index 000000000000..eef5bd7a59fa
--- /dev/null
+++ b/drivers/acpi/acpica/acresrc.h
@@ -0,0 +1,336 @@
1/******************************************************************************
2 *
3 * Name: acresrc.h - Resource Manager function prototypes
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACRESRC_H__
45#define __ACRESRC_H__
46
47/* Need the AML resource descriptor structs */
48
49#include "amlresrc.h"
50
51/*
52 * If possible, pack the following structures to byte alignment, since we
53 * don't care about performance for debug output. Two cases where we cannot
54 * pack the structures:
55 *
56 * 1) Hardware does not support misaligned memory transfers
57 * 2) Compiler does not support pointers within packed structures
58 */
59#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
60#pragma pack(1)
61#endif
62
63/*
64 * Individual entry for the resource conversion tables
65 */
66typedef const struct acpi_rsconvert_info {
67 u8 opcode;
68 u8 resource_offset;
69 u8 aml_offset;
70 u8 value;
71
72} acpi_rsconvert_info;
73
74/* Resource conversion opcodes */
75
76#define ACPI_RSC_INITGET 0
77#define ACPI_RSC_INITSET 1
78#define ACPI_RSC_FLAGINIT 2
79#define ACPI_RSC_1BITFLAG 3
80#define ACPI_RSC_2BITFLAG 4
81#define ACPI_RSC_COUNT 5
82#define ACPI_RSC_COUNT16 6
83#define ACPI_RSC_LENGTH 7
84#define ACPI_RSC_MOVE8 8
85#define ACPI_RSC_MOVE16 9
86#define ACPI_RSC_MOVE32 10
87#define ACPI_RSC_MOVE64 11
88#define ACPI_RSC_SET8 12
89#define ACPI_RSC_DATA8 13
90#define ACPI_RSC_ADDRESS 14
91#define ACPI_RSC_SOURCE 15
92#define ACPI_RSC_SOURCEX 16
93#define ACPI_RSC_BITMASK 17
94#define ACPI_RSC_BITMASK16 18
95#define ACPI_RSC_EXIT_NE 19
96#define ACPI_RSC_EXIT_LE 20
97#define ACPI_RSC_EXIT_EQ 21
98
99/* Resource Conversion sub-opcodes */
100
101#define ACPI_RSC_COMPARE_AML_LENGTH 0
102#define ACPI_RSC_COMPARE_VALUE 1
103
104#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
105
106#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
107#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
108
109typedef const struct acpi_rsdump_info {
110 u8 opcode;
111 u8 offset;
112 char *name;
113 const char **pointer;
114
115} acpi_rsdump_info;
116
117/* Values for the Opcode field above */
118
119#define ACPI_RSD_TITLE 0
120#define ACPI_RSD_LITERAL 1
121#define ACPI_RSD_STRING 2
122#define ACPI_RSD_UINT8 3
123#define ACPI_RSD_UINT16 4
124#define ACPI_RSD_UINT32 5
125#define ACPI_RSD_UINT64 6
126#define ACPI_RSD_1BITFLAG 7
127#define ACPI_RSD_2BITFLAG 8
128#define ACPI_RSD_SHORTLIST 9
129#define ACPI_RSD_LONGLIST 10
130#define ACPI_RSD_DWORDLIST 11
131#define ACPI_RSD_ADDRESS 12
132#define ACPI_RSD_SOURCE 13
133
134/* restore default alignment */
135
136#pragma pack()
137
138/* Resource tables indexed by internal resource type */
139
140extern const u8 acpi_gbl_aml_resource_sizes[];
141extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
142
143/* Resource tables indexed by raw AML resource descriptor type */
144
145extern const u8 acpi_gbl_resource_struct_sizes[];
146extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
147
148struct acpi_vendor_walk_info {
149 struct acpi_vendor_uuid *uuid;
150 struct acpi_buffer *buffer;
151 acpi_status status;
152};
153
154/*
155 * rscreate
156 */
157acpi_status
158acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
159 struct acpi_buffer *output_buffer);
160
161acpi_status
162acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
163 struct acpi_buffer *output_buffer);
164
165acpi_status
166acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
167 struct acpi_buffer *output_buffer);
168
169/*
170 * rsutils
171 */
172
173acpi_status
174acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
175 struct acpi_buffer *ret_buffer);
176
177acpi_status
178acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
179 struct acpi_buffer *ret_buffer);
180
181acpi_status
182acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
183 struct acpi_buffer *ret_buffer);
184
185acpi_status
186acpi_rs_get_method_data(acpi_handle handle,
187 char *path, struct acpi_buffer *ret_buffer);
188
189acpi_status
190acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
191 struct acpi_buffer *ret_buffer);
192
193/*
194 * rscalc
195 */
196acpi_status
197acpi_rs_get_list_length(u8 * aml_buffer,
198 u32 aml_buffer_length, acpi_size * size_needed);
199
200acpi_status
201acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
202 acpi_size * size_needed);
203
204acpi_status
205acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
206 acpi_size * buffer_size_needed);
207
208acpi_status
209acpi_rs_convert_aml_to_resources(u8 * aml,
210 u32 length,
211 u32 offset, u8 resource_index, void **context);
212
213acpi_status
214acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
215 acpi_size aml_size_needed, u8 * output_buffer);
216
217/*
218 * rsaddr
219 */
220void
221acpi_rs_set_address_common(union aml_resource *aml,
222 struct acpi_resource *resource);
223
224u8
225acpi_rs_get_address_common(struct acpi_resource *resource,
226 union aml_resource *aml);
227
228/*
229 * rsmisc
230 */
231acpi_status
232acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
233 union aml_resource *aml,
234 struct acpi_rsconvert_info *info);
235
236acpi_status
237acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
238 union aml_resource *aml,
239 struct acpi_rsconvert_info *info);
240
241/*
242 * rsutils
243 */
244void
245acpi_rs_move_data(void *destination,
246 void *source, u16 item_count, u8 move_type);
247
248u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
249
250u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
251
252acpi_rs_length
253acpi_rs_get_resource_source(acpi_rs_length resource_length,
254 acpi_rs_length minimum_length,
255 struct acpi_resource_source *resource_source,
256 union aml_resource *aml, char *string_ptr);
257
258acpi_rsdesc_size
259acpi_rs_set_resource_source(union aml_resource *aml,
260 acpi_rs_length minimum_length,
261 struct acpi_resource_source *resource_source);
262
263void
264acpi_rs_set_resource_header(u8 descriptor_type,
265 acpi_rsdesc_size total_length,
266 union aml_resource *aml);
267
268void
269acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
270 union aml_resource *aml);
271
272/*
273 * rsdump
274 */
275void acpi_rs_dump_resource_list(struct acpi_resource *resource);
276
277void acpi_rs_dump_irq_list(u8 * route_table);
278
279/*
280 * Resource conversion tables
281 */
282extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
283extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
284extern struct acpi_rsconvert_info acpi_rs_convert_io[];
285extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
286extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
287extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
288extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
289extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
290extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
291extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
292extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
293extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
294extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
295extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
296
297/* These resources require separate get/set tables */
298
299extern struct acpi_rsconvert_info acpi_rs_get_irq[];
300extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
301extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
302extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
303
304extern struct acpi_rsconvert_info acpi_rs_set_irq[];
305extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
306extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
307
308#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
309/*
310 * rsinfo
311 */
312extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
313
314/*
315 * rsdump
316 */
317extern struct acpi_rsdump_info acpi_rs_dump_irq[];
318extern struct acpi_rsdump_info acpi_rs_dump_dma[];
319extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
320extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
321extern struct acpi_rsdump_info acpi_rs_dump_io[];
322extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
323extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
324extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
325extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
326extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
327extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
328extern struct acpi_rsdump_info acpi_rs_dump_address16[];
329extern struct acpi_rsdump_info acpi_rs_dump_address32[];
330extern struct acpi_rsdump_info acpi_rs_dump_address64[];
331extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
332extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
333extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
334#endif
335
336#endif /* __ACRESRC_H__ */
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
new file mode 100644
index 000000000000..7980a26bad35
--- /dev/null
+++ b/drivers/acpi/acpica/acstruct.h
@@ -0,0 +1,228 @@
1/******************************************************************************
2 *
3 * Name: acstruct.h - Internal structs
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACSTRUCT_H__
45#define __ACSTRUCT_H__
46
47/* acpisrc:struct_defs -- for acpisrc conversion */
48
49/*****************************************************************************
50 *
51 * Tree walking typedefs and structs
52 *
53 ****************************************************************************/
54
55/*
56 * Walk state - current state of a parse tree walk. Used for both a leisurely
57 * stroll through the tree (for whatever reason), and for control method
58 * execution.
59 */
60#define ACPI_NEXT_OP_DOWNWARD 1
61#define ACPI_NEXT_OP_UPWARD 2
62
63/*
64 * Groups of definitions for walk_type used for different implementations of
65 * walkers (never simultaneously) - flags for interpreter:
66 */
67#define ACPI_WALK_NON_METHOD 0
68#define ACPI_WALK_METHOD 0x01
69#define ACPI_WALK_METHOD_RESTART 0x02
70
71/* Flags for i_aSL compiler only */
72
73#define ACPI_WALK_CONST_REQUIRED 0x10
74#define ACPI_WALK_CONST_OPTIONAL 0x20
75
76struct acpi_walk_state {
77 struct acpi_walk_state *next; /* Next walk_state in list */
78 u8 descriptor_type; /* To differentiate various internal objs */
79 u8 walk_type;
80 u16 opcode; /* Current AML opcode */
81 u8 next_op_info; /* Info about next_op */
82 u8 num_operands; /* Stack pointer for Operands[] array */
83 u8 operand_index; /* Index into operand stack, to be used by acpi_ds_obj_stack_push */
84 acpi_owner_id owner_id; /* Owner of objects created during the walk */
85 u8 last_predicate; /* Result of last predicate */
86 u8 current_result;
87 u8 return_used;
88 u8 scope_depth;
89 u8 pass_number; /* Parse pass during table load */
90 u8 result_size; /* Total elements for the result stack */
91 u8 result_count; /* Current number of occupied elements of result stack */
92 u32 aml_offset;
93 u32 arg_types;
94 u32 method_breakpoint; /* For single stepping */
95 u32 user_breakpoint; /* User AML breakpoint */
96 u32 parse_flags;
97
98 struct acpi_parse_state parser_state; /* Current state of parser */
99 u32 prev_arg_types;
100 u32 arg_count; /* push for fixed or var args */
101
102 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
103 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
104 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
105 union acpi_operand_object **params;
106
107 u8 *aml_last_while;
108 union acpi_operand_object **caller_return_desc;
109 union acpi_generic_state *control_state; /* List of control states (nested IFs) */
110 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */
111 union acpi_operand_object *implicit_return_obj;
112 struct acpi_namespace_node *method_call_node; /* Called method Node */
113 union acpi_parse_object *method_call_op; /* method_call Op if running a method */
114 union acpi_operand_object *method_desc; /* Method descriptor if running a method */
115 struct acpi_namespace_node *method_node; /* Method node if running a method. */
116 union acpi_parse_object *op; /* Current parser op */
117 const struct acpi_opcode_info *op_info; /* Info on current opcode */
118 union acpi_parse_object *origin; /* Start of walk [Obsolete] */
119 union acpi_operand_object *result_obj;
120 union acpi_generic_state *results; /* Stack of accumulated results */
121 union acpi_operand_object *return_desc; /* Return object, if any */
122 union acpi_generic_state *scope_info; /* Stack of nested scopes */
123 union acpi_parse_object *prev_op; /* Last op that was processed */
124 union acpi_parse_object *next_op; /* next op to be processed */
125 struct acpi_thread_state *thread;
126 acpi_parse_downwards descending_callback;
127 acpi_parse_upwards ascending_callback;
128};
129
130/* Info used by acpi_ps_init_objects */
131
132struct acpi_init_walk_info {
133 u16 method_count;
134 u16 device_count;
135 u16 op_region_count;
136 u16 field_count;
137 u16 buffer_count;
138 u16 package_count;
139 u16 op_region_init;
140 u16 field_init;
141 u16 buffer_init;
142 u16 package_init;
143 u16 object_count;
144 acpi_owner_id owner_id;
145 u32 table_index;
146};
147
148struct acpi_get_devices_info {
149 acpi_walk_callback user_function;
150 void *context;
151 const char *hid;
152};
153
154union acpi_aml_operands {
155 union acpi_operand_object *operands[7];
156
157 struct {
158 struct acpi_object_integer *type;
159 struct acpi_object_integer *code;
160 struct acpi_object_integer *argument;
161
162 } fatal;
163
164 struct {
165 union acpi_operand_object *source;
166 struct acpi_object_integer *index;
167 union acpi_operand_object *target;
168
169 } index;
170
171 struct {
172 union acpi_operand_object *source;
173 struct acpi_object_integer *index;
174 struct acpi_object_integer *length;
175 union acpi_operand_object *target;
176
177 } mid;
178};
179
180/*
181 * Structure used to pass object evaluation parameters.
182 * Purpose is to reduce CPU stack use.
183 */
184struct acpi_evaluate_info {
185 struct acpi_namespace_node *prefix_node;
186 char *pathname;
187 union acpi_operand_object *obj_desc;
188 union acpi_operand_object **parameters;
189 struct acpi_namespace_node *resolved_node;
190 union acpi_operand_object *return_object;
191 u8 param_count;
192 u8 pass_number;
193 u8 return_object_type;
194 u8 flags;
195};
196
197/* Values for Flags above */
198
199#define ACPI_IGNORE_RETURN_VALUE 1
200
201/* Info used by acpi_ns_initialize_devices */
202
203struct acpi_device_walk_info {
204 u16 device_count;
205 u16 num_STA;
206 u16 num_INI;
207 struct acpi_table_desc *table_desc;
208 struct acpi_evaluate_info *evaluate_info;
209};
210
211/* TBD: [Restructure] Merge with struct above */
212
213struct acpi_walk_info {
214 u32 debug_level;
215 u32 count;
216 acpi_owner_id owner_id;
217 u8 display_type;
218};
219
220/* Display Types */
221
222#define ACPI_DISPLAY_SUMMARY (u8) 0
223#define ACPI_DISPLAY_OBJECTS (u8) 1
224#define ACPI_DISPLAY_MASK (u8) 1
225
226#define ACPI_DISPLAY_SHORT (u8) 2
227
228#endif
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
new file mode 100644
index 000000000000..7ce6e33c7f78
--- /dev/null
+++ b/drivers/acpi/acpica/actables.h
@@ -0,0 +1,117 @@
1/******************************************************************************
2 *
3 * Name: actables.h - ACPI table management
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACTABLES_H__
45#define __ACTABLES_H__
46
47acpi_status acpi_allocate_root_table(u32 initial_table_count);
48
49/*
50 * tbfadt - FADT parse/convert/validate
51 */
52void acpi_tb_parse_fadt(u32 table_index, u8 flags);
53
54void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length);
55
56/*
57 * tbfind - find ACPI table
58 */
59acpi_status
60acpi_tb_find_table(char *signature,
61 char *oem_id, char *oem_table_id, u32 *table_index);
62
63/*
64 * tbinstal - Table removal and deletion
65 */
66acpi_status acpi_tb_resize_root_table_list(void);
67
68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
69
70acpi_status
71acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
72
73acpi_status
74acpi_tb_store_table(acpi_physical_address address,
75 struct acpi_table_header *table,
76 u32 length, u8 flags, u32 *table_index);
77
78void acpi_tb_delete_table(struct acpi_table_desc *table_desc);
79
80void acpi_tb_terminate(void);
81
82void acpi_tb_delete_namespace_by_owner(u32 table_index);
83
84acpi_status acpi_tb_allocate_owner_id(u32 table_index);
85
86acpi_status acpi_tb_release_owner_id(u32 table_index);
87
88acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id);
89
90u8 acpi_tb_is_table_loaded(u32 table_index);
91
92void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
93
94/*
95 * tbutils - table manager utilities
96 */
97acpi_status acpi_tb_initialize_facs(void);
98
99u8 acpi_tb_tables_loaded(void);
100
101void
102acpi_tb_print_table_header(acpi_physical_address address,
103 struct acpi_table_header *header);
104
105u8 acpi_tb_checksum(u8 *buffer, u32 length);
106
107acpi_status
108acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
109
110void
111acpi_tb_install_table(acpi_physical_address address,
112 u8 flags, char *signature, u32 table_index);
113
114acpi_status
115acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags);
116
117#endif /* __ACTABLES_H__ */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
new file mode 100644
index 000000000000..80d8813484fe
--- /dev/null
+++ b/drivers/acpi/acpica/acutils.h
@@ -0,0 +1,549 @@
1/******************************************************************************
2 *
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACUTILS_H
45#define _ACUTILS_H
46
47extern const u8 acpi_gbl_resource_aml_sizes[];
48
49/* Strings used by the disassembler and debugger resource dump routines */
50
51#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
52
53extern const char *acpi_gbl_bm_decode[];
54extern const char *acpi_gbl_config_decode[];
55extern const char *acpi_gbl_consume_decode[];
56extern const char *acpi_gbl_dec_decode[];
57extern const char *acpi_gbl_he_decode[];
58extern const char *acpi_gbl_io_decode[];
59extern const char *acpi_gbl_ll_decode[];
60extern const char *acpi_gbl_max_decode[];
61extern const char *acpi_gbl_mem_decode[];
62extern const char *acpi_gbl_min_decode[];
63extern const char *acpi_gbl_mtp_decode[];
64extern const char *acpi_gbl_rng_decode[];
65extern const char *acpi_gbl_rw_decode[];
66extern const char *acpi_gbl_shr_decode[];
67extern const char *acpi_gbl_siz_decode[];
68extern const char *acpi_gbl_trs_decode[];
69extern const char *acpi_gbl_ttp_decode[];
70extern const char *acpi_gbl_typ_decode[];
71#endif
72
73/* Types for Resource descriptor entries */
74
75#define ACPI_INVALID_RESOURCE 0
76#define ACPI_FIXED_LENGTH 1
77#define ACPI_VARIABLE_LENGTH 2
78#define ACPI_SMALL_VARIABLE_LENGTH 3
79
80typedef
81acpi_status(*acpi_walk_aml_callback) (u8 * aml,
82 u32 length,
83 u32 offset,
84 u8 resource_index, void **context);
85
86typedef
87acpi_status(*acpi_pkg_callback) (u8 object_type,
88 union acpi_operand_object * source_object,
89 union acpi_generic_state * state,
90 void *context);
91
92struct acpi_pkg_info {
93 u8 *free_space;
94 acpi_size length;
95 u32 object_space;
96 u32 num_packages;
97};
98
99#define REF_INCREMENT (u16) 0
100#define REF_DECREMENT (u16) 1
101#define REF_FORCE_DELETE (u16) 2
102
103/* acpi_ut_dump_buffer */
104
105#define DB_BYTE_DISPLAY 1
106#define DB_WORD_DISPLAY 2
107#define DB_DWORD_DISPLAY 4
108#define DB_QWORD_DISPLAY 8
109
110/*
111 * utglobal - Global data structures and procedures
112 */
113acpi_status acpi_ut_init_globals(void);
114
115#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
116
117char *acpi_ut_get_mutex_name(u32 mutex_id);
118
119const char *acpi_ut_get_notify_name(u32 notify_value);
120
121#endif
122
123char *acpi_ut_get_type_name(acpi_object_type type);
124
125char *acpi_ut_get_node_name(void *object);
126
127char *acpi_ut_get_descriptor_name(void *object);
128
129const char *acpi_ut_get_reference_name(union acpi_operand_object *object);
130
131char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
132
133char *acpi_ut_get_region_name(u8 space_id);
134
135char *acpi_ut_get_event_name(u32 event_id);
136
137char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position);
138
139u8 acpi_ut_valid_object_type(acpi_object_type type);
140
141/*
142 * utinit - miscellaneous initialization and shutdown
143 */
144acpi_status acpi_ut_hardware_initialize(void);
145
146void acpi_ut_subsystem_shutdown(void);
147
148/*
149 * utclib - Local implementations of C library functions
150 */
151#ifndef ACPI_USE_SYSTEM_CLIBRARY
152
153acpi_size acpi_ut_strlen(const char *string);
154
155char *acpi_ut_strcpy(char *dst_string, const char *src_string);
156
157char *acpi_ut_strncpy(char *dst_string,
158 const char *src_string, acpi_size count);
159
160int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count);
161
162int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count);
163
164int acpi_ut_strcmp(const char *string1, const char *string2);
165
166char *acpi_ut_strcat(char *dst_string, const char *src_string);
167
168char *acpi_ut_strncat(char *dst_string,
169 const char *src_string, acpi_size count);
170
171u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base);
172
173char *acpi_ut_strstr(char *string1, char *string2);
174
175void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count);
176
177void *acpi_ut_memset(void *dest, u8 value, acpi_size count);
178
179int acpi_ut_to_upper(int c);
180
181int acpi_ut_to_lower(int c);
182
183extern const u8 _acpi_ctype[];
184
185#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
186#define _ACPI_XS 0x40 /* extra space */
187#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
188#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
189#define _ACPI_DI 0x04 /* '0'-'9' */
190#define _ACPI_LO 0x02 /* 'a'-'z' */
191#define _ACPI_PU 0x10 /* punctuation */
192#define _ACPI_SP 0x08 /* space */
193#define _ACPI_UP 0x01 /* 'A'-'Z' */
194#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
195
196#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
197#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
198#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
199#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
200#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
201#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
202#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
203
204#endif /* ACPI_USE_SYSTEM_CLIBRARY */
205
206/*
207 * utcopy - Object construction and conversion interfaces
208 */
209acpi_status
210acpi_ut_build_simple_object(union acpi_operand_object *obj,
211 union acpi_object *user_obj,
212 u8 * data_space, u32 * buffer_space_used);
213
214acpi_status
215acpi_ut_build_package_object(union acpi_operand_object *obj,
216 u8 * buffer, u32 * space_used);
217
218acpi_status
219acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj,
220 struct acpi_buffer *ret_buffer);
221
222acpi_status
223acpi_ut_copy_eobject_to_iobject(union acpi_object *obj,
224 union acpi_operand_object **internal_obj);
225
226acpi_status
227acpi_ut_copy_isimple_to_isimple(union acpi_operand_object *source_obj,
228 union acpi_operand_object *dest_obj);
229
230acpi_status
231acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
232 union acpi_operand_object **dest_desc,
233 struct acpi_walk_state *walk_state);
234
235/*
236 * utcreate - Object creation
237 */
238acpi_status
239acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action);
240
241/*
242 * utdebug - Debug interfaces
243 */
244void acpi_ut_init_stack_ptr_trace(void);
245
246void acpi_ut_track_stack_ptr(void);
247
248void
249acpi_ut_trace(u32 line_number,
250 const char *function_name,
251 const char *module_name, u32 component_id);
252
253void
254acpi_ut_trace_ptr(u32 line_number,
255 const char *function_name,
256 const char *module_name, u32 component_id, void *pointer);
257
258void
259acpi_ut_trace_u32(u32 line_number,
260 const char *function_name,
261 const char *module_name, u32 component_id, u32 integer);
262
263void
264acpi_ut_trace_str(u32 line_number,
265 const char *function_name,
266 const char *module_name, u32 component_id, char *string);
267
268void
269acpi_ut_exit(u32 line_number,
270 const char *function_name,
271 const char *module_name, u32 component_id);
272
273void
274acpi_ut_status_exit(u32 line_number,
275 const char *function_name,
276 const char *module_name,
277 u32 component_id, acpi_status status);
278
279void
280acpi_ut_value_exit(u32 line_number,
281 const char *function_name,
282 const char *module_name,
283 u32 component_id, acpi_integer value);
284
285void
286acpi_ut_ptr_exit(u32 line_number,
287 const char *function_name,
288 const char *module_name, u32 component_id, u8 *ptr);
289
290void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
291
292void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display);
293
294void acpi_ut_report_error(char *module_name, u32 line_number);
295
296void acpi_ut_report_info(char *module_name, u32 line_number);
297
298void acpi_ut_report_warning(char *module_name, u32 line_number);
299
300/*
301 * utdelete - Object deletion and reference counts
302 */
303void acpi_ut_add_reference(union acpi_operand_object *object);
304
305void acpi_ut_remove_reference(union acpi_operand_object *object);
306
307void acpi_ut_delete_internal_package_object(union acpi_operand_object *object);
308
309void acpi_ut_delete_internal_simple_object(union acpi_operand_object *object);
310
311void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list);
312
313/*
314 * uteval - object evaluation
315 */
316acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
317
318acpi_status
319acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
320 char *path,
321 u32 expected_return_btypes,
322 union acpi_operand_object **return_desc);
323
324acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node,
327 acpi_integer * address);
328
329acpi_status
330acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
331 struct acpica_device_id *hid);
332
333acpi_status
334acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
335 struct acpi_compatible_id_list **return_cid_list);
336
337acpi_status
338acpi_ut_execute_STA(struct acpi_namespace_node *device_node,
339 u32 * status_flags);
340
341acpi_status
342acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
343 struct acpica_device_id *uid);
344
345acpi_status
346acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
347
348/*
349 * utobject - internal object create/delete/cache routines
350 */
351union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
352 *module_name,
353 u32 line_number,
354 u32 component_id,
355 acpi_object_type
356 type);
357
358void *acpi_ut_allocate_object_desc_dbg(const char *module_name,
359 u32 line_number, u32 component_id);
360
361#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t)
362#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT)
363
364void acpi_ut_delete_object_desc(union acpi_operand_object *object);
365
366u8 acpi_ut_valid_internal_object(void *object);
367
368union acpi_operand_object *acpi_ut_create_package_object(u32 count);
369
370union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
371
372union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
373
374acpi_status
375acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length);
376
377/*
378 * utstate - Generic state creation/cache routines
379 */
380void
381acpi_ut_push_generic_state(union acpi_generic_state **list_head,
382 union acpi_generic_state *state);
383
384union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
385 **list_head);
386
387union acpi_generic_state *acpi_ut_create_generic_state(void);
388
389struct acpi_thread_state *acpi_ut_create_thread_state(void);
390
391union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
392 *object, u16 action);
393
394union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
395 void *external_object,
396 u16 index);
397
398acpi_status
399acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
400 u16 action,
401 union acpi_generic_state **state_list);
402
403#ifdef ACPI_FUTURE_USAGE
404acpi_status
405acpi_ut_create_pkg_state_and_push(void *internal_object,
406 void *external_object,
407 u16 index,
408 union acpi_generic_state **state_list);
409#endif /* ACPI_FUTURE_USAGE */
410
411union acpi_generic_state *acpi_ut_create_control_state(void);
412
413void acpi_ut_delete_generic_state(union acpi_generic_state *state);
414
415/*
416 * utmath
417 */
418acpi_status
419acpi_ut_divide(acpi_integer in_dividend,
420 acpi_integer in_divisor,
421 acpi_integer * out_quotient, acpi_integer * out_remainder);
422
423acpi_status
424acpi_ut_short_divide(acpi_integer in_dividend,
425 u32 divisor,
426 acpi_integer * out_quotient, u32 * out_remainder);
427
428/*
429 * utmisc
430 */
431const char *acpi_ut_validate_exception(acpi_status status);
432
433u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
434
435acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
436
437void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
438
439acpi_status
440acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
441 void *target_object,
442 acpi_pkg_callback walk_callback, void *context);
443
444void acpi_ut_strupr(char *src_string);
445
446void acpi_ut_print_string(char *string, u8 max_length);
447
448u8 acpi_ut_valid_acpi_name(u32 name);
449
450acpi_name acpi_ut_repair_name(char *name);
451
452u8 acpi_ut_valid_acpi_char(char character, u32 position);
453
454acpi_status
455acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
456
457/* Values for Base above (16=Hex, 10=Decimal) */
458
459#define ACPI_ANY_BASE 0
460
461u32 acpi_ut_dword_byte_swap(u32 value);
462
463void acpi_ut_set_integer_width(u8 revision);
464
465#ifdef ACPI_DEBUG_OUTPUT
466void
467acpi_ut_display_init_pathname(u8 type,
468 struct acpi_namespace_node *obj_handle,
469 char *path);
470#endif
471
472/*
473 * utresrc
474 */
475acpi_status
476acpi_ut_walk_aml_resources(u8 * aml,
477 acpi_size aml_length,
478 acpi_walk_aml_callback user_function,
479 void **context);
480
481acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index);
482
483u32 acpi_ut_get_descriptor_length(void *aml);
484
485u16 acpi_ut_get_resource_length(void *aml);
486
487u8 acpi_ut_get_resource_header_length(void *aml);
488
489u8 acpi_ut_get_resource_type(void *aml);
490
491acpi_status
492acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc,
493 u8 ** end_tag);
494
495/*
496 * utmutex - mutex support
497 */
498acpi_status acpi_ut_mutex_initialize(void);
499
500void acpi_ut_mutex_terminate(void);
501
502acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id);
503
504acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id);
505
506/*
507 * utalloc - memory allocation and object caching
508 */
509acpi_status acpi_ut_create_caches(void);
510
511acpi_status acpi_ut_delete_caches(void);
512
513acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer);
514
515acpi_status
516acpi_ut_initialize_buffer(struct acpi_buffer *buffer,
517 acpi_size required_length);
518
519void *acpi_ut_allocate(acpi_size size,
520 u32 component, const char *module, u32 line);
521
522void *acpi_ut_allocate_zeroed(acpi_size size,
523 u32 component, const char *module, u32 line);
524
525#ifdef ACPI_DBG_TRACK_ALLOCATIONS
526void *acpi_ut_allocate_and_track(acpi_size size,
527 u32 component, const char *module, u32 line);
528
529void *acpi_ut_allocate_zeroed_and_track(acpi_size size,
530 u32 component,
531 const char *module, u32 line);
532
533void
534acpi_ut_free_and_track(void *address,
535 u32 component, const char *module, u32 line);
536
537#ifdef ACPI_FUTURE_USAGE
538void acpi_ut_dump_allocation_info(void);
539#endif /* ACPI_FUTURE_USAGE */
540
541void acpi_ut_dump_allocations(u32 component, const char *module);
542
543acpi_status
544acpi_ut_create_list(char *list_name,
545 u16 object_size, struct acpi_memory_list **return_cache);
546
547#endif
548
549#endif /* _ACUTILS_H */
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
new file mode 100644
index 000000000000..ff851c5df698
--- /dev/null
+++ b/drivers/acpi/acpica/amlcode.h
@@ -0,0 +1,494 @@
1/******************************************************************************
2 *
3 * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
4 * Declarations and definitions contained herein are derived
5 * directly from the ACPI specification.
6 *
7 *****************************************************************************/
8
9/*
10 * Copyright (C) 2000 - 2008, Intel Corp.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions, and the following disclaimer,
18 * without modification.
19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20 * substantially similar to the "NO WARRANTY" disclaimer below
21 * ("Disclaimer") and any redistribution must be conditioned upon
22 * including a substantially similar Disclaimer requirement for further
23 * binary redistribution.
24 * 3. Neither the names of the above-listed copyright holders nor the names
25 * of any contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * Alternatively, this software may be distributed under the terms of the
29 * GNU General Public License ("GPL") version 2 as published by the Free
30 * Software Foundation.
31 *
32 * NO WARRANTY
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGES.
44 */
45
46#ifndef __AMLCODE_H__
47#define __AMLCODE_H__
48
49/* primary opcodes */
50
51#define AML_NULL_CHAR (u16) 0x00
52
53#define AML_ZERO_OP (u16) 0x00
54#define AML_ONE_OP (u16) 0x01
55#define AML_UNASSIGNED (u16) 0x02
56#define AML_ALIAS_OP (u16) 0x06
57#define AML_NAME_OP (u16) 0x08
58#define AML_BYTE_OP (u16) 0x0a
59#define AML_WORD_OP (u16) 0x0b
60#define AML_DWORD_OP (u16) 0x0c
61#define AML_STRING_OP (u16) 0x0d
62#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */
63#define AML_SCOPE_OP (u16) 0x10
64#define AML_BUFFER_OP (u16) 0x11
65#define AML_PACKAGE_OP (u16) 0x12
66#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */
67#define AML_METHOD_OP (u16) 0x14
68#define AML_DUAL_NAME_PREFIX (u16) 0x2e
69#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f
70#define AML_NAME_CHAR_SUBSEQ (u16) 0x30
71#define AML_NAME_CHAR_FIRST (u16) 0x41
72#define AML_EXTENDED_OP_PREFIX (u16) 0x5b
73#define AML_ROOT_PREFIX (u16) 0x5c
74#define AML_PARENT_PREFIX (u16) 0x5e
75#define AML_LOCAL_OP (u16) 0x60
76#define AML_LOCAL0 (u16) 0x60
77#define AML_LOCAL1 (u16) 0x61
78#define AML_LOCAL2 (u16) 0x62
79#define AML_LOCAL3 (u16) 0x63
80#define AML_LOCAL4 (u16) 0x64
81#define AML_LOCAL5 (u16) 0x65
82#define AML_LOCAL6 (u16) 0x66
83#define AML_LOCAL7 (u16) 0x67
84#define AML_ARG_OP (u16) 0x68
85#define AML_ARG0 (u16) 0x68
86#define AML_ARG1 (u16) 0x69
87#define AML_ARG2 (u16) 0x6a
88#define AML_ARG3 (u16) 0x6b
89#define AML_ARG4 (u16) 0x6c
90#define AML_ARG5 (u16) 0x6d
91#define AML_ARG6 (u16) 0x6e
92#define AML_STORE_OP (u16) 0x70
93#define AML_REF_OF_OP (u16) 0x71
94#define AML_ADD_OP (u16) 0x72
95#define AML_CONCAT_OP (u16) 0x73
96#define AML_SUBTRACT_OP (u16) 0x74
97#define AML_INCREMENT_OP (u16) 0x75
98#define AML_DECREMENT_OP (u16) 0x76
99#define AML_MULTIPLY_OP (u16) 0x77
100#define AML_DIVIDE_OP (u16) 0x78
101#define AML_SHIFT_LEFT_OP (u16) 0x79
102#define AML_SHIFT_RIGHT_OP (u16) 0x7a
103#define AML_BIT_AND_OP (u16) 0x7b
104#define AML_BIT_NAND_OP (u16) 0x7c
105#define AML_BIT_OR_OP (u16) 0x7d
106#define AML_BIT_NOR_OP (u16) 0x7e
107#define AML_BIT_XOR_OP (u16) 0x7f
108#define AML_BIT_NOT_OP (u16) 0x80
109#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81
110#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82
111#define AML_DEREF_OF_OP (u16) 0x83
112#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */
113#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */
114#define AML_NOTIFY_OP (u16) 0x86
115#define AML_SIZE_OF_OP (u16) 0x87
116#define AML_INDEX_OP (u16) 0x88
117#define AML_MATCH_OP (u16) 0x89
118#define AML_CREATE_DWORD_FIELD_OP (u16) 0x8a
119#define AML_CREATE_WORD_FIELD_OP (u16) 0x8b
120#define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c
121#define AML_CREATE_BIT_FIELD_OP (u16) 0x8d
122#define AML_TYPE_OP (u16) 0x8e
123#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */
124#define AML_LAND_OP (u16) 0x90
125#define AML_LOR_OP (u16) 0x91
126#define AML_LNOT_OP (u16) 0x92
127#define AML_LEQUAL_OP (u16) 0x93
128#define AML_LGREATER_OP (u16) 0x94
129#define AML_LLESS_OP (u16) 0x95
130#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */
131#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */
132#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */
133#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */
134#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */
135#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */
136#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */
137#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */
138#define AML_IF_OP (u16) 0xa0
139#define AML_ELSE_OP (u16) 0xa1
140#define AML_WHILE_OP (u16) 0xa2
141#define AML_NOOP_OP (u16) 0xa3
142#define AML_RETURN_OP (u16) 0xa4
143#define AML_BREAK_OP (u16) 0xa5
144#define AML_BREAK_POINT_OP (u16) 0xcc
145#define AML_ONES_OP (u16) 0xff
146
147/* prefixed opcodes */
148
149#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */
150
151#define AML_MUTEX_OP (u16) 0x5b01
152#define AML_EVENT_OP (u16) 0x5b02
153#define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10
154#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11
155#define AML_COND_REF_OF_OP (u16) 0x5b12
156#define AML_CREATE_FIELD_OP (u16) 0x5b13
157#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */
158#define AML_LOAD_OP (u16) 0x5b20
159#define AML_STALL_OP (u16) 0x5b21
160#define AML_SLEEP_OP (u16) 0x5b22
161#define AML_ACQUIRE_OP (u16) 0x5b23
162#define AML_SIGNAL_OP (u16) 0x5b24
163#define AML_WAIT_OP (u16) 0x5b25
164#define AML_RESET_OP (u16) 0x5b26
165#define AML_RELEASE_OP (u16) 0x5b27
166#define AML_FROM_BCD_OP (u16) 0x5b28
167#define AML_TO_BCD_OP (u16) 0x5b29
168#define AML_UNLOAD_OP (u16) 0x5b2a
169#define AML_REVISION_OP (u16) 0x5b30
170#define AML_DEBUG_OP (u16) 0x5b31
171#define AML_FATAL_OP (u16) 0x5b32
172#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */
173#define AML_REGION_OP (u16) 0x5b80
174#define AML_FIELD_OP (u16) 0x5b81
175#define AML_DEVICE_OP (u16) 0x5b82
176#define AML_PROCESSOR_OP (u16) 0x5b83
177#define AML_POWER_RES_OP (u16) 0x5b84
178#define AML_THERMAL_ZONE_OP (u16) 0x5b85
179#define AML_INDEX_FIELD_OP (u16) 0x5b86
180#define AML_BANK_FIELD_OP (u16) 0x5b87
181#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */
182
183/*
184 * Combination opcodes (actually two one-byte opcodes)
185 * Used by the disassembler and i_aSL compiler
186 */
187#define AML_LGREATEREQUAL_OP (u16) 0x9295
188#define AML_LLESSEQUAL_OP (u16) 0x9294
189#define AML_LNOTEQUAL_OP (u16) 0x9293
190
191/*
192 * Internal opcodes
193 * Use only "Unknown" AML opcodes, don't attempt to use
194 * any valid ACPI ASCII values (A-Z, 0-9, '-')
195 */
196#define AML_INT_NAMEPATH_OP (u16) 0x002d
197#define AML_INT_NAMEDFIELD_OP (u16) 0x0030
198#define AML_INT_RESERVEDFIELD_OP (u16) 0x0031
199#define AML_INT_ACCESSFIELD_OP (u16) 0x0032
200#define AML_INT_BYTELIST_OP (u16) 0x0033
201#define AML_INT_STATICSTRING_OP (u16) 0x0034
202#define AML_INT_METHODCALL_OP (u16) 0x0035
203#define AML_INT_RETURN_VALUE_OP (u16) 0x0036
204#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037
205
206#define ARG_NONE 0x0
207
208/*
209 * Argument types for the AML Parser
210 * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
211 * There can be up to 31 unique argument types
212 * Zero is reserved as end-of-list indicator
213 */
214#define ARGP_BYTEDATA 0x01
215#define ARGP_BYTELIST 0x02
216#define ARGP_CHARLIST 0x03
217#define ARGP_DATAOBJ 0x04
218#define ARGP_DATAOBJLIST 0x05
219#define ARGP_DWORDDATA 0x06
220#define ARGP_FIELDLIST 0x07
221#define ARGP_NAME 0x08
222#define ARGP_NAMESTRING 0x09
223#define ARGP_OBJLIST 0x0A
224#define ARGP_PKGLENGTH 0x0B
225#define ARGP_SUPERNAME 0x0C
226#define ARGP_TARGET 0x0D
227#define ARGP_TERMARG 0x0E
228#define ARGP_TERMLIST 0x0F
229#define ARGP_WORDDATA 0x10
230#define ARGP_QWORDDATA 0x11
231#define ARGP_SIMPLENAME 0x12
232
233/*
234 * Resolved argument types for the AML Interpreter
235 * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
236 * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
237 *
238 * Note1: These values are completely independent from the ACPI_TYPEs
239 * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
240 *
241 * Note2: If and when 5 bits becomes insufficient, it would probably be best
242 * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
243 */
244
245/* Single, simple types */
246
247#define ARGI_ANYTYPE 0x01 /* Don't care */
248#define ARGI_PACKAGE 0x02
249#define ARGI_EVENT 0x03
250#define ARGI_MUTEX 0x04
251#define ARGI_DDBHANDLE 0x05
252
253/* Interchangeable types (via implicit conversion) */
254
255#define ARGI_INTEGER 0x06
256#define ARGI_STRING 0x07
257#define ARGI_BUFFER 0x08
258#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */
259#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */
260
261/* Reference objects */
262
263#define ARGI_INTEGER_REF 0x0B
264#define ARGI_OBJECT_REF 0x0C
265#define ARGI_DEVICE_REF 0x0D
266#define ARGI_REFERENCE 0x0E
267#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */
268#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */
269#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */
270
271/* Multiple/complex types */
272
273#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator */
274#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */
275#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */
276#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */
277#define ARGI_DATAREFOBJ 0x16
278
279/* Note: types above can expand to 0x1F maximum */
280
281#define ARGI_INVALID_OPCODE 0xFFFFFFFF
282
283/*
284 * hash offsets
285 */
286#define AML_EXTOP_HASH_OFFSET 22
287#define AML_LNOT_HASH_OFFSET 19
288
289/*
290 * opcode groups and types
291 */
292#define OPGRP_NAMED 0x01
293#define OPGRP_FIELD 0x02
294#define OPGRP_BYTELIST 0x04
295
296/*
297 * Opcode information
298 */
299
300/* Opcode flags */
301
302#define AML_LOGICAL 0x0001
303#define AML_LOGICAL_NUMERIC 0x0002
304#define AML_MATH 0x0004
305#define AML_CREATE 0x0008
306#define AML_FIELD 0x0010
307#define AML_DEFER 0x0020
308#define AML_NAMED 0x0040
309#define AML_NSNODE 0x0080
310#define AML_NSOPCODE 0x0100
311#define AML_NSOBJECT 0x0200
312#define AML_HAS_RETVAL 0x0400
313#define AML_HAS_TARGET 0x0800
314#define AML_HAS_ARGS 0x1000
315#define AML_CONSTANT 0x2000
316#define AML_NO_OPERAND_RESOLVE 0x4000
317
318/* Convenient flag groupings */
319
320#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL
321#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */
322#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */
323#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET
324#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */
325#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */
326#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */
327#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */
328#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
329#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS
330#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
331#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL
332
333/*
334 * The opcode Type is used in a dispatch table, do not change
335 * without updating the table.
336 */
337#define AML_TYPE_EXEC_0A_0T_1R 0x00
338#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */
339#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */
340#define AML_TYPE_EXEC_1A_1T_0R 0x03
341#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */
342#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */
343#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */
344#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */
345#define AML_TYPE_EXEC_2A_2T_1R 0x08
346#define AML_TYPE_EXEC_3A_0T_0R 0x09
347#define AML_TYPE_EXEC_3A_1T_1R 0x0A
348#define AML_TYPE_EXEC_6A_0T_1R 0x0B
349/* End of types used in dispatch table */
350
351#define AML_TYPE_LITERAL 0x0B
352#define AML_TYPE_CONSTANT 0x0C
353#define AML_TYPE_METHOD_ARGUMENT 0x0D
354#define AML_TYPE_LOCAL_VARIABLE 0x0E
355#define AML_TYPE_DATA_TERM 0x0F
356
357/* Generic for an op that returns a value */
358
359#define AML_TYPE_METHOD_CALL 0x10
360
361/* Misc */
362
363#define AML_TYPE_CREATE_FIELD 0x11
364#define AML_TYPE_CREATE_OBJECT 0x12
365#define AML_TYPE_CONTROL 0x13
366#define AML_TYPE_NAMED_NO_OBJ 0x14
367#define AML_TYPE_NAMED_FIELD 0x15
368#define AML_TYPE_NAMED_SIMPLE 0x16
369#define AML_TYPE_NAMED_COMPLEX 0x17
370#define AML_TYPE_RETURN 0x18
371
372#define AML_TYPE_UNDEFINED 0x19
373#define AML_TYPE_BOGUS 0x1A
374
375/* AML Package Length encodings */
376
377#define ACPI_AML_PACKAGE_TYPE1 0x40
378#define ACPI_AML_PACKAGE_TYPE2 0x4000
379#define ACPI_AML_PACKAGE_TYPE3 0x400000
380#define ACPI_AML_PACKAGE_TYPE4 0x40000000
381
382/*
383 * Opcode classes
384 */
385#define AML_CLASS_EXECUTE 0x00
386#define AML_CLASS_CREATE 0x01
387#define AML_CLASS_ARGUMENT 0x02
388#define AML_CLASS_NAMED_OBJECT 0x03
389#define AML_CLASS_CONTROL 0x04
390#define AML_CLASS_ASCII 0x05
391#define AML_CLASS_PREFIX 0x06
392#define AML_CLASS_INTERNAL 0x07
393#define AML_CLASS_RETURN_VALUE 0x08
394#define AML_CLASS_METHOD_CALL 0x09
395#define AML_CLASS_UNKNOWN 0x0A
396
397/* Predefined Operation Region space_iDs */
398
399typedef enum {
400 REGION_MEMORY = 0,
401 REGION_IO,
402 REGION_PCI_CONFIG,
403 REGION_EC,
404 REGION_SMBUS,
405 REGION_CMOS,
406 REGION_PCI_BAR,
407 REGION_DATA_TABLE, /* Internal use only */
408 REGION_FIXED_HW = 0x7F
409} AML_REGION_TYPES;
410
411/* Comparison operation codes for match_op operator */
412
413typedef enum {
414 MATCH_MTR = 0,
415 MATCH_MEQ = 1,
416 MATCH_MLE = 2,
417 MATCH_MLT = 3,
418 MATCH_MGE = 4,
419 MATCH_MGT = 5
420} AML_MATCH_OPERATOR;
421
422#define MAX_MATCH_OPERATOR 5
423
424/*
425 * field_flags
426 *
427 * This byte is extracted from the AML and includes three separate
428 * pieces of information about the field:
429 * 1) The field access type
430 * 2) The field update rule
431 * 3) The lock rule for the field
432 *
433 * Bits 00 - 03 : access_type (any_acc, byte_acc, etc.)
434 * 04 : lock_rule (1 == Lock)
435 * 05 - 06 : update_rule
436 */
437#define AML_FIELD_ACCESS_TYPE_MASK 0x0F
438#define AML_FIELD_LOCK_RULE_MASK 0x10
439#define AML_FIELD_UPDATE_RULE_MASK 0x60
440
441/* 1) Field Access Types */
442
443typedef enum {
444 AML_FIELD_ACCESS_ANY = 0x00,
445 AML_FIELD_ACCESS_BYTE = 0x01,
446 AML_FIELD_ACCESS_WORD = 0x02,
447 AML_FIELD_ACCESS_DWORD = 0x03,
448 AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */
449 AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */
450} AML_ACCESS_TYPE;
451
452/* 2) Field Lock Rules */
453
454typedef enum {
455 AML_FIELD_LOCK_NEVER = 0x00,
456 AML_FIELD_LOCK_ALWAYS = 0x10
457} AML_LOCK_RULE;
458
459/* 3) Field Update Rules */
460
461typedef enum {
462 AML_FIELD_UPDATE_PRESERVE = 0x00,
463 AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20,
464 AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
465} AML_UPDATE_RULE;
466
467/*
468 * Field Access Attributes.
469 * This byte is extracted from the AML via the
470 * access_as keyword
471 */
472typedef enum {
473 AML_FIELD_ATTRIB_SMB_QUICK = 0x02,
474 AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04,
475 AML_FIELD_ATTRIB_SMB_BYTE = 0x06,
476 AML_FIELD_ATTRIB_SMB_WORD = 0x08,
477 AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A,
478 AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C,
479 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
480} AML_ACCESS_ATTRIBUTE;
481
482/* Bit fields in method_flags byte */
483
484#define AML_METHOD_ARG_COUNT 0x07
485#define AML_METHOD_SERIALIZED 0x08
486#define AML_METHOD_SYNCH_LEVEL 0xF0
487
488/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */
489
490#define AML_METHOD_INTERNAL_ONLY 0x01
491#define AML_METHOD_RESERVED1 0x02
492#define AML_METHOD_RESERVED2 0x04
493
494#endif /* __AMLCODE_H__ */
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
new file mode 100644
index 000000000000..7b070e42b7c5
--- /dev/null
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -0,0 +1,311 @@
1
2/******************************************************************************
3 *
4 * Module Name: amlresrc.h - AML resource descriptors
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45/* acpisrc:struct_defs -- for acpisrc conversion */
46
47#ifndef __AMLRESRC_H
48#define __AMLRESRC_H
49
50/*
51 * Resource descriptor tags, as defined in the ACPI specification.
52 * Used to symbolically reference fields within a descriptor.
53 */
54#define ACPI_RESTAG_ADDRESS "_ADR"
55#define ACPI_RESTAG_ALIGNMENT "_ALN"
56#define ACPI_RESTAG_ADDRESSSPACE "_ASI"
57#define ACPI_RESTAG_ACCESSSIZE "_ASZ"
58#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
59#define ACPI_RESTAG_BASEADDRESS "_BAS"
60#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
61#define ACPI_RESTAG_DECODE "_DEC"
62#define ACPI_RESTAG_DMA "_DMA"
63#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
64#define ACPI_RESTAG_GRANULARITY "_GRA"
65#define ACPI_RESTAG_INTERRUPT "_INT"
66#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
67#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
68#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
69#define ACPI_RESTAG_LENGTH "_LEN"
70#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
71#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
72#define ACPI_RESTAG_MAXADDR "_MAX"
73#define ACPI_RESTAG_MINADDR "_MIN"
74#define ACPI_RESTAG_MAXTYPE "_MAF"
75#define ACPI_RESTAG_MINTYPE "_MIF"
76#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
77#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
78#define ACPI_RESTAG_RANGETYPE "_RNG"
79#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
80#define ACPI_RESTAG_TRANSLATION "_TRA"
81#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
82#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
83#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */
84
85/* Default sizes for "small" resource descriptors */
86
87#define ASL_RDESC_IRQ_SIZE 0x02
88#define ASL_RDESC_DMA_SIZE 0x02
89#define ASL_RDESC_ST_DEPEND_SIZE 0x00
90#define ASL_RDESC_END_DEPEND_SIZE 0x00
91#define ASL_RDESC_IO_SIZE 0x07
92#define ASL_RDESC_FIXED_IO_SIZE 0x03
93#define ASL_RDESC_END_TAG_SIZE 0x01
94
95struct asl_resource_node {
96 u32 buffer_length;
97 void *buffer;
98 struct asl_resource_node *next;
99};
100
101/* Macros used to generate AML resource length fields */
102
103#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
104#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
105
106/*
107 * Resource descriptors defined in the ACPI specification.
108 *
109 * Packing/alignment must be BYTE because these descriptors
110 * are used to overlay the raw AML byte stream.
111 */
112#pragma pack(1)
113
114/*
115 * SMALL descriptors
116 */
117#define AML_RESOURCE_SMALL_HEADER_COMMON \
118 u8 descriptor_type;
119
120struct aml_resource_small_header {
121AML_RESOURCE_SMALL_HEADER_COMMON};
122
123struct aml_resource_irq {
124 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
125 u8 flags;
126};
127
128struct aml_resource_irq_noflags {
129 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
130};
131
132struct aml_resource_dma {
133 AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
134 u8 flags;
135};
136
137struct aml_resource_start_dependent {
138 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
139};
140
141struct aml_resource_start_dependent_noprio {
142AML_RESOURCE_SMALL_HEADER_COMMON};
143
144struct aml_resource_end_dependent {
145AML_RESOURCE_SMALL_HEADER_COMMON};
146
147struct aml_resource_io {
148 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
149 u16 minimum;
150 u16 maximum;
151 u8 alignment;
152 u8 address_length;
153};
154
155struct aml_resource_fixed_io {
156 AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
157 u8 address_length;
158};
159
160struct aml_resource_vendor_small {
161AML_RESOURCE_SMALL_HEADER_COMMON};
162
163struct aml_resource_end_tag {
164 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
165};
166
167/*
168 * LARGE descriptors
169 */
170#define AML_RESOURCE_LARGE_HEADER_COMMON \
171 u8 descriptor_type;\
172 u16 resource_length;
173
174struct aml_resource_large_header {
175AML_RESOURCE_LARGE_HEADER_COMMON};
176
177struct aml_resource_memory24 {
178 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
179 u16 minimum;
180 u16 maximum;
181 u16 alignment;
182 u16 address_length;
183};
184
185struct aml_resource_vendor_large {
186AML_RESOURCE_LARGE_HEADER_COMMON};
187
188struct aml_resource_memory32 {
189 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
190 u32 minimum;
191 u32 maximum;
192 u32 alignment;
193 u32 address_length;
194};
195
196struct aml_resource_fixed_memory32 {
197 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
198 u32 address;
199 u32 address_length;
200};
201
202#define AML_RESOURCE_ADDRESS_COMMON \
203 u8 resource_type; \
204 u8 flags; \
205 u8 specific_flags;
206
207struct aml_resource_address {
208AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
209
210struct aml_resource_extended_address64 {
211 AML_RESOURCE_LARGE_HEADER_COMMON
212 AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
213 u8 reserved;
214 u64 granularity;
215 u64 minimum;
216 u64 maximum;
217 u64 translation_offset;
218 u64 address_length;
219 u64 type_specific;
220};
221
222#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
223
224struct aml_resource_address64 {
225 AML_RESOURCE_LARGE_HEADER_COMMON
226 AML_RESOURCE_ADDRESS_COMMON u64 granularity;
227 u64 minimum;
228 u64 maximum;
229 u64 translation_offset;
230 u64 address_length;
231};
232
233struct aml_resource_address32 {
234 AML_RESOURCE_LARGE_HEADER_COMMON
235 AML_RESOURCE_ADDRESS_COMMON u32 granularity;
236 u32 minimum;
237 u32 maximum;
238 u32 translation_offset;
239 u32 address_length;
240};
241
242struct aml_resource_address16 {
243 AML_RESOURCE_LARGE_HEADER_COMMON
244 AML_RESOURCE_ADDRESS_COMMON u16 granularity;
245 u16 minimum;
246 u16 maximum;
247 u16 translation_offset;
248 u16 address_length;
249};
250
251struct aml_resource_extended_irq {
252 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
253 u8 interrupt_count;
254 u32 interrupts[1];
255 /* res_source_index, res_source optional fields follow */
256};
257
258struct aml_resource_generic_register {
259 AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
260 u8 bit_width;
261 u8 bit_offset;
262 u8 access_size; /* ACPI 3.0, was previously Reserved */
263 u64 address;
264};
265
266/* restore default alignment */
267
268#pragma pack()
269
270/* Union of all resource descriptors, so we can allocate the worst case */
271
272union aml_resource {
273 /* Descriptor headers */
274
275 u8 descriptor_type;
276 struct aml_resource_small_header small_header;
277 struct aml_resource_large_header large_header;
278
279 /* Small resource descriptors */
280
281 struct aml_resource_irq irq;
282 struct aml_resource_dma dma;
283 struct aml_resource_start_dependent start_dpf;
284 struct aml_resource_end_dependent end_dpf;
285 struct aml_resource_io io;
286 struct aml_resource_fixed_io fixed_io;
287 struct aml_resource_vendor_small vendor_small;
288 struct aml_resource_end_tag end_tag;
289
290 /* Large resource descriptors */
291
292 struct aml_resource_memory24 memory24;
293 struct aml_resource_generic_register generic_reg;
294 struct aml_resource_vendor_large vendor_large;
295 struct aml_resource_memory32 memory32;
296 struct aml_resource_fixed_memory32 fixed_memory32;
297 struct aml_resource_address16 address16;
298 struct aml_resource_address32 address32;
299 struct aml_resource_address64 address64;
300 struct aml_resource_extended_address64 ext_address64;
301 struct aml_resource_extended_irq extended_irq;
302
303 /* Utility overlays */
304
305 struct aml_resource_address address;
306 u32 dword_item;
307 u16 word_item;
308 u8 byte_item;
309};
310
311#endif
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/acpica/dsfield.c
index f988a5e7d2b4..53e27bc5a734 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -42,11 +42,12 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "amlcode.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include <acpi/acparser.h> 49#include "acnamesp.h"
50#include "acparser.h"
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsfield") 53ACPI_MODULE_NAME("dsfield")
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 949f7c75029e..eb144b13d8fa 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acdispat.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dsinit") 51ACPI_MODULE_NAME("dsinit")
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 279a5a60a0dd..14b8b8ed8023 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -42,11 +42,14 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "amlcode.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include "acnamesp.h"
50#ifdef ACPI_DISASSEMBLER
49#include <acpi/acdisasm.h> 51#include <acpi/acdisasm.h>
52#endif
50 53
51#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsmethod") 55ACPI_MODULE_NAME("dsmethod")
@@ -412,6 +415,9 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
412 415
413 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
414 status = obj_desc->method.implementation(next_walk_state); 417 status = obj_desc->method.implementation(next_walk_state);
418 if (status == AE_OK) {
419 status = AE_CTRL_TERMINATE;
420 }
415 } 421 }
416 422
417 return_ACPI_STATUS(status); 423 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index d03f81bd1bcb..da0f5468184c 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acdispat.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dsmthdat") 51ACPI_MODULE_NAME("dsmthdat")
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 4f08e599d07e..15c628e6aa00 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -42,11 +42,12 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acnamesp.h> 48#include "acdispat.h"
49#include <acpi/acinterp.h> 49#include "acnamesp.h"
50#include "acinterp.h"
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsobject") 53ACPI_MODULE_NAME("dsobject")
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 69fae5905bb8..0c3b4dd60e8a 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -43,13 +43,14 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acparser.h"
48#include <acpi/acdispat.h> 48#include "amlcode.h"
49#include <acpi/acinterp.h> 49#include "acdispat.h"
50#include <acpi/acnamesp.h> 50#include "acinterp.h"
51#include <acpi/acevents.h> 51#include "acnamesp.h"
52#include <acpi/actables.h> 52#include "acevents.h"
53#include "actables.h"
53 54
54#define _COMPONENT ACPI_DISPATCHER 55#define _COMPONENT ACPI_DISPATCHER
55ACPI_MODULE_NAME("dsopcode") 56ACPI_MODULE_NAME("dsopcode")
@@ -1140,10 +1141,29 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1140 op->common.aml_opcode, walk_state)); 1141 op->common.aml_opcode, walk_state));
1141 1142
1142 switch (op->common.aml_opcode) { 1143 switch (op->common.aml_opcode) {
1143 case AML_IF_OP:
1144 case AML_WHILE_OP: 1144 case AML_WHILE_OP:
1145 1145
1146 /* 1146 /*
1147 * If this is an additional iteration of a while loop, continue.
1148 * There is no need to allocate a new control state.
1149 */
1150 if (walk_state->control_state) {
1151 if (walk_state->control_state->control.aml_predicate_start
1152 == (walk_state->parser_state.aml - 1)) {
1153
1154 /* Reset the state to start-of-loop */
1155
1156 walk_state->control_state->common.state =
1157 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1158 break;
1159 }
1160 }
1161
1162 /*lint -fallthrough */
1163
1164 case AML_IF_OP:
1165
1166 /*
1147 * IF/WHILE: Create a new control state to manage these 1167 * IF/WHILE: Create a new control state to manage these
1148 * constructs. We need to manage these as a stack, in order 1168 * constructs. We need to manage these as a stack, in order
1149 * to handle nesting. 1169 * to handle nesting.
@@ -1243,13 +1263,36 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1243 1263
1244 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 1264 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1245 1265
1246 if (walk_state->control_state->common.value) { 1266 control_state = walk_state->control_state;
1267 if (control_state->common.value) {
1247 1268
1248 /* Predicate was true, go back and evaluate it again! */ 1269 /* Predicate was true, the body of the loop was just executed */
1249 1270
1271 /*
1272 * This loop counter mechanism allows the interpreter to escape
1273 * possibly infinite loops. This can occur in poorly written AML
1274 * when the hardware does not respond within a while loop and the
1275 * loop does not implement a timeout.
1276 */
1277 control_state->control.loop_count++;
1278 if (control_state->control.loop_count >
1279 ACPI_MAX_LOOP_ITERATIONS) {
1280 status = AE_AML_INFINITE_LOOP;
1281 break;
1282 }
1283
1284 /*
1285 * Go back and evaluate the predicate and maybe execute the loop
1286 * another time
1287 */
1250 status = AE_CTRL_PENDING; 1288 status = AE_CTRL_PENDING;
1289 walk_state->aml_last_while =
1290 control_state->control.aml_predicate_start;
1291 break;
1251 } 1292 }
1252 1293
1294 /* Predicate was false, terminate this while loop */
1295
1253 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 1296 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1254 "[WHILE_OP] termination! Op=%p\n", op)); 1297 "[WHILE_OP] termination! Op=%p\n", op));
1255 1298
@@ -1257,9 +1300,6 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1257 1300
1258 control_state = 1301 control_state =
1259 acpi_ut_pop_generic_state(&walk_state->control_state); 1302 acpi_ut_pop_generic_state(&walk_state->control_state);
1260
1261 walk_state->aml_last_while =
1262 control_state->control.aml_predicate_start;
1263 acpi_ut_delete_generic_state(control_state); 1303 acpi_ut_delete_generic_state(control_state);
1264 break; 1304 break;
1265 1305
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/acpica/dsutils.c
index b398982f0d8b..dabc23a46176 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -42,12 +42,13 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include <acpi/acdebug.h> 50#include "acnamesp.h"
51#include "acdebug.h"
51 52
52#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsutils") 54ACPI_MODULE_NAME("dsutils")
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 396fe12078cd..350e6656bc89 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -43,12 +43,13 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acparser.h"
48#include <acpi/acdispat.h> 48#include "amlcode.h"
49#include <acpi/acinterp.h> 49#include "acdispat.h"
50#include <acpi/acnamesp.h> 50#include "acinterp.h"
51#include <acpi/acdebug.h> 51#include "acnamesp.h"
52#include "acdebug.h"
52 53
53#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
54ACPI_MODULE_NAME("dswexec") 55ACPI_MODULE_NAME("dswexec")
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/acpica/dswload.c
index dff7a3e445a8..3023ceaa8d54 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -42,12 +42,13 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include <acpi/acevents.h> 50#include "acnamesp.h"
51#include "acevents.h"
51 52
52#ifdef ACPI_ASL_COMPILER 53#ifdef ACPI_ASL_COMPILER
53#include <acpi/acdisasm.h> 54#include <acpi/acdisasm.h>
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/acpica/dswscope.c
index 9e6073265873..908645e72f03 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include "acdispat.h"
46 47
47#define _COMPONENT ACPI_DISPATCHER 48#define _COMPONENT ACPI_DISPATCHER
48ACPI_MODULE_NAME("dswscope") 49ACPI_MODULE_NAME("dswscope")
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/acpica/dswstate.c
index b00d4af791aa..40f92bf7dce5 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "acdispat.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dswstate") 51ACPI_MODULE_NAME("dswstate")
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/acpica/evevent.c
index c56c5c6ea77b..803edd9e3f6a 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include "acevents.h"
46 47
47#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
48ACPI_MODULE_NAME("evevent") 49ACPI_MODULE_NAME("evevent")
@@ -72,8 +73,8 @@ acpi_status acpi_ev_initialize_events(void)
72 73
73 /* 74 /*
74 * Initialize the Fixed and General Purpose Events. This is done prior to 75 * Initialize the Fixed and General Purpose Events. This is done prior to
75 * enabling SCIs to prevent interrupts from occurring before the handlers are 76 * enabling SCIs to prevent interrupts from occurring before the handlers
76 * installed. 77 * are installed.
77 */ 78 */
78 status = acpi_ev_fixed_event_initialize(); 79 status = acpi_ev_fixed_event_initialize();
79 if (ACPI_FAILURE(status)) { 80 if (ACPI_FAILURE(status)) {
@@ -192,8 +193,8 @@ static acpi_status acpi_ev_fixed_event_initialize(void)
192 acpi_status status; 193 acpi_status status;
193 194
194 /* 195 /*
195 * Initialize the structure that keeps track of fixed event handlers 196 * Initialize the structure that keeps track of fixed event handlers and
196 * and enable the fixed events. 197 * enable the fixed events.
197 */ 198 */
198 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 199 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
199 acpi_gbl_fixed_event_handlers[i].handler = NULL; 200 acpi_gbl_fixed_event_handlers[i].handler = NULL;
@@ -237,7 +238,7 @@ u32 acpi_ev_fixed_event_detect(void)
237 238
238 /* 239 /*
239 * Read the fixed feature status and enable registers, as all the cases 240 * Read the fixed feature status and enable registers, as all the cases
240 * depend on their values. Ignore errors here. 241 * depend on their values. Ignore errors here.
241 */ 242 */
242 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 243 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status);
243 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 244 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
@@ -291,8 +292,8 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
291 status_register_id, 1); 292 status_register_id, 1);
292 293
293 /* 294 /*
294 * Make sure we've got a handler. If not, report an error. 295 * Make sure we've got a handler. If not, report an error. The event is
295 * The event is disabled to prevent further interrupts. 296 * disabled to prevent further interrupts.
296 */ 297 */
297 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 298 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
298 (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. 299 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/acpica/evgpe.c
index c5e53aae86f7..f345ced36477 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpe") 50ACPI_MODULE_NAME("evgpe")
@@ -125,7 +126,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
125 (1 << 126 (1 <<
126 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); 127 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
127 128
128 /* 1) Disable case. Simply clear all enable bits */ 129 /* 1) Disable case. Simply clear all enable bits */
129 130
130 if (type == ACPI_GPE_DISABLE) { 131 if (type == ACPI_GPE_DISABLE) {
131 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, 132 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
@@ -134,7 +135,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
134 return_ACPI_STATUS(AE_OK); 135 return_ACPI_STATUS(AE_OK);
135 } 136 }
136 137
137 /* 2) Enable case. Set/Clear the appropriate enable bits */ 138 /* 2) Enable case. Set/Clear the appropriate enable bits */
138 139
139 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 140 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
140 case ACPI_GPE_TYPE_WAKE: 141 case ACPI_GPE_TYPE_WAKE:
@@ -289,15 +290,13 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
289 */ 290 */
290 status = acpi_hw_low_disable_gpe(gpe_event_info); 291 status = acpi_hw_low_disable_gpe(gpe_event_info);
291 return_ACPI_STATUS(status); 292 return_ACPI_STATUS(status);
292
293 return_ACPI_STATUS(AE_OK);
294} 293}
295 294
296/******************************************************************************* 295/*******************************************************************************
297 * 296 *
298 * FUNCTION: acpi_ev_get_gpe_event_info 297 * FUNCTION: acpi_ev_get_gpe_event_info
299 * 298 *
300 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 299 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
301 * gpe_number - Raw GPE number 300 * gpe_number - Raw GPE number
302 * 301 *
303 * RETURN: A GPE event_info struct. NULL if not a valid GPE 302 * RETURN: A GPE event_info struct. NULL if not a valid GPE
@@ -374,7 +373,7 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
374 * 373 *
375 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 374 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
376 * 375 *
377 * DESCRIPTION: Detect if any GP events have occurred. This function is 376 * DESCRIPTION: Detect if any GP events have occurred. This function is
378 * executed at interrupt level. 377 * executed at interrupt level.
379 * 378 *
380 ******************************************************************************/ 379 ******************************************************************************/
@@ -402,8 +401,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
402 401
403 /* 402 /*
404 * We need to obtain the GPE lock for both the data structs and registers 403 * We need to obtain the GPE lock for both the data structs and registers
405 * Note: Not necessary to obtain the hardware lock, since the GPE registers 404 * Note: Not necessary to obtain the hardware lock, since the GPE
406 * are owned by the gpe_lock. 405 * registers are owned by the gpe_lock.
407 */ 406 */
408 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 407 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
409 408
@@ -412,9 +411,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
412 gpe_block = gpe_xrupt_list->gpe_block_list_head; 411 gpe_block = gpe_xrupt_list->gpe_block_list_head;
413 while (gpe_block) { 412 while (gpe_block) {
414 /* 413 /*
415 * Read all of the 8-bit GPE status and enable registers 414 * Read all of the 8-bit GPE status and enable registers in this GPE
416 * in this GPE block, saving all of them. 415 * block, saving all of them. Find all currently active GP events.
417 * Find all currently active GP events.
418 */ 416 */
419 for (i = 0; i < gpe_block->register_count; i++) { 417 for (i = 0; i < gpe_block->register_count; i++) {
420 418
@@ -425,10 +423,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
425 /* Read the Status Register */ 423 /* Read the Status Register */
426 424
427 status = 425 status =
428 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 426 acpi_read(&status_reg,
429 &status_reg, 427 &gpe_register_info->status_address);
430 &gpe_register_info->
431 status_address);
432 if (ACPI_FAILURE(status)) { 428 if (ACPI_FAILURE(status)) {
433 goto unlock_and_exit; 429 goto unlock_and_exit;
434 } 430 }
@@ -436,10 +432,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
436 /* Read the Enable Register */ 432 /* Read the Enable Register */
437 433
438 status = 434 status =
439 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 435 acpi_read(&enable_reg,
440 &enable_reg, 436 &gpe_register_info->enable_address);
441 &gpe_register_info->
442 enable_address);
443 if (ACPI_FAILURE(status)) { 437 if (ACPI_FAILURE(status)) {
444 goto unlock_and_exit; 438 goto unlock_and_exit;
445 } 439 }
@@ -529,8 +523,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
529 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); 523 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
530 524
531 /* 525 /*
532 * Take a snapshot of the GPE info for this level - we copy the 526 * Take a snapshot of the GPE info for this level - we copy the info to
533 * info to prevent a race condition with remove_handler/remove_block. 527 * prevent a race condition with remove_handler/remove_block.
534 */ 528 */
535 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, 529 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
536 sizeof(struct acpi_gpe_event_info)); 530 sizeof(struct acpi_gpe_event_info));
@@ -541,8 +535,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
541 } 535 }
542 536
543 /* 537 /*
544 * Must check for control method type dispatch one more 538 * Must check for control method type dispatch one more time to avoid a
545 * time to avoid race with ev_gpe_install_handler 539 * race with ev_gpe_install_handler
546 */ 540 */
547 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 541 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
548 ACPI_GPE_DISPATCH_METHOD) { 542 ACPI_GPE_DISPATCH_METHOD) {
@@ -586,8 +580,8 @@ static void acpi_ev_asynch_enable_gpe(void *context)
586 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 580 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
587 ACPI_GPE_LEVEL_TRIGGERED) { 581 ACPI_GPE_LEVEL_TRIGGERED) {
588 /* 582 /*
589 * GPE is level-triggered, we clear the GPE status bit after 583 * GPE is level-triggered, we clear the GPE status bit after handling
590 * handling the event. 584 * the event.
591 */ 585 */
592 status = acpi_hw_clear_gpe(gpe_event_info); 586 status = acpi_hw_clear_gpe(gpe_event_info);
593 if (ACPI_FAILURE(status)) { 587 if (ACPI_FAILURE(status)) {
@@ -626,7 +620,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
626 acpi_os_gpe_count(gpe_number); 620 acpi_os_gpe_count(gpe_number);
627 621
628 /* 622 /*
629 * If edge-triggered, clear the GPE status bit now. Note that 623 * If edge-triggered, clear the GPE status bit now. Note that
630 * level-triggered events are cleared after the GPE is serviced. 624 * level-triggered events are cleared after the GPE is serviced.
631 */ 625 */
632 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 626 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
@@ -652,7 +646,8 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
652 646
653 /* 647 /*
654 * Invoke the installed handler (at interrupt level) 648 * Invoke the installed handler (at interrupt level)
655 * Ignore return status for now. TBD: leave GPE disabled on error? 649 * Ignore return status for now.
650 * TBD: leave GPE disabled on error?
656 */ 651 */
657 (void)gpe_event_info->dispatch.handler->address(gpe_event_info-> 652 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
658 dispatch. 653 dispatch.
@@ -710,7 +705,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
710 gpe_number)); 705 gpe_number));
711 706
712 /* 707 /*
713 * Disable the GPE. The GPE will remain disabled until the ACPI 708 * Disable the GPE. The GPE will remain disabled until the ACPICA
714 * Core Subsystem is restarted, or a handler is installed. 709 * Core Subsystem is restarted, or a handler is installed.
715 */ 710 */
716 status = acpi_ev_disable_gpe(gpe_event_info); 711 status = acpi_ev_disable_gpe(gpe_event_info);
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 73c058e2f5c2..484cc0565d5b 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpeblk") 50ACPI_MODULE_NAME("evgpeblk")
@@ -124,6 +125,7 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
124 * FUNCTION: acpi_ev_walk_gpe_list 125 * FUNCTION: acpi_ev_walk_gpe_list
125 * 126 *
126 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block 127 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
128 * Context - Value passed to callback
127 * 129 *
128 * RETURN: Status 130 * RETURN: Status
129 * 131 *
@@ -131,7 +133,8 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
131 * 133 *
132 ******************************************************************************/ 134 ******************************************************************************/
133 135
134acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback) 136acpi_status
137acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context)
135{ 138{
136 struct acpi_gpe_block_info *gpe_block; 139 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 140 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
@@ -154,8 +157,13 @@ acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
154 157
155 /* One callback per GPE block */ 158 /* One callback per GPE block */
156 159
157 status = gpe_walk_callback(gpe_xrupt_info, gpe_block); 160 status =
161 gpe_walk_callback(gpe_xrupt_info, gpe_block,
162 context);
158 if (ACPI_FAILURE(status)) { 163 if (ACPI_FAILURE(status)) {
164 if (status == AE_CTRL_END) { /* Callback abort */
165 status = AE_OK;
166 }
159 goto unlock_and_exit; 167 goto unlock_and_exit;
160 } 168 }
161 169
@@ -186,7 +194,8 @@ acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
186 194
187acpi_status 195acpi_status
188acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 196acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
189 struct acpi_gpe_block_info *gpe_block) 197 struct acpi_gpe_block_info *gpe_block,
198 void *context)
190{ 199{
191 struct acpi_gpe_event_info *gpe_event_info; 200 struct acpi_gpe_event_info *gpe_event_info;
192 u32 i; 201 u32 i;
@@ -309,17 +318,17 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
309 (gpe_block->block_base_number + 318 (gpe_block->block_base_number +
310 (gpe_block->register_count * 8)))) { 319 (gpe_block->register_count * 8)))) {
311 /* 320 /*
312 * Not valid for this GPE block, just ignore it 321 * Not valid for this GPE block, just ignore it. However, it may be
313 * However, it may be valid for a different GPE block, since GPE0 and GPE1 322 * valid for a different GPE block, since GPE0 and GPE1 methods both
314 * methods both appear under \_GPE. 323 * appear under \_GPE.
315 */ 324 */
316 return_ACPI_STATUS(AE_OK); 325 return_ACPI_STATUS(AE_OK);
317 } 326 }
318 327
319 /* 328 /*
320 * Now we can add this information to the gpe_event_info block 329 * Now we can add this information to the gpe_event_info block for use
321 * for use during dispatch of this GPE. Default type is RUNTIME, although 330 * during dispatch of this GPE. Default type is RUNTIME, although this may
322 * this may change when the _PRW methods are executed later. 331 * change when the _PRW methods are executed later.
323 */ 332 */
324 gpe_event_info = 333 gpe_event_info =
325 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 334 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
@@ -394,8 +403,8 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
394 gpe_block = gpe_info->gpe_block; 403 gpe_block = gpe_info->gpe_block;
395 404
396 /* 405 /*
397 * The _PRW object must return a package, we are only interested 406 * The _PRW object must return a package, we are only interested in the
398 * in the first element 407 * first element
399 */ 408 */
400 obj_desc = pkg_desc->package.elements[0]; 409 obj_desc = pkg_desc->package.elements[0];
401 410
@@ -434,7 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
434 /* 443 /*
435 * Is this GPE within this block? 444 * Is this GPE within this block?
436 * 445 *
437 * TRUE iff these conditions are true: 446 * TRUE if and only if these conditions are true:
438 * 1) The GPE devices match. 447 * 1) The GPE devices match.
439 * 2) The GPE index(number) is within the range of the Gpe Block 448 * 2) The GPE index(number) is within the range of the Gpe Block
440 * associated with the GPE device. 449 * associated with the GPE device.
@@ -457,6 +466,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
457 if (ACPI_FAILURE(status)) { 466 if (ACPI_FAILURE(status)) {
458 goto cleanup; 467 goto cleanup;
459 } 468 }
469
460 status = 470 status =
461 acpi_ev_update_gpe_enable_masks(gpe_event_info, 471 acpi_ev_update_gpe_enable_masks(gpe_event_info,
462 ACPI_GPE_DISABLE); 472 ACPI_GPE_DISABLE);
@@ -476,9 +486,9 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
476 * RETURN: A GPE interrupt block 486 * RETURN: A GPE interrupt block
477 * 487 *
478 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 488 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
479 * block per unique interrupt level used for GPEs. 489 * block per unique interrupt level used for GPEs. Should be
480 * Should be called only when the GPE lists are semaphore locked 490 * called only when the GPE lists are semaphore locked and not
481 * and not subject to change. 491 * subject to change.
482 * 492 *
483 ******************************************************************************/ 493 ******************************************************************************/
484 494
@@ -608,8 +618,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
608 * 618 *
609 * FUNCTION: acpi_ev_install_gpe_block 619 * FUNCTION: acpi_ev_install_gpe_block
610 * 620 *
611 * PARAMETERS: gpe_block - New GPE block 621 * PARAMETERS: gpe_block - New GPE block
612 * interrupt_number - Xrupt to be associated with this GPE block 622 * interrupt_number - Xrupt to be associated with this
623 * GPE block
613 * 624 *
614 * RETURN: Status 625 * RETURN: Status
615 * 626 *
@@ -666,7 +677,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
666 * 677 *
667 * FUNCTION: acpi_ev_delete_gpe_block 678 * FUNCTION: acpi_ev_delete_gpe_block
668 * 679 *
669 * PARAMETERS: gpe_block - Existing GPE block 680 * PARAMETERS: gpe_block - Existing GPE block
670 * 681 *
671 * RETURN: Status 682 * RETURN: Status
672 * 683 *
@@ -688,7 +699,8 @@ acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
688 699
689 /* Disable all GPEs in this block */ 700 /* Disable all GPEs in this block */
690 701
691 status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block); 702 status =
703 acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL);
692 704
693 if (!gpe_block->previous && !gpe_block->next) { 705 if (!gpe_block->previous && !gpe_block->next) {
694 706
@@ -715,6 +727,9 @@ acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
715 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 727 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
716 } 728 }
717 729
730 acpi_current_gpe_count -=
731 gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH;
732
718 /* Free the gpe_block */ 733 /* Free the gpe_block */
719 734
720 ACPI_FREE(gpe_block->register_info); 735 ACPI_FREE(gpe_block->register_info);
@@ -786,9 +801,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
786 801
787 /* 802 /*
788 * Initialize the GPE Register and Event structures. A goal of these 803 * Initialize the GPE Register and Event structures. A goal of these
789 * tables is to hide the fact that there are two separate GPE register sets 804 * tables is to hide the fact that there are two separate GPE register
790 * in a given GPE hardware block, the status registers occupy the first half, 805 * sets in a given GPE hardware block, the status registers occupy the
791 * and the enable registers occupy the second half. 806 * first half, and the enable registers occupy the second half.
792 */ 807 */
793 this_register = gpe_register_info; 808 this_register = gpe_register_info;
794 this_event = gpe_event_info; 809 this_event = gpe_event_info;
@@ -816,10 +831,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
816 ACPI_GPE_REGISTER_WIDTH; 831 ACPI_GPE_REGISTER_WIDTH;
817 this_register->enable_address.bit_width = 832 this_register->enable_address.bit_width =
818 ACPI_GPE_REGISTER_WIDTH; 833 ACPI_GPE_REGISTER_WIDTH;
819 this_register->status_address.bit_offset = 834 this_register->status_address.bit_offset = 0;
820 ACPI_GPE_REGISTER_WIDTH; 835 this_register->enable_address.bit_offset = 0;
821 this_register->enable_address.bit_offset =
822 ACPI_GPE_REGISTER_WIDTH;
823 836
824 /* Init the event_info for each GPE within this register */ 837 /* Init the event_info for each GPE within this register */
825 838
@@ -832,18 +845,14 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
832 845
833 /* Disable all GPEs within this register */ 846 /* Disable all GPEs within this register */
834 847
835 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 848 status = acpi_write(0x00, &this_register->enable_address);
836 &this_register->
837 enable_address);
838 if (ACPI_FAILURE(status)) { 849 if (ACPI_FAILURE(status)) {
839 goto error_exit; 850 goto error_exit;
840 } 851 }
841 852
842 /* Clear any pending GPE events within this register */ 853 /* Clear any pending GPE events within this register */
843 854
844 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 855 status = acpi_write(0xFF, &this_register->status_address);
845 &this_register->
846 status_address);
847 if (ACPI_FAILURE(status)) { 856 if (ACPI_FAILURE(status)) {
848 goto error_exit; 857 goto error_exit;
849 } 858 }
@@ -956,6 +965,9 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
956 gpe_device->name.ascii, gpe_block->register_count, 965 gpe_device->name.ascii, gpe_block->register_count,
957 interrupt_number)); 966 interrupt_number));
958 967
968 /* Update global count of currently available GPEs */
969
970 acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH;
959 return_ACPI_STATUS(AE_OK); 971 return_ACPI_STATUS(AE_OK);
960} 972}
961 973
@@ -1055,7 +1067,7 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1055 1067
1056 /* Enable all valid runtime GPEs found above */ 1068 /* Enable all valid runtime GPEs found above */
1057 1069
1058 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); 1070 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block, NULL);
1059 if (ACPI_FAILURE(status)) { 1071 if (ACPI_FAILURE(status)) {
1060 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p", 1072 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p",
1061 gpe_block)); 1073 gpe_block));
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 1d5670be729a..5f893057bcc6 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -42,18 +42,15 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evmisc") 51ACPI_MODULE_NAME("evmisc")
51 52
52/* Pointer to FACS needed for the Global Lock */
53static struct acpi_table_facs *facs = NULL;
54
55/* Local prototypes */ 53/* Local prototypes */
56
57static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); 54static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
58 55
59static u32 acpi_ev_global_lock_handler(void *context); 56static u32 acpi_ev_global_lock_handler(void *context);
@@ -152,7 +149,9 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
152 break; 149 break;
153 150
154 default: 151 default:
152
155 /* All other types are not supported */ 153 /* All other types are not supported */
154
156 return (AE_TYPE); 155 return (AE_TYPE);
157 } 156 }
158 } 157 }
@@ -193,9 +192,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
193 acpi_ut_delete_generic_state(notify_info); 192 acpi_ut_delete_generic_state(notify_info);
194 } 193 }
195 } else { 194 } else {
196 /* 195 /* There is no notify handler (per-device or system) for this device */
197 * There is no notify handler (per-device or system) for this device. 196
198 */
199 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 197 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
200 "No notify handler for Notify (%4.4s, %X) node %p\n", 198 "No notify handler for Notify (%4.4s, %X) node %p\n",
201 acpi_ut_get_node_name(node), notify_value, 199 acpi_ut_get_node_name(node), notify_value,
@@ -229,9 +227,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
229 ACPI_FUNCTION_ENTRY(); 227 ACPI_FUNCTION_ENTRY();
230 228
231 /* 229 /*
232 * We will invoke a global notify handler if installed. 230 * We will invoke a global notify handler if installed. This is done
233 * This is done _before_ we invoke the per-device handler attached 231 * _before_ we invoke the per-device handler attached to the device.
234 * to the device.
235 */ 232 */
236 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) { 233 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
237 234
@@ -299,7 +296,7 @@ static u32 acpi_ev_global_lock_handler(void *context)
299 * If we don't get it now, it will be marked pending and we will 296 * If we don't get it now, it will be marked pending and we will
300 * take another interrupt when it becomes free. 297 * take another interrupt when it becomes free.
301 */ 298 */
302 ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired); 299 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
303 if (acquired) { 300 if (acquired) {
304 301
305 /* Got the lock, now wake all threads waiting for it */ 302 /* Got the lock, now wake all threads waiting for it */
@@ -336,34 +333,27 @@ acpi_status acpi_ev_init_global_lock_handler(void)
336 333
337 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); 334 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
338 335
339 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 336 /* Attempt installation of the global lock handler */
340 ACPI_CAST_INDIRECT_PTR(struct
341 acpi_table_header,
342 &facs));
343 if (ACPI_FAILURE(status)) {
344 return_ACPI_STATUS(status);
345 }
346 337
347 acpi_gbl_global_lock_present = TRUE;
348 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, 338 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
349 acpi_ev_global_lock_handler, 339 acpi_ev_global_lock_handler,
350 NULL); 340 NULL);
351 341
352 /* 342 /*
353 * If the global lock does not exist on this platform, the attempt 343 * If the global lock does not exist on this platform, the attempt to
354 * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) 344 * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick).
355 * Map to AE_OK, but mark global lock as not present. 345 * Map to AE_OK, but mark global lock as not present. Any attempt to
356 * Any attempt to actually use the global lock will be flagged 346 * actually use the global lock will be flagged with an error.
357 * with an error.
358 */ 347 */
359 if (status == AE_NO_HARDWARE_RESPONSE) { 348 if (status == AE_NO_HARDWARE_RESPONSE) {
360 ACPI_ERROR((AE_INFO, 349 ACPI_ERROR((AE_INFO,
361 "No response from Global Lock hardware, disabling lock")); 350 "No response from Global Lock hardware, disabling lock"));
362 351
363 acpi_gbl_global_lock_present = FALSE; 352 acpi_gbl_global_lock_present = FALSE;
364 status = AE_OK; 353 return_ACPI_STATUS(AE_OK);
365 } 354 }
366 355
356 acpi_gbl_global_lock_present = TRUE;
367 return_ACPI_STATUS(status); 357 return_ACPI_STATUS(status);
368} 358}
369 359
@@ -462,8 +452,8 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout)
462 } 452 }
463 453
464 /* 454 /*
465 * Make sure that a global lock actually exists. If not, just treat 455 * Make sure that a global lock actually exists. If not, just treat the
466 * the lock as a standard mutex. 456 * lock as a standard mutex.
467 */ 457 */
468 if (!acpi_gbl_global_lock_present) { 458 if (!acpi_gbl_global_lock_present) {
469 acpi_gbl_global_lock_acquired = TRUE; 459 acpi_gbl_global_lock_acquired = TRUE;
@@ -472,7 +462,7 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout)
472 462
473 /* Attempt to acquire the actual hardware lock */ 463 /* Attempt to acquire the actual hardware lock */
474 464
475 ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired); 465 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
476 if (acquired) { 466 if (acquired) {
477 467
478 /* We got the lock */ 468 /* We got the lock */
@@ -536,7 +526,7 @@ acpi_status acpi_ev_release_global_lock(void)
536 526
537 /* Allow any thread to release the lock */ 527 /* Allow any thread to release the lock */
538 528
539 ACPI_RELEASE_GLOBAL_LOCK(facs, pending); 529 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending);
540 530
541 /* 531 /*
542 * If the pending bit was set, we must write GBL_RLS to the control 532 * If the pending bit was set, we must write GBL_RLS to the control
@@ -582,8 +572,8 @@ void acpi_ev_terminate(void)
582 572
583 if (acpi_gbl_events_initialized) { 573 if (acpi_gbl_events_initialized) {
584 /* 574 /*
585 * Disable all event-related functionality. 575 * Disable all event-related functionality. In all cases, on error,
586 * In all cases, on error, print a message but obviously we don't abort. 576 * print a message but obviously we don't abort.
587 */ 577 */
588 578
589 /* Disable all fixed events */ 579 /* Disable all fixed events */
@@ -599,7 +589,7 @@ void acpi_ev_terminate(void)
599 589
600 /* Disable all GPEs in all GPE blocks */ 590 /* Disable all GPEs in all GPE blocks */
601 591
602 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); 592 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
603 593
604 /* Remove SCI handler */ 594 /* Remove SCI handler */
605 595
@@ -617,7 +607,7 @@ void acpi_ev_terminate(void)
617 607
618 /* Deallocate all handler objects installed within GPE info structs */ 608 /* Deallocate all handler objects installed within GPE info structs */
619 609
620 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers); 610 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers, NULL);
621 611
622 /* Return to original mode if necessary */ 612 /* Return to original mode if necessary */
623 613
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/acpica/evregion.c
index 236fbd1ca438..665c0887ab4d 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -42,22 +42,15 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evregion") 51ACPI_MODULE_NAME("evregion")
51#define ACPI_NUM_DEFAULT_SPACES 4
52static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
53 ACPI_ADR_SPACE_SYSTEM_MEMORY,
54 ACPI_ADR_SPACE_SYSTEM_IO,
55 ACPI_ADR_SPACE_PCI_CONFIG,
56 ACPI_ADR_SPACE_DATA_TABLE
57};
58 52
59/* Local prototypes */ 53/* Local prototypes */
60
61static acpi_status 54static acpi_status
62acpi_ev_reg_run(acpi_handle obj_handle, 55acpi_ev_reg_run(acpi_handle obj_handle,
63 u32 level, void *context, void **return_value); 56 u32 level, void *context, void **return_value);
@@ -66,6 +59,17 @@ static acpi_status
66acpi_ev_install_handler(acpi_handle obj_handle, 59acpi_ev_install_handler(acpi_handle obj_handle,
67 u32 level, void *context, void **return_value); 60 u32 level, void *context, void **return_value);
68 61
62/* These are the address spaces that will get default handlers */
63
64#define ACPI_NUM_DEFAULT_SPACES 4
65
66static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
67 ACPI_ADR_SPACE_SYSTEM_MEMORY,
68 ACPI_ADR_SPACE_SYSTEM_IO,
69 ACPI_ADR_SPACE_PCI_CONFIG,
70 ACPI_ADR_SPACE_DATA_TABLE
71};
72
69/******************************************************************************* 73/*******************************************************************************
70 * 74 *
71 * FUNCTION: acpi_ev_install_region_handlers 75 * FUNCTION: acpi_ev_install_region_handlers
@@ -91,18 +95,19 @@ acpi_status acpi_ev_install_region_handlers(void)
91 } 95 }
92 96
93 /* 97 /*
94 * All address spaces (PCI Config, EC, SMBus) are scope dependent 98 * All address spaces (PCI Config, EC, SMBus) are scope dependent and
95 * and registration must occur for a specific device. 99 * registration must occur for a specific device.
96 * 100 *
97 * In the case of the system memory and IO address spaces there is currently 101 * In the case of the system memory and IO address spaces there is
98 * no device associated with the address space. For these we use the root. 102 * currently no device associated with the address space. For these we
103 * use the root.
99 * 104 *
100 * We install the default PCI config space handler at the root so 105 * We install the default PCI config space handler at the root so that
101 * that this space is immediately available even though the we have 106 * this space is immediately available even though the we have not
102 * not enumerated all the PCI Root Buses yet. This is to conform 107 * enumerated all the PCI Root Buses yet. This is to conform to the ACPI
103 * to the ACPI specification which states that the PCI config 108 * specification which states that the PCI config space must be always
104 * space must be always available -- even though we are nowhere 109 * available -- even though we are nowhere near ready to find the PCI root
105 * near ready to find the PCI root buses at this point. 110 * buses at this point.
106 * 111 *
107 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler 112 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
108 * has already been installed (via acpi_install_address_space_handler). 113 * has already been installed (via acpi_install_address_space_handler).
@@ -160,12 +165,11 @@ acpi_status acpi_ev_initialize_op_regions(void)
160 return_ACPI_STATUS(status); 165 return_ACPI_STATUS(status);
161 } 166 }
162 167
163 /* 168 /* Run the _REG methods for op_regions in each default address space */
164 * Run the _REG methods for op_regions in each default address space
165 */
166 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
167 169
168 /* TBD: Make sure handler is the DEFAULT handler, otherwise 170 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
171 /*
172 * TBD: Make sure handler is the DEFAULT handler, otherwise
169 * _REG will have already been run. 173 * _REG will have already been run.
170 */ 174 */
171 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, 175 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
@@ -318,13 +322,13 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
318 } 322 }
319 323
320 /* 324 /*
321 * It may be the case that the region has never been initialized 325 * It may be the case that the region has never been initialized.
322 * Some types of regions require special init code 326 * Some types of regions require special init code
323 */ 327 */
324 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { 328 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
325 /* 329
326 * This region has not been initialized yet, do it 330 /* This region has not been initialized yet, do it */
327 */ 331
328 region_setup = handler_desc->address_space.setup; 332 region_setup = handler_desc->address_space.setup;
329 if (!region_setup) { 333 if (!region_setup) {
330 334
@@ -339,9 +343,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
339 } 343 }
340 344
341 /* 345 /*
342 * We must exit the interpreter because the region 346 * We must exit the interpreter because the region setup will
343 * setup will potentially execute control methods 347 * potentially execute control methods (for example, the _REG method
344 * (e.g., _REG method for this region) 348 * for this region)
345 */ 349 */
346 acpi_ex_exit_interpreter(); 350 acpi_ex_exit_interpreter();
347 351
@@ -364,9 +368,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
364 return_ACPI_STATUS(status); 368 return_ACPI_STATUS(status);
365 } 369 }
366 370
367 /* 371 /* Region initialization may have been completed by region_setup */
368 * Region initialization may have been completed by region_setup 372
369 */
370 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { 373 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
371 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; 374 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
372 375
@@ -521,8 +524,8 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
521 } 524 }
522 525
523 /* 526 /*
524 * If the region has been activated, call the setup handler 527 * If the region has been activated, call the setup handler with
525 * with the deactivate notification 528 * the deactivate notification
526 */ 529 */
527 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 530 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
528 region_setup = handler_obj->address_space.setup; 531 region_setup = handler_obj->address_space.setup;
@@ -668,8 +671,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
668 } 671 }
669 672
670 /* 673 /*
671 * We only care about regions.and objects 674 * We only care about regions and objects that are allowed to have
672 * that are allowed to have address space handlers 675 * address space handlers
673 */ 676 */
674 if ((node->type != ACPI_TYPE_DEVICE) && 677 if ((node->type != ACPI_TYPE_DEVICE) &&
675 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { 678 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
@@ -710,9 +713,9 @@ acpi_ev_install_handler(acpi_handle obj_handle,
710 /* 713 /*
711 * Since the object we found it on was a device, then it 714 * Since the object we found it on was a device, then it
712 * means that someone has already installed a handler for 715 * means that someone has already installed a handler for
713 * the branch of the namespace from this device on. Just 716 * the branch of the namespace from this device on. Just
714 * bail out telling the walk routine to not traverse this 717 * bail out telling the walk routine to not traverse this
715 * branch. This preserves the scoping rule for handlers. 718 * branch. This preserves the scoping rule for handlers.
716 */ 719 */
717 return (AE_CTRL_DEPTH); 720 return (AE_CTRL_DEPTH);
718 } 721 }
@@ -723,9 +726,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
723 } 726 }
724 727
725 /* 728 /*
726 * As long as the device didn't have a handler for this 729 * As long as the device didn't have a handler for this space we
727 * space we don't care about it. We just ignore it and 730 * don't care about it. We just ignore it and proceed.
728 * proceed.
729 */ 731 */
730 return (AE_OK); 732 return (AE_OK);
731 } 733 }
@@ -733,16 +735,14 @@ acpi_ev_install_handler(acpi_handle obj_handle,
733 /* Object is a Region */ 735 /* Object is a Region */
734 736
735 if (obj_desc->region.space_id != handler_obj->address_space.space_id) { 737 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
736 /* 738
737 * This region is for a different address space 739 /* This region is for a different address space, just ignore it */
738 * -- just ignore it 740
739 */
740 return (AE_OK); 741 return (AE_OK);
741 } 742 }
742 743
743 /* 744 /*
744 * Now we have a region and it is for the handler's address 745 * Now we have a region and it is for the handler's address space type.
745 * space type.
746 * 746 *
747 * First disconnect region for any previous handler (if any) 747 * First disconnect region for any previous handler (if any)
748 */ 748 */
@@ -786,9 +786,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
786 ACPI_FUNCTION_TRACE(ev_install_space_handler); 786 ACPI_FUNCTION_TRACE(ev_install_space_handler);
787 787
788 /* 788 /*
789 * This registration is valid for only the types below 789 * This registration is valid for only the types below and the root. This
790 * and the root. This is where the default handlers 790 * is where the default handlers get placed.
791 * get placed.
792 */ 791 */
793 if ((node->type != ACPI_TYPE_DEVICE) && 792 if ((node->type != ACPI_TYPE_DEVICE) &&
794 (node->type != ACPI_TYPE_PROCESSOR) && 793 (node->type != ACPI_TYPE_PROCESSOR) &&
@@ -848,8 +847,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
848 obj_desc = acpi_ns_get_attached_object(node); 847 obj_desc = acpi_ns_get_attached_object(node);
849 if (obj_desc) { 848 if (obj_desc) {
850 /* 849 /*
851 * The attached device object already exists. 850 * The attached device object already exists. Make sure the handler
852 * Make sure the handler is not already installed. 851 * is not already installed.
853 */ 852 */
854 handler_obj = obj_desc->device.handler; 853 handler_obj = obj_desc->device.handler;
855 854
@@ -864,8 +863,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
864 handler) { 863 handler) {
865 /* 864 /*
866 * It is (relatively) OK to attempt to install the SAME 865 * It is (relatively) OK to attempt to install the SAME
867 * handler twice. This can easily happen 866 * handler twice. This can easily happen with the
868 * with PCI_Config space. 867 * PCI_Config space.
869 */ 868 */
870 status = AE_SAME_HANDLER; 869 status = AE_SAME_HANDLER;
871 goto unlock_and_exit; 870 goto unlock_and_exit;
@@ -925,9 +924,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
925 /* 924 /*
926 * Install the handler 925 * Install the handler
927 * 926 *
928 * At this point there is no existing handler. 927 * At this point there is no existing handler. Just allocate the object
929 * Just allocate the object for the handler and link it 928 * for the handler and link it into the list.
930 * into the list.
931 */ 929 */
932 handler_obj = 930 handler_obj =
933 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); 931 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
@@ -1000,11 +998,10 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1000 ACPI_FUNCTION_TRACE(ev_execute_reg_methods); 998 ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
1001 999
1002 /* 1000 /*
1003 * Run all _REG methods for all Operation Regions for this 1001 * Run all _REG methods for all Operation Regions for this space ID. This
1004 * space ID. This is a separate walk in order to handle any 1002 * is a separate walk in order to handle any interdependencies between
1005 * interdependencies between regions and _REG methods. (i.e. handlers 1003 * regions and _REG methods. (i.e. handlers must be installed for all
1006 * must be installed for all regions of this Space ID before we 1004 * regions of this Space ID before we can run any _REG methods)
1007 * can run any _REG methods)
1008 */ 1005 */
1009 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 1006 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1010 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 1007 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
@@ -1042,8 +1039,8 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1042 } 1039 }
1043 1040
1044 /* 1041 /*
1045 * We only care about regions.and objects 1042 * We only care about regions.and objects that are allowed to have address
1046 * that are allowed to have address space handlers 1043 * space handlers
1047 */ 1044 */
1048 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { 1045 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1049 return (AE_OK); 1046 return (AE_OK);
@@ -1062,10 +1059,9 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1062 /* Object is a Region */ 1059 /* Object is a Region */
1063 1060
1064 if (obj_desc->region.space_id != space_id) { 1061 if (obj_desc->region.space_id != space_id) {
1065 /* 1062
1066 * This region is for a different address space 1063 /* This region is for a different address space, just ignore it */
1067 * -- just ignore it 1064
1068 */
1069 return (AE_OK); 1065 return (AE_OK);
1070 } 1066 }
1071 1067
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 6b94b38df07d..f3f1fb45c3dc 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evrgnini") 50ACPI_MODULE_NAME("evrgnini")
@@ -233,9 +234,9 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
233 if (ACPI_FAILURE(status)) { 234 if (ACPI_FAILURE(status)) {
234 if (status == AE_SAME_HANDLER) { 235 if (status == AE_SAME_HANDLER) {
235 /* 236 /*
236 * It is OK if the handler is already installed on the root 237 * It is OK if the handler is already installed on the
237 * bridge. Still need to return a context object for the 238 * root bridge. Still need to return a context object
238 * new PCI_Config operation region, however. 239 * for the new PCI_Config operation region, however.
239 */ 240 */
240 status = AE_OK; 241 status = AE_OK;
241 } else { 242 } else {
@@ -272,8 +273,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
272 } 273 }
273 274
274 /* 275 /*
275 * For PCI_Config space access, we need the segment, bus, 276 * For PCI_Config space access, we need the segment, bus, device and
276 * device and function numbers. Acquire them here. 277 * function numbers. Acquire them here.
277 * 278 *
278 * Find the parent device object. (This allows the operation region to be 279 * Find the parent device object. (This allows the operation region to be
279 * within a subscope under the device, such as a control method.) 280 * within a subscope under the device, such as a control method.)
@@ -289,16 +290,16 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
289 } 290 }
290 291
291 /* 292 /*
292 * Get the PCI device and function numbers from the _ADR object 293 * Get the PCI device and function numbers from the _ADR object contained
293 * contained in the parent's scope. 294 * in the parent's scope.
294 */ 295 */
295 status = 296 status =
296 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node, 297 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node,
297 &pci_value); 298 &pci_value);
298 299
299 /* 300 /*
300 * The default is zero, and since the allocation above zeroed 301 * The default is zero, and since the allocation above zeroed the data,
301 * the data, just do nothing on failure. 302 * just do nothing on failure.
302 */ 303 */
303 if (ACPI_SUCCESS(status)) { 304 if (ACPI_SUCCESS(status)) {
304 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value)); 305 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
@@ -382,9 +383,8 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
382 struct acpi_compatible_id_list *cid; 383 struct acpi_compatible_id_list *cid;
383 u32 i; 384 u32 i;
384 385
385 /* 386 /* Get the _HID and check for a PCI Root Bridge */
386 * Get the _HID and check for a PCI Root Bridge 387
387 */
388 status = acpi_ut_execute_HID(node, &hid); 388 status = acpi_ut_execute_HID(node, &hid);
389 if (ACPI_FAILURE(status)) { 389 if (ACPI_FAILURE(status)) {
390 return (FALSE); 390 return (FALSE);
@@ -394,10 +394,8 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
394 return (TRUE); 394 return (TRUE);
395 } 395 }
396 396
397 /* 397 /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */
398 * The _HID did not match. 398
399 * Get the _CID and check for a PCI Root Bridge
400 */
401 status = acpi_ut_execute_CID(node, &cid); 399 status = acpi_ut_execute_CID(node, &cid);
402 if (ACPI_FAILURE(status)) { 400 if (ACPI_FAILURE(status)) {
403 return (FALSE); 401 return (FALSE);
@@ -516,9 +514,9 @@ acpi_ev_default_region_setup(acpi_handle handle,
516 * Get the appropriate address space handler for a newly 514 * Get the appropriate address space handler for a newly
517 * created region. 515 * created region.
518 * 516 *
519 * This also performs address space specific initialization. For 517 * This also performs address space specific initialization. For
520 * example, PCI regions must have an _ADR object that contains 518 * example, PCI regions must have an _ADR object that contains
521 * a PCI address in the scope of the definition. This address is 519 * a PCI address in the scope of the definition. This address is
522 * required to perform an access to PCI config space. 520 * required to perform an access to PCI config space.
523 * 521 *
524 * MUTEX: Interpreter should be unlocked, because we may run the _REG 522 * MUTEX: Interpreter should be unlocked, because we may run the _REG
@@ -572,7 +570,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
572 if (ACPI_SUCCESS(status)) { 570 if (ACPI_SUCCESS(status)) {
573 /* 571 /*
574 * The _REG method is optional and there can be only one per region 572 * The _REG method is optional and there can be only one per region
575 * definition. This will be executed when the handler is attached 573 * definition. This will be executed when the handler is attached
576 * or removed 574 * or removed
577 */ 575 */
578 region_obj2->extra.method_REG = method_node; 576 region_obj2->extra.method_REG = method_node;
@@ -670,10 +668,8 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
670 } 668 }
671 } 669 }
672 670
673 /* 671 /* This node does not have the handler we need; Pop up one level */
674 * This node does not have the handler we need; 672
675 * Pop up one level
676 */
677 node = acpi_ns_get_parent_node(node); 673 node = acpi_ns_get_parent_node(node);
678 } 674 }
679 675
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/acpica/evsci.c
index 2a8b77877610..567b356c85af 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include "accommon.h"
47#include "acevents.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evsci") 50ACPI_MODULE_NAME("evsci")
@@ -115,10 +116,8 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
115 * if this interrupt handler is installed, ACPI is enabled. 116 * if this interrupt handler is installed, ACPI is enabled.
116 */ 117 */
117 118
118 /* 119 /* GPEs: Check for and dispatch any GPEs that have occurred */
119 * GPEs: 120
120 * Check for and dispatch any GPEs that have occurred
121 */
122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 121 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
123 122
124 return_UINT32(interrupt_handled); 123 return_UINT32(interrupt_handled);
@@ -158,11 +157,11 @@ u32 acpi_ev_install_sci_handler(void)
158 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not 157 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
159 * installed to begin with 158 * installed to begin with
160 * 159 *
161 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be 160 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
162 * taken. 161 * taken.
163 * 162 *
164 * Note: It doesn't seem important to disable all events or set the event 163 * Note: It doesn't seem important to disable all events or set the event
165 * enable registers to their original values. The OS should disable 164 * enable registers to their original values. The OS should disable
166 * the SCI interrupt level when the handler is removed, so no more 165 * the SCI interrupt level when the handler is removed, so no more
167 * events will come in. 166 * events will come in.
168 * 167 *
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/acpica/evxface.c
index 94a6efe020be..3aca9010a11e 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acevents.h> 46#include "acnamesp.h"
47#include <acpi/acinterp.h> 47#include "acevents.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxface") 51ACPI_MODULE_NAME("evxface")
@@ -267,7 +268,7 @@ acpi_install_notify_handler(acpi_handle device,
267 /* 268 /*
268 * Root Object: 269 * Root Object:
269 * Registering a notify handler on the root object indicates that the 270 * Registering a notify handler on the root object indicates that the
270 * caller wishes to receive notifications for all objects. Note that 271 * caller wishes to receive notifications for all objects. Note that
271 * only one <external> global handler can be regsitered (per notify type). 272 * only one <external> global handler can be regsitered (per notify type).
272 */ 273 */
273 if (device == ACPI_ROOT_OBJECT) { 274 if (device == ACPI_ROOT_OBJECT) {
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 73bfd6bf962f..35485e4b60a6 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -42,13 +42,19 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfevnt") 51ACPI_MODULE_NAME("evxfevnt")
51 52
53/* Local prototypes */
54acpi_status
55acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
56 struct acpi_gpe_block_info *gpe_block, void *context);
57
52/******************************************************************************* 58/*******************************************************************************
53 * 59 *
54 * FUNCTION: acpi_enable 60 * FUNCTION: acpi_enable
@@ -60,6 +66,7 @@ ACPI_MODULE_NAME("evxfevnt")
60 * DESCRIPTION: Transfers the system into ACPI mode. 66 * DESCRIPTION: Transfers the system into ACPI mode.
61 * 67 *
62 ******************************************************************************/ 68 ******************************************************************************/
69
63acpi_status acpi_enable(void) 70acpi_status acpi_enable(void)
64{ 71{
65 acpi_status status = AE_OK; 72 acpi_status status = AE_OK;
@@ -161,8 +168,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
161 } 168 }
162 169
163 /* 170 /*
164 * Enable the requested fixed event (by writing a one to the 171 * Enable the requested fixed event (by writing a one to the enable
165 * enable register bit) 172 * register bit)
166 */ 173 */
167 status = 174 status =
168 acpi_set_register(acpi_gbl_fixed_event_info[event]. 175 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -248,21 +255,15 @@ ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
248 * DESCRIPTION: Enable an ACPI event (general purpose) 255 * DESCRIPTION: Enable an ACPI event (general purpose)
249 * 256 *
250 ******************************************************************************/ 257 ******************************************************************************/
251acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) 258acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
252{ 259{
253 acpi_status status = AE_OK; 260 acpi_status status = AE_OK;
261 acpi_cpu_flags flags;
254 struct acpi_gpe_event_info *gpe_event_info; 262 struct acpi_gpe_event_info *gpe_event_info;
255 263
256 ACPI_FUNCTION_TRACE(acpi_enable_gpe); 264 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
257 265
258 /* Use semaphore lock if not executing at interrupt level */ 266 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
259
260 if (flags & ACPI_NOT_ISR) {
261 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
262 if (ACPI_FAILURE(status)) {
263 return_ACPI_STATUS(status);
264 }
265 }
266 267
267 /* Ensure that we have a valid GPE number */ 268 /* Ensure that we have a valid GPE number */
268 269
@@ -277,9 +278,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
277 status = acpi_ev_enable_gpe(gpe_event_info, TRUE); 278 status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
278 279
279 unlock_and_exit: 280 unlock_and_exit:
280 if (flags & ACPI_NOT_ISR) { 281 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
281 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
282 }
283 return_ACPI_STATUS(status); 282 return_ACPI_STATUS(status);
284} 283}
285 284
@@ -299,22 +298,15 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
299 * DESCRIPTION: Disable an ACPI event (general purpose) 298 * DESCRIPTION: Disable an ACPI event (general purpose)
300 * 299 *
301 ******************************************************************************/ 300 ******************************************************************************/
302acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) 301acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
303{ 302{
304 acpi_status status = AE_OK; 303 acpi_status status = AE_OK;
304 acpi_cpu_flags flags;
305 struct acpi_gpe_event_info *gpe_event_info; 305 struct acpi_gpe_event_info *gpe_event_info;
306 306
307 ACPI_FUNCTION_TRACE(acpi_disable_gpe); 307 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
308 308
309 /* Use semaphore lock if not executing at interrupt level */ 309 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
310
311 if (flags & ACPI_NOT_ISR) {
312 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
313 if (ACPI_FAILURE(status)) {
314 return_ACPI_STATUS(status);
315 }
316 }
317
318 /* Ensure that we have a valid GPE number */ 310 /* Ensure that we have a valid GPE number */
319 311
320 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 312 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
@@ -325,10 +317,8 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
325 317
326 status = acpi_ev_disable_gpe(gpe_event_info); 318 status = acpi_ev_disable_gpe(gpe_event_info);
327 319
328 unlock_and_exit: 320unlock_and_exit:
329 if (flags & ACPI_NOT_ISR) { 321 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
330 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
331 }
332 return_ACPI_STATUS(status); 322 return_ACPI_STATUS(status);
333} 323}
334 324
@@ -360,8 +350,8 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
360 } 350 }
361 351
362 /* 352 /*
363 * Disable the requested fixed event (by writing a zero to the 353 * Disable the requested fixed event (by writing a zero to the enable
364 * enable register bit) 354 * register bit)
365 */ 355 */
366 status = 356 status =
367 acpi_set_register(acpi_gbl_fixed_event_info[event]. 357 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -413,8 +403,8 @@ acpi_status acpi_clear_event(u32 event)
413 } 403 }
414 404
415 /* 405 /*
416 * Clear the requested fixed event (By writing a one to the 406 * Clear the requested fixed event (By writing a one to the status
417 * status register bit) 407 * register bit)
418 */ 408 */
419 status = 409 status =
420 acpi_set_register(acpi_gbl_fixed_event_info[event]. 410 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -521,6 +511,9 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
521 if (value) 511 if (value)
522 *event_status |= ACPI_EVENT_FLAG_SET; 512 *event_status |= ACPI_EVENT_FLAG_SET;
523 513
514 if (acpi_gbl_fixed_event_handlers[event].handler)
515 *event_status |= ACPI_EVENT_FLAG_HANDLE;
516
524 return_ACPI_STATUS(status); 517 return_ACPI_STATUS(status);
525} 518}
526 519
@@ -571,6 +564,9 @@ acpi_get_gpe_status(acpi_handle gpe_device,
571 564
572 status = acpi_hw_get_gpe_status(gpe_event_info, event_status); 565 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
573 566
567 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
568 *event_status |= ACPI_EVENT_FLAG_HANDLE;
569
574 unlock_and_exit: 570 unlock_and_exit:
575 if (flags & ACPI_NOT_ISR) { 571 if (flags & ACPI_NOT_ISR) {
576 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 572 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
@@ -728,3 +724,148 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
728} 724}
729 725
730ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) 726ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
727
728/*******************************************************************************
729 *
730 * FUNCTION: acpi_get_gpe_device
731 *
732 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
733 * gpe_device - Where the parent GPE Device is returned
734 *
735 * RETURN: Status
736 *
737 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
738 * gpe device indicates that the gpe number is contained in one of
739 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
740 *
741 ******************************************************************************/
742acpi_status
743acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
744{
745 struct acpi_gpe_device_info info;
746 acpi_status status;
747
748 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
749
750 if (!gpe_device) {
751 return_ACPI_STATUS(AE_BAD_PARAMETER);
752 }
753
754 if (index >= acpi_current_gpe_count) {
755 return_ACPI_STATUS(AE_NOT_EXIST);
756 }
757
758 /* Setup and walk the GPE list */
759
760 info.index = index;
761 info.status = AE_NOT_EXIST;
762 info.gpe_device = NULL;
763 info.next_block_base_index = 0;
764
765 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
766 if (ACPI_FAILURE(status)) {
767 return_ACPI_STATUS(status);
768 }
769
770 *gpe_device = info.gpe_device;
771 return_ACPI_STATUS(info.status);
772}
773
774ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
775
776/*******************************************************************************
777 *
778 * FUNCTION: acpi_ev_get_gpe_device
779 *
780 * PARAMETERS: GPE_WALK_CALLBACK
781 *
782 * RETURN: Status
783 *
784 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
785 * block device. NULL if the GPE is one of the FADT-defined GPEs.
786 *
787 ******************************************************************************/
788acpi_status
789acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
790 struct acpi_gpe_block_info *gpe_block, void *context)
791{
792 struct acpi_gpe_device_info *info = context;
793
794 /* Increment Index by the number of GPEs in this block */
795
796 info->next_block_base_index +=
797 (gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH);
798
799 if (info->index < info->next_block_base_index) {
800 /*
801 * The GPE index is within this block, get the node. Leave the node
802 * NULL for the FADT-defined GPEs
803 */
804 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
805 info->gpe_device = gpe_block->node;
806 }
807
808 info->status = AE_OK;
809 return (AE_CTRL_END);
810 }
811
812 return (AE_OK);
813}
814
815/******************************************************************************
816 *
817 * FUNCTION: acpi_disable_all_gpes
818 *
819 * PARAMETERS: None
820 *
821 * RETURN: Status
822 *
823 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
824 *
825 ******************************************************************************/
826
827acpi_status acpi_disable_all_gpes(void)
828{
829 acpi_status status;
830
831 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
832
833 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
834 if (ACPI_FAILURE(status)) {
835 return_ACPI_STATUS(status);
836 }
837
838 status = acpi_hw_disable_all_gpes();
839 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
840
841 return_ACPI_STATUS(status);
842}
843
844/******************************************************************************
845 *
846 * FUNCTION: acpi_enable_all_runtime_gpes
847 *
848 * PARAMETERS: None
849 *
850 * RETURN: Status
851 *
852 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
853 *
854 ******************************************************************************/
855
856acpi_status acpi_enable_all_runtime_gpes(void)
857{
858 acpi_status status;
859
860 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
861
862 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
863 if (ACPI_FAILURE(status)) {
864 return_ACPI_STATUS(status);
865 }
866
867 status = acpi_hw_enable_all_runtime_gpes();
868 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
869
870 return_ACPI_STATUS(status);
871}
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index e8750807e57d..479e7a3721be 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acevents.h> 47#include "acnamesp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfregn") 51ACPI_MODULE_NAME("evxfregn")
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 74da6fa52ef1..932bbc26aa04 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acinterp.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include <acpi/acdispat.h> 48#include "actables.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exconfig") 52ACPI_MODULE_NAME("exconfig")
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 1d1f35adddde..0be10188316e 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exconvrt") 50ACPI_MODULE_NAME("exconvrt")
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/acpica/excreate.c
index ad09696d5069..a57ad2564ab0 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("excreate") 51ACPI_MODULE_NAME("excreate")
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/acpica/exdump.c
index d087a7d28aa5..aa313574b0df 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exdump") 51ACPI_MODULE_NAME("exdump")
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/acpica/exfield.c
index 3e440d84226a..a352d0233857 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acdispat.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exfield") 50ACPI_MODULE_NAME("exfield")
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 9ff9d1f4615d..ef58ac4e687b 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acevents.h> 47#include "amlcode.h"
48#include <acpi/acdispat.h> 48#include "acevents.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exfldio") 52ACPI_MODULE_NAME("exfldio")
@@ -498,14 +499,13 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
498 return_ACPI_STATUS(status); 499 return_ACPI_STATUS(status);
499 } 500 }
500 501
501 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
502 "I/O to Data Register: ValuePtr %p\n",
503 value));
504
505 if (read_write == ACPI_READ) { 502 if (read_write == ACPI_READ) {
506 503
507 /* Read the datum from the data_register */ 504 /* Read the datum from the data_register */
508 505
506 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
507 "Read from Data Register\n"));
508
509 status = 509 status =
510 acpi_ex_extract_from_field(obj_desc->index_field. 510 acpi_ex_extract_from_field(obj_desc->index_field.
511 data_obj, value, 511 data_obj, value,
@@ -513,6 +513,10 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
513 } else { 513 } else {
514 /* Write the datum to the data_register */ 514 /* Write the datum to the data_register */
515 515
516 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
517 "Write to Data Register: Value %8.8X%8.8X\n",
518 ACPI_FORMAT_UINT64(*value)));
519
516 status = 520 status =
517 acpi_ex_insert_into_field(obj_desc->index_field. 521 acpi_ex_insert_into_field(obj_desc->index_field.
518 data_obj, value, 522 data_obj, value,
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/acpica/exmisc.c
index efb191340059..6b0747ac683b 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include <acpi/amlresrc.h> 48#include "amlcode.h"
49#include "amlresrc.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exmisc") 52ACPI_MODULE_NAME("exmisc")
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/acpica/exmutex.c
index a8bf3d713e28..d301c1f363ef 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acevents.h> 47#include "acinterp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmutex") 51ACPI_MODULE_NAME("exmutex")
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/acpica/exnames.c
index 817e67be3697..ffdae122d94a 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include "amlcode.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exnames") 51ACPI_MODULE_NAME("exnames")
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index f622f9eac8a1..b530480cc7d5 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -43,11 +43,12 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/acdispat.h> 47#include "acparser.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/amlcode.h> 49#include "acinterp.h"
50#include <acpi/acnamesp.h> 50#include "amlcode.h"
51#include "acnamesp.h"
51 52
52#define _COMPONENT ACPI_EXECUTER 53#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exoparg1") 54ACPI_MODULE_NAME("exoparg1")
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 368def5dffce..0b4f513ca885 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acparser.h"
47#include <acpi/acevents.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acevents.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg2") 52ACPI_MODULE_NAME("exoparg2")
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 9cb4197681af..c6520bbf882b 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acparser.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg3") 52ACPI_MODULE_NAME("exoparg3")
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 67d48737af53..ae43f7670a6c 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acparser.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg6") 52ACPI_MODULE_NAME("exoparg6")
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/acpica/exprep.c
index 5d438c32989d..a226f74d4a5c 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include <acpi/acnamesp.h> 48#include "amlcode.h"
49#include "acnamesp.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exprep") 52ACPI_MODULE_NAME("exprep")
@@ -404,7 +405,7 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
404 * 405 *
405 * RETURN: Status 406 * RETURN: Status
406 * 407 *
407 * DESCRIPTION: Construct an union acpi_operand_object of type def_field and 408 * DESCRIPTION: Construct a union acpi_operand_object of type def_field and
408 * connect it to the parent Node. 409 * connect it to the parent Node.
409 * 410 *
410 ******************************************************************************/ 411 ******************************************************************************/
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/acpica/exregion.c
index 7a41c409ae4d..76ec8ff903b8 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exregion") 50ACPI_MODULE_NAME("exregion")
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 423ad3635f3d..a063a74006f6 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include "acnamesp.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exresnte") 52ACPI_MODULE_NAME("exresnte")
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/acpica/exresolv.c
index 89571b92a522..f6105a6d6126 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 46#include "accommon.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exresolv") 53ACPI_MODULE_NAME("exresolv")
@@ -146,7 +147,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
146 147
147 stack_desc = *stack_ptr; 148 stack_desc = *stack_ptr;
148 149
149 /* This is an union acpi_operand_object */ 150 /* This is a union acpi_operand_object */
150 151
151 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { 152 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) {
152 case ACPI_TYPE_LOCAL_REFERENCE: 153 case ACPI_TYPE_LOCAL_REFERENCE:
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/acpica/exresop.c
index 0bb82593da72..3c3802764bfb 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acparser.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exresop") 53ACPI_MODULE_NAME("exresop")
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/acpica/exstore.c
index 3318df4cbd98..e35e9b4f6a4e 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/amlcode.h> 48#include "acinterp.h"
49#include <acpi/acnamesp.h> 49#include "amlcode.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exstore") 53ACPI_MODULE_NAME("exstore")
@@ -274,7 +275,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
274 * 275 *
275 * PARAMETERS: *source_desc - Value to be stored 276 * PARAMETERS: *source_desc - Value to be stored
276 * *dest_desc - Where to store it. Must be an NS node 277 * *dest_desc - Where to store it. Must be an NS node
277 * or an union acpi_operand_object of type 278 * or a union acpi_operand_object of type
278 * Reference; 279 * Reference;
279 * walk_state - Current walk state 280 * walk_state - Current walk state
280 * 281 *
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/acpica/exstoren.c
index eef61a00803e..145d15305f70 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -44,8 +44,9 @@
44 */ 44 */
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 47#include "accommon.h"
48#include <acpi/amlcode.h> 48#include "acinterp.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exstoren") 52ACPI_MODULE_NAME("exstoren")
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 9a75ff09fb0c..67340cc70142 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exstorob") 50ACPI_MODULE_NAME("exstorob")
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 68990f1df371..3d00b9357233 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exsystem") 50ACPI_MODULE_NAME("exsystem")
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/acpica/exutils.c
index 86c03880b523..32b85d68e756 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -59,8 +59,9 @@
59#define DEFINE_AML_GLOBALS 59#define DEFINE_AML_GLOBALS
60 60
61#include <acpi/acpi.h> 61#include <acpi/acpi.h>
62#include <acpi/acinterp.h> 62#include "accommon.h"
63#include <acpi/amlcode.h> 63#include "acinterp.h"
64#include "amlcode.h"
64 65
65#define _COMPONENT ACPI_EXECUTER 66#define _COMPONENT ACPI_EXECUTER
66ACPI_MODULE_NAME("exutils") 67ACPI_MODULE_NAME("exutils")
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 816894ea839e..a9d4fea4167f 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h"
46 47
47#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
48ACPI_MODULE_NAME("hwacpi") 49ACPI_MODULE_NAME("hwacpi")
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 0b80db9d9197..2013b66745d2 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include "accommon.h"
47#include "acevents.h"
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwgpe") 50ACPI_MODULE_NAME("hwgpe")
@@ -51,7 +52,8 @@ ACPI_MODULE_NAME("hwgpe")
51/* Local prototypes */ 52/* Local prototypes */
52static acpi_status 53static acpi_status
53acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
54 struct acpi_gpe_block_info *gpe_block); 55 struct acpi_gpe_block_info *gpe_block,
56 void *context);
55 57
56/****************************************************************************** 58/******************************************************************************
57 * 59 *
@@ -80,8 +82,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
80 82
81 /* Get current value of the enable register that contains this GPE */ 83 /* Get current value of the enable register that contains this GPE */
82 84
83 status = acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, &enable_mask, 85 status = acpi_read(&enable_mask, &gpe_register_info->enable_address);
84 &gpe_register_info->enable_address);
85 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
86 return (status); 87 return (status);
87 } 88 }
@@ -95,9 +96,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
95 96
96 /* Write the updated enable mask */ 97 /* Write the updated enable mask */
97 98
98 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, enable_mask, 99 status = acpi_write(enable_mask, &gpe_register_info->enable_address);
99 &gpe_register_info->enable_address);
100
101 return (status); 100 return (status);
102} 101}
103 102
@@ -132,8 +131,8 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
132 131
133 /* Write the entire GPE (runtime) enable register */ 132 /* Write the entire GPE (runtime) enable register */
134 133
135 status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run, 134 status = acpi_write(gpe_register_info->enable_for_run,
136 &gpe_register_info->enable_address); 135 &gpe_register_info->enable_address);
137 136
138 return (status); 137 return (status);
139} 138}
@@ -166,9 +165,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
166 * Write a one to the appropriate bit in the status register to 165 * Write a one to the appropriate bit in the status register to
167 * clear this GPE. 166 * clear this GPE.
168 */ 167 */
169 status = acpi_hw_low_level_write(8, register_bit, 168 status = acpi_write(register_bit,
170 &gpe_event_info->register_info-> 169 &gpe_event_info->register_info->status_address);
171 status_address);
172 170
173 return (status); 171 return (status);
174} 172}
@@ -227,9 +225,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
227 225
228 /* GPE currently active (status bit == 1)? */ 226 /* GPE currently active (status bit == 1)? */
229 227
230 status = 228 status = acpi_read(&in_byte, &gpe_register_info->status_address);
231 acpi_hw_low_level_read(8, &in_byte,
232 &gpe_register_info->status_address);
233 if (ACPI_FAILURE(status)) { 229 if (ACPI_FAILURE(status)) {
234 goto unlock_and_exit; 230 goto unlock_and_exit;
235 } 231 }
@@ -260,8 +256,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
260 ******************************************************************************/ 256 ******************************************************************************/
261 257
262acpi_status 258acpi_status
263acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 259acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
264 struct acpi_gpe_block_info * gpe_block) 260 struct acpi_gpe_block_info *gpe_block, void *context)
265{ 261{
266 u32 i; 262 u32 i;
267 acpi_status status; 263 acpi_status status;
@@ -272,9 +268,9 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
272 268
273 /* Disable all GPEs in this register */ 269 /* Disable all GPEs in this register */
274 270
275 status = acpi_hw_low_level_write(8, 0x00, 271 status =
276 &gpe_block->register_info[i]. 272 acpi_write(0x00,
277 enable_address); 273 &gpe_block->register_info[i].enable_address);
278 if (ACPI_FAILURE(status)) { 274 if (ACPI_FAILURE(status)) {
279 return (status); 275 return (status);
280 } 276 }
@@ -297,8 +293,8 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
297 ******************************************************************************/ 293 ******************************************************************************/
298 294
299acpi_status 295acpi_status
300acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 296acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
301 struct acpi_gpe_block_info * gpe_block) 297 struct acpi_gpe_block_info *gpe_block, void *context)
302{ 298{
303 u32 i; 299 u32 i;
304 acpi_status status; 300 acpi_status status;
@@ -309,9 +305,9 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
309 305
310 /* Clear status on all GPEs in this register */ 306 /* Clear status on all GPEs in this register */
311 307
312 status = acpi_hw_low_level_write(8, 0xFF, 308 status =
313 &gpe_block->register_info[i]. 309 acpi_write(0xFF,
314 status_address); 310 &gpe_block->register_info[i].status_address);
315 if (ACPI_FAILURE(status)) { 311 if (ACPI_FAILURE(status)) {
316 return (status); 312 return (status);
317 } 313 }
@@ -335,8 +331,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
335 ******************************************************************************/ 331 ******************************************************************************/
336 332
337acpi_status 333acpi_status
338acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 334acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
339 struct acpi_gpe_block_info * gpe_block) 335 struct acpi_gpe_block_info *gpe_block, void *context)
340{ 336{
341 u32 i; 337 u32 i;
342 acpi_status status; 338 acpi_status status;
@@ -352,12 +348,9 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
352 348
353 /* Enable all "runtime" GPEs in this register */ 349 /* Enable all "runtime" GPEs in this register */
354 350
355 status = 351 status = acpi_write(gpe_block->register_info[i].enable_for_run,
356 acpi_hw_low_level_write(8, 352 &gpe_block->register_info[i].
357 gpe_block->register_info[i]. 353 enable_address);
358 enable_for_run,
359 &gpe_block->register_info[i].
360 enable_address);
361 if (ACPI_FAILURE(status)) { 354 if (ACPI_FAILURE(status)) {
362 return (status); 355 return (status);
363 } 356 }
@@ -382,7 +375,8 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
382 375
383static acpi_status 376static acpi_status
384acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 377acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
385 struct acpi_gpe_block_info *gpe_block) 378 struct acpi_gpe_block_info *gpe_block,
379 void *context)
386{ 380{
387 u32 i; 381 u32 i;
388 acpi_status status; 382 acpi_status status;
@@ -396,11 +390,9 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
396 390
397 /* Enable all "wake" GPEs in this register */ 391 /* Enable all "wake" GPEs in this register */
398 392
399 status = acpi_hw_low_level_write(8, 393 status = acpi_write(gpe_block->register_info[i].enable_for_wake,
400 gpe_block->register_info[i]. 394 &gpe_block->register_info[i].
401 enable_for_wake, 395 enable_address);
402 &gpe_block->register_info[i].
403 enable_address);
404 if (ACPI_FAILURE(status)) { 396 if (ACPI_FAILURE(status)) {
405 return (status); 397 return (status);
406 } 398 }
@@ -427,8 +419,8 @@ acpi_status acpi_hw_disable_all_gpes(void)
427 419
428 ACPI_FUNCTION_TRACE(hw_disable_all_gpes); 420 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
429 421
430 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); 422 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
431 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block); 423 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
432 return_ACPI_STATUS(status); 424 return_ACPI_STATUS(status);
433} 425}
434 426
@@ -450,7 +442,7 @@ acpi_status acpi_hw_enable_all_runtime_gpes(void)
450 442
451 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes); 443 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
452 444
453 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block); 445 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
454 return_ACPI_STATUS(status); 446 return_ACPI_STATUS(status);
455} 447}
456 448
@@ -472,6 +464,6 @@ acpi_status acpi_hw_enable_all_wakeup_gpes(void)
472 464
473 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes); 465 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
474 466
475 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block); 467 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
476 return_ACPI_STATUS(status); 468 return_ACPI_STATUS(status);
477} 469}
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
new file mode 100644
index 000000000000..4dc43b018517
--- /dev/null
+++ b/drivers/acpi/acpica/hwregs.c
@@ -0,0 +1,353 @@
1
2/*******************************************************************************
3 *
4 * Module Name: hwregs - Read/write access functions for the various ACPI
5 * control and status registers.
6 *
7 ******************************************************************************/
8
9/*
10 * Copyright (C) 2000 - 2008, Intel Corp.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions, and the following disclaimer,
18 * without modification.
19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20 * substantially similar to the "NO WARRANTY" disclaimer below
21 * ("Disclaimer") and any redistribution must be conditioned upon
22 * including a substantially similar Disclaimer requirement for further
23 * binary redistribution.
24 * 3. Neither the names of the above-listed copyright holders nor the names
25 * of any contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * Alternatively, this software may be distributed under the terms of the
29 * GNU General Public License ("GPL") version 2 as published by the Free
30 * Software Foundation.
31 *
32 * NO WARRANTY
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGES.
44 */
45
46#include <acpi/acpi.h>
47#include "accommon.h"
48#include "acnamesp.h"
49#include "acevents.h"
50
51#define _COMPONENT ACPI_HARDWARE
52ACPI_MODULE_NAME("hwregs")
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_hw_clear_acpi_status
57 *
58 * PARAMETERS: None
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Clears all fixed and general purpose status bits
63 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
64 *
65 ******************************************************************************/
66acpi_status acpi_hw_clear_acpi_status(void)
67{
68 acpi_status status;
69 acpi_cpu_flags lock_flags = 0;
70
71 ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
72
73 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n",
74 ACPI_BITMASK_ALL_FIXED_STATUS,
75 (u16) acpi_gbl_FADT.xpm1a_event_block.address));
76
77 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
78
79 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS);
81 if (ACPI_FAILURE(status)) {
82 goto unlock_and_exit;
83 }
84
85 /* Clear the fixed events */
86
87 if (acpi_gbl_FADT.xpm1b_event_block.address) {
88 status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS,
89 &acpi_gbl_FADT.xpm1b_event_block);
90 if (ACPI_FAILURE(status)) {
91 goto unlock_and_exit;
92 }
93 }
94
95 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
96
97 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
98
99 unlock_and_exit:
100 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
101 return_ACPI_STATUS(status);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_hw_get_register_bit_mask
107 *
108 * PARAMETERS: register_id - Index of ACPI Register to access
109 *
110 * RETURN: The bitmask to be used when accessing the register
111 *
112 * DESCRIPTION: Map register_id into a register bitmask.
113 *
114 ******************************************************************************/
115
116struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
117{
118 ACPI_FUNCTION_ENTRY();
119
120 if (register_id > ACPI_BITREG_MAX) {
121 ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X",
122 register_id));
123 return (NULL);
124 }
125
126 return (&acpi_gbl_bit_register_info[register_id]);
127}
128
129/******************************************************************************
130 *
131 * FUNCTION: acpi_hw_register_read
132 *
133 * PARAMETERS: register_id - ACPI Register ID
134 * return_value - Where the register value is returned
135 *
136 * RETURN: Status and the value read.
137 *
138 * DESCRIPTION: Read from the specified ACPI register
139 *
140 ******************************************************************************/
141acpi_status
142acpi_hw_register_read(u32 register_id, u32 * return_value)
143{
144 u32 value1 = 0;
145 u32 value2 = 0;
146 acpi_status status;
147
148 ACPI_FUNCTION_TRACE(hw_register_read);
149
150 switch (register_id) {
151 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
152
153 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block);
154 if (ACPI_FAILURE(status)) {
155 goto exit;
156 }
157
158 /* PM1B is optional */
159
160 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block);
161 value1 |= value2;
162 break;
163
164 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
165
166 status = acpi_read(&value1, &acpi_gbl_xpm1a_enable);
167 if (ACPI_FAILURE(status)) {
168 goto exit;
169 }
170
171 /* PM1B is optional */
172
173 status = acpi_read(&value2, &acpi_gbl_xpm1b_enable);
174 value1 |= value2;
175 break;
176
177 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
178
179 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block);
180 if (ACPI_FAILURE(status)) {
181 goto exit;
182 }
183
184 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block);
185 value1 |= value2;
186 break;
187
188 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
189
190 status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block);
191 break;
192
193 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
194
195 status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block);
196 break;
197
198 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
199
200 status =
201 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8);
202 break;
203
204 default:
205 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
206 status = AE_BAD_PARAMETER;
207 break;
208 }
209
210 exit:
211
212 if (ACPI_SUCCESS(status)) {
213 *return_value = value1;
214 }
215
216 return_ACPI_STATUS(status);
217}
218
219/******************************************************************************
220 *
221 * FUNCTION: acpi_hw_register_write
222 *
223 * PARAMETERS: register_id - ACPI Register ID
224 * Value - The value to write
225 *
226 * RETURN: Status
227 *
228 * DESCRIPTION: Write to the specified ACPI register
229 *
230 * NOTE: In accordance with the ACPI specification, this function automatically
231 * preserves the value of the following bits, meaning that these bits cannot be
232 * changed via this interface:
233 *
234 * PM1_CONTROL[0] = SCI_EN
235 * PM1_CONTROL[9]
236 * PM1_STATUS[11]
237 *
238 * ACPI References:
239 * 1) Hardware Ignored Bits: When software writes to a register with ignored
240 * bit fields, it preserves the ignored bit fields
241 * 2) SCI_EN: OSPM always preserves this bit position
242 *
243 ******************************************************************************/
244
245acpi_status acpi_hw_register_write(u32 register_id, u32 value)
246{
247 acpi_status status;
248 u32 read_value;
249
250 ACPI_FUNCTION_TRACE(hw_register_write);
251
252 switch (register_id) {
253 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
254
255 /* Perform a read first to preserve certain bits (per ACPI spec) */
256
257 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS,
258 &read_value);
259 if (ACPI_FAILURE(status)) {
260 goto exit;
261 }
262
263 /* Insert the bits to be preserved */
264
265 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
266 read_value);
267
268 /* Now we can write the data */
269
270 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block);
271 if (ACPI_FAILURE(status)) {
272 goto exit;
273 }
274
275 /* PM1B is optional */
276
277 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block);
278 break;
279
280 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
281
282 status = acpi_write(value, &acpi_gbl_xpm1a_enable);
283 if (ACPI_FAILURE(status)) {
284 goto exit;
285 }
286
287 /* PM1B is optional */
288
289 status = acpi_write(value, &acpi_gbl_xpm1b_enable);
290 break;
291
292 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
293
294 /*
295 * Perform a read first to preserve certain bits (per ACPI spec)
296 */
297 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
298 &read_value);
299 if (ACPI_FAILURE(status)) {
300 goto exit;
301 }
302
303 /* Insert the bits to be preserved */
304
305 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
306 read_value);
307
308 /* Now we can write the data */
309
310 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
311 if (ACPI_FAILURE(status)) {
312 goto exit;
313 }
314
315 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
316 break;
317
318 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
319
320 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
321 break;
322
323 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
324
325 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
326 break;
327
328 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
329
330 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
331 break;
332
333 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
334
335 status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
336 break;
337
338 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
339
340 /* SMI_CMD is currently always in IO space */
341
342 status =
343 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8);
344 break;
345
346 default:
347 status = AE_BAD_PARAMETER;
348 break;
349 }
350
351 exit:
352 return_ACPI_STATUS(status);
353}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 25dccdf179b9..a2af2a4f2f26 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/actables.h> 46#include "accommon.h"
47#include "actables.h"
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwsleep") 50ACPI_MODULE_NAME("hwsleep")
@@ -52,31 +53,19 @@ ACPI_MODULE_NAME("hwsleep")
52 * 53 *
53 * FUNCTION: acpi_set_firmware_waking_vector 54 * FUNCTION: acpi_set_firmware_waking_vector
54 * 55 *
55 * PARAMETERS: physical_address - Physical address of ACPI real mode 56 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
56 * entry point. 57 * entry point.
57 * 58 *
58 * RETURN: Status 59 * RETURN: Status
59 * 60 *
60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 61 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
61 * 62 *
62 ******************************************************************************/ 63 ******************************************************************************/
63acpi_status 64acpi_status
64acpi_set_firmware_waking_vector(acpi_physical_address physical_address) 65acpi_set_firmware_waking_vector(u32 physical_address)
65{ 66{
66 struct acpi_table_facs *facs;
67 acpi_status status;
68
69 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); 67 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
70 68
71 /* Get the FACS */
72
73 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
74 ACPI_CAST_INDIRECT_PTR(struct
75 acpi_table_header,
76 &facs));
77 if (ACPI_FAILURE(status)) {
78 return_ACPI_STATUS(status);
79 }
80 69
81 /* 70 /*
82 * According to the ACPI specification 2.0c and later, the 64-bit 71 * According to the ACPI specification 2.0c and later, the 64-bit
@@ -85,10 +74,16 @@ acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
85 * Protected Mode. Some systems (for example HP dv5-1004nr) are known 74 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
86 * to fail to resume if the 64-bit vector is used. 75 * to fail to resume if the 64-bit vector is used.
87 */ 76 */
88 if (facs->version >= 1)
89 facs->xfirmware_waking_vector = 0;
90 77
91 facs->firmware_waking_vector = (u32)physical_address; 78 /* Set the 32-bit vector */
79
80 acpi_gbl_FACS->firmware_waking_vector = physical_address;
81
82 /* Clear the 64-bit vector if it exists */
83
84 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
85 acpi_gbl_FACS->xfirmware_waking_vector = 0;
86 }
92 87
93 return_ACPI_STATUS(AE_OK); 88 return_ACPI_STATUS(AE_OK);
94} 89}
@@ -97,48 +92,39 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
97 92
98/******************************************************************************* 93/*******************************************************************************
99 * 94 *
100 * FUNCTION: acpi_get_firmware_waking_vector 95 * FUNCTION: acpi_set_firmware_waking_vector64
101 * 96 *
102 * PARAMETERS: *physical_address - Where the contents of 97 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
103 * the firmware_waking_vector field of 98 * mode entry point.
104 * the FACS will be returned.
105 * 99 *
106 * RETURN: Status, vector 100 * RETURN: Status
107 * 101 *
108 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 102 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
103 * it exists in the table.
109 * 104 *
110 ******************************************************************************/ 105 ******************************************************************************/
111#ifdef ACPI_FUTURE_USAGE
112acpi_status 106acpi_status
113acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) 107acpi_set_firmware_waking_vector64(u64 physical_address)
114{ 108{
115 struct acpi_table_facs *facs; 109 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
116 acpi_status status;
117 110
118 ACPI_FUNCTION_TRACE(acpi_get_firmware_waking_vector);
119
120 if (!physical_address) {
121 return_ACPI_STATUS(AE_BAD_PARAMETER);
122 }
123 111
124 /* Get the FACS */ 112 /* Determine if the 64-bit vector actually exists */
125 113
126 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 114 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
127 ACPI_CAST_INDIRECT_PTR(struct 115 return_ACPI_STATUS(AE_NOT_EXIST);
128 acpi_table_header,
129 &facs));
130 if (ACPI_FAILURE(status)) {
131 return_ACPI_STATUS(status);
132 } 116 }
133 117
134 /* Get the vector */ 118 /* Clear 32-bit vector, set the 64-bit X_ vector */
135 *physical_address = (acpi_physical_address)facs->firmware_waking_vector; 119
120 acpi_gbl_FACS->firmware_waking_vector = 0;
121 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
136 122
137 return_ACPI_STATUS(AE_OK); 123 return_ACPI_STATUS(AE_OK);
138} 124}
139 125
140ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector) 126ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
141#endif 127
142/******************************************************************************* 128/*******************************************************************************
143 * 129 *
144 * FUNCTION: acpi_enter_sleep_state_prep 130 * FUNCTION: acpi_enter_sleep_state_prep
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index b53d575491b9..b7f522c8f023 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h"
46 47
47#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
48ACPI_MODULE_NAME("hwtimer") 49ACPI_MODULE_NAME("hwtimer")
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/acpica/hwxface.c
index ddf792adcf96..ae597c0ab53f 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -1,10 +1,9 @@
1 1
2/******************************************************************************* 2/******************************************************************************
3 * 3 *
4 * Module Name: hwregs - Read/write access functions for the various ACPI 4 * Module Name: hwxface - Public ACPICA hardware interfaces
5 * control and status registers.
6 * 5 *
7 ******************************************************************************/ 6 *****************************************************************************/
8 7
9/* 8/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2008, Intel Corp.
@@ -44,209 +43,208 @@
44 */ 43 */
45 44
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include "accommon.h"
48#include <acpi/acevents.h> 47#include "acnamesp.h"
49 48
50#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwregs") 50ACPI_MODULE_NAME("hwxface")
52 51
53/******************************************************************************* 52/******************************************************************************
54 * 53 *
55 * FUNCTION: acpi_hw_clear_acpi_status 54 * FUNCTION: acpi_reset
56 * 55 *
57 * PARAMETERS: None 56 * PARAMETERS: None
58 * 57 *
59 * RETURN: None 58 * RETURN: Status
60 * 59 *
61 * DESCRIPTION: Clears all fixed and general purpose status bits 60 * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
62 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 61 * support reset register in PCI config space, this must be
62 * handled separately.
63 * 63 *
64 ******************************************************************************/ 64 ******************************************************************************/
65acpi_status acpi_hw_clear_acpi_status(void) 65acpi_status acpi_reset(void)
66{ 66{
67 struct acpi_generic_address *reset_reg;
67 acpi_status status; 68 acpi_status status;
68 acpi_cpu_flags lock_flags = 0;
69 69
70 ACPI_FUNCTION_TRACE(hw_clear_acpi_status); 70 ACPI_FUNCTION_TRACE(acpi_reset);
71 71
72 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", 72 reset_reg = &acpi_gbl_FADT.reset_register;
73 ACPI_BITMASK_ALL_FIXED_STATUS,
74 (u16) acpi_gbl_FADT.xpm1a_event_block.address));
75 73
76 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 74 /* Check if the reset register is supported */
77 75
78 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 76 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
79 ACPI_BITMASK_ALL_FIXED_STATUS); 77 !reset_reg->address) {
80 if (ACPI_FAILURE(status)) { 78 return_ACPI_STATUS(AE_NOT_EXIST);
81 goto unlock_and_exit;
82 } 79 }
83 80
84 /* Clear the fixed events */ 81 /* Write the reset value to the reset register */
85
86 if (acpi_gbl_FADT.xpm1b_event_block.address) {
87 status =
88 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
89 &acpi_gbl_FADT.xpm1b_event_block);
90 if (ACPI_FAILURE(status)) {
91 goto unlock_and_exit;
92 }
93 }
94
95 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
96
97 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
98 82
99 unlock_and_exit: 83 status = acpi_write(acpi_gbl_FADT.reset_value, reset_reg);
100 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
101 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
102} 85}
103 86
104/******************************************************************************* 87ACPI_EXPORT_SYMBOL(acpi_reset)
88
89/******************************************************************************
105 * 90 *
106 * FUNCTION: acpi_get_sleep_type_data 91 * FUNCTION: acpi_read
107 * 92 *
108 * PARAMETERS: sleep_state - Numeric sleep state 93 * PARAMETERS: Value - Where the value is returned
109 * *sleep_type_a - Where SLP_TYPa is returned 94 * Reg - GAS register structure
110 * *sleep_type_b - Where SLP_TYPb is returned
111 * 95 *
112 * RETURN: Status - ACPI status 96 * RETURN: Status
113 * 97 *
114 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep 98 * DESCRIPTION: Read from either memory or IO space.
115 * state.
116 * 99 *
117 ******************************************************************************/ 100 ******************************************************************************/
118 101acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
119acpi_status
120acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
121{ 102{
122 acpi_status status = AE_OK; 103 u32 width;
123 struct acpi_evaluate_info *info; 104 u64 address;
124 105 acpi_status status;
125 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
126
127 /* Validate parameters */
128
129 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
130 return_ACPI_STATUS(AE_BAD_PARAMETER);
131 }
132 106
133 /* Allocate the evaluation information block */ 107 ACPI_FUNCTION_NAME(acpi_read);
134 108
135 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); 109 /*
136 if (!info) { 110 * Must have a valid pointer to a GAS structure, and
137 return_ACPI_STATUS(AE_NO_MEMORY); 111 * a non-zero address within. However, don't return an error
112 * because the PM1A/B code must not fail if B isn't present.
113 */
114 if (!reg) {
115 return (AE_OK);
138 } 116 }
139 117
140 info->pathname = 118 /* Get a local copy of the address. Handles possible alignment issues */
141 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
142
143 /* Evaluate the namespace object containing the values for this state */
144
145 status = acpi_ns_evaluate(info);
146 if (ACPI_FAILURE(status)) {
147 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
148 "%s while evaluating SleepState [%s]\n",
149 acpi_format_exception(status),
150 info->pathname));
151 119
152 goto cleanup; 120 ACPI_MOVE_64_TO_64(&address, &reg->address);
121 if (!address) {
122 return (AE_OK);
153 } 123 }
154 124
155 /* Must have a return object */ 125 /* Supported widths are 8/16/32 */
156 126
157 if (!info->return_object) { 127 width = reg->bit_width;
158 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", 128 if ((width != 8) && (width != 16) && (width != 32)) {
159 info->pathname)); 129 return (AE_SUPPORT);
160 status = AE_NOT_EXIST;
161 } 130 }
162 131
163 /* It must be of type Package */ 132 /* Initialize entire 32-bit return value to zero */
164 133
165 else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { 134 *value = 0;
166 ACPI_ERROR((AE_INFO,
167 "Sleep State return object is not a Package"));
168 status = AE_AML_OPERAND_TYPE;
169 }
170 135
171 /* 136 /*
172 * The package must have at least two elements. NOTE (March 2005): This 137 * Two address spaces supported: Memory or IO.
173 * goes against the current ACPI spec which defines this object as a 138 * PCI_Config is not supported here because the GAS struct is insufficient
174 * package with one encoded DWORD element. However, existing practice
175 * by BIOS vendors seems to be to have 2 or more elements, at least
176 * one per sleep type (A/B).
177 */ 139 */
178 else if (info->return_object->package.count < 2) { 140 switch (reg->space_id) {
179 ACPI_ERROR((AE_INFO, 141 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
180 "Sleep State return package does not have at least two elements"));
181 status = AE_AML_NO_OPERAND;
182 }
183 142
184 /* The first two elements must both be of type Integer */ 143 status = acpi_os_read_memory((acpi_physical_address) address,
144 value, width);
145 break;
185 146
186 else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) 147 case ACPI_ADR_SPACE_SYSTEM_IO:
187 != ACPI_TYPE_INTEGER) ||
188 (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1])
189 != ACPI_TYPE_INTEGER)) {
190 ACPI_ERROR((AE_INFO,
191 "Sleep State return package elements are not both Integers (%s, %s)",
192 acpi_ut_get_object_type_name(info->return_object->
193 package.elements[0]),
194 acpi_ut_get_object_type_name(info->return_object->
195 package.elements[1])));
196 status = AE_AML_OPERAND_TYPE;
197 } else {
198 /* Valid _Sx_ package size, type, and value */
199 148
200 *sleep_type_a = (u8) 149 status =
201 (info->return_object->package.elements[0])->integer.value; 150 acpi_os_read_port((acpi_io_address) address, value, width);
202 *sleep_type_b = (u8) 151 break;
203 (info->return_object->package.elements[1])->integer.value;
204 }
205 152
206 if (ACPI_FAILURE(status)) { 153 default:
207 ACPI_EXCEPTION((AE_INFO, status, 154 ACPI_ERROR((AE_INFO,
208 "While evaluating SleepState [%s], bad Sleep object %p type %s", 155 "Unsupported address space: %X", reg->space_id));
209 info->pathname, info->return_object, 156 return (AE_BAD_PARAMETER);
210 acpi_ut_get_object_type_name(info->
211 return_object)));
212 } 157 }
213 158
214 acpi_ut_remove_reference(info->return_object); 159 ACPI_DEBUG_PRINT((ACPI_DB_IO,
160 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
161 *value, width, ACPI_FORMAT_UINT64(address),
162 acpi_ut_get_region_name(reg->space_id)));
215 163
216 cleanup: 164 return (status);
217 ACPI_FREE(info);
218 return_ACPI_STATUS(status);
219} 165}
220 166
221ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) 167ACPI_EXPORT_SYMBOL(acpi_read)
222 168
223/******************************************************************************* 169/******************************************************************************
224 * 170 *
225 * FUNCTION: acpi_hw_get_register_bit_mask 171 * FUNCTION: acpi_write
226 * 172 *
227 * PARAMETERS: register_id - Index of ACPI Register to access 173 * PARAMETERS: Value - To be written
174 * Reg - GAS register structure
228 * 175 *
229 * RETURN: The bitmask to be used when accessing the register 176 * RETURN: Status
230 * 177 *
231 * DESCRIPTION: Map register_id into a register bitmask. 178 * DESCRIPTION: Write to either memory or IO space.
232 * 179 *
233 ******************************************************************************/ 180 ******************************************************************************/
234struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) 181acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
235{ 182{
236 ACPI_FUNCTION_ENTRY(); 183 u32 width;
184 u64 address;
185 acpi_status status;
237 186
238 if (register_id > ACPI_BITREG_MAX) { 187 ACPI_FUNCTION_NAME(acpi_write);
239 ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X", 188
240 register_id)); 189 /*
241 return (NULL); 190 * Must have a valid pointer to a GAS structure, and
191 * a non-zero address within. However, don't return an error
192 * because the PM1A/B code must not fail if B isn't present.
193 */
194 if (!reg) {
195 return (AE_OK);
242 } 196 }
243 197
244 return (&acpi_gbl_bit_register_info[register_id]); 198 /* Get a local copy of the address. Handles possible alignment issues */
199
200 ACPI_MOVE_64_TO_64(&address, &reg->address);
201 if (!address) {
202 return (AE_OK);
203 }
204
205 /* Supported widths are 8/16/32 */
206
207 width = reg->bit_width;
208 if ((width != 8) && (width != 16) && (width != 32)) {
209 return (AE_SUPPORT);
210 }
211
212 /*
213 * Two address spaces supported: Memory or IO.
214 * PCI_Config is not supported here because the GAS struct is insufficient
215 */
216 switch (reg->space_id) {
217 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
218
219 status = acpi_os_write_memory((acpi_physical_address) address,
220 value, width);
221 break;
222
223 case ACPI_ADR_SPACE_SYSTEM_IO:
224
225 status = acpi_os_write_port((acpi_io_address) address, value,
226 width);
227 break;
228
229 default:
230 ACPI_ERROR((AE_INFO,
231 "Unsupported address space: %X", reg->space_id));
232 return (AE_BAD_PARAMETER);
233 }
234
235 ACPI_DEBUG_PRINT((ACPI_DB_IO,
236 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
237 value, width, ACPI_FORMAT_UINT64(address),
238 acpi_ut_get_region_name(reg->space_id)));
239
240 return (status);
245} 241}
246 242
243ACPI_EXPORT_SYMBOL(acpi_write)
244
247/******************************************************************************* 245/*******************************************************************************
248 * 246 *
249 * FUNCTION: acpi_get_register 247 * FUNCTION: acpi_get_register_unlocked
250 * 248 *
251 * PARAMETERS: register_id - ID of ACPI bit_register to access 249 * PARAMETERS: register_id - ID of ACPI bit_register to access
252 * return_value - Value that was read from the register 250 * return_value - Value that was read from the register
@@ -254,17 +252,16 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
254 * RETURN: Status and the value read from specified Register. Value 252 * RETURN: Status and the value read from specified Register. Value
255 * returned is normalized to bit0 (is shifted all the way right) 253 * returned is normalized to bit0 (is shifted all the way right)
256 * 254 *
257 * DESCRIPTION: ACPI bit_register read function. 255 * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock.
258 * 256 *
259 ******************************************************************************/ 257 ******************************************************************************/
260 258acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value)
261acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value)
262{ 259{
263 u32 register_value = 0; 260 u32 register_value = 0;
264 struct acpi_bit_register_info *bit_reg_info; 261 struct acpi_bit_register_info *bit_reg_info;
265 acpi_status status; 262 acpi_status status;
266 263
267 ACPI_FUNCTION_TRACE(acpi_get_register); 264 ACPI_FUNCTION_TRACE(acpi_get_register_unlocked);
268 265
269 /* Get the info structure corresponding to the requested ACPI Register */ 266 /* Get the info structure corresponding to the requested ACPI Register */
270 267
@@ -296,14 +293,31 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value)
296 return_ACPI_STATUS(status); 293 return_ACPI_STATUS(status);
297} 294}
298 295
299acpi_status acpi_get_register(u32 register_id, u32 * return_value) 296ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked)
297
298/*******************************************************************************
299 *
300 * FUNCTION: acpi_get_register
301 *
302 * PARAMETERS: register_id - ID of ACPI bit_register to access
303 * return_value - Value that was read from the register
304 *
305 * RETURN: Status and the value read from specified Register. Value
306 * returned is normalized to bit0 (is shifted all the way right)
307 *
308 * DESCRIPTION: ACPI bit_register read function.
309 *
310 ******************************************************************************/
311acpi_status acpi_get_register(u32 register_id, u32 *return_value)
300{ 312{
301 acpi_status status; 313 acpi_status status;
302 acpi_cpu_flags flags; 314 acpi_cpu_flags flags;
315
303 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 316 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
304 status = acpi_get_register_unlocked(register_id, return_value); 317 status = acpi_get_register_unlocked(register_id, return_value);
305 acpi_os_release_lock(acpi_gbl_hardware_lock, flags); 318 acpi_os_release_lock(acpi_gbl_hardware_lock, flags);
306 return status; 319
320 return (status);
307} 321}
308 322
309ACPI_EXPORT_SYMBOL(acpi_get_register) 323ACPI_EXPORT_SYMBOL(acpi_get_register)
@@ -370,8 +384,9 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
370 bit_reg_info-> 384 bit_reg_info->
371 access_bit_mask); 385 access_bit_mask);
372 if (value) { 386 if (value) {
373 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 387 status =
374 (u16) value); 388 acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
389 (u16) value);
375 register_value = 0; 390 register_value = 0;
376 } 391 }
377 break; 392 break;
@@ -459,399 +474,120 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
459 474
460ACPI_EXPORT_SYMBOL(acpi_set_register) 475ACPI_EXPORT_SYMBOL(acpi_set_register)
461 476
462/****************************************************************************** 477/*******************************************************************************
463 * 478 *
464 * FUNCTION: acpi_hw_register_read 479 * FUNCTION: acpi_get_sleep_type_data
465 * 480 *
466 * PARAMETERS: register_id - ACPI Register ID 481 * PARAMETERS: sleep_state - Numeric sleep state
467 * return_value - Where the register value is returned 482 * *sleep_type_a - Where SLP_TYPa is returned
483 * *sleep_type_b - Where SLP_TYPb is returned
468 * 484 *
469 * RETURN: Status and the value read. 485 * RETURN: Status - ACPI status
470 * 486 *
471 * DESCRIPTION: Read from the specified ACPI register 487 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
488 * state.
472 * 489 *
473 ******************************************************************************/ 490 ******************************************************************************/
474acpi_status 491acpi_status
475acpi_hw_register_read(u32 register_id, u32 * return_value) 492acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
476{ 493{
477 u32 value1 = 0; 494 acpi_status status = AE_OK;
478 u32 value2 = 0; 495 struct acpi_evaluate_info *info;
479 acpi_status status;
480
481 ACPI_FUNCTION_TRACE(hw_register_read);
482
483 switch (register_id) {
484 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
485
486 status =
487 acpi_hw_low_level_read(16, &value1,
488 &acpi_gbl_FADT.xpm1a_event_block);
489 if (ACPI_FAILURE(status)) {
490 goto exit;
491 }
492
493 /* PM1B is optional */
494
495 status =
496 acpi_hw_low_level_read(16, &value2,
497 &acpi_gbl_FADT.xpm1b_event_block);
498 value1 |= value2;
499 break;
500
501 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
502
503 status =
504 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
505 if (ACPI_FAILURE(status)) {
506 goto exit;
507 }
508
509 /* PM1B is optional */
510
511 status =
512 acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
513 value1 |= value2;
514 break;
515
516 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
517
518 status =
519 acpi_hw_low_level_read(16, &value1,
520 &acpi_gbl_FADT.xpm1a_control_block);
521 if (ACPI_FAILURE(status)) {
522 goto exit;
523 }
524
525 status =
526 acpi_hw_low_level_read(16, &value2,
527 &acpi_gbl_FADT.xpm1b_control_block);
528 value1 |= value2;
529 break;
530
531 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
532
533 status =
534 acpi_hw_low_level_read(8, &value1,
535 &acpi_gbl_FADT.xpm2_control_block);
536 break;
537
538 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
539
540 status =
541 acpi_hw_low_level_read(32, &value1,
542 &acpi_gbl_FADT.xpm_timer_block);
543 break;
544 496
545 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 497 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
546 498
547 status = 499 /* Validate parameters */
548 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8);
549 break;
550 500
551 default: 501 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
552 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id)); 502 return_ACPI_STATUS(AE_BAD_PARAMETER);
553 status = AE_BAD_PARAMETER;
554 break;
555 } 503 }
556 504
557 exit: 505 /* Allocate the evaluation information block */
558 506
559 if (ACPI_SUCCESS(status)) { 507 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
560 *return_value = value1; 508 if (!info) {
509 return_ACPI_STATUS(AE_NO_MEMORY);
561 } 510 }
562 511
563 return_ACPI_STATUS(status); 512 info->pathname =
564} 513 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
565
566/******************************************************************************
567 *
568 * FUNCTION: acpi_hw_register_write
569 *
570 * PARAMETERS: register_id - ACPI Register ID
571 * Value - The value to write
572 *
573 * RETURN: Status
574 *
575 * DESCRIPTION: Write to the specified ACPI register
576 *
577 * NOTE: In accordance with the ACPI specification, this function automatically
578 * preserves the value of the following bits, meaning that these bits cannot be
579 * changed via this interface:
580 *
581 * PM1_CONTROL[0] = SCI_EN
582 * PM1_CONTROL[9]
583 * PM1_STATUS[11]
584 *
585 * ACPI References:
586 * 1) Hardware Ignored Bits: When software writes to a register with ignored
587 * bit fields, it preserves the ignored bit fields
588 * 2) SCI_EN: OSPM always preserves this bit position
589 *
590 ******************************************************************************/
591
592acpi_status acpi_hw_register_write(u32 register_id, u32 value)
593{
594 acpi_status status;
595 u32 read_value;
596
597 ACPI_FUNCTION_TRACE(hw_register_write);
598
599 switch (register_id) {
600 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
601
602 /* Perform a read first to preserve certain bits (per ACPI spec) */
603
604 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS,
605 &read_value);
606 if (ACPI_FAILURE(status)) {
607 goto exit;
608 }
609
610 /* Insert the bits to be preserved */
611
612 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
613 read_value);
614
615 /* Now we can write the data */
616
617 status =
618 acpi_hw_low_level_write(16, value,
619 &acpi_gbl_FADT.xpm1a_event_block);
620 if (ACPI_FAILURE(status)) {
621 goto exit;
622 }
623
624 /* PM1B is optional */
625
626 status =
627 acpi_hw_low_level_write(16, value,
628 &acpi_gbl_FADT.xpm1b_event_block);
629 break;
630
631 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
632
633 status =
634 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
635 if (ACPI_FAILURE(status)) {
636 goto exit;
637 }
638
639 /* PM1B is optional */
640
641 status =
642 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
643 break;
644
645 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
646
647 /*
648 * Perform a read first to preserve certain bits (per ACPI spec)
649 */
650 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
651 &read_value);
652 if (ACPI_FAILURE(status)) {
653 goto exit;
654 }
655
656 /* Insert the bits to be preserved */
657
658 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
659 read_value);
660
661 /* Now we can write the data */
662
663 status =
664 acpi_hw_low_level_write(16, value,
665 &acpi_gbl_FADT.xpm1a_control_block);
666 if (ACPI_FAILURE(status)) {
667 goto exit;
668 }
669
670 status =
671 acpi_hw_low_level_write(16, value,
672 &acpi_gbl_FADT.xpm1b_control_block);
673 break;
674
675 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
676
677 status =
678 acpi_hw_low_level_write(16, value,
679 &acpi_gbl_FADT.xpm1a_control_block);
680 break;
681
682 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
683
684 status =
685 acpi_hw_low_level_write(16, value,
686 &acpi_gbl_FADT.xpm1b_control_block);
687 break;
688
689 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
690
691 status =
692 acpi_hw_low_level_write(8, value,
693 &acpi_gbl_FADT.xpm2_control_block);
694 break;
695
696 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
697
698 status =
699 acpi_hw_low_level_write(32, value,
700 &acpi_gbl_FADT.xpm_timer_block);
701 break;
702
703 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
704 514
705 /* SMI_CMD is currently always in IO space */ 515 /* Evaluate the namespace object containing the values for this state */
706 516
707 status = 517 status = acpi_ns_evaluate(info);
708 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8); 518 if (ACPI_FAILURE(status)) {
709 break; 519 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
520 "%s while evaluating SleepState [%s]\n",
521 acpi_format_exception(status),
522 info->pathname));
710 523
711 default: 524 goto cleanup;
712 status = AE_BAD_PARAMETER;
713 break;
714 } 525 }
715 526
716 exit: 527 /* Must have a return object */
717 return_ACPI_STATUS(status);
718}
719
720/******************************************************************************
721 *
722 * FUNCTION: acpi_hw_low_level_read
723 *
724 * PARAMETERS: Width - 8, 16, or 32
725 * Value - Where the value is returned
726 * Reg - GAS register structure
727 *
728 * RETURN: Status
729 *
730 * DESCRIPTION: Read from either memory or IO space.
731 *
732 ******************************************************************************/
733
734acpi_status
735acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
736{
737 u64 address;
738 acpi_status status;
739
740 ACPI_FUNCTION_NAME(hw_low_level_read);
741 528
742 /* 529 if (!info->return_object) {
743 * Must have a valid pointer to a GAS structure, and 530 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
744 * a non-zero address within. However, don't return an error 531 info->pathname));
745 * because the PM1A/B code must not fail if B isn't present. 532 status = AE_NOT_EXIST;
746 */
747 if (!reg) {
748 return (AE_OK);
749 } 533 }
750 534
751 /* Get a local copy of the address. Handles possible alignment issues */ 535 /* It must be of type Package */
752 536
753 ACPI_MOVE_64_TO_64(&address, &reg->address); 537 else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) {
754 if (!address) { 538 ACPI_ERROR((AE_INFO,
755 return (AE_OK); 539 "Sleep State return object is not a Package"));
540 status = AE_AML_OPERAND_TYPE;
756 } 541 }
757 *value = 0;
758 542
759 /* 543 /*
760 * Two address spaces supported: Memory or IO. 544 * The package must have at least two elements. NOTE (March 2005): This
761 * PCI_Config is not supported here because the GAS struct is insufficient 545 * goes against the current ACPI spec which defines this object as a
546 * package with one encoded DWORD element. However, existing practice
547 * by BIOS vendors seems to be to have 2 or more elements, at least
548 * one per sleep type (A/B).
762 */ 549 */
763 switch (reg->space_id) { 550 else if (info->return_object->package.count < 2) {
764 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
765
766 status = acpi_os_read_memory((acpi_physical_address) address,
767 value, width);
768 break;
769
770 case ACPI_ADR_SPACE_SYSTEM_IO:
771
772 status =
773 acpi_os_read_port((acpi_io_address) address, value, width);
774 break;
775
776 default:
777 ACPI_ERROR((AE_INFO, 551 ACPI_ERROR((AE_INFO,
778 "Unsupported address space: %X", reg->space_id)); 552 "Sleep State return package does not have at least two elements"));
779 return (AE_BAD_PARAMETER); 553 status = AE_AML_NO_OPERAND;
780 } 554 }
781 555
782 ACPI_DEBUG_PRINT((ACPI_DB_IO, 556 /* The first two elements must both be of type Integer */
783 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
784 *value, width, ACPI_FORMAT_UINT64(address),
785 acpi_ut_get_region_name(reg->space_id)));
786
787 return (status);
788}
789
790/******************************************************************************
791 *
792 * FUNCTION: acpi_hw_low_level_write
793 *
794 * PARAMETERS: Width - 8, 16, or 32
795 * Value - To be written
796 * Reg - GAS register structure
797 *
798 * RETURN: Status
799 *
800 * DESCRIPTION: Write to either memory or IO space.
801 *
802 ******************************************************************************/
803
804acpi_status
805acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
806{
807 u64 address;
808 acpi_status status;
809
810 ACPI_FUNCTION_NAME(hw_low_level_write);
811
812 /*
813 * Must have a valid pointer to a GAS structure, and
814 * a non-zero address within. However, don't return an error
815 * because the PM1A/B code must not fail if B isn't present.
816 */
817 if (!reg) {
818 return (AE_OK);
819 }
820 557
821 /* Get a local copy of the address. Handles possible alignment issues */ 558 else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0])
559 != ACPI_TYPE_INTEGER) ||
560 (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1])
561 != ACPI_TYPE_INTEGER)) {
562 ACPI_ERROR((AE_INFO,
563 "Sleep State return package elements are not both Integers (%s, %s)",
564 acpi_ut_get_object_type_name(info->return_object->
565 package.elements[0]),
566 acpi_ut_get_object_type_name(info->return_object->
567 package.elements[1])));
568 status = AE_AML_OPERAND_TYPE;
569 } else {
570 /* Valid _Sx_ package size, type, and value */
822 571
823 ACPI_MOVE_64_TO_64(&address, &reg->address); 572 *sleep_type_a = (u8)
824 if (!address) { 573 (info->return_object->package.elements[0])->integer.value;
825 return (AE_OK); 574 *sleep_type_b = (u8)
575 (info->return_object->package.elements[1])->integer.value;
826 } 576 }
827 577
828 /* 578 if (ACPI_FAILURE(status)) {
829 * Two address spaces supported: Memory or IO. 579 ACPI_EXCEPTION((AE_INFO, status,
830 * PCI_Config is not supported here because the GAS struct is insufficient 580 "While evaluating SleepState [%s], bad Sleep object %p type %s",
831 */ 581 info->pathname, info->return_object,
832 switch (reg->space_id) { 582 acpi_ut_get_object_type_name(info->
833 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 583 return_object)));
834
835 status = acpi_os_write_memory((acpi_physical_address) address,
836 value, width);
837 break;
838
839 case ACPI_ADR_SPACE_SYSTEM_IO:
840
841 status = acpi_os_write_port((acpi_io_address) address, value,
842 width);
843 break;
844
845 default:
846 ACPI_ERROR((AE_INFO,
847 "Unsupported address space: %X", reg->space_id));
848 return (AE_BAD_PARAMETER);
849 } 584 }
850 585
851 ACPI_DEBUG_PRINT((ACPI_DB_IO, 586 acpi_ut_remove_reference(info->return_object);
852 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
853 value, width, ACPI_FORMAT_UINT64(address),
854 acpi_ut_get_region_name(reg->space_id)));
855 587
856 return (status); 588 cleanup:
589 ACPI_FREE(info);
590 return_ACPI_STATUS(status);
857} 591}
592
593ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data)
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index c39a7f68b889..88303ebe924c 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "amlcode.h"
47#include <acpi/acdispat.h> 47#include "acnamesp.h"
48#include "acdispat.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsaccess") 51ACPI_MODULE_NAME("nsaccess")
@@ -165,12 +166,9 @@ acpi_status acpi_ns_root_initialize(void)
165 166
166 obj_desc->method.method_flags = 167 obj_desc->method.method_flags =
167 AML_METHOD_INTERNAL_ONLY; 168 AML_METHOD_INTERNAL_ONLY;
168
169#ifndef ACPI_DUMP_APP
170 obj_desc->method.implementation = 169 obj_desc->method.implementation =
171 acpi_ut_osi_implementation; 170 acpi_ut_osi_implementation;
172#endif 171#endif
173#endif
174 break; 172 break;
175 173
176 case ACPI_TYPE_INTEGER: 174 case ACPI_TYPE_INTEGER:
@@ -521,11 +519,11 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
521 } 519 }
522 520
523 /* 521 /*
524 * Search namespace for each segment of the name. Loop through and 522 * Search namespace for each segment of the name. Loop through and
525 * verify (or add to the namespace) each name segment. 523 * verify (or add to the namespace) each name segment.
526 * 524 *
527 * The object type is significant only at the last name 525 * The object type is significant only at the last name
528 * segment. (We don't care about the types along the path, only 526 * segment. (We don't care about the types along the path, only
529 * the type of the final target object.) 527 * the type of the final target object.)
530 */ 528 */
531 this_search_type = ACPI_TYPE_ANY; 529 this_search_type = ACPI_TYPE_ANY;
@@ -591,6 +589,10 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
591 * segments). 589 * segments).
592 */ 590 */
593 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) { 591 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
592 if (!this_node->object) {
593 return_ACPI_STATUS(AE_NOT_EXIST);
594 }
595
594 if (acpi_ns_opens_scope 596 if (acpi_ns_opens_scope
595 (((struct acpi_namespace_node *)this_node-> 597 (((struct acpi_namespace_node *)this_node->
596 object)->type)) { 598 object)->type)) {
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 3a1740ac2edc..f976d848fe82 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nsalloc") 49ACPI_MODULE_NAME("nsalloc")
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/acpica/nsdump.c
index cc0ae39440e4..0da33c8e9ba2 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nsdump") 49ACPI_MODULE_NAME("nsdump")
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 428f50fde11a..41994fe7fbb8 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46/* TBD: This entire module is apparently obsolete and should be removed */ 47/* TBD: This entire module is apparently obsolete and should be removed */
47 48
@@ -49,7 +50,7 @@
49ACPI_MODULE_NAME("nsdumpdv") 50ACPI_MODULE_NAME("nsdumpdv")
50#ifdef ACPI_OBSOLETE_FUNCTIONS 51#ifdef ACPI_OBSOLETE_FUNCTIONS
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 52#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
52#include <acpi/acnamesp.h> 53#include "acnamesp.h"
53/******************************************************************************* 54/*******************************************************************************
54 * 55 *
55 * FUNCTION: acpi_ns_dump_one_device 56 * FUNCTION: acpi_ns_dump_one_device
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/acpica/nseval.c
index 4cdf03ac2b46..0f3d5f9b5966 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "acinterp.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nseval") 51ACPI_MODULE_NAME("nseval")
@@ -89,6 +90,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
89 /* Initialize the return value to an invalid object */ 90 /* Initialize the return value to an invalid object */
90 91
91 info->return_object = NULL; 92 info->return_object = NULL;
93 info->param_count = 0;
92 94
93 /* 95 /*
94 * Get the actual namespace node for the target object. Handles these cases: 96 * Get the actual namespace node for the target object. Handles these cases:
@@ -141,41 +143,17 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
141 return_ACPI_STATUS(AE_NULL_OBJECT); 143 return_ACPI_STATUS(AE_NULL_OBJECT);
142 } 144 }
143 145
144 /* 146 /* Count the number of arguments being passed to the method */
145 * Calculate the number of arguments being passed to the method
146 */
147 147
148 info->param_count = 0;
149 if (info->parameters) { 148 if (info->parameters) {
150 while (info->parameters[info->param_count]) 149 while (info->parameters[info->param_count]) {
150 if (info->param_count > ACPI_METHOD_MAX_ARG) {
151 return_ACPI_STATUS(AE_LIMIT);
152 }
151 info->param_count++; 153 info->param_count++;
154 }
152 } 155 }
153 156
154 /*
155 * Warning if too few or too many arguments have been passed by the
156 * caller. We don't want to abort here with an error because an
157 * incorrect number of arguments may not cause the method to fail.
158 * However, the method will fail if there are too few arguments passed
159 * and the method attempts to use one of the missing ones.
160 */
161
162 if (info->param_count < info->obj_desc->method.param_count) {
163 ACPI_WARNING((AE_INFO,
164 "Insufficient arguments - "
165 "method [%4.4s] needs %d, found %d",
166 acpi_ut_get_node_name(info->resolved_node),
167 info->obj_desc->method.param_count,
168 info->param_count));
169 } else if (info->param_count >
170 info->obj_desc->method.param_count) {
171 ACPI_WARNING((AE_INFO,
172 "Excess arguments - "
173 "method [%4.4s] needs %d, found %d",
174 acpi_ut_get_node_name(info->
175 resolved_node),
176 info->obj_desc->method.param_count,
177 info->param_count));
178 }
179 157
180 ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:", 158 ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:",
181 ACPI_LV_INFO, _COMPONENT); 159 ACPI_LV_INFO, _COMPONENT);
@@ -264,32 +242,13 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
264 } 242 }
265 } 243 }
266 244
267 /* Validation of return values for ACPI-predefined methods and objects */ 245 /*
268 246 * Check input argument count against the ASL-defined count for a method.
269 if ((status == AE_OK) || (status == AE_CTRL_RETURN_VALUE)) { 247 * Also check predefined names: argument count and return value against
270 /* 248 * the ACPI specification. Some incorrect return value types are repaired.
271 * If this is the first evaluation, check the return value. This 249 */
272 * ensures that any warnings will only be emitted during the very 250 (void)acpi_ns_check_predefined_names(node, info->param_count,
273 * first evaluation of the object. 251 status, &info->return_object);
274 */
275 if (!(node->flags & ANOBJ_EVALUATED)) {
276 /*
277 * Check for a predefined ACPI name. If found, validate the
278 * returned object.
279 *
280 * Note: Ignore return status for now, emit warnings if there are
281 * problems with the returned object. May change later to abort
282 * the method on invalid return object.
283 */
284 (void)acpi_ns_check_predefined_names(node,
285 info->
286 return_object);
287 }
288
289 /* Mark the node as having been evaluated */
290
291 node->flags |= ANOBJ_EVALUATED;
292 }
293 252
294 /* Check if there is a return value that must be dealt with */ 253 /* Check if there is a return value that must be dealt with */
295 254
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/acpica/nsinit.c
index e4c57510d798..13501cb81863 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acnamesp.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include "acinterp.h"
48#include <linux/nmi.h> 49#include <linux/nmi.h>
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/acpica/nsload.c
index a4a412b7c029..a0ba9e12379e 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acnamesp.h"
47#include <acpi/actables.h> 47#include "acdispat.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsload") 51ACPI_MODULE_NAME("nsload")
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 42a39a7c96e9..ae3dc10a7e81 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "amlcode.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsnames") 50ACPI_MODULE_NAME("nsnames")
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 15fe09e24f71..08a97a57f8f9 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsobject") 50ACPI_MODULE_NAME("nsobject")
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/acpica/nsparse.c
index a82271a9dbb3..b9e8d0070b6f 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acparser.h> 46#include "acnamesp.h"
47#include <acpi/acdispat.h> 47#include "acparser.h"
48#include <acpi/actables.h> 48#include "acdispat.h"
49#include "actables.h"
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsparse") 52ACPI_MODULE_NAME("nsparse")
diff --git a/drivers/acpi/namespace/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 0f17cf0898c9..452703290d35 100644
--- a/drivers/acpi/namespace/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acpredef.h> 47#include "acnamesp.h"
48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nspredef") 51ACPI_MODULE_NAME("nspredef")
@@ -72,7 +73,7 @@ ACPI_MODULE_NAME("nspredef")
72/* Local prototypes */ 73/* Local prototypes */
73static acpi_status 74static acpi_status
74acpi_ns_check_package(char *pathname, 75acpi_ns_check_package(char *pathname,
75 union acpi_operand_object *return_object, 76 union acpi_operand_object **return_object_ptr,
76 const union acpi_predefined_info *predefined); 77 const union acpi_predefined_info *predefined);
77 78
78static acpi_status 79static acpi_status
@@ -82,13 +83,18 @@ acpi_ns_check_package_elements(char *pathname,
82 83
83static acpi_status 84static acpi_status
84acpi_ns_check_object_type(char *pathname, 85acpi_ns_check_object_type(char *pathname,
85 union acpi_operand_object *return_object, 86 union acpi_operand_object **return_object_ptr,
86 u32 expected_btypes, u32 package_index); 87 u32 expected_btypes, u32 package_index);
87 88
88static acpi_status 89static acpi_status
89acpi_ns_check_reference(char *pathname, 90acpi_ns_check_reference(char *pathname,
90 union acpi_operand_object *return_object); 91 union acpi_operand_object *return_object);
91 92
93static acpi_status
94acpi_ns_repair_object(u32 expected_btypes,
95 u32 package_index,
96 union acpi_operand_object **return_object_ptr);
97
92/* 98/*
93 * Names for the types that can be returned by the predefined objects. 99 * Names for the types that can be returned by the predefined objects.
94 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs 100 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
@@ -108,8 +114,8 @@ static const char *acpi_rtype_names[] = {
108 * FUNCTION: acpi_ns_check_predefined_names 114 * FUNCTION: acpi_ns_check_predefined_names
109 * 115 *
110 * PARAMETERS: Node - Namespace node for the method/object 116 * PARAMETERS: Node - Namespace node for the method/object
111 * return_object - Object returned from the evaluation of this 117 * return_object_ptr - Pointer to the object returned from the
112 * method/object 118 * evaluation of a method or object
113 * 119 *
114 * RETURN: Status 120 * RETURN: Status
115 * 121 *
@@ -119,8 +125,11 @@ static const char *acpi_rtype_names[] = {
119 125
120acpi_status 126acpi_status
121acpi_ns_check_predefined_names(struct acpi_namespace_node *node, 127acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
122 union acpi_operand_object *return_object) 128 u32 user_param_count,
129 acpi_status return_status,
130 union acpi_operand_object **return_object_ptr)
123{ 131{
132 union acpi_operand_object *return_object = *return_object_ptr;
124 acpi_status status = AE_OK; 133 acpi_status status = AE_OK;
125 const union acpi_predefined_info *predefined; 134 const union acpi_predefined_info *predefined;
126 char *pathname; 135 char *pathname;
@@ -128,12 +137,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
128 /* Match the name for this method/object against the predefined list */ 137 /* Match the name for this method/object against the predefined list */
129 138
130 predefined = acpi_ns_check_for_predefined_name(node); 139 predefined = acpi_ns_check_for_predefined_name(node);
131 if (!predefined) {
132
133 /* Name was not one of the predefined names */
134
135 return (AE_OK);
136 }
137 140
138 /* Get the full pathname to the object, for use in error messages */ 141 /* Get the full pathname to the object, for use in error messages */
139 142
@@ -143,10 +146,37 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
143 } 146 }
144 147
145 /* 148 /*
146 * Check that the parameter count for this method is in accordance 149 * Check that the parameter count for this method matches the ASL
147 * with the ACPI specification. 150 * definition. For predefined names, ensure that both the caller and
151 * the method itself are in accordance with the ACPI specification.
148 */ 152 */
149 acpi_ns_check_parameter_count(pathname, node, predefined); 153 acpi_ns_check_parameter_count(pathname, node, user_param_count,
154 predefined);
155
156 /* If not a predefined name, we cannot validate the return object */
157
158 if (!predefined) {
159 goto exit;
160 }
161
162 /* If the method failed, we cannot validate the return object */
163
164 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
165 goto exit;
166 }
167
168 /*
169 * Only validate the return value on the first successful evaluation of
170 * the method. This ensures that any warnings will only be emitted during
171 * the very first evaluation of the method/object.
172 */
173 if (node->flags & ANOBJ_EVALUATED) {
174 goto exit;
175 }
176
177 /* Mark the node as having been successfully evaluated */
178
179 node->flags |= ANOBJ_EVALUATED;
150 180
151 /* 181 /*
152 * If there is no return value, check if we require a return value for 182 * If there is no return value, check if we require a return value for
@@ -171,7 +201,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
171 * We have a return value, but if one wasn't expected, just exit, this is 201 * We have a return value, but if one wasn't expected, just exit, this is
172 * not a problem 202 * not a problem
173 * 203 *
174 * For example, if "Implicit return value" is enabled, methods will 204 * For example, if the "Implicit Return" feature is enabled, methods will
175 * always return a value 205 * always return a value
176 */ 206 */
177 if (!predefined->info.expected_btypes) { 207 if (!predefined->info.expected_btypes) {
@@ -182,7 +212,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
182 * Check that the type of the return object is what is expected for 212 * Check that the type of the return object is what is expected for
183 * this predefined name 213 * this predefined name
184 */ 214 */
185 status = acpi_ns_check_object_type(pathname, return_object, 215 status = acpi_ns_check_object_type(pathname, return_object_ptr,
186 predefined->info.expected_btypes, 216 predefined->info.expected_btypes,
187 ACPI_NOT_PACKAGE); 217 ACPI_NOT_PACKAGE);
188 if (ACPI_FAILURE(status)) { 218 if (ACPI_FAILURE(status)) {
@@ -193,11 +223,12 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
193 223
194 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) { 224 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) {
195 status = 225 status =
196 acpi_ns_check_package(pathname, return_object, predefined); 226 acpi_ns_check_package(pathname, return_object_ptr,
227 predefined);
197 } 228 }
198 229
199 exit: 230 exit:
200 if (pathname) { 231 if (pathname != predefined->info.name) {
201 ACPI_FREE(pathname); 232 ACPI_FREE(pathname);
202 } 233 }
203 234
@@ -210,6 +241,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
210 * 241 *
211 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 242 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
212 * Node - Namespace node for the method/object 243 * Node - Namespace node for the method/object
244 * user_param_count - Number of args passed in by the caller
213 * Predefined - Pointer to entry in predefined name table 245 * Predefined - Pointer to entry in predefined name table
214 * 246 *
215 * RETURN: None 247 * RETURN: None
@@ -223,32 +255,76 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
223void 255void
224acpi_ns_check_parameter_count(char *pathname, 256acpi_ns_check_parameter_count(char *pathname,
225 struct acpi_namespace_node *node, 257 struct acpi_namespace_node *node,
258 u32 user_param_count,
226 const union acpi_predefined_info *predefined) 259 const union acpi_predefined_info *predefined)
227{ 260{
228 u32 param_count; 261 u32 param_count;
229 u32 required_params_current; 262 u32 required_params_current;
230 u32 required_params_old; 263 u32 required_params_old;
231 264
232 /* 265 /* Methods have 0-7 parameters. All other types have zero. */
233 * Check that the ASL-defined parameter count is what is expected for 266
234 * this predefined name.
235 *
236 * Methods have 0-7 parameters. All other types have zero.
237 */
238 param_count = 0; 267 param_count = 0;
239 if (node->type == ACPI_TYPE_METHOD) { 268 if (node->type == ACPI_TYPE_METHOD) {
240 param_count = node->object->method.param_count; 269 param_count = node->object->method.param_count;
241 } 270 }
242 271
243 /* Validate parameter count - allow two different legal counts (_SCP) */ 272 /* Argument count check for non-predefined methods/objects */
273
274 if (!predefined) {
275 /*
276 * Warning if too few or too many arguments have been passed by the
277 * caller. An incorrect number of arguments may not cause the method
278 * to fail. However, the method will fail if there are too few
279 * arguments and the method attempts to use one of the missing ones.
280 */
281 if (user_param_count < param_count) {
282 ACPI_WARNING((AE_INFO,
283 "%s: Insufficient arguments - needs %d, found %d",
284 pathname, param_count, user_param_count));
285 } else if (user_param_count > param_count) {
286 ACPI_WARNING((AE_INFO,
287 "%s: Excess arguments - needs %d, found %d",
288 pathname, param_count, user_param_count));
289 }
290 return;
291 }
292
293 /* Allow two different legal argument counts (_SCP, etc.) */
244 294
245 required_params_current = predefined->info.param_count & 0x0F; 295 required_params_current = predefined->info.param_count & 0x0F;
246 required_params_old = predefined->info.param_count >> 4; 296 required_params_old = predefined->info.param_count >> 4;
247 297
298 if (user_param_count != ACPI_UINT32_MAX) {
299
300 /* Validate the user-supplied parameter count */
301
302 if ((user_param_count != required_params_current) &&
303 (user_param_count != required_params_old)) {
304 ACPI_WARNING((AE_INFO,
305 "%s: Parameter count mismatch - caller passed %d, ACPI requires %d",
306 pathname, user_param_count,
307 required_params_current));
308 }
309 }
310
311 /*
312 * Only validate the argument count on the first successful evaluation of
313 * the method. This ensures that any warnings will only be emitted during
314 * the very first evaluation of the method/object.
315 */
316 if (node->flags & ANOBJ_EVALUATED) {
317 return;
318 }
319
320 /*
321 * Check that the ASL-defined parameter count is what is expected for
322 * this predefined name.
323 */
248 if ((param_count != required_params_current) && 324 if ((param_count != required_params_current) &&
249 (param_count != required_params_old)) { 325 (param_count != required_params_old)) {
250 ACPI_WARNING((AE_INFO, 326 ACPI_WARNING((AE_INFO,
251 "%s: Parameter count mismatch - ASL declared %d, expected %d", 327 "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d",
252 pathname, param_count, required_params_current)); 328 pathname, param_count, required_params_current));
253 } 329 }
254} 330}
@@ -307,8 +383,8 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
307 * FUNCTION: acpi_ns_check_package 383 * FUNCTION: acpi_ns_check_package
308 * 384 *
309 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 385 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
310 * return_object - Object returned from the evaluation of a 386 * return_object_ptr - Pointer to the object returned from the
311 * method or object 387 * evaluation of a method or object
312 * Predefined - Pointer to entry in predefined name table 388 * Predefined - Pointer to entry in predefined name table
313 * 389 *
314 * RETURN: Status 390 * RETURN: Status
@@ -320,9 +396,10 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
320 396
321static acpi_status 397static acpi_status
322acpi_ns_check_package(char *pathname, 398acpi_ns_check_package(char *pathname,
323 union acpi_operand_object *return_object, 399 union acpi_operand_object **return_object_ptr,
324 const union acpi_predefined_info *predefined) 400 const union acpi_predefined_info *predefined)
325{ 401{
402 union acpi_operand_object *return_object = *return_object_ptr;
326 const union acpi_predefined_info *package; 403 const union acpi_predefined_info *package;
327 union acpi_operand_object *sub_package; 404 union acpi_operand_object *sub_package;
328 union acpi_operand_object **elements; 405 union acpi_operand_object **elements;
@@ -408,7 +485,7 @@ acpi_ns_check_package(char *pathname,
408 * elements must be of the same type 485 * elements must be of the same type
409 */ 486 */
410 for (i = 0; i < count; i++) { 487 for (i = 0; i < count; i++) {
411 status = acpi_ns_check_object_type(pathname, *elements, 488 status = acpi_ns_check_object_type(pathname, elements,
412 package->ret_info. 489 package->ret_info.
413 object_type1, i); 490 object_type1, i);
414 if (ACPI_FAILURE(status)) { 491 if (ACPI_FAILURE(status)) {
@@ -441,7 +518,7 @@ acpi_ns_check_package(char *pathname,
441 518
442 status = 519 status =
443 acpi_ns_check_object_type(pathname, 520 acpi_ns_check_object_type(pathname,
444 *elements, 521 elements,
445 package-> 522 package->
446 ret_info3. 523 ret_info3.
447 object_type[i], 524 object_type[i],
@@ -454,7 +531,7 @@ acpi_ns_check_package(char *pathname,
454 531
455 status = 532 status =
456 acpi_ns_check_object_type(pathname, 533 acpi_ns_check_object_type(pathname,
457 *elements, 534 elements,
458 package-> 535 package->
459 ret_info3. 536 ret_info3.
460 tail_object_type, 537 tail_object_type,
@@ -471,7 +548,7 @@ acpi_ns_check_package(char *pathname,
471 548
472 /* First element is the (Integer) count of sub-packages to follow */ 549 /* First element is the (Integer) count of sub-packages to follow */
473 550
474 status = acpi_ns_check_object_type(pathname, *elements, 551 status = acpi_ns_check_object_type(pathname, elements,
475 ACPI_RTYPE_INTEGER, 0); 552 ACPI_RTYPE_INTEGER, 0);
476 if (ACPI_FAILURE(status)) { 553 if (ACPI_FAILURE(status)) {
477 return (status); 554 return (status);
@@ -509,7 +586,7 @@ acpi_ns_check_package(char *pathname,
509 /* Each sub-object must be of type Package */ 586 /* Each sub-object must be of type Package */
510 587
511 status = 588 status =
512 acpi_ns_check_object_type(pathname, sub_package, 589 acpi_ns_check_object_type(pathname, &sub_package,
513 ACPI_RTYPE_PACKAGE, i); 590 ACPI_RTYPE_PACKAGE, i);
514 if (ACPI_FAILURE(status)) { 591 if (ACPI_FAILURE(status)) {
515 return (status); 592 return (status);
@@ -567,12 +644,8 @@ acpi_ns_check_package(char *pathname,
567 for (j = 0; j < expected_count; j++) { 644 for (j = 0; j < expected_count; j++) {
568 status = 645 status =
569 acpi_ns_check_object_type(pathname, 646 acpi_ns_check_object_type(pathname,
570 sub_elements 647 &sub_elements[j],
571 [j], 648 package->ret_info2.object_type[j], j);
572 package->
573 ret_info2.
574 object_type
575 [j], j);
576 if (ACPI_FAILURE(status)) { 649 if (ACPI_FAILURE(status)) {
577 return (status); 650 return (status);
578 } 651 }
@@ -611,7 +684,7 @@ acpi_ns_check_package(char *pathname,
611 684
612 status = 685 status =
613 acpi_ns_check_object_type(pathname, 686 acpi_ns_check_object_type(pathname,
614 *sub_elements, 687 sub_elements,
615 ACPI_RTYPE_INTEGER, 688 ACPI_RTYPE_INTEGER,
616 0); 689 0);
617 if (ACPI_FAILURE(status)) { 690 if (ACPI_FAILURE(status)) {
@@ -708,7 +781,7 @@ acpi_ns_check_package_elements(char *pathname,
708 * The second group can have a count of zero. 781 * The second group can have a count of zero.
709 */ 782 */
710 for (i = 0; i < count1; i++) { 783 for (i = 0; i < count1; i++) {
711 status = acpi_ns_check_object_type(pathname, *this_element, 784 status = acpi_ns_check_object_type(pathname, this_element,
712 type1, i); 785 type1, i);
713 if (ACPI_FAILURE(status)) { 786 if (ACPI_FAILURE(status)) {
714 return (status); 787 return (status);
@@ -717,7 +790,7 @@ acpi_ns_check_package_elements(char *pathname,
717 } 790 }
718 791
719 for (i = 0; i < count2; i++) { 792 for (i = 0; i < count2; i++) {
720 status = acpi_ns_check_object_type(pathname, *this_element, 793 status = acpi_ns_check_object_type(pathname, this_element,
721 type2, (i + count1)); 794 type2, (i + count1));
722 if (ACPI_FAILURE(status)) { 795 if (ACPI_FAILURE(status)) {
723 return (status); 796 return (status);
@@ -733,8 +806,8 @@ acpi_ns_check_package_elements(char *pathname,
733 * FUNCTION: acpi_ns_check_object_type 806 * FUNCTION: acpi_ns_check_object_type
734 * 807 *
735 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 808 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
736 * return_object - Object return from the execution of this 809 * return_object_ptr - Pointer to the object returned from the
737 * method/object 810 * evaluation of a method or object
738 * expected_btypes - Bitmap of expected return type(s) 811 * expected_btypes - Bitmap of expected return type(s)
739 * package_index - Index of object within parent package (if 812 * package_index - Index of object within parent package (if
740 * applicable - ACPI_NOT_PACKAGE otherwise) 813 * applicable - ACPI_NOT_PACKAGE otherwise)
@@ -748,9 +821,10 @@ acpi_ns_check_package_elements(char *pathname,
748 821
749static acpi_status 822static acpi_status
750acpi_ns_check_object_type(char *pathname, 823acpi_ns_check_object_type(char *pathname,
751 union acpi_operand_object *return_object, 824 union acpi_operand_object **return_object_ptr,
752 u32 expected_btypes, u32 package_index) 825 u32 expected_btypes, u32 package_index)
753{ 826{
827 union acpi_operand_object *return_object = *return_object_ptr;
754 acpi_status status = AE_OK; 828 acpi_status status = AE_OK;
755 u32 return_btype; 829 u32 return_btype;
756 char type_buffer[48]; /* Room for 5 types */ 830 char type_buffer[48]; /* Room for 5 types */
@@ -814,6 +888,14 @@ acpi_ns_check_object_type(char *pathname,
814 /* Is the object one of the expected types? */ 888 /* Is the object one of the expected types? */
815 889
816 if (!(return_btype & expected_btypes)) { 890 if (!(return_btype & expected_btypes)) {
891
892 /* Type mismatch -- attempt repair of the returned object */
893
894 status = acpi_ns_repair_object(expected_btypes, package_index,
895 return_object_ptr);
896 if (ACPI_SUCCESS(status)) {
897 return (status);
898 }
817 goto type_error_exit; 899 goto type_error_exit;
818 } 900 }
819 901
@@ -898,3 +980,86 @@ acpi_ns_check_reference(char *pathname,
898 980
899 return (AE_AML_OPERAND_TYPE); 981 return (AE_AML_OPERAND_TYPE);
900} 982}
983
984/*******************************************************************************
985 *
986 * FUNCTION: acpi_ns_repair_object
987 *
988 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
989 * package_index - Used to determine if target is in a package
990 * return_object_ptr - Pointer to the object returned from the
991 * evaluation of a method or object
992 *
993 * RETURN: Status. AE_OK if repair was successful.
994 *
995 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
996 * not expected.
997 *
998 ******************************************************************************/
999
1000static acpi_status
1001acpi_ns_repair_object(u32 expected_btypes,
1002 u32 package_index,
1003 union acpi_operand_object **return_object_ptr)
1004{
1005 union acpi_operand_object *return_object = *return_object_ptr;
1006 union acpi_operand_object *new_object;
1007 acpi_size length;
1008
1009 switch (ACPI_GET_OBJECT_TYPE(return_object)) {
1010 case ACPI_TYPE_BUFFER:
1011
1012 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
1013 return (AE_AML_OPERAND_TYPE);
1014 }
1015
1016 /*
1017 * Have a Buffer, expected a String, convert. Use a to_string
1018 * conversion, no transform performed on the buffer data. The best
1019 * example of this is the _BIF method, where the string data from
1020 * the battery is often (incorrectly) returned as buffer object(s).
1021 */
1022 length = 0;
1023 while ((length < return_object->buffer.length) &&
1024 (return_object->buffer.pointer[length])) {
1025 length++;
1026 }
1027
1028 /* Allocate a new string object */
1029
1030 new_object = acpi_ut_create_string_object(length);
1031 if (!new_object) {
1032 return (AE_NO_MEMORY);
1033 }
1034
1035 /*
1036 * Copy the raw buffer data with no transform. String is already NULL
1037 * terminated at Length+1.
1038 */
1039 ACPI_MEMCPY(new_object->string.pointer,
1040 return_object->buffer.pointer, length);
1041
1042 /* Install the new return object */
1043
1044 acpi_ut_remove_reference(return_object);
1045 *return_object_ptr = new_object;
1046
1047 /*
1048 * If the object is a package element, we need to:
1049 * 1. Decrement the reference count of the orignal object, it was
1050 * incremented when building the package
1051 * 2. Increment the reference count of the new object, it will be
1052 * decremented when releasing the package
1053 */
1054 if (package_index != ACPI_NOT_PACKAGE) {
1055 acpi_ut_remove_reference(return_object);
1056 acpi_ut_add_reference(new_object);
1057 }
1058 return (AE_OK);
1059
1060 default:
1061 break;
1062 }
1063
1064 return (AE_AML_OPERAND_TYPE);
1065}
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/acpica/nssearch.c
index a9a80bf811b3..6fea13f3f52d 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nssearch") 49ACPI_MODULE_NAME("nssearch")
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/acpica/nsutils.c
index b0817e1127b1..3e1149bf4aa5 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acnamesp.h"
48#include <acpi/actables.h> 48#include "amlcode.h"
49#include "actables.h"
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsutils") 52ACPI_MODULE_NAME("nsutils")
@@ -314,9 +315,15 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
314 * 315 *
315 * strlen() + 1 covers the first name_seg, which has no path separator 316 * strlen() + 1 covers the first name_seg, which has no path separator
316 */ 317 */
317 if (acpi_ns_valid_root_prefix(next_external_char[0])) { 318 if (acpi_ns_valid_root_prefix(*next_external_char)) {
318 info->fully_qualified = TRUE; 319 info->fully_qualified = TRUE;
319 next_external_char++; 320 next_external_char++;
321
322 /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
323
324 while (acpi_ns_valid_root_prefix(*next_external_char)) {
325 next_external_char++;
326 }
320 } else { 327 } else {
321 /* 328 /*
322 * Handle Carat prefixes 329 * Handle Carat prefixes
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 3c905ce26d7d..200895fa2728 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nswalk") 49ACPI_MODULE_NAME("nswalk")
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index a085cc39c055..22a7171ac1ed 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsxfeval") 51ACPI_MODULE_NAME("nsxfeval")
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 5efa4e7ddb0b..9589fea24997 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsxfname") 50ACPI_MODULE_NAME("nsxfname")
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 2b375ee80cef..1c7efc15225f 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsxfobj") 50ACPI_MODULE_NAME("nsxfobj")
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/acpica/psargs.c
index d830b29b85b1..b161f3544b51 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include <acpi/acdispat.h> 48#include "acnamesp.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
51ACPI_MODULE_NAME("psargs") 52ACPI_MODULE_NAME("psargs")
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/acpica/psloop.c
index 4647039a0d8a..c5f6ce19a401 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -50,9 +50,10 @@
50 */ 50 */
51 51
52#include <acpi/acpi.h> 52#include <acpi/acpi.h>
53#include <acpi/acparser.h> 53#include "accommon.h"
54#include <acpi/acdispat.h> 54#include "acparser.h"
55#include <acpi/amlcode.h> 55#include "acdispat.h"
56#include "amlcode.h"
56 57
57#define _COMPONENT ACPI_PARSER 58#define _COMPONENT ACPI_PARSER
58ACPI_MODULE_NAME("psloop") 59ACPI_MODULE_NAME("psloop")
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/acpica/psopcode.c
index f425ab30eae8..3bc3a60194d6 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acopcode.h> 46#include "acparser.h"
47#include <acpi/amlcode.h> 47#include "acopcode.h"
48#include "amlcode.h"
48 49
49#define _COMPONENT ACPI_PARSER 50#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psopcode") 51ACPI_MODULE_NAME("psopcode")
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/acpica/psparse.c
index 68e932f215ea..70838e9b608c 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -51,11 +51,12 @@
51 */ 51 */
52 52
53#include <acpi/acpi.h> 53#include <acpi/acpi.h>
54#include <acpi/acparser.h> 54#include "accommon.h"
55#include <acpi/acdispat.h> 55#include "acparser.h"
56#include <acpi/amlcode.h> 56#include "acdispat.h"
57#include <acpi/acnamesp.h> 57#include "amlcode.h"
58#include <acpi/acinterp.h> 58#include "acnamesp.h"
59#include "acinterp.h"
59 60
60#define _COMPONENT ACPI_PARSER 61#define _COMPONENT ACPI_PARSER
61ACPI_MODULE_NAME("psparse") 62ACPI_MODULE_NAME("psparse")
@@ -447,10 +448,22 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
447 walk_state, walk_state->parser_state.aml, 448 walk_state, walk_state->parser_state.aml,
448 walk_state->parser_state.aml_size)); 449 walk_state->parser_state.aml_size));
449 450
451 if (!walk_state->parser_state.aml) {
452 return_ACPI_STATUS(AE_NULL_OBJECT);
453 }
454
450 /* Create and initialize a new thread state */ 455 /* Create and initialize a new thread state */
451 456
452 thread = acpi_ut_create_thread_state(); 457 thread = acpi_ut_create_thread_state();
453 if (!thread) { 458 if (!thread) {
459 if (walk_state->method_desc) {
460
461 /* Executing a control method - additional cleanup */
462
463 acpi_ds_terminate_control_method(
464 walk_state->method_desc, walk_state);
465 }
466
454 acpi_ds_delete_walk_state(walk_state); 467 acpi_ds_delete_walk_state(walk_state);
455 return_ACPI_STATUS(AE_NO_MEMORY); 468 return_ACPI_STATUS(AE_NO_MEMORY);
456 } 469 }
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/acpica/psscope.c
index ee50e67c9443..2feca5ca9581 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include "acparser.h"
46 47
47#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
48ACPI_MODULE_NAME("psscope") 49ACPI_MODULE_NAME("psscope")
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/acpica/pstree.c
index 1dd355ddd182..4d3389118ec3 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
49ACPI_MODULE_NAME("pstree") 50ACPI_MODULE_NAME("pstree")
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/acpica/psutils.c
index 7cf1f65cd5bb..e636e078ad3d 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
49ACPI_MODULE_NAME("psutils") 50ACPI_MODULE_NAME("psutils")
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 8b86ad5a3201..78b8b791f2ae 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include "acparser.h"
46 47
47#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
48ACPI_MODULE_NAME("pswalk") 49ACPI_MODULE_NAME("pswalk")
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/acpica/psxface.c
index 270469aae842..ff06032c0f06 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -42,9 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acparser.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include "acinterp.h"
49#include "amlcode.h"
48 50
49#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psxface") 52ACPI_MODULE_NAME("psxface")
@@ -278,6 +280,38 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
278 goto cleanup; 280 goto cleanup;
279 } 281 }
280 282
283 /* Invoke an internal method if necessary */
284
285 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
286 status = info->obj_desc->method.implementation(walk_state);
287 info->return_object = walk_state->return_desc;
288
289 /* Cleanup states */
290
291 acpi_ds_scope_stack_clear(walk_state);
292 acpi_ps_cleanup_scope(&walk_state->parser_state);
293 acpi_ds_terminate_control_method(walk_state->method_desc,
294 walk_state);
295 acpi_ds_delete_walk_state(walk_state);
296 goto cleanup;
297 }
298
299 /*
300 * Start method evaluation with an implicit return of zero.
301 * This is done for Windows compatibility.
302 */
303 if (acpi_gbl_enable_interpreter_slack) {
304 walk_state->implicit_return_obj =
305 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
306 if (!walk_state->implicit_return_obj) {
307 status = AE_NO_MEMORY;
308 acpi_ds_delete_walk_state(walk_state);
309 goto cleanup;
310 }
311
312 walk_state->implicit_return_obj->integer.value = 0;
313 }
314
281 /* Parse the AML */ 315 /* Parse the AML */
282 316
283 status = acpi_ps_parse_aml(walk_state); 317 status = acpi_ps_parse_aml(walk_state);
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 7f96332822bf..1e437bfd8db5 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsaddr") 49ACPI_MODULE_NAME("rsaddr")
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 8eaaecf92009..52865ee6bc77 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rscalc") 50ACPI_MODULE_NAME("rscalc")
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/acpica/rscreate.c
index c0bbfa2c4193..61566b1a0616 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rscreate") 50ACPI_MODULE_NAME("rscreate")
@@ -124,7 +125,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
124 * 125 *
125 * FUNCTION: acpi_rs_create_pci_routing_table 126 * FUNCTION: acpi_rs_create_pci_routing_table
126 * 127 *
127 * PARAMETERS: package_object - Pointer to an union acpi_operand_object 128 * PARAMETERS: package_object - Pointer to a union acpi_operand_object
128 * package 129 * package
129 * output_buffer - Pointer to the user's buffer 130 * output_buffer - Pointer to the user's buffer
130 * 131 *
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 6bbbb7b8941a..3f0ca5a12d34 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsdump") 49ACPI_MODULE_NAME("rsdump")
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 3f0a1fedbe0e..77b25fdb459c 100644
--- a/drivers/acpi/resources/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsinfo") 49ACPI_MODULE_NAME("rsinfo")
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/acpica/rsio.c
index b66d42e7402e..35a49aa95609 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsio") 49ACPI_MODULE_NAME("rsio")
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/acpica/rsirq.c
index a8805efc0366..2e0256983aa6 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsirq") 49ACPI_MODULE_NAME("rsirq")
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/acpica/rslist.c
index b78c7e797a19..1b1dbc69f087 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rslist") 49ACPI_MODULE_NAME("rslist")
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index 63b21abd90bb..ddc76cebdc92 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmemory") 49ACPI_MODULE_NAME("rsmemory")
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 96a6c0353255..5bc49a553284 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmisc") 49ACPI_MODULE_NAME("rsmisc")
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/acpica/rsutils.c
index f7b3bcd59ba7..bc03d5966829 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acresrc.h> 46#include "acnamesp.h"
47#include "acresrc.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsutils") 50ACPI_MODULE_NAME("rsutils")
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/acpica/rsxface.c
index f59f4c4e034c..69a2aa5b5d83 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsxface") 50ACPI_MODULE_NAME("rsxface")
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 2c7885e7ffba..3636e4f8fb73 100644
--- a/drivers/acpi/tables/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -42,15 +42,16 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbfadt") 49ACPI_MODULE_NAME("tbfadt")
49 50
50/* Local prototypes */ 51/* Local prototypes */
51static void inline 52static inline void
52acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 53acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
53 u8 byte_width, u64 address); 54 u8 space_id, u8 byte_width, u64 address);
54 55
55static void acpi_tb_convert_fadt(void); 56static void acpi_tb_convert_fadt(void);
56 57
@@ -60,9 +61,10 @@ static void acpi_tb_validate_fadt(void);
60 61
61typedef struct acpi_fadt_info { 62typedef struct acpi_fadt_info {
62 char *name; 63 char *name;
63 u8 target; 64 u8 address64;
64 u8 source; 65 u8 address32;
65 u8 length; 66 u8 length;
67 u8 default_length;
66 u8 type; 68 u8 type;
67 69
68} acpi_fadt_info; 70} acpi_fadt_info;
@@ -71,37 +73,61 @@ typedef struct acpi_fadt_info {
71#define ACPI_FADT_SEPARATE_LENGTH 2 73#define ACPI_FADT_SEPARATE_LENGTH 2
72 74
73static struct acpi_fadt_info fadt_info_table[] = { 75static struct acpi_fadt_info fadt_info_table[] = {
74 {"Pm1aEventBlock", ACPI_FADT_OFFSET(xpm1a_event_block), 76 {"Pm1aEventBlock",
77 ACPI_FADT_OFFSET(xpm1a_event_block),
75 ACPI_FADT_OFFSET(pm1a_event_block), 78 ACPI_FADT_OFFSET(pm1a_event_block),
76 ACPI_FADT_OFFSET(pm1_event_length), ACPI_FADT_REQUIRED}, 79 ACPI_FADT_OFFSET(pm1_event_length),
80 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
81 ACPI_FADT_REQUIRED},
77 82
78 {"Pm1bEventBlock", ACPI_FADT_OFFSET(xpm1b_event_block), 83 {"Pm1bEventBlock",
84 ACPI_FADT_OFFSET(xpm1b_event_block),
79 ACPI_FADT_OFFSET(pm1b_event_block), 85 ACPI_FADT_OFFSET(pm1b_event_block),
80 ACPI_FADT_OFFSET(pm1_event_length), 0}, 86 ACPI_FADT_OFFSET(pm1_event_length),
87 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
88 0},
81 89
82 {"Pm1aControlBlock", ACPI_FADT_OFFSET(xpm1a_control_block), 90 {"Pm1aControlBlock",
91 ACPI_FADT_OFFSET(xpm1a_control_block),
83 ACPI_FADT_OFFSET(pm1a_control_block), 92 ACPI_FADT_OFFSET(pm1a_control_block),
84 ACPI_FADT_OFFSET(pm1_control_length), ACPI_FADT_REQUIRED}, 93 ACPI_FADT_OFFSET(pm1_control_length),
94 ACPI_PM1_REGISTER_WIDTH,
95 ACPI_FADT_REQUIRED},
85 96
86 {"Pm1bControlBlock", ACPI_FADT_OFFSET(xpm1b_control_block), 97 {"Pm1bControlBlock",
98 ACPI_FADT_OFFSET(xpm1b_control_block),
87 ACPI_FADT_OFFSET(pm1b_control_block), 99 ACPI_FADT_OFFSET(pm1b_control_block),
88 ACPI_FADT_OFFSET(pm1_control_length), 0}, 100 ACPI_FADT_OFFSET(pm1_control_length),
101 ACPI_PM1_REGISTER_WIDTH,
102 0},
89 103
90 {"Pm2ControlBlock", ACPI_FADT_OFFSET(xpm2_control_block), 104 {"Pm2ControlBlock",
105 ACPI_FADT_OFFSET(xpm2_control_block),
91 ACPI_FADT_OFFSET(pm2_control_block), 106 ACPI_FADT_OFFSET(pm2_control_block),
92 ACPI_FADT_OFFSET(pm2_control_length), ACPI_FADT_SEPARATE_LENGTH}, 107 ACPI_FADT_OFFSET(pm2_control_length),
108 ACPI_PM2_REGISTER_WIDTH,
109 ACPI_FADT_SEPARATE_LENGTH},
93 110
94 {"PmTimerBlock", ACPI_FADT_OFFSET(xpm_timer_block), 111 {"PmTimerBlock",
112 ACPI_FADT_OFFSET(xpm_timer_block),
95 ACPI_FADT_OFFSET(pm_timer_block), 113 ACPI_FADT_OFFSET(pm_timer_block),
96 ACPI_FADT_OFFSET(pm_timer_length), ACPI_FADT_REQUIRED}, 114 ACPI_FADT_OFFSET(pm_timer_length),
115 ACPI_PM_TIMER_WIDTH,
116 ACPI_FADT_REQUIRED},
97 117
98 {"Gpe0Block", ACPI_FADT_OFFSET(xgpe0_block), 118 {"Gpe0Block",
119 ACPI_FADT_OFFSET(xgpe0_block),
99 ACPI_FADT_OFFSET(gpe0_block), 120 ACPI_FADT_OFFSET(gpe0_block),
100 ACPI_FADT_OFFSET(gpe0_block_length), ACPI_FADT_SEPARATE_LENGTH}, 121 ACPI_FADT_OFFSET(gpe0_block_length),
122 0,
123 ACPI_FADT_SEPARATE_LENGTH},
101 124
102 {"Gpe1Block", ACPI_FADT_OFFSET(xgpe1_block), 125 {"Gpe1Block",
126 ACPI_FADT_OFFSET(xgpe1_block),
103 ACPI_FADT_OFFSET(gpe1_block), 127 ACPI_FADT_OFFSET(gpe1_block),
104 ACPI_FADT_OFFSET(gpe1_block_length), ACPI_FADT_SEPARATE_LENGTH} 128 ACPI_FADT_OFFSET(gpe1_block_length),
129 0,
130 ACPI_FADT_SEPARATE_LENGTH}
105}; 131};
106 132
107#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) 133#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
@@ -122,9 +148,9 @@ static struct acpi_fadt_info fadt_info_table[] = {
122 * 148 *
123 ******************************************************************************/ 149 ******************************************************************************/
124 150
125static void inline 151static inline void
126acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 152acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
127 u8 byte_width, u64 address) 153 u8 space_id, u8 byte_width, u64 address)
128{ 154{
129 155
130 /* 156 /*
@@ -135,10 +161,10 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
135 161
136 /* All other fields are byte-wide */ 162 /* All other fields are byte-wide */
137 163
138 generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; 164 generic_address->space_id = space_id;
139 generic_address->bit_width = byte_width << 3; 165 generic_address->bit_width = (u8)ACPI_MUL_8(byte_width);
140 generic_address->bit_offset = 0; 166 generic_address->bit_offset = 0;
141 generic_address->access_width = 0; 167 generic_address->access_width = 0; /* Access width ANY */
142} 168}
143 169
144/******************************************************************************* 170/*******************************************************************************
@@ -225,7 +251,8 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
225 */ 251 */
226 if (length > sizeof(struct acpi_table_fadt)) { 252 if (length > sizeof(struct acpi_table_fadt)) {
227 ACPI_WARNING((AE_INFO, 253 ACPI_WARNING((AE_INFO,
228 "FADT (revision %u) is longer than ACPI 2.0 version, truncating length 0x%X to 0x%zX", 254 "FADT (revision %u) is longer than ACPI 2.0 version, "
255 "truncating length 0x%X to 0x%zX",
229 table->revision, (unsigned)length, 256 table->revision, (unsigned)length,
230 sizeof(struct acpi_table_fadt))); 257 sizeof(struct acpi_table_fadt)));
231 } 258 }
@@ -244,7 +271,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
244 * 2) Validate some of the important values within the FADT 271 * 2) Validate some of the important values within the FADT
245 */ 272 */
246 acpi_tb_convert_fadt(); 273 acpi_tb_convert_fadt();
247 acpi_tb_validate_fadt();
248} 274}
249 275
250/******************************************************************************* 276/*******************************************************************************
@@ -278,22 +304,36 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
278 304
279static void acpi_tb_convert_fadt(void) 305static void acpi_tb_convert_fadt(void)
280{ 306{
281 u8 pm1_register_length; 307 u8 pm1_register_bit_width;
282 struct acpi_generic_address *target; 308 u8 pm1_register_byte_width;
309 struct acpi_generic_address *target64;
283 u32 i; 310 u32 i;
284 311
285 /* Update the local FADT table header length */ 312 /* Update the local FADT table header length */
286 313
287 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); 314 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
288 315
289 /* Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary */ 316 /*
290 317 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
318 * Later code will always use the X 64-bit field. Also, check for an
319 * address mismatch between the 32-bit and 64-bit address fields
320 * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
321 * the presence of two FACS or two DSDT tables.
322 */
291 if (!acpi_gbl_FADT.Xfacs) { 323 if (!acpi_gbl_FADT.Xfacs) {
292 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; 324 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
325 } else if (acpi_gbl_FADT.facs &&
326 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
327 ACPI_WARNING((AE_INFO,
328 "32/64 FACS address mismatch in FADT - two FACS tables!"));
293 } 329 }
294 330
295 if (!acpi_gbl_FADT.Xdsdt) { 331 if (!acpi_gbl_FADT.Xdsdt) {
296 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; 332 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
333 } else if (acpi_gbl_FADT.dsdt &&
334 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
335 ACPI_WARNING((AE_INFO,
336 "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
297 } 337 }
298 338
299 /* 339 /*
@@ -304,7 +344,7 @@ static void acpi_tb_convert_fadt(void)
304 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at 344 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
305 * offset 45, 55, 95, and the word located at offset 109, 110. 345 * offset 45, 55, 95, and the word located at offset 109, 110.
306 */ 346 */
307 if (acpi_gbl_FADT.header.revision < 3) { 347 if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) {
308 acpi_gbl_FADT.preferred_profile = 0; 348 acpi_gbl_FADT.preferred_profile = 0;
309 acpi_gbl_FADT.pstate_control = 0; 349 acpi_gbl_FADT.pstate_control = 0;
310 acpi_gbl_FADT.cst_control = 0; 350 acpi_gbl_FADT.cst_control = 0;
@@ -312,18 +352,23 @@ static void acpi_tb_convert_fadt(void)
312 } 352 }
313 353
314 /* 354 /*
315 * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X" 355 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
316 * generic address structures as necessary. 356 * generic address structures as necessary. Later code will always use
357 * the 64-bit address structures.
317 */ 358 */
318 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 359 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
319 target = 360 target64 =
320 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, 361 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
321 fadt_info_table[i].target); 362 fadt_info_table[i].address64);
322 363
323 /* Expand only if the X target is null */ 364 /* Expand only if the 64-bit X target is null */
324 365
325 if (!target->address) { 366 if (!target64->address) {
326 acpi_tb_init_generic_address(target, 367
368 /* The space_id is always I/O for the 32-bit legacy address fields */
369
370 acpi_tb_init_generic_address(target64,
371 ACPI_ADR_SPACE_SYSTEM_IO,
327 *ACPI_ADD_PTR(u8, 372 *ACPI_ADD_PTR(u8,
328 &acpi_gbl_FADT, 373 &acpi_gbl_FADT,
329 fadt_info_table 374 fadt_info_table
@@ -332,11 +377,64 @@ static void acpi_tb_convert_fadt(void)
332 &acpi_gbl_FADT, 377 &acpi_gbl_FADT,
333 fadt_info_table 378 fadt_info_table
334 [i]. 379 [i].
335 source)); 380 address32));
381 }
382 }
383
384 /* Validate FADT values now, before we make any changes */
385
386 acpi_tb_validate_fadt();
387
388 /*
389 * Optionally check all register lengths against the default values and
390 * update them if they are incorrect.
391 */
392 if (acpi_gbl_use_default_register_widths) {
393 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
394 target64 =
395 ACPI_ADD_PTR(struct acpi_generic_address,
396 &acpi_gbl_FADT,
397 fadt_info_table[i].address64);
398
399 /*
400 * If a valid register (Address != 0) and the (default_length > 0)
401 * (Not a GPE register), then check the width against the default.
402 */
403 if ((target64->address) &&
404 (fadt_info_table[i].default_length > 0) &&
405 (fadt_info_table[i].default_length !=
406 target64->bit_width)) {
407 ACPI_WARNING((AE_INFO,
408 "Invalid length for %s: %d, using default %d",
409 fadt_info_table[i].name,
410 target64->bit_width,
411 fadt_info_table[i].
412 default_length));
413
414 /* Incorrect size, set width to the default */
415
416 target64->bit_width =
417 fadt_info_table[i].default_length;
418 }
336 } 419 }
337 } 420 }
338 421
339 /* 422 /*
423 * Get the length of the individual PM1 registers (enable and status).
424 * Each register is defined to be (event block length / 2).
425 */
426 pm1_register_bit_width =
427 (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width);
428 pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width);
429
430 /*
431 * Adjust the lengths of the PM1 Event Blocks so that they can be used to
432 * access the PM1 status register(s). Use (width / 2)
433 */
434 acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width;
435 acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width;
436
437 /*
340 * Calculate separate GAS structs for the PM1 Enable registers. 438 * Calculate separate GAS structs for the PM1 Enable registers.
341 * These addresses do not appear (directly) in the FADT, so it is 439 * These addresses do not appear (directly) in the FADT, so it is
342 * useful to calculate them once, here. 440 * useful to calculate them once, here.
@@ -356,14 +454,14 @@ static void acpi_tb_convert_fadt(void)
356 " PM1_EVT_LEN (%u)\n", 454 " PM1_EVT_LEN (%u)\n",
357 acpi_gbl_FADT.xpm1a_event_block.bit_width, 455 acpi_gbl_FADT.xpm1a_event_block.bit_width,
358 acpi_gbl_FADT.pm1_event_length); 456 acpi_gbl_FADT.pm1_event_length);
359 pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length);
360 457
361 /* The PM1A register block is required */ 458 /* The PM1A register block is required */
362 459
363 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, 460 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
364 pm1_register_length, 461 acpi_gbl_FADT.xpm1a_event_block.space_id,
462 pm1_register_byte_width,
365 (acpi_gbl_FADT.xpm1a_event_block.address + 463 (acpi_gbl_FADT.xpm1a_event_block.address +
366 pm1_register_length)); 464 pm1_register_byte_width));
367 /* Don't forget to copy space_id of the GAS */ 465 /* Don't forget to copy space_id of the GAS */
368 acpi_gbl_xpm1a_enable.space_id = 466 acpi_gbl_xpm1a_enable.space_id =
369 acpi_gbl_FADT.xpm1a_event_block.space_id; 467 acpi_gbl_FADT.xpm1a_event_block.space_id;
@@ -379,9 +477,10 @@ static void acpi_tb_convert_fadt(void)
379 acpi_gbl_FADT.xpm1b_event_block.bit_width, 477 acpi_gbl_FADT.xpm1b_event_block.bit_width,
380 acpi_gbl_FADT.pm1_event_length); 478 acpi_gbl_FADT.pm1_event_length);
381 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, 479 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
382 pm1_register_length, 480 acpi_gbl_FADT.xpm1b_event_block.space_id,
481 pm1_register_byte_width,
383 (acpi_gbl_FADT.xpm1b_event_block. 482 (acpi_gbl_FADT.xpm1b_event_block.
384 address + pm1_register_length)); 483 address + pm1_register_byte_width));
385 /* Don't forget to copy space_id of the GAS */ 484 /* Don't forget to copy space_id of the GAS */
386 acpi_gbl_xpm1b_enable.space_id = 485 acpi_gbl_xpm1b_enable.space_id =
387 acpi_gbl_FADT.xpm1b_event_block.space_id; 486 acpi_gbl_FADT.xpm1b_event_block.space_id;
@@ -411,26 +510,63 @@ static void acpi_tb_convert_fadt(void)
411 510
412static void acpi_tb_validate_fadt(void) 511static void acpi_tb_validate_fadt(void)
413{ 512{
513 char *name;
414 u32 *address32; 514 u32 *address32;
415 struct acpi_generic_address *address64; 515 struct acpi_generic_address *address64;
416 u8 length; 516 u8 length;
417 u32 i; 517 u32 i;
418 518
419 /* Examine all of the 64-bit extended address fields (X fields) */ 519 /*
520 * Check for FACS and DSDT address mismatches. An address mismatch between
521 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
522 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
523 */
524 if (acpi_gbl_FADT.facs &&
525 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
526 ACPI_WARNING((AE_INFO,
527 "32/64X FACS address mismatch in FADT - "
528 "two FACS tables! %8.8X/%8.8X%8.8X",
529 acpi_gbl_FADT.facs,
530 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
531 }
420 532
421 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 533 if (acpi_gbl_FADT.dsdt &&
534 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
535 ACPI_WARNING((AE_INFO,
536 "32/64X DSDT address mismatch in FADT - "
537 "two DSDT tables! %8.8X/%8.8X%8.8X",
538 acpi_gbl_FADT.dsdt,
539 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
540 }
422 541
423 /* Generate pointers to the 32-bit and 64-bit addresses and get the length */ 542 /* Examine all of the 64-bit extended address fields (X fields) */
424 543
425 address64 = 544 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
426 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, 545 /*
427 fadt_info_table[i].target); 546 * Generate pointers to the 32-bit and 64-bit addresses, get the
547 * register length (width), and the register name
548 */
549 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
550 &acpi_gbl_FADT,
551 fadt_info_table[i].address64);
428 address32 = 552 address32 =
429 ACPI_ADD_PTR(u32, &acpi_gbl_FADT, 553 ACPI_ADD_PTR(u32, &acpi_gbl_FADT,
430 fadt_info_table[i].source); 554 fadt_info_table[i].address32);
431 length = 555 length =
432 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, 556 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
433 fadt_info_table[i].length); 557 fadt_info_table[i].length);
558 name = fadt_info_table[i].name;
559
560 /*
561 * For each extended field, check for length mismatch between the
562 * legacy length field and the corresponding 64-bit X length field.
563 */
564 if (address64 && (address64->bit_width != ACPI_MUL_8(length))) {
565 ACPI_WARNING((AE_INFO,
566 "32/64X length mismatch in %s: %d/%d",
567 name, ACPI_MUL_8(length),
568 address64->bit_width));
569 }
434 570
435 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) { 571 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
436 /* 572 /*
@@ -439,8 +575,8 @@ static void acpi_tb_validate_fadt(void)
439 */ 575 */
440 if (!address64->address || !length) { 576 if (!address64->address || !length) {
441 ACPI_ERROR((AE_INFO, 577 ACPI_ERROR((AE_INFO,
442 "Required field \"%s\" has zero address and/or length: %8.8X%8.8X/%X", 578 "Required field %s has zero address and/or length: %8.8X%8.8X/%X",
443 fadt_info_table[i].name, 579 name,
444 ACPI_FORMAT_UINT64(address64-> 580 ACPI_FORMAT_UINT64(address64->
445 address), 581 address),
446 length)); 582 length));
@@ -453,8 +589,8 @@ static void acpi_tb_validate_fadt(void)
453 if ((address64->address && !length) 589 if ((address64->address && !length)
454 || (!address64->address && length)) { 590 || (!address64->address && length)) {
455 ACPI_WARNING((AE_INFO, 591 ACPI_WARNING((AE_INFO,
456 "Optional field \"%s\" has zero address or length: %8.8X%8.8X/%X", 592 "Optional field %s has zero address or length: %8.8X%8.8X/%X",
457 fadt_info_table[i].name, 593 name,
458 ACPI_FORMAT_UINT64(address64-> 594 ACPI_FORMAT_UINT64(address64->
459 address), 595 address),
460 length)); 596 length));
@@ -466,8 +602,8 @@ static void acpi_tb_validate_fadt(void)
466 if (address64->address && *address32 && 602 if (address64->address && *address32 &&
467 (address64->address != (u64) * address32)) { 603 (address64->address != (u64) * address32)) {
468 ACPI_ERROR((AE_INFO, 604 ACPI_ERROR((AE_INFO,
469 "32/64X address mismatch in \"%s\": [%8.8X] [%8.8X%8.8X], using 64X", 605 "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X",
470 fadt_info_table[i].name, *address32, 606 name, *address32,
471 ACPI_FORMAT_UINT64(address64->address))); 607 ACPI_FORMAT_UINT64(address64->address)));
472 } 608 }
473 } 609 }
diff --git a/drivers/acpi/tables/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 531584defbb8..1054dfd49207 100644
--- a/drivers/acpi/tables/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbfind") 49ACPI_MODULE_NAME("tbfind")
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 18747ce8dd2f..37374b21969d 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/actables.h> 46#include "acnamesp.h"
47#include "actables.h"
47 48
48#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
49ACPI_MODULE_NAME("tbinstal") 50ACPI_MODULE_NAME("tbinstal")
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 0cc92ef5236f..22ce48985720 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
@@ -113,6 +114,30 @@ acpi_tb_check_xsdt(acpi_physical_address address)
113 114
114/******************************************************************************* 115/*******************************************************************************
115 * 116 *
117 * FUNCTION: acpi_tb_initialize_facs
118 *
119 * PARAMETERS: None
120 *
121 * RETURN: Status
122 *
123 * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
124 * for accessing the Global Lock and Firmware Waking Vector
125 *
126 ******************************************************************************/
127
128acpi_status acpi_tb_initialize_facs(void)
129{
130 acpi_status status;
131
132 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
133 ACPI_CAST_INDIRECT_PTR(struct
134 acpi_table_header,
135 &acpi_gbl_FACS));
136 return status;
137}
138
139/*******************************************************************************
140 *
116 * FUNCTION: acpi_tb_tables_loaded 141 * FUNCTION: acpi_tb_tables_loaded
117 * 142 *
118 * PARAMETERS: None 143 * PARAMETERS: None
@@ -420,7 +445,8 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
420 445
421 /* Differentiate between RSDT and XSDT root tables */ 446 /* Differentiate between RSDT and XSDT root tables */
422 447
423 if (rsdp->revision > 1 && rsdp->xsdt_physical_address) { 448 if (rsdp->revision > 1 && rsdp->xsdt_physical_address
449 && !acpi_rsdt_forced) {
424 /* 450 /*
425 * Root table is an XSDT (64-bit physical addresses). We must use the 451 * Root table is an XSDT (64-bit physical addresses). We must use the
426 * XSDT if the revision is > 1 and the XSDT pointer is present, as per 452 * XSDT if the revision is > 1 and the XSDT pointer is present, as per
@@ -512,10 +538,9 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
512 if (ACPI_FAILURE(status)) { 538 if (ACPI_FAILURE(status)) {
513 ACPI_WARNING((AE_INFO, 539 ACPI_WARNING((AE_INFO,
514 "Truncating %u table entries!", 540 "Truncating %u table entries!",
515 (unsigned) 541 (unsigned) (table_count -
516 (acpi_gbl_root_table_list.size - 542 (acpi_gbl_root_table_list.
517 acpi_gbl_root_table_list. 543 count - 2))));
518 count)));
519 break; 544 break;
520 } 545 }
521 } 546 }
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/acpica/tbxface.c
index fd7770aa1061..ab0aff3c7d6a 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_TABLES 50#define _COMPONENT ACPI_TABLES
50ACPI_MODULE_NAME("tbxface") 51ACPI_MODULE_NAME("tbxface")
@@ -364,7 +365,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
364 365
365/******************************************************************************* 366/*******************************************************************************
366 * 367 *
367 * FUNCTION: acpi_get_table 368 * FUNCTION: acpi_get_table_with_size
368 * 369 *
369 * PARAMETERS: Signature - ACPI signature of needed table 370 * PARAMETERS: Signature - ACPI signature of needed table
370 * Instance - Which instance (for SSDTs) 371 * Instance - Which instance (for SSDTs)
@@ -376,8 +377,9 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
376 * 377 *
377 *****************************************************************************/ 378 *****************************************************************************/
378acpi_status 379acpi_status
379acpi_get_table(char *signature, 380acpi_get_table_with_size(char *signature,
380 u32 instance, struct acpi_table_header **out_table) 381 u32 instance, struct acpi_table_header **out_table,
382 acpi_size *tbl_size)
381{ 383{
382 u32 i; 384 u32 i;
383 u32 j; 385 u32 j;
@@ -407,6 +409,7 @@ acpi_get_table(char *signature,
407 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); 409 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
408 if (ACPI_SUCCESS(status)) { 410 if (ACPI_SUCCESS(status)) {
409 *out_table = acpi_gbl_root_table_list.tables[i].pointer; 411 *out_table = acpi_gbl_root_table_list.tables[i].pointer;
412 *tbl_size = acpi_gbl_root_table_list.tables[i].length;
410 } 413 }
411 414
412 if (!acpi_gbl_permanent_mmap) { 415 if (!acpi_gbl_permanent_mmap) {
@@ -419,6 +422,15 @@ acpi_get_table(char *signature,
419 return (AE_NOT_FOUND); 422 return (AE_NOT_FOUND);
420} 423}
421 424
425acpi_status
426acpi_get_table(char *signature,
427 u32 instance, struct acpi_table_header **out_table)
428{
429 acpi_size tbl_size;
430
431 return acpi_get_table_with_size(signature,
432 instance, out_table, &tbl_size);
433}
422ACPI_EXPORT_SYMBOL(acpi_get_table) 434ACPI_EXPORT_SYMBOL(acpi_get_table)
423 435
424/******************************************************************************* 436/*******************************************************************************
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 2d157e0f98d2..b7fc8dd43341 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbxfroot") 49ACPI_MODULE_NAME("tbxfroot")
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 241c535c1753..7580f6b3069e 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdebug.h> 45#include "accommon.h"
46#include "acdebug.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utalloc") 49ACPI_MODULE_NAME("utalloc")
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 5b2f7c27b705..b0dcfd3c872a 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47 48
48#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/acpica/utdebug.c
index fd66ecb6741e..38821f53042c 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utdebug") 48ACPI_MODULE_NAME("utdebug")
@@ -136,7 +137,7 @@ static const char *acpi_ut_trim_function_name(const char *function_name)
136 137
137/******************************************************************************* 138/*******************************************************************************
138 * 139 *
139 * FUNCTION: acpi_ut_debug_print 140 * FUNCTION: acpi_debug_print
140 * 141 *
141 * PARAMETERS: requested_debug_level - Requested debug print level 142 * PARAMETERS: requested_debug_level - Requested debug print level
142 * line_number - Caller's line number (for error output) 143 * line_number - Caller's line number (for error output)
@@ -154,11 +155,11 @@ static const char *acpi_ut_trim_function_name(const char *function_name)
154 ******************************************************************************/ 155 ******************************************************************************/
155 156
156void ACPI_INTERNAL_VAR_XFACE 157void ACPI_INTERNAL_VAR_XFACE
157acpi_ut_debug_print(u32 requested_debug_level, 158acpi_debug_print(u32 requested_debug_level,
158 u32 line_number, 159 u32 line_number,
159 const char *function_name, 160 const char *function_name,
160 const char *module_name, 161 const char *module_name,
161 u32 component_id, const char *format, ...) 162 u32 component_id, const char *format, ...)
162{ 163{
163 acpi_thread_id thread_id; 164 acpi_thread_id thread_id;
164 va_list args; 165 va_list args;
@@ -205,11 +206,11 @@ acpi_ut_debug_print(u32 requested_debug_level,
205 va_end(args); 206 va_end(args);
206} 207}
207 208
208ACPI_EXPORT_SYMBOL(acpi_ut_debug_print) 209ACPI_EXPORT_SYMBOL(acpi_debug_print)
209 210
210/******************************************************************************* 211/*******************************************************************************
211 * 212 *
212 * FUNCTION: acpi_ut_debug_print_raw 213 * FUNCTION: acpi_debug_print_raw
213 * 214 *
214 * PARAMETERS: requested_debug_level - Requested debug print level 215 * PARAMETERS: requested_debug_level - Requested debug print level
215 * line_number - Caller's line number 216 * line_number - Caller's line number
@@ -226,11 +227,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
226 * 227 *
227 ******************************************************************************/ 228 ******************************************************************************/
228void ACPI_INTERNAL_VAR_XFACE 229void ACPI_INTERNAL_VAR_XFACE
229acpi_ut_debug_print_raw(u32 requested_debug_level, 230acpi_debug_print_raw(u32 requested_debug_level,
230 u32 line_number, 231 u32 line_number,
231 const char *function_name, 232 const char *function_name,
232 const char *module_name, 233 const char *module_name,
233 u32 component_id, const char *format, ...) 234 u32 component_id, const char *format, ...)
234{ 235{
235 va_list args; 236 va_list args;
236 237
@@ -244,7 +245,7 @@ acpi_ut_debug_print_raw(u32 requested_debug_level,
244 va_end(args); 245 va_end(args);
245} 246}
246 247
247ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw) 248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
248 249
249/******************************************************************************* 250/*******************************************************************************
250 * 251 *
@@ -270,9 +271,9 @@ acpi_ut_trace(u32 line_number,
270 acpi_gbl_nesting_level++; 271 acpi_gbl_nesting_level++;
271 acpi_ut_track_stack_ptr(); 272 acpi_ut_track_stack_ptr();
272 273
273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 274 acpi_debug_print(ACPI_LV_FUNCTIONS,
274 line_number, function_name, module_name, 275 line_number, function_name, module_name, component_id,
275 component_id, "%s\n", acpi_gbl_fn_entry_str); 276 "%s\n", acpi_gbl_fn_entry_str);
276} 277}
277 278
278ACPI_EXPORT_SYMBOL(acpi_ut_trace) 279ACPI_EXPORT_SYMBOL(acpi_ut_trace)
@@ -301,10 +302,9 @@ acpi_ut_trace_ptr(u32 line_number,
301 acpi_gbl_nesting_level++; 302 acpi_gbl_nesting_level++;
302 acpi_ut_track_stack_ptr(); 303 acpi_ut_track_stack_ptr();
303 304
304 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 305 acpi_debug_print(ACPI_LV_FUNCTIONS,
305 line_number, function_name, module_name, 306 line_number, function_name, module_name, component_id,
306 component_id, "%s %p\n", acpi_gbl_fn_entry_str, 307 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
307 pointer);
308} 308}
309 309
310/******************************************************************************* 310/*******************************************************************************
@@ -333,10 +333,9 @@ acpi_ut_trace_str(u32 line_number,
333 acpi_gbl_nesting_level++; 333 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr(); 334 acpi_ut_track_stack_ptr();
335 335
336 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, 337 line_number, function_name, module_name, component_id,
338 component_id, "%s %s\n", acpi_gbl_fn_entry_str, 338 "%s %s\n", acpi_gbl_fn_entry_str, string);
339 string);
340} 339}
341 340
342/******************************************************************************* 341/*******************************************************************************
@@ -365,10 +364,9 @@ acpi_ut_trace_u32(u32 line_number,
365 acpi_gbl_nesting_level++; 364 acpi_gbl_nesting_level++;
366 acpi_ut_track_stack_ptr(); 365 acpi_ut_track_stack_ptr();
367 366
368 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 367 acpi_debug_print(ACPI_LV_FUNCTIONS,
369 line_number, function_name, module_name, 368 line_number, function_name, module_name, component_id,
370 component_id, "%s %08X\n", acpi_gbl_fn_entry_str, 369 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
371 integer);
372} 370}
373 371
374/******************************************************************************* 372/*******************************************************************************
@@ -393,9 +391,9 @@ acpi_ut_exit(u32 line_number,
393 const char *module_name, u32 component_id) 391 const char *module_name, u32 component_id)
394{ 392{
395 393
396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 394 acpi_debug_print(ACPI_LV_FUNCTIONS,
397 line_number, function_name, module_name, 395 line_number, function_name, module_name, component_id,
398 component_id, "%s\n", acpi_gbl_fn_exit_str); 396 "%s\n", acpi_gbl_fn_exit_str);
399 397
400 acpi_gbl_nesting_level--; 398 acpi_gbl_nesting_level--;
401} 399}
@@ -426,17 +424,16 @@ acpi_ut_status_exit(u32 line_number,
426{ 424{
427 425
428 if (ACPI_SUCCESS(status)) { 426 if (ACPI_SUCCESS(status)) {
429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 427 acpi_debug_print(ACPI_LV_FUNCTIONS,
430 line_number, function_name, module_name, 428 line_number, function_name, module_name,
431 component_id, "%s %s\n", 429 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
432 acpi_gbl_fn_exit_str, 430 acpi_format_exception(status));
433 acpi_format_exception(status));
434 } else { 431 } else {
435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 432 acpi_debug_print(ACPI_LV_FUNCTIONS,
436 line_number, function_name, module_name, 433 line_number, function_name, module_name,
437 component_id, "%s ****Exception****: %s\n", 434 component_id, "%s ****Exception****: %s\n",
438 acpi_gbl_fn_exit_str, 435 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status)); 436 acpi_format_exception(status));
440 } 437 }
441 438
442 acpi_gbl_nesting_level--; 439 acpi_gbl_nesting_level--;
@@ -467,10 +464,10 @@ acpi_ut_value_exit(u32 line_number,
467 u32 component_id, acpi_integer value) 464 u32 component_id, acpi_integer value)
468{ 465{
469 466
470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 467 acpi_debug_print(ACPI_LV_FUNCTIONS,
471 line_number, function_name, module_name, 468 line_number, function_name, module_name, component_id,
472 component_id, "%s %8.8X%8.8X\n", 469 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value)); 470 ACPI_FORMAT_UINT64(value));
474 471
475 acpi_gbl_nesting_level--; 472 acpi_gbl_nesting_level--;
476} 473}
@@ -499,9 +496,9 @@ acpi_ut_ptr_exit(u32 line_number,
499 const char *module_name, u32 component_id, u8 *ptr) 496 const char *module_name, u32 component_id, u8 *ptr)
500{ 497{
501 498
502 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 499 acpi_debug_print(ACPI_LV_FUNCTIONS,
503 line_number, function_name, module_name, 500 line_number, function_name, module_name, component_id,
504 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr); 501 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
505 502
506 acpi_gbl_nesting_level--; 503 acpi_gbl_nesting_level--;
507} 504}
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/acpica/utdelete.c
index d197c6b29e17..a0be9e39531e 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acinterp.h"
47#include <acpi/acevents.h> 47#include "acnamesp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utdelete") 51ACPI_MODULE_NAME("utdelete")
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/acpica/uteval.c
index 352747e49c7a..9c9897dbe907 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acnamesp.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("uteval") 50ACPI_MODULE_NAME("uteval")
@@ -115,9 +116,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
115 return_ACPI_STATUS(AE_NO_MEMORY); 116 return_ACPI_STATUS(AE_NO_MEMORY);
116 } 117 }
117 118
118 /* Default return value is SUPPORTED */ 119 /* Default return value is 0, NOT-SUPPORTED */
119 120
120 return_desc->integer.value = ACPI_UINT32_MAX; 121 return_desc->integer.value = 0;
121 walk_state->return_desc = return_desc; 122 walk_state->return_desc = return_desc;
122 123
123 /* Compare input string to static table of supported interfaces */ 124 /* Compare input string to static table of supported interfaces */
@@ -126,10 +127,8 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
126 if (!ACPI_STRCMP 127 if (!ACPI_STRCMP
127 (string_desc->string.pointer, 128 (string_desc->string.pointer,
128 acpi_interfaces_supported[i])) { 129 acpi_interfaces_supported[i])) {
129 130 return_desc->integer.value = ACPI_UINT32_MAX;
130 /* The interface is supported */ 131 goto done;
131
132 return_ACPI_STATUS(AE_CTRL_TERMINATE);
133 } 132 }
134 } 133 }
135 134
@@ -140,16 +139,15 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
140 */ 139 */
141 status = acpi_os_validate_interface(string_desc->string.pointer); 140 status = acpi_os_validate_interface(string_desc->string.pointer);
142 if (ACPI_SUCCESS(status)) { 141 if (ACPI_SUCCESS(status)) {
143 142 return_desc->integer.value = ACPI_UINT32_MAX;
144 /* The interface is supported */
145
146 return_ACPI_STATUS(AE_CTRL_TERMINATE);
147 } 143 }
148 144
149 /* The interface is not supported */ 145done:
146 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, "ACPI: BIOS _OSI(%s) %ssupported\n",
147 string_desc->string.pointer,
148 return_desc->integer.value == 0 ? "not-" : ""));
150 149
151 return_desc->integer.value = 0; 150 return_ACPI_STATUS(AE_OK);
152 return_ACPI_STATUS(AE_CTRL_TERMINATE);
153} 151}
154 152
155/******************************************************************************* 153/*******************************************************************************
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 670551b95e56..a3ab9d9da299 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -44,11 +44,11 @@
44#define DEFINE_ACPI_GLOBALS 44#define DEFINE_ACPI_GLOBALS
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 47#include "accommon.h"
48#include "acnamesp.h"
48 49
49ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME("utglobal") 51ACPI_MODULE_NAME("utglobal")
52 52
53/******************************************************************************* 53/*******************************************************************************
54 * 54 *
@@ -64,7 +64,7 @@ u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
64 64
65/* Debug switch - layer (component) mask */ 65/* Debug switch - layer (component) mask */
66 66
67u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; 67u32 acpi_dbg_layer = 0;
68u32 acpi_gbl_nesting_level = 0; 68u32 acpi_gbl_nesting_level = 0;
69 69
70/* Debugger globals */ 70/* Debugger globals */
@@ -352,7 +352,7 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
352 "PCI_Config", 352 "PCI_Config",
353 "EmbeddedControl", 353 "EmbeddedControl",
354 "SMBus", 354 "SMBus",
355 "CMOS", 355 "SystemCMOS",
356 "PCIBARTarget", 356 "PCIBARTarget",
357 "DataTable" 357 "DataTable"
358}; 358};
@@ -756,6 +756,7 @@ acpi_status acpi_ut_init_globals(void)
756 acpi_gbl_gpe_xrupt_list_head = NULL; 756 acpi_gbl_gpe_xrupt_list_head = NULL;
757 acpi_gbl_gpe_fadt_blocks[0] = NULL; 757 acpi_gbl_gpe_fadt_blocks[0] = NULL;
758 acpi_gbl_gpe_fadt_blocks[1] = NULL; 758 acpi_gbl_gpe_fadt_blocks[1] = NULL;
759 acpi_current_gpe_count = 0;
759 760
760 /* Global handlers */ 761 /* Global handlers */
761 762
@@ -771,6 +772,7 @@ acpi_status acpi_ut_init_globals(void)
771 acpi_gbl_global_lock_mutex = NULL; 772 acpi_gbl_global_lock_mutex = NULL;
772 acpi_gbl_global_lock_acquired = FALSE; 773 acpi_gbl_global_lock_acquired = FALSE;
773 acpi_gbl_global_lock_handle = 0; 774 acpi_gbl_global_lock_handle = 0;
775 acpi_gbl_global_lock_present = FALSE;
774 776
775 /* Miscellaneous variables */ 777 /* Miscellaneous variables */
776 778
@@ -815,5 +817,7 @@ acpi_status acpi_ut_init_globals(void)
815 return_ACPI_STATUS(AE_OK); 817 return_ACPI_STATUS(AE_OK);
816} 818}
817 819
820ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
818ACPI_EXPORT_SYMBOL(acpi_dbg_level) 821ACPI_EXPORT_SYMBOL(acpi_dbg_level)
819ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 822ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
823ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/acpica/utinit.c
index cae515fc02d3..a54ca84eb362 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acevents.h> 46#include "acnamesp.h"
47#include <acpi/actables.h> 47#include "acevents.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utinit") 51ACPI_MODULE_NAME("utinit")
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/acpica/utmath.c
index c927324fdd26..c9f682d640ef 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utmath") 48ACPI_MODULE_NAME("utmath")
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 9089a158a874..c1f7f4e1a72d 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -44,7 +44,8 @@
44#include <linux/module.h> 44#include <linux/module.h>
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 47#include "accommon.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utmisc") 51ACPI_MODULE_NAME("utmisc")
@@ -1016,7 +1017,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
1016 1017
1017/******************************************************************************* 1018/*******************************************************************************
1018 * 1019 *
1019 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info 1020 * FUNCTION: acpi_error, acpi_exception, acpi_warning, acpi_info
1020 * 1021 *
1021 * PARAMETERS: module_name - Caller's module name (for error output) 1022 * PARAMETERS: module_name - Caller's module name (for error output)
1022 * line_number - Caller's line number (for error output) 1023 * line_number - Caller's line number (for error output)
@@ -1029,7 +1030,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
1029 ******************************************************************************/ 1030 ******************************************************************************/
1030 1031
1031void ACPI_INTERNAL_VAR_XFACE 1032void ACPI_INTERNAL_VAR_XFACE
1032acpi_ut_error(const char *module_name, u32 line_number, const char *format, ...) 1033acpi_error(const char *module_name, u32 line_number, const char *format, ...)
1033{ 1034{
1034 va_list args; 1035 va_list args;
1035 1036
@@ -1042,8 +1043,8 @@ acpi_ut_error(const char *module_name, u32 line_number, const char *format, ...)
1042} 1043}
1043 1044
1044void ACPI_INTERNAL_VAR_XFACE 1045void ACPI_INTERNAL_VAR_XFACE
1045acpi_ut_exception(const char *module_name, 1046acpi_exception(const char *module_name,
1046 u32 line_number, acpi_status status, const char *format, ...) 1047 u32 line_number, acpi_status status, const char *format, ...)
1047{ 1048{
1048 va_list args; 1049 va_list args;
1049 1050
@@ -1056,11 +1057,8 @@ acpi_ut_exception(const char *module_name,
1056 va_end(args); 1057 va_end(args);
1057} 1058}
1058 1059
1059EXPORT_SYMBOL(acpi_ut_exception);
1060
1061void ACPI_INTERNAL_VAR_XFACE 1060void ACPI_INTERNAL_VAR_XFACE
1062acpi_ut_warning(const char *module_name, 1061acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
1063 u32 line_number, const char *format, ...)
1064{ 1062{
1065 va_list args; 1063 va_list args;
1066 1064
@@ -1073,7 +1071,7 @@ acpi_ut_warning(const char *module_name,
1073} 1071}
1074 1072
1075void ACPI_INTERNAL_VAR_XFACE 1073void ACPI_INTERNAL_VAR_XFACE
1076acpi_ut_info(const char *module_name, u32 line_number, const char *format, ...) 1074acpi_info(const char *module_name, u32 line_number, const char *format, ...)
1077{ 1075{
1078 va_list args; 1076 va_list args;
1079 1077
@@ -1088,3 +1086,8 @@ acpi_ut_info(const char *module_name, u32 line_number, const char *format, ...)
1088 acpi_os_printf("\n"); 1086 acpi_os_printf("\n");
1089 va_end(args); 1087 va_end(args);
1090} 1088}
1089
1090ACPI_EXPORT_SYMBOL(acpi_error)
1091ACPI_EXPORT_SYMBOL(acpi_exception)
1092ACPI_EXPORT_SYMBOL(acpi_warning)
1093ACPI_EXPORT_SYMBOL(acpi_info)
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 7331dde9e1b3..14eb52c4d647 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utmutex") 48ACPI_MODULE_NAME("utmutex")
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/acpica/utobject.c
index c354e7a42bcd..fd5ea7543e5b 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utobject") 49ACPI_MODULE_NAME("utobject")
@@ -297,7 +298,7 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
297 * 298 *
298 * RETURN: TRUE if object is valid, FALSE otherwise 299 * RETURN: TRUE if object is valid, FALSE otherwise
299 * 300 *
300 * DESCRIPTION: Validate a pointer to be an union acpi_operand_object 301 * DESCRIPTION: Validate a pointer to be a union acpi_operand_object
301 * 302 *
302 ******************************************************************************/ 303 ******************************************************************************/
303 304
@@ -389,7 +390,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
389{ 390{
390 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object); 391 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
391 392
392 /* Object must be an union acpi_operand_object */ 393 /* Object must be a union acpi_operand_object */
393 394
394 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 395 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
395 ACPI_ERROR((AE_INFO, 396 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/acpica/utresrc.c
index c3e3e1308edc..91b7c00236f4 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlresrc.h> 45#include "accommon.h"
46#include "amlresrc.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/acpica/utstate.c
index 63a6d3d77d88..0440c958f5a4 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utstate") 48ACPI_MODULE_NAME("utstate")
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/acpica/utxface.c
index c198a4d40583..078a22728c6b 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -42,9 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acdebug.h> 47#include "acnamesp.h"
48#include "acdebug.h"
49#include "actables.h"
48 50
49#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utxface") 52ACPI_MODULE_NAME("utxface")
@@ -148,6 +150,16 @@ acpi_status acpi_enable_subsystem(u32 flags)
148 } 150 }
149 151
150 /* 152 /*
153 * Obtain a permanent mapping for the FACS. This is required for the
154 * Global Lock and the Firmware Waking Vector
155 */
156 status = acpi_tb_initialize_facs();
157 if (ACPI_FAILURE(status)) {
158 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
159 return_ACPI_STATUS(status);
160 }
161
162 /*
151 * Install the default op_region handlers. These are installed unless 163 * Install the default op_region handlers. These are installed unless
152 * other handlers have already been installed via the 164 * other handlers have already been installed via the
153 * install_address_space_handler interface. 165 * install_address_space_handler interface.
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
deleted file mode 100644
index 1e74988c7b2d..000000000000
--- a/drivers/acpi/asus_acpi.c
+++ /dev/null
@@ -1,1460 +0,0 @@
1/*
2 * asus_acpi.c - Asus Laptop ACPI Extras
3 *
4 *
5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *
22 * The development page for this driver is located at
23 * http://sourceforge.net/projects/acpi4asus/
24 *
25 * Credits:
26 * Pontus Fuchs - Helper functions, cleanup
27 * Johann Wiesner - Small compile fixes
28 * John Belmonte - ACPI code for Toshiba laptop was a good starting point.
29 * �ic Burghard - LED display support for W1N
30 *
31 */
32
33#include <linux/kernel.h>
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/types.h>
37#include <linux/proc_fs.h>
38#include <linux/backlight.h>
39#include <acpi/acpi_drivers.h>
40#include <acpi/acpi_bus.h>
41#include <asm/uaccess.h>
42
43#define ASUS_ACPI_VERSION "0.30"
44
45#define PROC_ASUS "asus" /* The directory */
46#define PROC_MLED "mled"
47#define PROC_WLED "wled"
48#define PROC_TLED "tled"
49#define PROC_BT "bluetooth"
50#define PROC_LEDD "ledd"
51#define PROC_INFO "info"
52#define PROC_LCD "lcd"
53#define PROC_BRN "brn"
54#define PROC_DISP "disp"
55
56#define ACPI_HOTK_NAME "Asus Laptop ACPI Extras Driver"
57#define ACPI_HOTK_CLASS "hotkey"
58#define ACPI_HOTK_DEVICE_NAME "Hotkey"
59
60/*
61 * Some events we use, same for all Asus
62 */
63#define BR_UP 0x10
64#define BR_DOWN 0x20
65
66/*
67 * Flags for hotk status
68 */
69#define MLED_ON 0x01 /* Mail LED */
70#define WLED_ON 0x02 /* Wireless LED */
71#define TLED_ON 0x04 /* Touchpad LED */
72#define BT_ON 0x08 /* Internal Bluetooth */
73
74MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
75MODULE_DESCRIPTION(ACPI_HOTK_NAME);
76MODULE_LICENSE("GPL");
77
78static uid_t asus_uid;
79static gid_t asus_gid;
80module_param(asus_uid, uint, 0);
81MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus");
82module_param(asus_gid, uint, 0);
83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus");
84
85/* For each model, all features implemented,
86 * those marked with R are relative to HOTK, A for absolute */
87struct model_data {
88 char *name; /* name of the laptop________________A */
89 char *mt_mled; /* method to handle mled_____________R */
90 char *mled_status; /* node to handle mled reading_______A */
91 char *mt_wled; /* method to handle wled_____________R */
92 char *wled_status; /* node to handle wled reading_______A */
93 char *mt_tled; /* method to handle tled_____________R */
94 char *tled_status; /* node to handle tled reading_______A */
95 char *mt_ledd; /* method to handle LED display______R */
96 char *mt_bt_switch; /* method to switch Bluetooth on/off_R */
97 char *bt_status; /* no model currently supports this__? */
98 char *mt_lcd_switch; /* method to turn LCD on/off_________A */
99 char *lcd_status; /* node to read LCD panel state______A */
100 char *brightness_up; /* method to set brightness up_______A */
101 char *brightness_down; /* method to set brightness down ____A */
102 char *brightness_set; /* method to set absolute brightness_R */
103 char *brightness_get; /* method to get absolute brightness_R */
104 char *brightness_status;/* node to get brightness____________A */
105 char *display_set; /* method to set video output________R */
106 char *display_get; /* method to get video output________R */
107};
108
109/*
110 * This is the main structure, we can use it to store anything interesting
111 * about the hotk device
112 */
113struct asus_hotk {
114 struct acpi_device *device; /* the device we are in */
115 acpi_handle handle; /* the handle of the hotk device */
116 char status; /* status of the hotk, for LEDs */
117 u32 ledd_status; /* status of the LED display */
118 struct model_data *methods; /* methods available on the laptop */
119 u8 brightness; /* brightness level */
120 enum {
121 A1x = 0, /* A1340D, A1300F */
122 A2x, /* A2500H */
123 A4G, /* A4700G */
124 D1x, /* D1 */
125 L2D, /* L2000D */
126 L3C, /* L3800C */
127 L3D, /* L3400D */
128 L3H, /* L3H, L2000E, L5D */
129 L4R, /* L4500R */
130 L5x, /* L5800C */
131 L8L, /* L8400L */
132 M1A, /* M1300A */
133 M2E, /* M2400E, L4400L */
134 M6N, /* M6800N, W3400N */
135 M6R, /* M6700R, A3000G */
136 P30, /* Samsung P30 */
137 S1x, /* S1300A, but also L1400B and M2400A (L84F) */
138 S2x, /* S200 (J1 reported), Victor MP-XP7210 */
139 W1N, /* W1000N */
140 W5A, /* W5A */
141 W3V, /* W3030V */
142 xxN, /* M2400N, M3700N, M5200N, M6800N,
143 S1300N, S5200N*/
144 A4S, /* Z81sp */
145 F3Sa, /* (Centrino) */
146 END_MODEL
147 } model; /* Models currently supported */
148 u16 event_count[128]; /* Count for each event TODO make this better */
149};
150
151/* Here we go */
152#define A1x_PREFIX "\\_SB.PCI0.ISA.EC0."
153#define L3C_PREFIX "\\_SB.PCI0.PX40.ECD0."
154#define M1A_PREFIX "\\_SB.PCI0.PX40.EC0."
155#define P30_PREFIX "\\_SB.PCI0.LPCB.EC0."
156#define S1x_PREFIX "\\_SB.PCI0.PX40."
157#define S2x_PREFIX A1x_PREFIX
158#define xxN_PREFIX "\\_SB.PCI0.SBRG.EC0."
159
160static struct model_data model_conf[END_MODEL] = {
161 /*
162 * TODO I have seen a SWBX and AIBX method on some models, like L1400B,
163 * it seems to be a kind of switch, but what for ?
164 */
165
166 {
167 .name = "A1x",
168 .mt_mled = "MLED",
169 .mled_status = "\\MAIL",
170 .mt_lcd_switch = A1x_PREFIX "_Q10",
171 .lcd_status = "\\BKLI",
172 .brightness_up = A1x_PREFIX "_Q0E",
173 .brightness_down = A1x_PREFIX "_Q0F"},
174
175 {
176 .name = "A2x",
177 .mt_mled = "MLED",
178 .mt_wled = "WLED",
179 .wled_status = "\\SG66",
180 .mt_lcd_switch = "\\Q10",
181 .lcd_status = "\\BAOF",
182 .brightness_set = "SPLV",
183 .brightness_get = "GPLV",
184 .display_set = "SDSP",
185 .display_get = "\\INFB"},
186
187 {
188 .name = "A4G",
189 .mt_mled = "MLED",
190/* WLED present, but not controlled by ACPI */
191 .mt_lcd_switch = xxN_PREFIX "_Q10",
192 .brightness_set = "SPLV",
193 .brightness_get = "GPLV",
194 .display_set = "SDSP",
195 .display_get = "\\ADVG"},
196
197 {
198 .name = "D1x",
199 .mt_mled = "MLED",
200 .mt_lcd_switch = "\\Q0D",
201 .lcd_status = "\\GP11",
202 .brightness_up = "\\Q0C",
203 .brightness_down = "\\Q0B",
204 .brightness_status = "\\BLVL",
205 .display_set = "SDSP",
206 .display_get = "\\INFB"},
207
208 {
209 .name = "L2D",
210 .mt_mled = "MLED",
211 .mled_status = "\\SGP6",
212 .mt_wled = "WLED",
213 .wled_status = "\\RCP3",
214 .mt_lcd_switch = "\\Q10",
215 .lcd_status = "\\SGP0",
216 .brightness_up = "\\Q0E",
217 .brightness_down = "\\Q0F",
218 .display_set = "SDSP",
219 .display_get = "\\INFB"},
220
221 {
222 .name = "L3C",
223 .mt_mled = "MLED",
224 .mt_wled = "WLED",
225 .mt_lcd_switch = L3C_PREFIX "_Q10",
226 .lcd_status = "\\GL32",
227 .brightness_set = "SPLV",
228 .brightness_get = "GPLV",
229 .display_set = "SDSP",
230 .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP"},
231
232 {
233 .name = "L3D",
234 .mt_mled = "MLED",
235 .mled_status = "\\MALD",
236 .mt_wled = "WLED",
237 .mt_lcd_switch = "\\Q10",
238 .lcd_status = "\\BKLG",
239 .brightness_set = "SPLV",
240 .brightness_get = "GPLV",
241 .display_set = "SDSP",
242 .display_get = "\\INFB"},
243
244 {
245 .name = "L3H",
246 .mt_mled = "MLED",
247 .mt_wled = "WLED",
248 .mt_lcd_switch = "EHK",
249 .lcd_status = "\\_SB.PCI0.PM.PBC",
250 .brightness_set = "SPLV",
251 .brightness_get = "GPLV",
252 .display_set = "SDSP",
253 .display_get = "\\INFB"},
254
255 {
256 .name = "L4R",
257 .mt_mled = "MLED",
258 .mt_wled = "WLED",
259 .wled_status = "\\_SB.PCI0.SBRG.SG13",
260 .mt_lcd_switch = xxN_PREFIX "_Q10",
261 .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
262 .brightness_set = "SPLV",
263 .brightness_get = "GPLV",
264 .display_set = "SDSP",
265 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
266
267 {
268 .name = "L5x",
269 .mt_mled = "MLED",
270/* WLED present, but not controlled by ACPI */
271 .mt_tled = "TLED",
272 .mt_lcd_switch = "\\Q0D",
273 .lcd_status = "\\BAOF",
274 .brightness_set = "SPLV",
275 .brightness_get = "GPLV",
276 .display_set = "SDSP",
277 .display_get = "\\INFB"},
278
279 {
280 .name = "L8L"
281/* No features, but at least support the hotkeys */
282 },
283
284 {
285 .name = "M1A",
286 .mt_mled = "MLED",
287 .mt_lcd_switch = M1A_PREFIX "Q10",
288 .lcd_status = "\\PNOF",
289 .brightness_up = M1A_PREFIX "Q0E",
290 .brightness_down = M1A_PREFIX "Q0F",
291 .brightness_status = "\\BRIT",
292 .display_set = "SDSP",
293 .display_get = "\\INFB"},
294
295 {
296 .name = "M2E",
297 .mt_mled = "MLED",
298 .mt_wled = "WLED",
299 .mt_lcd_switch = "\\Q10",
300 .lcd_status = "\\GP06",
301 .brightness_set = "SPLV",
302 .brightness_get = "GPLV",
303 .display_set = "SDSP",
304 .display_get = "\\INFB"},
305
306 {
307 .name = "M6N",
308 .mt_mled = "MLED",
309 .mt_wled = "WLED",
310 .wled_status = "\\_SB.PCI0.SBRG.SG13",
311 .mt_lcd_switch = xxN_PREFIX "_Q10",
312 .lcd_status = "\\_SB.BKLT",
313 .brightness_set = "SPLV",
314 .brightness_get = "GPLV",
315 .display_set = "SDSP",
316 .display_get = "\\SSTE"},
317
318 {
319 .name = "M6R",
320 .mt_mled = "MLED",
321 .mt_wled = "WLED",
322 .mt_lcd_switch = xxN_PREFIX "_Q10",
323 .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
324 .brightness_set = "SPLV",
325 .brightness_get = "GPLV",
326 .display_set = "SDSP",
327 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
328
329 {
330 .name = "P30",
331 .mt_wled = "WLED",
332 .mt_lcd_switch = P30_PREFIX "_Q0E",
333 .lcd_status = "\\BKLT",
334 .brightness_up = P30_PREFIX "_Q68",
335 .brightness_down = P30_PREFIX "_Q69",
336 .brightness_get = "GPLV",
337 .display_set = "SDSP",
338 .display_get = "\\DNXT"},
339
340 {
341 .name = "S1x",
342 .mt_mled = "MLED",
343 .mled_status = "\\EMLE",
344 .mt_wled = "WLED",
345 .mt_lcd_switch = S1x_PREFIX "Q10",
346 .lcd_status = "\\PNOF",
347 .brightness_set = "SPLV",
348 .brightness_get = "GPLV"},
349
350 {
351 .name = "S2x",
352 .mt_mled = "MLED",
353 .mled_status = "\\MAIL",
354 .mt_lcd_switch = S2x_PREFIX "_Q10",
355 .lcd_status = "\\BKLI",
356 .brightness_up = S2x_PREFIX "_Q0B",
357 .brightness_down = S2x_PREFIX "_Q0A"},
358
359 {
360 .name = "W1N",
361 .mt_mled = "MLED",
362 .mt_wled = "WLED",
363 .mt_ledd = "SLCM",
364 .mt_lcd_switch = xxN_PREFIX "_Q10",
365 .lcd_status = "\\BKLT",
366 .brightness_set = "SPLV",
367 .brightness_get = "GPLV",
368 .display_set = "SDSP",
369 .display_get = "\\ADVG"},
370
371 {
372 .name = "W5A",
373 .mt_bt_switch = "BLED",
374 .mt_wled = "WLED",
375 .mt_lcd_switch = xxN_PREFIX "_Q10",
376 .brightness_set = "SPLV",
377 .brightness_get = "GPLV",
378 .display_set = "SDSP",
379 .display_get = "\\ADVG"},
380
381 {
382 .name = "W3V",
383 .mt_mled = "MLED",
384 .mt_wled = "WLED",
385 .mt_lcd_switch = xxN_PREFIX "_Q10",
386 .lcd_status = "\\BKLT",
387 .brightness_set = "SPLV",
388 .brightness_get = "GPLV",
389 .display_set = "SDSP",
390 .display_get = "\\INFB"},
391
392 {
393 .name = "xxN",
394 .mt_mled = "MLED",
395/* WLED present, but not controlled by ACPI */
396 .mt_lcd_switch = xxN_PREFIX "_Q10",
397 .lcd_status = "\\BKLT",
398 .brightness_set = "SPLV",
399 .brightness_get = "GPLV",
400 .display_set = "SDSP",
401 .display_get = "\\ADVG"},
402
403 {
404 .name = "A4S",
405 .brightness_set = "SPLV",
406 .brightness_get = "GPLV",
407 .mt_bt_switch = "BLED",
408 .mt_wled = "WLED"
409 },
410
411 {
412 .name = "F3Sa",
413 .mt_bt_switch = "BLED",
414 .mt_wled = "WLED",
415 .mt_mled = "MLED",
416 .brightness_get = "GPLV",
417 .brightness_set = "SPLV",
418 .mt_lcd_switch = "\\_SB.PCI0.SBRG.EC0._Q10",
419 .lcd_status = "\\_SB.PCI0.SBRG.EC0.RPIN",
420 .display_get = "\\ADVG",
421 .display_set = "SDSP",
422 },
423
424};
425
426/* procdir we use */
427static struct proc_dir_entry *asus_proc_dir;
428
429static struct backlight_device *asus_backlight_device;
430
431/*
432 * This header is made available to allow proper configuration given model,
433 * revision number , ... this info cannot go in struct asus_hotk because it is
434 * available before the hotk
435 */
436static struct acpi_table_header *asus_info;
437
438/* The actual device the driver binds to */
439static struct asus_hotk *hotk;
440
441/*
442 * The hotkey driver and autoloading declaration
443 */
444static int asus_hotk_add(struct acpi_device *device);
445static int asus_hotk_remove(struct acpi_device *device, int type);
446static const struct acpi_device_id asus_device_ids[] = {
447 {"ATK0100", 0},
448 {"", 0},
449};
450MODULE_DEVICE_TABLE(acpi, asus_device_ids);
451
452static struct acpi_driver asus_hotk_driver = {
453 .name = "asus_acpi",
454 .class = ACPI_HOTK_CLASS,
455 .ids = asus_device_ids,
456 .ops = {
457 .add = asus_hotk_add,
458 .remove = asus_hotk_remove,
459 },
460};
461
462/*
463 * This function evaluates an ACPI method, given an int as parameter, the
464 * method is searched within the scope of the handle, can be NULL. The output
465 * of the method is written is output, which can also be NULL
466 *
467 * returns 1 if write is successful, 0 else.
468 */
469static int write_acpi_int(acpi_handle handle, const char *method, int val,
470 struct acpi_buffer *output)
471{
472 struct acpi_object_list params; /* list of input parameters (int) */
473 union acpi_object in_obj; /* the only param we use */
474 acpi_status status;
475
476 params.count = 1;
477 params.pointer = &in_obj;
478 in_obj.type = ACPI_TYPE_INTEGER;
479 in_obj.integer.value = val;
480
481 status = acpi_evaluate_object(handle, (char *)method, &params, output);
482 return (status == AE_OK);
483}
484
485static int read_acpi_int(acpi_handle handle, const char *method, int *val)
486{
487 struct acpi_buffer output;
488 union acpi_object out_obj;
489 acpi_status status;
490
491 output.length = sizeof(out_obj);
492 output.pointer = &out_obj;
493
494 status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
495 *val = out_obj.integer.value;
496 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
497}
498
499/*
500 * We write our info in page, we begin at offset off and cannot write more
501 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
502 * number of bytes written in page
503 */
504static int
505proc_read_info(char *page, char **start, off_t off, int count, int *eof,
506 void *data)
507{
508 int len = 0;
509 int temp;
510 char buf[16]; /* enough for all info */
511 /*
512 * We use the easy way, we don't care of off and count,
513 * so we don't set eof to 1
514 */
515
516 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
517 len += sprintf(page + len, "Model reference : %s\n",
518 hotk->methods->name);
519 /*
520 * The SFUN method probably allows the original driver to get the list
521 * of features supported by a given model. For now, 0x0100 or 0x0800
522 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
523 * The significance of others is yet to be found.
524 */
525 if (read_acpi_int(hotk->handle, "SFUN", &temp))
526 len +=
527 sprintf(page + len, "SFUN value : 0x%04x\n", temp);
528 /*
529 * Another value for userspace: the ASYM method returns 0x02 for
530 * battery low and 0x04 for battery critical, its readings tend to be
531 * more accurate than those provided by _BST.
532 * Note: since not all the laptops provide this method, errors are
533 * silently ignored.
534 */
535 if (read_acpi_int(hotk->handle, "ASYM", &temp))
536 len +=
537 sprintf(page + len, "ASYM value : 0x%04x\n", temp);
538 if (asus_info) {
539 snprintf(buf, 16, "%d", asus_info->length);
540 len += sprintf(page + len, "DSDT length : %s\n", buf);
541 snprintf(buf, 16, "%d", asus_info->checksum);
542 len += sprintf(page + len, "DSDT checksum : %s\n", buf);
543 snprintf(buf, 16, "%d", asus_info->revision);
544 len += sprintf(page + len, "DSDT revision : %s\n", buf);
545 snprintf(buf, 7, "%s", asus_info->oem_id);
546 len += sprintf(page + len, "OEM id : %s\n", buf);
547 snprintf(buf, 9, "%s", asus_info->oem_table_id);
548 len += sprintf(page + len, "OEM table id : %s\n", buf);
549 snprintf(buf, 16, "%x", asus_info->oem_revision);
550 len += sprintf(page + len, "OEM revision : 0x%s\n", buf);
551 snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
552 len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
553 snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
554 len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf);
555 }
556
557 return len;
558}
559
560/*
561 * /proc handlers
562 * We write our info in page, we begin at offset off and cannot write more
563 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
564 * number of bytes written in page
565 */
566
567/* Generic LED functions */
568static int read_led(const char *ledname, int ledmask)
569{
570 if (ledname) {
571 int led_status;
572
573 if (read_acpi_int(NULL, ledname, &led_status))
574 return led_status;
575 else
576 printk(KERN_WARNING "Asus ACPI: Error reading LED "
577 "status\n");
578 }
579 return (hotk->status & ledmask) ? 1 : 0;
580}
581
582static int parse_arg(const char __user *buf, unsigned long count, int *val)
583{
584 char s[32];
585 if (!count)
586 return 0;
587 if (count > 31)
588 return -EINVAL;
589 if (copy_from_user(s, buf, count))
590 return -EFAULT;
591 s[count] = 0;
592 if (sscanf(s, "%i", val) != 1)
593 return -EINVAL;
594 return count;
595}
596
597/* FIXME: kill extraneous args so it can be called independently */
598static int
599write_led(const char __user *buffer, unsigned long count,
600 char *ledname, int ledmask, int invert)
601{
602 int rv, value;
603 int led_out = 0;
604
605 rv = parse_arg(buffer, count, &value);
606 if (rv > 0)
607 led_out = value ? 1 : 0;
608
609 hotk->status =
610 (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
611
612 if (invert) /* invert target value */
613 led_out = !led_out;
614
615 if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
616 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
617 ledname);
618
619 return rv;
620}
621
622/*
623 * Proc handlers for MLED
624 */
625static int
626proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
627 void *data)
628{
629 return sprintf(page, "%d\n",
630 read_led(hotk->methods->mled_status, MLED_ON));
631}
632
633static int
634proc_write_mled(struct file *file, const char __user *buffer,
635 unsigned long count, void *data)
636{
637 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
638}
639
640/*
641 * Proc handlers for LED display
642 */
643static int
644proc_read_ledd(char *page, char **start, off_t off, int count, int *eof,
645 void *data)
646{
647 return sprintf(page, "0x%08x\n", hotk->ledd_status);
648}
649
650static int
651proc_write_ledd(struct file *file, const char __user *buffer,
652 unsigned long count, void *data)
653{
654 int rv, value;
655
656 rv = parse_arg(buffer, count, &value);
657 if (rv > 0) {
658 if (!write_acpi_int
659 (hotk->handle, hotk->methods->mt_ledd, value, NULL))
660 printk(KERN_WARNING
661 "Asus ACPI: LED display write failed\n");
662 else
663 hotk->ledd_status = (u32) value;
664 }
665 return rv;
666}
667
668/*
669 * Proc handlers for WLED
670 */
671static int
672proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
673 void *data)
674{
675 return sprintf(page, "%d\n",
676 read_led(hotk->methods->wled_status, WLED_ON));
677}
678
679static int
680proc_write_wled(struct file *file, const char __user *buffer,
681 unsigned long count, void *data)
682{
683 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
684}
685
686/*
687 * Proc handlers for Bluetooth
688 */
689static int
690proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof,
691 void *data)
692{
693 return sprintf(page, "%d\n", read_led(hotk->methods->bt_status, BT_ON));
694}
695
696static int
697proc_write_bluetooth(struct file *file, const char __user *buffer,
698 unsigned long count, void *data)
699{
700 /* Note: mt_bt_switch controls both internal Bluetooth adapter's
701 presence and its LED */
702 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0);
703}
704
705/*
706 * Proc handlers for TLED
707 */
708static int
709proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
710 void *data)
711{
712 return sprintf(page, "%d\n",
713 read_led(hotk->methods->tled_status, TLED_ON));
714}
715
716static int
717proc_write_tled(struct file *file, const char __user *buffer,
718 unsigned long count, void *data)
719{
720 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
721}
722
723static int get_lcd_state(void)
724{
725 int lcd = 0;
726
727 if (hotk->model == L3H) {
728 /* L3H and the like have to be handled differently */
729 acpi_status status = 0;
730 struct acpi_object_list input;
731 union acpi_object mt_params[2];
732 struct acpi_buffer output;
733 union acpi_object out_obj;
734
735 input.count = 2;
736 input.pointer = mt_params;
737 /* Note: the following values are partly guessed up, but
738 otherwise they seem to work */
739 mt_params[0].type = ACPI_TYPE_INTEGER;
740 mt_params[0].integer.value = 0x02;
741 mt_params[1].type = ACPI_TYPE_INTEGER;
742 mt_params[1].integer.value = 0x02;
743
744 output.length = sizeof(out_obj);
745 output.pointer = &out_obj;
746
747 status =
748 acpi_evaluate_object(NULL, hotk->methods->lcd_status,
749 &input, &output);
750 if (status != AE_OK)
751 return -1;
752 if (out_obj.type == ACPI_TYPE_INTEGER)
753 /* That's what the AML code does */
754 lcd = out_obj.integer.value >> 8;
755 } else if (hotk->model == F3Sa) {
756 unsigned long long tmp;
757 union acpi_object param;
758 struct acpi_object_list input;
759 acpi_status status;
760
761 /* Read pin 11 */
762 param.type = ACPI_TYPE_INTEGER;
763 param.integer.value = 0x11;
764 input.count = 1;
765 input.pointer = &param;
766
767 status = acpi_evaluate_integer(NULL, hotk->methods->lcd_status,
768 &input, &tmp);
769 if (status != AE_OK)
770 return -1;
771
772 lcd = tmp;
773 } else {
774 /* We don't have to check anything if we are here */
775 if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
776 printk(KERN_WARNING
777 "Asus ACPI: Error reading LCD status\n");
778
779 if (hotk->model == L2D)
780 lcd = ~lcd;
781 }
782
783 return (lcd & 1);
784}
785
786static int set_lcd_state(int value)
787{
788 int lcd = 0;
789 acpi_status status = 0;
790
791 lcd = value ? 1 : 0;
792 if (lcd != get_lcd_state()) {
793 /* switch */
794 if (hotk->model != L3H) {
795 status =
796 acpi_evaluate_object(NULL,
797 hotk->methods->mt_lcd_switch,
798 NULL, NULL);
799 } else {
800 /* L3H and the like must be handled differently */
801 if (!write_acpi_int
802 (hotk->handle, hotk->methods->mt_lcd_switch, 0x07,
803 NULL))
804 status = AE_ERROR;
805 /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress,
806 the exact behaviour is simulated here */
807 }
808 if (ACPI_FAILURE(status))
809 printk(KERN_WARNING "Asus ACPI: Error switching LCD\n");
810 }
811 return 0;
812
813}
814
815static int
816proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
817 void *data)
818{
819 return sprintf(page, "%d\n", get_lcd_state());
820}
821
822static int
823proc_write_lcd(struct file *file, const char __user *buffer,
824 unsigned long count, void *data)
825{
826 int rv, value;
827
828 rv = parse_arg(buffer, count, &value);
829 if (rv > 0)
830 set_lcd_state(value);
831 return rv;
832}
833
834static int read_brightness(struct backlight_device *bd)
835{
836 int value;
837
838 if (hotk->methods->brightness_get) { /* SPLV/GPLV laptop */
839 if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get,
840 &value))
841 printk(KERN_WARNING
842 "Asus ACPI: Error reading brightness\n");
843 } else if (hotk->methods->brightness_status) { /* For D1 for example */
844 if (!read_acpi_int(NULL, hotk->methods->brightness_status,
845 &value))
846 printk(KERN_WARNING
847 "Asus ACPI: Error reading brightness\n");
848 } else /* No GPLV method */
849 value = hotk->brightness;
850 return value;
851}
852
853/*
854 * Change the brightness level
855 */
856static int set_brightness(int value)
857{
858 acpi_status status = 0;
859 int ret = 0;
860
861 /* SPLV laptop */
862 if (hotk->methods->brightness_set) {
863 if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set,
864 value, NULL))
865 printk(KERN_WARNING
866 "Asus ACPI: Error changing brightness\n");
867 ret = -EIO;
868 goto out;
869 }
870
871 /* No SPLV method if we are here, act as appropriate */
872 value -= read_brightness(NULL);
873 while (value != 0) {
874 status = acpi_evaluate_object(NULL, (value > 0) ?
875 hotk->methods->brightness_up :
876 hotk->methods->brightness_down,
877 NULL, NULL);
878 (value > 0) ? value-- : value++;
879 if (ACPI_FAILURE(status))
880 printk(KERN_WARNING
881 "Asus ACPI: Error changing brightness\n");
882 ret = -EIO;
883 }
884out:
885 return ret;
886}
887
888static int set_brightness_status(struct backlight_device *bd)
889{
890 return set_brightness(bd->props.brightness);
891}
892
893static int
894proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
895 void *data)
896{
897 return sprintf(page, "%d\n", read_brightness(NULL));
898}
899
900static int
901proc_write_brn(struct file *file, const char __user *buffer,
902 unsigned long count, void *data)
903{
904 int rv, value;
905
906 rv = parse_arg(buffer, count, &value);
907 if (rv > 0) {
908 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
909 /* 0 <= value <= 15 */
910 set_brightness(value);
911 }
912 return rv;
913}
914
915static void set_display(int value)
916{
917 /* no sanity check needed for now */
918 if (!write_acpi_int(hotk->handle, hotk->methods->display_set,
919 value, NULL))
920 printk(KERN_WARNING "Asus ACPI: Error setting display\n");
921 return;
922}
923
924/*
925 * Now, *this* one could be more user-friendly, but so far, no-one has
926 * complained. The significance of bits is the same as in proc_write_disp()
927 */
928static int
929proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
930 void *data)
931{
932 int value = 0;
933
934 if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
935 printk(KERN_WARNING
936 "Asus ACPI: Error reading display status\n");
937 value &= 0x07; /* needed for some models, shouldn't hurt others */
938 return sprintf(page, "%d\n", value);
939}
940
941/*
942 * Experimental support for display switching. As of now: 1 should activate
943 * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination
944 * (bitwise) of these will suffice. I never actually tested 3 displays hooked
945 * up simultaneously, so be warned. See the acpi4asus README for more info.
946 */
947static int
948proc_write_disp(struct file *file, const char __user *buffer,
949 unsigned long count, void *data)
950{
951 int rv, value;
952
953 rv = parse_arg(buffer, count, &value);
954 if (rv > 0)
955 set_display(value);
956 return rv;
957}
958
959typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
960 int *eof, void *data);
961typedef int (proc_writefunc) (struct file *file, const char __user *buffer,
962 unsigned long count, void *data);
963
964static int
965asus_proc_add(char *name, proc_writefunc *writefunc,
966 proc_readfunc *readfunc, mode_t mode,
967 struct acpi_device *device)
968{
969 struct proc_dir_entry *proc =
970 create_proc_entry(name, mode, acpi_device_dir(device));
971 if (!proc) {
972 printk(KERN_WARNING " Unable to create %s fs entry\n", name);
973 return -1;
974 }
975 proc->write_proc = writefunc;
976 proc->read_proc = readfunc;
977 proc->data = acpi_driver_data(device);
978 proc->owner = THIS_MODULE;
979 proc->uid = asus_uid;
980 proc->gid = asus_gid;
981 return 0;
982}
983
984static int asus_hotk_add_fs(struct acpi_device *device)
985{
986 struct proc_dir_entry *proc;
987 mode_t mode;
988
989 /*
990 * If parameter uid or gid is not changed, keep the default setting for
991 * our proc entries (-rw-rw-rw-) else, it means we care about security,
992 * and then set to -rw-rw----
993 */
994
995 if ((asus_uid == 0) && (asus_gid == 0)) {
996 mode = S_IFREG | S_IRUGO | S_IWUGO;
997 } else {
998 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
999 printk(KERN_WARNING " asus_uid and asus_gid parameters are "
1000 "deprecated, use chown and chmod instead!\n");
1001 }
1002
1003 acpi_device_dir(device) = asus_proc_dir;
1004 if (!acpi_device_dir(device))
1005 return -ENODEV;
1006
1007 proc = create_proc_entry(PROC_INFO, mode, acpi_device_dir(device));
1008 if (proc) {
1009 proc->read_proc = proc_read_info;
1010 proc->data = acpi_driver_data(device);
1011 proc->owner = THIS_MODULE;
1012 proc->uid = asus_uid;
1013 proc->gid = asus_gid;
1014 } else {
1015 printk(KERN_WARNING " Unable to create " PROC_INFO
1016 " fs entry\n");
1017 }
1018
1019 if (hotk->methods->mt_wled) {
1020 asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled,
1021 mode, device);
1022 }
1023
1024 if (hotk->methods->mt_ledd) {
1025 asus_proc_add(PROC_LEDD, &proc_write_ledd, &proc_read_ledd,
1026 mode, device);
1027 }
1028
1029 if (hotk->methods->mt_mled) {
1030 asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled,
1031 mode, device);
1032 }
1033
1034 if (hotk->methods->mt_tled) {
1035 asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled,
1036 mode, device);
1037 }
1038
1039 if (hotk->methods->mt_bt_switch) {
1040 asus_proc_add(PROC_BT, &proc_write_bluetooth,
1041 &proc_read_bluetooth, mode, device);
1042 }
1043
1044 /*
1045 * We need both read node and write method as LCD switch is also
1046 * accessible from the keyboard
1047 */
1048 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
1049 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode,
1050 device);
1051 }
1052
1053 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
1054 (hotk->methods->brightness_get && hotk->methods->brightness_set)) {
1055 asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode,
1056 device);
1057 }
1058
1059 if (hotk->methods->display_set) {
1060 asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp,
1061 mode, device);
1062 }
1063
1064 return 0;
1065}
1066
1067static int asus_hotk_remove_fs(struct acpi_device *device)
1068{
1069 if (acpi_device_dir(device)) {
1070 remove_proc_entry(PROC_INFO, acpi_device_dir(device));
1071 if (hotk->methods->mt_wled)
1072 remove_proc_entry(PROC_WLED, acpi_device_dir(device));
1073 if (hotk->methods->mt_mled)
1074 remove_proc_entry(PROC_MLED, acpi_device_dir(device));
1075 if (hotk->methods->mt_tled)
1076 remove_proc_entry(PROC_TLED, acpi_device_dir(device));
1077 if (hotk->methods->mt_ledd)
1078 remove_proc_entry(PROC_LEDD, acpi_device_dir(device));
1079 if (hotk->methods->mt_bt_switch)
1080 remove_proc_entry(PROC_BT, acpi_device_dir(device));
1081 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status)
1082 remove_proc_entry(PROC_LCD, acpi_device_dir(device));
1083 if ((hotk->methods->brightness_up
1084 && hotk->methods->brightness_down)
1085 || (hotk->methods->brightness_get
1086 && hotk->methods->brightness_set))
1087 remove_proc_entry(PROC_BRN, acpi_device_dir(device));
1088 if (hotk->methods->display_set)
1089 remove_proc_entry(PROC_DISP, acpi_device_dir(device));
1090 }
1091 return 0;
1092}
1093
1094static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
1095{
1096 /* TODO Find a better way to handle events count. */
1097 if (!hotk)
1098 return;
1099
1100 if ((event & ~((u32) BR_UP)) < 16)
1101 hotk->brightness = (event & ~((u32) BR_UP));
1102 else if ((event & ~((u32) BR_DOWN)) < 16)
1103 hotk->brightness = (event & ~((u32) BR_DOWN));
1104
1105 acpi_bus_generate_proc_event(hotk->device, event,
1106 hotk->event_count[event % 128]++);
1107
1108 return;
1109}
1110
1111/*
1112 * Match the model string to the list of supported models. Return END_MODEL if
1113 * no match or model is NULL.
1114 */
1115static int asus_model_match(char *model)
1116{
1117 if (model == NULL)
1118 return END_MODEL;
1119
1120 if (strncmp(model, "L3D", 3) == 0)
1121 return L3D;
1122 else if (strncmp(model, "L2E", 3) == 0 ||
1123 strncmp(model, "L3H", 3) == 0 || strncmp(model, "L5D", 3) == 0)
1124 return L3H;
1125 else if (strncmp(model, "L3", 2) == 0 || strncmp(model, "L2B", 3) == 0)
1126 return L3C;
1127 else if (strncmp(model, "L8L", 3) == 0)
1128 return L8L;
1129 else if (strncmp(model, "L4R", 3) == 0)
1130 return L4R;
1131 else if (strncmp(model, "M6N", 3) == 0 || strncmp(model, "W3N", 3) == 0)
1132 return M6N;
1133 else if (strncmp(model, "M6R", 3) == 0 || strncmp(model, "A3G", 3) == 0)
1134 return M6R;
1135 else if (strncmp(model, "M2N", 3) == 0 ||
1136 strncmp(model, "M3N", 3) == 0 ||
1137 strncmp(model, "M5N", 3) == 0 ||
1138 strncmp(model, "M6N", 3) == 0 ||
1139 strncmp(model, "S1N", 3) == 0 ||
1140 strncmp(model, "S5N", 3) == 0 || strncmp(model, "W1N", 3) == 0)
1141 return xxN;
1142 else if (strncmp(model, "M1", 2) == 0)
1143 return M1A;
1144 else if (strncmp(model, "M2", 2) == 0 || strncmp(model, "L4E", 3) == 0)
1145 return M2E;
1146 else if (strncmp(model, "L2", 2) == 0)
1147 return L2D;
1148 else if (strncmp(model, "L8", 2) == 0)
1149 return S1x;
1150 else if (strncmp(model, "D1", 2) == 0)
1151 return D1x;
1152 else if (strncmp(model, "A1", 2) == 0)
1153 return A1x;
1154 else if (strncmp(model, "A2", 2) == 0)
1155 return A2x;
1156 else if (strncmp(model, "J1", 2) == 0)
1157 return S2x;
1158 else if (strncmp(model, "L5", 2) == 0)
1159 return L5x;
1160 else if (strncmp(model, "A4G", 3) == 0)
1161 return A4G;
1162 else if (strncmp(model, "W1N", 3) == 0)
1163 return W1N;
1164 else if (strncmp(model, "W3V", 3) == 0)
1165 return W3V;
1166 else if (strncmp(model, "W5A", 3) == 0)
1167 return W5A;
1168 else if (strncmp(model, "A4S", 3) == 0)
1169 return A4S;
1170 else if (strncmp(model, "F3Sa", 4) == 0)
1171 return F3Sa;
1172 else
1173 return END_MODEL;
1174}
1175
1176/*
1177 * This function is used to initialize the hotk with right values. In this
1178 * method, we can make all the detection we want, and modify the hotk struct
1179 */
1180static int asus_hotk_get_info(void)
1181{
1182 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1183 union acpi_object *model = NULL;
1184 int bsts_result;
1185 char *string = NULL;
1186 acpi_status status;
1187
1188 /*
1189 * Get DSDT headers early enough to allow for differentiating between
1190 * models, but late enough to allow acpi_bus_register_driver() to fail
1191 * before doing anything ACPI-specific. Should we encounter a machine,
1192 * which needs special handling (i.e. its hotkey device has a different
1193 * HID), this bit will be moved. A global variable asus_info contains
1194 * the DSDT header.
1195 */
1196 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info);
1197 if (ACPI_FAILURE(status))
1198 printk(KERN_WARNING " Couldn't get the DSDT table header\n");
1199
1200 /* We have to write 0 on init this far for all ASUS models */
1201 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
1202 printk(KERN_ERR " Hotkey initialization failed\n");
1203 return -ENODEV;
1204 }
1205
1206 /* This needs to be called for some laptops to init properly */
1207 if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result))
1208 printk(KERN_WARNING " Error calling BSTS\n");
1209 else if (bsts_result)
1210 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n",
1211 bsts_result);
1212
1213 /*
1214 * Try to match the object returned by INIT to the specific model.
1215 * Handle every possible object (or the lack of thereof) the DSDT
1216 * writers might throw at us. When in trouble, we pass NULL to
1217 * asus_model_match() and try something completely different.
1218 */
1219 if (buffer.pointer) {
1220 model = buffer.pointer;
1221 switch (model->type) {
1222 case ACPI_TYPE_STRING:
1223 string = model->string.pointer;
1224 break;
1225 case ACPI_TYPE_BUFFER:
1226 string = model->buffer.pointer;
1227 break;
1228 default:
1229 kfree(model);
1230 model = NULL;
1231 break;
1232 }
1233 }
1234 hotk->model = asus_model_match(string);
1235 if (hotk->model == END_MODEL) { /* match failed */
1236 if (asus_info &&
1237 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
1238 hotk->model = P30;
1239 printk(KERN_NOTICE
1240 " Samsung P30 detected, supported\n");
1241 } else {
1242 hotk->model = M2E;
1243 printk(KERN_NOTICE " unsupported model %s, trying "
1244 "default values\n", string);
1245 printk(KERN_NOTICE
1246 " send /proc/acpi/dsdt to the developers\n");
1247 kfree(model);
1248 return -ENODEV;
1249 }
1250 hotk->methods = &model_conf[hotk->model];
1251 return AE_OK;
1252 }
1253 hotk->methods = &model_conf[hotk->model];
1254 printk(KERN_NOTICE " %s model detected, supported\n", string);
1255
1256 /* Sort of per-model blacklist */
1257 if (strncmp(string, "L2B", 3) == 0)
1258 hotk->methods->lcd_status = NULL;
1259 /* L2B is similar enough to L3C to use its settings, with this only
1260 exception */
1261 else if (strncmp(string, "A3G", 3) == 0)
1262 hotk->methods->lcd_status = "\\BLFG";
1263 /* A3G is like M6R */
1264 else if (strncmp(string, "S5N", 3) == 0 ||
1265 strncmp(string, "M5N", 3) == 0 ||
1266 strncmp(string, "W3N", 3) == 0)
1267 hotk->methods->mt_mled = NULL;
1268 /* S5N, M5N and W3N have no MLED */
1269 else if (strncmp(string, "L5D", 3) == 0)
1270 hotk->methods->mt_wled = NULL;
1271 /* L5D's WLED is not controlled by ACPI */
1272 else if (strncmp(string, "M2N", 3) == 0 ||
1273 strncmp(string, "W3V", 3) == 0 ||
1274 strncmp(string, "S1N", 3) == 0)
1275 hotk->methods->mt_wled = "WLED";
1276 /* M2N, S1N and W3V have a usable WLED */
1277 else if (asus_info) {
1278 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
1279 hotk->methods->mled_status = NULL;
1280 /* S1300A reports L84F, but L1400B too, account for that */
1281 }
1282
1283 kfree(model);
1284
1285 return AE_OK;
1286}
1287
1288static int asus_hotk_check(void)
1289{
1290 int result = 0;
1291
1292 result = acpi_bus_get_status(hotk->device);
1293 if (result)
1294 return result;
1295
1296 if (hotk->device->status.present) {
1297 result = asus_hotk_get_info();
1298 } else {
1299 printk(KERN_ERR " Hotkey device not present, aborting\n");
1300 return -EINVAL;
1301 }
1302
1303 return result;
1304}
1305
1306static int asus_hotk_found;
1307
1308static int asus_hotk_add(struct acpi_device *device)
1309{
1310 acpi_status status = AE_OK;
1311 int result;
1312
1313 if (!device)
1314 return -EINVAL;
1315
1316 printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
1317 ASUS_ACPI_VERSION);
1318
1319 hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
1320 if (!hotk)
1321 return -ENOMEM;
1322
1323 hotk->handle = device->handle;
1324 strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
1325 strcpy(acpi_device_class(device), ACPI_HOTK_CLASS);
1326 device->driver_data = hotk;
1327 hotk->device = device;
1328
1329 result = asus_hotk_check();
1330 if (result)
1331 goto end;
1332
1333 result = asus_hotk_add_fs(device);
1334 if (result)
1335 goto end;
1336
1337 /*
1338 * We install the handler, it will receive the hotk in parameter, so, we
1339 * could add other data to the hotk struct
1340 */
1341 status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
1342 asus_hotk_notify, hotk);
1343 if (ACPI_FAILURE(status))
1344 printk(KERN_ERR " Error installing notify handler\n");
1345
1346 /* For laptops without GPLV: init the hotk->brightness value */
1347 if ((!hotk->methods->brightness_get)
1348 && (!hotk->methods->brightness_status)
1349 && (hotk->methods->brightness_up && hotk->methods->brightness_down)) {
1350 status =
1351 acpi_evaluate_object(NULL, hotk->methods->brightness_down,
1352 NULL, NULL);
1353 if (ACPI_FAILURE(status))
1354 printk(KERN_WARNING " Error changing brightness\n");
1355 else {
1356 status =
1357 acpi_evaluate_object(NULL,
1358 hotk->methods->brightness_up,
1359 NULL, NULL);
1360 if (ACPI_FAILURE(status))
1361 printk(KERN_WARNING " Strange, error changing"
1362 " brightness\n");
1363 }
1364 }
1365
1366 asus_hotk_found = 1;
1367
1368 /* LED display is off by default */
1369 hotk->ledd_status = 0xFFF;
1370
1371end:
1372 if (result)
1373 kfree(hotk);
1374
1375 return result;
1376}
1377
1378static int asus_hotk_remove(struct acpi_device *device, int type)
1379{
1380 acpi_status status = 0;
1381
1382 if (!device || !acpi_driver_data(device))
1383 return -EINVAL;
1384
1385 status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
1386 asus_hotk_notify);
1387 if (ACPI_FAILURE(status))
1388 printk(KERN_ERR "Asus ACPI: Error removing notify handler\n");
1389
1390 asus_hotk_remove_fs(device);
1391
1392 kfree(hotk);
1393
1394 return 0;
1395}
1396
1397static struct backlight_ops asus_backlight_data = {
1398 .get_brightness = read_brightness,
1399 .update_status = set_brightness_status,
1400};
1401
1402static void asus_acpi_exit(void)
1403{
1404 if (asus_backlight_device)
1405 backlight_device_unregister(asus_backlight_device);
1406
1407 acpi_bus_unregister_driver(&asus_hotk_driver);
1408 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1409
1410 return;
1411}
1412
1413static int __init asus_acpi_init(void)
1414{
1415 int result;
1416
1417 if (acpi_disabled)
1418 return -ENODEV;
1419
1420 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
1421 if (!asus_proc_dir) {
1422 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
1423 return -ENODEV;
1424 }
1425 asus_proc_dir->owner = THIS_MODULE;
1426
1427 result = acpi_bus_register_driver(&asus_hotk_driver);
1428 if (result < 0) {
1429 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1430 return result;
1431 }
1432
1433 /*
1434 * This is a bit of a kludge. We only want this module loaded
1435 * for ASUS systems, but there's currently no way to probe the
1436 * ACPI namespace for ASUS HIDs. So we just return failure if
1437 * we didn't find one, which will cause the module to be
1438 * unloaded.
1439 */
1440 if (!asus_hotk_found) {
1441 acpi_bus_unregister_driver(&asus_hotk_driver);
1442 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1443 return -ENODEV;
1444 }
1445
1446 asus_backlight_device = backlight_device_register("asus", NULL, NULL,
1447 &asus_backlight_data);
1448 if (IS_ERR(asus_backlight_device)) {
1449 printk(KERN_ERR "Could not register asus backlight device\n");
1450 asus_backlight_device = NULL;
1451 asus_acpi_exit();
1452 return -ENODEV;
1453 }
1454 asus_backlight_device->props.max_brightness = 15;
1455
1456 return 0;
1457}
1458
1459module_init(asus_acpi_init);
1460module_exit(asus_acpi_exit);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b2133e89ad9a..65132f920459 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -46,7 +46,6 @@
46 46
47#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF 47#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
48 48
49#define ACPI_BATTERY_COMPONENT 0x00040000
50#define ACPI_BATTERY_CLASS "battery" 49#define ACPI_BATTERY_CLASS "battery"
51#define ACPI_BATTERY_DEVICE_NAME "Battery" 50#define ACPI_BATTERY_DEVICE_NAME "Battery"
52#define ACPI_BATTERY_NOTIFY_STATUS 0x80 51#define ACPI_BATTERY_NOTIFY_STATUS 0x80
@@ -472,7 +471,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
472 471
473static int acpi_battery_update(struct acpi_battery *battery) 472static int acpi_battery_update(struct acpi_battery *battery)
474{ 473{
475 int result; 474 int result, old_present = acpi_battery_present(battery);
476 result = acpi_battery_get_status(battery); 475 result = acpi_battery_get_status(battery);
477 if (result) 476 if (result)
478 return result; 477 return result;
@@ -483,7 +482,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
483 return 0; 482 return 0;
484 } 483 }
485#endif 484#endif
486 if (!battery->update_time) { 485 if (!battery->update_time ||
486 old_present != acpi_battery_present(battery)) {
487 result = acpi_battery_get_info(battery); 487 result = acpi_battery_get_info(battery);
488 if (result) 488 if (result)
489 return result; 489 return result;
@@ -782,7 +782,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
782 acpi_bus_generate_proc_event(device, event, 782 acpi_bus_generate_proc_event(device, event,
783 acpi_battery_present(battery)); 783 acpi_battery_present(battery));
784 acpi_bus_generate_netlink_event(device->pnp.device_class, 784 acpi_bus_generate_netlink_event(device->pnp.device_class,
785 device->dev.bus_id, event, 785 dev_name(&device->dev), event,
786 acpi_battery_present(battery)); 786 acpi_battery_present(battery));
787#ifdef CONFIG_ACPI_SYSFS_POWER 787#ifdef CONFIG_ACPI_SYSFS_POWER
788 /* acpi_batter_update could remove power_supply object */ 788 /* acpi_batter_update could remove power_supply object */
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index ea92bac42c53..09c69806c1fc 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -176,16 +176,6 @@ static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
176 acpi_dmi_osi_linux(1, d); /* enable */ 176 acpi_dmi_osi_linux(1, d); /* enable */
177 return 0; 177 return 0;
178} 178}
179static int __init dmi_disable_osi_linux(const struct dmi_system_id *d)
180{
181 acpi_dmi_osi_linux(0, d); /* disable */
182 return 0;
183}
184static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d)
185{
186 acpi_dmi_osi_linux(-1, d); /* unknown */
187 return 0;
188}
189static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) 179static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
190{ 180{
191 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); 181 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
@@ -193,295 +183,21 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
193 return 0; 183 return 0;
194} 184}
195 185
196/*
197 * Most BIOS that invoke OSI(Linux) do nothing with it.
198 * But some cause Linux to break.
199 * Only a couple use it to make Linux run better.
200 *
201 * Thus, Linux should continue to disable OSI(Linux) by default,
202 * should continue to discourage BIOS writers from using it, and
203 * should whitelist the few existing systems that require it.
204 *
205 * If it appears clear a vendor isn't using OSI(Linux)
206 * for anything constructive, blacklist them by name to disable
207 * unnecessary dmesg warnings on all of their products.
208 */
209
210static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { 186static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
211 /*
212 * Disable OSI(Linux) warnings on all "Acer, inc."
213 *
214 * _OSI(Linux) disables the latest Windows BIOS code:
215 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"),
216 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5050"),
217 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
218 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5580"),
219 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 3010"),
220 * _OSI(Linux) effect unknown:
221 * DMI_MATCH(DMI_PRODUCT_NAME, "Ferrari 5000"),
222 */
223 /*
224 * note that dmi_check_system() uses strstr()
225 * to match sub-strings rather than !strcmp(),
226 * so "Acer" below matches "Acer, inc." above.
227 */
228 /*
229 * Disable OSI(Linux) warnings on all "Acer"
230 *
231 * _OSI(Linux) effect unknown:
232 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
233 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720Z"),
234 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"),
235 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"),
236 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"),
237 *
238 * _OSI(Linux) is a NOP:
239 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"),
240 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
241 */
242 {
243 .callback = dmi_disable_osi_linux,
244 .ident = "Acer",
245 .matches = {
246 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
247 },
248 },
249 /*
250 * Disable OSI(Linux) warnings on all "Apple Computer, Inc."
251 * Disable OSI(Linux) warnings on all "Apple Inc."
252 *
253 * _OSI(Linux) confirmed to be a NOP:
254 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"),
255 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook2,1"),
256 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2"),
257 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
258 * _OSI(Linux) effect unknown:
259 * DMI_MATCH(DMI_PRODUCT_NAME, "MacPro2,1"),
260 * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,1"),
261 */
262 {
263 .callback = dmi_disable_osi_linux,
264 .ident = "Apple",
265 .matches = {
266 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
267 },
268 },
269 /*
270 * Disable OSI(Linux) warnings on all "BenQ"
271 *
272 * _OSI(Linux) confirmed to be a NOP:
273 * DMI_MATCH(DMI_PRODUCT_NAME, "Joybook S31"),
274 */
275 {
276 .callback = dmi_disable_osi_linux,
277 .ident = "BenQ",
278 .matches = {
279 DMI_MATCH(DMI_SYS_VENDOR, "BenQ"),
280 },
281 },
282 /*
283 * Disable OSI(Linux) warnings on all "Clevo Co."
284 *
285 * _OSI(Linux) confirmed to be a NOP:
286 * DMI_MATCH(DMI_PRODUCT_NAME, "M570RU"),
287 */
288 {
289 .callback = dmi_disable_osi_linux,
290 .ident = "Clevo",
291 .matches = {
292 DMI_MATCH(DMI_SYS_VENDOR, "Clevo Co."),
293 },
294 },
295 /*
296 * Disable OSI(Linux) warnings on all "COMPAL"
297 *
298 * _OSI(Linux) confirmed to be a NOP:
299 * DMI_MATCH(DMI_BOARD_NAME, "HEL8X"),
300 * _OSI(Linux) unknown effect:
301 * DMI_MATCH(DMI_BOARD_NAME, "IFL91"),
302 */
303 {
304 .callback = dmi_disable_osi_linux,
305 .ident = "Compal",
306 .matches = {
307 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
308 },
309 },
310 { /* OSI(Linux) touches USB, unknown side-effect */
311 .callback = dmi_disable_osi_linux,
312 .ident = "Dell Dimension 5150",
313 .matches = {
314 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
315 DMI_MATCH(DMI_PRODUCT_NAME, "Dell DM051"),
316 },
317 },
318 { /* OSI(Linux) is a NOP */
319 .callback = dmi_disable_osi_linux,
320 .ident = "Dell i1501",
321 .matches = {
322 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
323 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1501"),
324 },
325 },
326 { /* OSI(Linux) effect unknown */
327 .callback = dmi_unknown_osi_linux,
328 .ident = "Dell Latitude D830",
329 .matches = {
330 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
331 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D830"),
332 },
333 },
334 { /* OSI(Linux) effect unknown */
335 .callback = dmi_unknown_osi_linux,
336 .ident = "Dell OptiPlex GX620",
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
339 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"),
340 },
341 },
342 { /* OSI(Linux) causes some USB initialization to not run */
343 .callback = dmi_unknown_osi_linux,
344 .ident = "Dell OptiPlex 755",
345 .matches = {
346 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
347 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"),
348 },
349 },
350 { /* OSI(Linux) effect unknown */
351 .callback = dmi_unknown_osi_linux,
352 .ident = "Dell PE 1900",
353 .matches = {
354 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
355 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1900"),
356 },
357 },
358 { /* OSI(Linux) is a NOP */
359 .callback = dmi_unknown_osi_linux,
360 .ident = "Dell PE 1950",
361 .matches = {
362 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
363 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
364 },
365 },
366 { /* OSI(Linux) is a NOP */
367 .callback = dmi_disable_osi_linux,
368 .ident = "Dell PE R200",
369 .matches = {
370 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
371 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R200"),
372 },
373 },
374 { /* OSI(Linux) touches USB */
375 .callback = dmi_disable_osi_linux,
376 .ident = "Dell PR 390",
377 .matches = {
378 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
379 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"),
380 },
381 },
382 { /* OSI(Linux) touches USB */
383 .callback = dmi_unknown_osi_linux,
384 .ident = "Dell PR 390",
385 .matches = {
386 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
387 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"),
388 },
389 },
390 { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */
391 .callback = dmi_unknown_osi_linux,
392 .ident = "Dell PR M4300",
393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"),
396 },
397 },
398 { /* OSI(Linux) is a NOP */
399 .callback = dmi_disable_osi_linux,
400 .ident = "Dell Vostro 1000",
401 .matches = {
402 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
403 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1000"),
404 },
405 },
406 { /* OSI(Linux) effect unknown */
407 .callback = dmi_unknown_osi_linux,
408 .ident = "Dell PE SC440",
409 .matches = {
410 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
411 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge SC440"),
412 },
413 },
414 { /* OSI(Linux) effect unknown */
415 .callback = dmi_unknown_osi_linux,
416 .ident = "Dialogue Flybook V5",
417 .matches = {
418 DMI_MATCH(DMI_SYS_VENDOR, "Dialogue Technology Corporation"),
419 DMI_MATCH(DMI_PRODUCT_NAME, "Flybook V5"),
420 },
421 },
422 /*
423 * Disable OSI(Linux) warnings on all "FUJITSU SIEMENS"
424 *
425 * _OSI(Linux) disables latest Windows BIOS code:
426 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 2510"),
427 * _OSI(Linux) confirmed to be a NOP:
428 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"),
429 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"),
430 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"),
431 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
432 * _OSI(Linux) unknown effect:
433 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"),
434 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"),
435 */
436 {
437 .callback = dmi_disable_osi_linux,
438 .ident = "Fujitsu Siemens",
439 .matches = {
440 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
441 },
442 },
443 { 187 {
444 .callback = dmi_disable_osi_vista, 188 .callback = dmi_disable_osi_vista,
445 .ident = "Fujitsu Siemens", 189 .ident = "Fujitsu Siemens",
446 .matches = { 190 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 191 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), 192 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
449 }, 193 },
450 }, 194 },
195
451 /* 196 /*
452 * Disable OSI(Linux) warnings on all "Hewlett-Packard" 197 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
453 * 198 * Linux ignores it, except for the machines enumerated below.
454 * _OSI(Linux) confirmed to be a NOP:
455 * .ident = "HP Pavilion tx 1000"
456 * DMI_MATCH(DMI_BOARD_NAME, "30BF"),
457 * .ident = "HP Pavilion dv2000"
458 * DMI_MATCH(DMI_BOARD_NAME, "30B5"),
459 * .ident = "HP Pavilion dv5000",
460 * DMI_MATCH(DMI_BOARD_NAME, "30A7"),
461 * .ident = "HP Pavilion dv6300 30BC",
462 * DMI_MATCH(DMI_BOARD_NAME, "30BC"),
463 * .ident = "HP Pavilion dv6000",
464 * DMI_MATCH(DMI_BOARD_NAME, "30B7"),
465 * DMI_MATCH(DMI_BOARD_NAME, "30B8"),
466 * .ident = "HP Pavilion dv9000",
467 * DMI_MATCH(DMI_BOARD_NAME, "30B9"),
468 * .ident = "HP Pavilion dv9500",
469 * DMI_MATCH(DMI_BOARD_NAME, "30CB"),
470 * .ident = "HP/Compaq Presario C500",
471 * DMI_MATCH(DMI_BOARD_NAME, "30C6"),
472 * .ident = "HP/Compaq Presario F500",
473 * DMI_MATCH(DMI_BOARD_NAME, "30D3"),
474 * _OSI(Linux) unknown effect:
475 * .ident = "HP Pavilion dv6500",
476 * DMI_MATCH(DMI_BOARD_NAME, "30D0"),
477 */ 199 */
478 { 200
479 .callback = dmi_disable_osi_linux,
480 .ident = "Hewlett-Packard",
481 .matches = {
482 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
483 },
484 },
485 /* 201 /*
486 * Lenovo has a mix of systems OSI(Linux) situations 202 * Lenovo has a mix of systems OSI(Linux) situations
487 * and thus we can not wildcard the vendor. 203 * and thus we can not wildcard the vendor.
@@ -519,113 +235,6 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
519 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), 235 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
520 }, 236 },
521 }, 237 },
522 {
523 .callback = dmi_disable_osi_linux,
524 .ident = "Lenovo 3000 V100",
525 .matches = {
526 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
527 DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"),
528 },
529 },
530 {
531 .callback = dmi_disable_osi_linux,
532 .ident = "Lenovo 3000 N100",
533 .matches = {
534 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
535 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
536 },
537 },
538 /*
539 * Disable OSI(Linux) warnings on all "LG Electronics"
540 *
541 * _OSI(Linux) confirmed to be a NOP:
542 * DMI_MATCH(DMI_PRODUCT_NAME, "P1-J150B"),
543 * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"),
544 *
545 * unknown:
546 * DMI_MATCH(DMI_PRODUCT_NAME, "S1-MDGDG"),
547 * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"),
548 */
549 {
550 .callback = dmi_disable_osi_linux,
551 .ident = "LG",
552 .matches = {
553 DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
554 },
555 },
556 /* NEC - OSI(Linux) effect unknown */
557 {
558 .callback = dmi_unknown_osi_linux,
559 .ident = "NEC VERSA M360",
560 .matches = {
561 DMI_MATCH(DMI_SYS_VENDOR, "NEC Computers SAS"),
562 DMI_MATCH(DMI_PRODUCT_NAME, "NEC VERSA M360"),
563 },
564 },
565 /* Panasonic */
566 {
567 .callback = dmi_unknown_osi_linux,
568 .ident = "Panasonic",
569 .matches = {
570 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
571 /* Toughbook CF-52 */
572 DMI_MATCH(DMI_PRODUCT_NAME, "CF-52CCABVBG"),
573 },
574 },
575 /*
576 * Disable OSI(Linux) warnings on all "Samsung Electronics"
577 *
578 * OSI(Linux) disables PNP0C32 and other BIOS code for Windows:
579 * DMI_MATCH(DMI_PRODUCT_NAME, "R40P/R41P"),
580 * DMI_MATCH(DMI_PRODUCT_NAME, "R59P/R60P/R61P"),
581 */
582 {
583 .callback = dmi_disable_osi_linux,
584 .ident = "Samsung",
585 .matches = {
586 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
587 },
588 },
589 /*
590 * Disable OSI(Linux) warnings on all "Sony Corporation"
591 *
592 * _OSI(Linux) is a NOP:
593 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"),
594 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"),
595 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"),
596 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"),
597 * _OSI(Linux) unknown effect:
598 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"),
599 */
600 {
601 .callback = dmi_disable_osi_linux,
602 .ident = "Sony",
603 .matches = {
604 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
605 },
606 },
607 /*
608 * Disable OSI(Linux) warnings on all "TOSHIBA"
609 *
610 * _OSI(Linux) breaks sound (bugzilla 7787):
611 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P100"),
612 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P105"),
613 * _OSI(Linux) is a NOP:
614 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A100"),
615 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A210"),
616 * _OSI(Linux) unknown effect:
617 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A135"),
618 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite A200"),
619 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P205"),
620 * DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U305"),
621 */
622 {
623 .callback = dmi_disable_osi_linux,
624 .ident = "Toshiba",
625 .matches = {
626 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
627 },
628 },
629 {} 238 {}
630}; 239};
631 240
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index c797c6473f31..765fd1c56cd6 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -774,7 +774,7 @@ static int __init acpi_bus_init(void)
774 "Unable to initialize ACPI OS objects\n"); 774 "Unable to initialize ACPI OS objects\n");
775 goto error1; 775 goto error1;
776 } 776 }
777#ifdef CONFIG_ACPI_EC 777
778 /* 778 /*
779 * ACPI 2.0 requires the EC driver to be loaded and work before 779 * ACPI 2.0 requires the EC driver to be loaded and work before
780 * the EC device is found in the namespace (i.e. before acpi_initialize_objects() 780 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
@@ -785,7 +785,6 @@ static int __init acpi_bus_init(void)
785 */ 785 */
786 status = acpi_ec_ecdt_probe(); 786 status = acpi_ec_ecdt_probe();
787 /* Ignore result. Not having an ECDT is not fatal. */ 787 /* Ignore result. Not having an ECDT is not fatal. */
788#endif
789 788
790 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); 789 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
791 if (ACPI_FAILURE(status)) { 790 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cb046c3fc3f2..171fd914f435 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -33,7 +33,6 @@
33#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
35 35
36#define ACPI_BUTTON_COMPONENT 0x00080000
37#define ACPI_BUTTON_CLASS "button" 36#define ACPI_BUTTON_CLASS "button"
38#define ACPI_BUTTON_FILE_INFO "info" 37#define ACPI_BUTTON_FILE_INFO "info"
39#define ACPI_BUTTON_FILE_STATE "state" 38#define ACPI_BUTTON_FILE_STATE "state"
@@ -479,7 +478,7 @@ static int acpi_button_add(struct acpi_device *device)
479 device->wakeup.gpe_number, 478 device->wakeup.gpe_number,
480 ACPI_GPE_TYPE_WAKE_RUN); 479 ACPI_GPE_TYPE_WAKE_RUN);
481 acpi_enable_gpe(device->wakeup.gpe_device, 480 acpi_enable_gpe(device->wakeup.gpe_device,
482 device->wakeup.gpe_number, ACPI_NOT_ISR); 481 device->wakeup.gpe_number);
483 device->wakeup.state.enabled = 1; 482 device->wakeup.state.enabled = 1;
484 } 483 }
485 484
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index 4441e84b28a9..332fe4b21708 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -27,14 +27,10 @@
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <acpi/acpi_bus.h> 28#include <acpi/acpi_bus.h>
29#include <acpi/acpi_drivers.h> 29#include <acpi/acpi_drivers.h>
30#include <acpi/acmacros.h>
31#include <acpi/actypes.h>
32#include <acpi/acutils.h>
33 30
34ACPI_MODULE_NAME("cm_sbs"); 31ACPI_MODULE_NAME("cm_sbs");
35#define ACPI_AC_CLASS "ac_adapter" 32#define ACPI_AC_CLASS "ac_adapter"
36#define ACPI_BATTERY_CLASS "battery" 33#define ACPI_BATTERY_CLASS "battery"
37#define ACPI_SBS_COMPONENT 0x00080000
38#define _COMPONENT ACPI_SBS_COMPONENT 34#define _COMPONENT ACPI_SBS_COMPONENT
39static struct proc_dir_entry *acpi_ac_dir; 35static struct proc_dir_entry *acpi_ac_dir;
40static struct proc_dir_entry *acpi_battery_dir; 36static struct proc_dir_entry *acpi_battery_dir;
@@ -105,9 +101,3 @@ void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
105 return; 101 return;
106} 102}
107EXPORT_SYMBOL(acpi_unlock_battery_dir); 103EXPORT_SYMBOL(acpi_unlock_battery_dir);
108
109static int __init acpi_cm_sbs_init(void)
110{
111 return 0;
112}
113subsys_initcall(acpi_cm_sbs_init);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 134818b265a9..fe0cdf83641a 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -41,7 +41,6 @@
41#define INSTALL_NOTIFY_HANDLER 1 41#define INSTALL_NOTIFY_HANDLER 1
42#define UNINSTALL_NOTIFY_HANDLER 2 42#define UNINSTALL_NOTIFY_HANDLER 2
43 43
44#define ACPI_CONTAINER_COMPONENT 0x01000000
45#define _COMPONENT ACPI_CONTAINER_COMPONENT 44#define _COMPONENT ACPI_CONTAINER_COMPONENT
46ACPI_MODULE_NAME("container"); 45ACPI_MODULE_NAME("container");
47 46
@@ -164,7 +163,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
164 case ACPI_NOTIFY_BUS_CHECK: 163 case ACPI_NOTIFY_BUS_CHECK:
165 /* Fall through */ 164 /* Fall through */
166 case ACPI_NOTIFY_DEVICE_CHECK: 165 case ACPI_NOTIFY_DEVICE_CHECK:
167 printk("Container driver received %s event\n", 166 printk(KERN_WARNING "Container driver received %s event\n",
168 (type == ACPI_NOTIFY_BUS_CHECK) ? 167 (type == ACPI_NOTIFY_BUS_CHECK) ?
169 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); 168 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
170 status = acpi_bus_get_device(handle, &device); 169 status = acpi_bus_get_device(handle, &device);
@@ -175,7 +174,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
175 kobject_uevent(&device->dev.kobj, 174 kobject_uevent(&device->dev.kobj,
176 KOBJ_ONLINE); 175 KOBJ_ONLINE);
177 else 176 else
178 printk("Failed to add container\n"); 177 printk(KERN_WARNING
178 "Failed to add container\n");
179 } 179 }
180 } else { 180 } else {
181 if (ACPI_SUCCESS(status)) { 181 if (ACPI_SUCCESS(status)) {
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index abf36b4b1d1d..20223cbd0d1c 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -9,7 +9,6 @@
9#include <linux/moduleparam.h> 9#include <linux/moduleparam.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
11#include <acpi/acpi_drivers.h> 11#include <acpi/acpi_drivers.h>
12#include <acpi/acglobal.h>
13 12
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 13#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME("debug"); 14ACPI_MODULE_NAME("debug");
@@ -44,6 +43,21 @@ static const struct acpi_dlayer acpi_debug_layers[] = {
44 ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), 43 ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER),
45 ACPI_DEBUG_INIT(ACPI_COMPILER), 44 ACPI_DEBUG_INIT(ACPI_COMPILER),
46 ACPI_DEBUG_INIT(ACPI_TOOLS), 45 ACPI_DEBUG_INIT(ACPI_TOOLS),
46
47 ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT),
48 ACPI_DEBUG_INIT(ACPI_AC_COMPONENT),
49 ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT),
50 ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT),
51 ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT),
52 ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT),
53 ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT),
54 ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT),
55 ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT),
56 ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT),
57 ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT),
58 ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT),
59 ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT),
60 ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT),
47}; 61};
48 62
49static const struct acpi_dlevel acpi_debug_levels[] = { 63static const struct acpi_dlevel acpi_debug_levels[] = {
diff --git a/drivers/acpi/dispatcher/Makefile b/drivers/acpi/dispatcher/Makefile
deleted file mode 100644
index eb7e602a83cd..000000000000
--- a/drivers/acpi/dispatcher/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
6 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
7 dsinit.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 5b30b8d91d71..35094f230b1e 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -855,10 +855,14 @@ fdd_out:
855static ssize_t show_docked(struct device *dev, 855static ssize_t show_docked(struct device *dev,
856 struct device_attribute *attr, char *buf) 856 struct device_attribute *attr, char *buf)
857{ 857{
858 struct acpi_device *tmp;
859
858 struct dock_station *dock_station = *((struct dock_station **) 860 struct dock_station *dock_station = *((struct dock_station **)
859 dev->platform_data); 861 dev->platform_data);
860 return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station));
861 862
863 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp)))
864 return snprintf(buf, PAGE_SIZE, "1\n");
865 return snprintf(buf, PAGE_SIZE, "0\n");
862} 866}
863static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); 867static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
864 868
@@ -984,7 +988,7 @@ static int dock_add(acpi_handle handle)
984 988
985 ret = device_create_file(&dock_device->dev, &dev_attr_docked); 989 ret = device_create_file(&dock_device->dev, &dev_attr_docked);
986 if (ret) { 990 if (ret) {
987 printk("Error %d adding sysfs file\n", ret); 991 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
988 platform_device_unregister(dock_device); 992 platform_device_unregister(dock_device);
989 kfree(dock_station); 993 kfree(dock_station);
990 dock_station = NULL; 994 dock_station = NULL;
@@ -992,7 +996,7 @@ static int dock_add(acpi_handle handle)
992 } 996 }
993 ret = device_create_file(&dock_device->dev, &dev_attr_undock); 997 ret = device_create_file(&dock_device->dev, &dev_attr_undock);
994 if (ret) { 998 if (ret) {
995 printk("Error %d adding sysfs file\n", ret); 999 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
996 device_remove_file(&dock_device->dev, &dev_attr_docked); 1000 device_remove_file(&dock_device->dev, &dev_attr_docked);
997 platform_device_unregister(dock_device); 1001 platform_device_unregister(dock_device);
998 kfree(dock_station); 1002 kfree(dock_station);
@@ -1001,7 +1005,7 @@ static int dock_add(acpi_handle handle)
1001 } 1005 }
1002 ret = device_create_file(&dock_device->dev, &dev_attr_uid); 1006 ret = device_create_file(&dock_device->dev, &dev_attr_uid);
1003 if (ret) { 1007 if (ret) {
1004 printk("Error %d adding sysfs file\n", ret); 1008 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1005 device_remove_file(&dock_device->dev, &dev_attr_docked); 1009 device_remove_file(&dock_device->dev, &dev_attr_docked);
1006 device_remove_file(&dock_device->dev, &dev_attr_undock); 1010 device_remove_file(&dock_device->dev, &dev_attr_undock);
1007 platform_device_unregister(dock_device); 1011 platform_device_unregister(dock_device);
@@ -1011,7 +1015,7 @@ static int dock_add(acpi_handle handle)
1011 } 1015 }
1012 ret = device_create_file(&dock_device->dev, &dev_attr_flags); 1016 ret = device_create_file(&dock_device->dev, &dev_attr_flags);
1013 if (ret) { 1017 if (ret) {
1014 printk("Error %d adding sysfs file\n", ret); 1018 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1015 device_remove_file(&dock_device->dev, &dev_attr_docked); 1019 device_remove_file(&dock_device->dev, &dev_attr_docked);
1016 device_remove_file(&dock_device->dev, &dev_attr_undock); 1020 device_remove_file(&dock_device->dev, &dev_attr_undock);
1017 device_remove_file(&dock_device->dev, &dev_attr_uid); 1021 device_remove_file(&dock_device->dev, &dev_attr_uid);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index ef42316f89f5..5c2f5d343be6 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -42,7 +42,6 @@
42#include <asm/io.h> 42#include <asm/io.h>
43#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 44#include <acpi/acpi_drivers.h>
45#include <acpi/actypes.h>
46 45
47#define ACPI_EC_CLASS "embedded_controller" 46#define ACPI_EC_CLASS "embedded_controller"
48#define ACPI_EC_DEVICE_NAME "Embedded Controller" 47#define ACPI_EC_DEVICE_NAME "Embedded Controller"
@@ -70,7 +69,7 @@ enum ec_command {
70#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 69#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
71#define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ 70#define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */
72 71
73#define ACPI_EC_STORM_THRESHOLD 20 /* number of false interrupts 72#define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts
74 per one transaction */ 73 per one transaction */
75 74
76enum { 75enum {
@@ -100,8 +99,11 @@ struct transaction {
100 u8 *rdata; 99 u8 *rdata;
101 unsigned short irq_count; 100 unsigned short irq_count;
102 u8 command; 101 u8 command;
102 u8 wi;
103 u8 ri;
103 u8 wlen; 104 u8 wlen;
104 u8 rlen; 105 u8 rlen;
106 bool done;
105}; 107};
106 108
107static struct acpi_ec { 109static struct acpi_ec {
@@ -118,31 +120,6 @@ static struct acpi_ec {
118 spinlock_t curr_lock; 120 spinlock_t curr_lock;
119} *boot_ec, *first_ec; 121} *boot_ec, *first_ec;
120 122
121/*
122 * Some Asus system have exchanged ECDT data/command IO addresses.
123 */
124static int print_ecdt_error(const struct dmi_system_id *id)
125{
126 printk(KERN_NOTICE PREFIX "%s detected - "
127 "ECDT has exchanged control/data I/O address\n",
128 id->ident);
129 return 0;
130}
131
132static struct dmi_system_id __cpuinitdata ec_dmi_table[] = {
133 {
134 print_ecdt_error, "Asus L4R", {
135 DMI_MATCH(DMI_BIOS_VERSION, "1008.006"),
136 DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),
137 DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL},
138 {
139 print_ecdt_error, "Asus M6R", {
140 DMI_MATCH(DMI_BIOS_VERSION, "0207"),
141 DMI_MATCH(DMI_PRODUCT_NAME, "M6R"),
142 DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL},
143 {},
144};
145
146/* -------------------------------------------------------------------------- 123/* --------------------------------------------------------------------------
147 Transaction Management 124 Transaction Management
148 -------------------------------------------------------------------------- */ 125 -------------------------------------------------------------------------- */
@@ -178,34 +155,46 @@ static int ec_transaction_done(struct acpi_ec *ec)
178 unsigned long flags; 155 unsigned long flags;
179 int ret = 0; 156 int ret = 0;
180 spin_lock_irqsave(&ec->curr_lock, flags); 157 spin_lock_irqsave(&ec->curr_lock, flags);
181 if (!ec->curr || (!ec->curr->wlen && !ec->curr->rlen)) 158 if (!ec->curr || ec->curr->done)
182 ret = 1; 159 ret = 1;
183 spin_unlock_irqrestore(&ec->curr_lock, flags); 160 spin_unlock_irqrestore(&ec->curr_lock, flags);
184 return ret; 161 return ret;
185} 162}
186 163
164static void start_transaction(struct acpi_ec *ec)
165{
166 ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0;
167 ec->curr->done = false;
168 acpi_ec_write_cmd(ec, ec->curr->command);
169}
170
187static void gpe_transaction(struct acpi_ec *ec, u8 status) 171static void gpe_transaction(struct acpi_ec *ec, u8 status)
188{ 172{
189 unsigned long flags; 173 unsigned long flags;
190 spin_lock_irqsave(&ec->curr_lock, flags); 174 spin_lock_irqsave(&ec->curr_lock, flags);
191 if (!ec->curr) 175 if (!ec->curr)
192 goto unlock; 176 goto unlock;
193 if (ec->curr->wlen > 0) { 177 if (ec->curr->wlen > ec->curr->wi) {
194 if ((status & ACPI_EC_FLAG_IBF) == 0) { 178 if ((status & ACPI_EC_FLAG_IBF) == 0)
195 acpi_ec_write_data(ec, *(ec->curr->wdata++)); 179 acpi_ec_write_data(ec,
196 --ec->curr->wlen; 180 ec->curr->wdata[ec->curr->wi++]);
197 } else 181 else
198 /* false interrupt, state didn't change */ 182 goto err;
199 ++ec->curr->irq_count; 183 } else if (ec->curr->rlen > ec->curr->ri) {
200
201 } else if (ec->curr->rlen > 0) {
202 if ((status & ACPI_EC_FLAG_OBF) == 1) { 184 if ((status & ACPI_EC_FLAG_OBF) == 1) {
203 *(ec->curr->rdata++) = acpi_ec_read_data(ec); 185 ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec);
204 --ec->curr->rlen; 186 if (ec->curr->rlen == ec->curr->ri)
187 ec->curr->done = true;
205 } else 188 } else
206 /* false interrupt, state didn't change */ 189 goto err;
207 ++ec->curr->irq_count; 190 } else if (ec->curr->wlen == ec->curr->wi &&
208 } 191 (status & ACPI_EC_FLAG_IBF) == 0)
192 ec->curr->done = true;
193 goto unlock;
194err:
195 /* false interrupt, state didn't change */
196 if (in_interrupt())
197 ++ec->curr->irq_count;
209unlock: 198unlock:
210 spin_unlock_irqrestore(&ec->curr_lock, flags); 199 spin_unlock_irqrestore(&ec->curr_lock, flags);
211} 200}
@@ -215,6 +204,15 @@ static int acpi_ec_wait(struct acpi_ec *ec)
215 if (wait_event_timeout(ec->wait, ec_transaction_done(ec), 204 if (wait_event_timeout(ec->wait, ec_transaction_done(ec),
216 msecs_to_jiffies(ACPI_EC_DELAY))) 205 msecs_to_jiffies(ACPI_EC_DELAY)))
217 return 0; 206 return 0;
207 /* try restart command if we get any false interrupts */
208 if (ec->curr->irq_count &&
209 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
210 pr_debug(PREFIX "controller reset, restart transaction\n");
211 start_transaction(ec);
212 if (wait_event_timeout(ec->wait, ec_transaction_done(ec),
213 msecs_to_jiffies(ACPI_EC_DELAY)))
214 return 0;
215 }
218 /* missing GPEs, switch back to poll mode */ 216 /* missing GPEs, switch back to poll mode */
219 if (printk_ratelimit()) 217 if (printk_ratelimit())
220 pr_info(PREFIX "missing confirmations, " 218 pr_info(PREFIX "missing confirmations, "
@@ -239,10 +237,10 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state)
239static int ec_poll(struct acpi_ec *ec) 237static int ec_poll(struct acpi_ec *ec)
240{ 238{
241 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); 239 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
242 msleep(1); 240 udelay(ACPI_EC_UDELAY);
243 while (time_before(jiffies, delay)) { 241 while (time_before(jiffies, delay)) {
244 gpe_transaction(ec, acpi_ec_read_status(ec)); 242 gpe_transaction(ec, acpi_ec_read_status(ec));
245 msleep(1); 243 udelay(ACPI_EC_UDELAY);
246 if (ec_transaction_done(ec)) 244 if (ec_transaction_done(ec))
247 return 0; 245 return 0;
248 } 246 }
@@ -259,14 +257,13 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
259 /* disable GPE during transaction if storm is detected */ 257 /* disable GPE during transaction if storm is detected */
260 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 258 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
261 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 259 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
262 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 260 acpi_disable_gpe(NULL, ec->gpe);
263 } 261 }
264 /* start transaction */ 262 /* start transaction */
265 spin_lock_irqsave(&ec->curr_lock, tmp); 263 spin_lock_irqsave(&ec->curr_lock, tmp);
266 /* following two actions should be kept atomic */ 264 /* following two actions should be kept atomic */
267 t->irq_count = 0;
268 ec->curr = t; 265 ec->curr = t;
269 acpi_ec_write_cmd(ec, ec->curr->command); 266 start_transaction(ec);
270 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) 267 if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
271 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 268 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
272 spin_unlock_irqrestore(&ec->curr_lock, tmp); 269 spin_unlock_irqrestore(&ec->curr_lock, tmp);
@@ -283,10 +280,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
283 /* check if we received SCI during transaction */ 280 /* check if we received SCI during transaction */
284 ec_check_sci(ec, acpi_ec_read_status(ec)); 281 ec_check_sci(ec, acpi_ec_read_status(ec));
285 /* it is safe to enable GPE outside of transaction */ 282 /* it is safe to enable GPE outside of transaction */
286 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 283 acpi_enable_gpe(NULL, ec->gpe);
287 } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && 284 } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
288 t->irq_count > ACPI_EC_STORM_THRESHOLD) { 285 t->irq_count > ACPI_EC_STORM_THRESHOLD) {
289 pr_debug(PREFIX "GPE storm detected\n"); 286 pr_info(PREFIX "GPE storm detected, "
287 "transactions will use polling mode\n");
290 set_bit(EC_FLAGS_GPE_STORM, &ec->flags); 288 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
291 } 289 }
292 return ret; 290 return ret;
@@ -346,7 +344,7 @@ unlock:
346 * Note: samsung nv5000 doesn't work with ec burst mode. 344 * Note: samsung nv5000 doesn't work with ec burst mode.
347 * http://bugzilla.kernel.org/show_bug.cgi?id=4980 345 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
348 */ 346 */
349int acpi_ec_burst_enable(struct acpi_ec *ec) 347static int acpi_ec_burst_enable(struct acpi_ec *ec)
350{ 348{
351 u8 d; 349 u8 d;
352 struct transaction t = {.command = ACPI_EC_BURST_ENABLE, 350 struct transaction t = {.command = ACPI_EC_BURST_ENABLE,
@@ -356,7 +354,7 @@ int acpi_ec_burst_enable(struct acpi_ec *ec)
356 return acpi_ec_transaction(ec, &t, 0); 354 return acpi_ec_transaction(ec, &t, 0);
357} 355}
358 356
359int acpi_ec_burst_disable(struct acpi_ec *ec) 357static int acpi_ec_burst_disable(struct acpi_ec *ec)
360{ 358{
361 struct transaction t = {.command = ACPI_EC_BURST_DISABLE, 359 struct transaction t = {.command = ACPI_EC_BURST_DISABLE,
362 .wdata = NULL, .rdata = NULL, 360 .wdata = NULL, .rdata = NULL,
@@ -558,17 +556,26 @@ static u32 acpi_ec_gpe_handler(void *data)
558 pr_debug(PREFIX "~~~> interrupt\n"); 556 pr_debug(PREFIX "~~~> interrupt\n");
559 status = acpi_ec_read_status(ec); 557 status = acpi_ec_read_status(ec);
560 558
561 gpe_transaction(ec, status); 559 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) {
562 if (ec_transaction_done(ec) && (status & ACPI_EC_FLAG_IBF) == 0) 560 gpe_transaction(ec, status);
563 wake_up(&ec->wait); 561 if (ec_transaction_done(ec) &&
562 (status & ACPI_EC_FLAG_IBF) == 0)
563 wake_up(&ec->wait);
564 }
564 565
565 ec_check_sci(ec, status); 566 ec_check_sci(ec, status);
566 if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && 567 if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
567 !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) { 568 !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) {
568 /* this is non-query, must be confirmation */ 569 /* this is non-query, must be confirmation */
569 if (printk_ratelimit()) 570 if (!test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
570 pr_info(PREFIX "non-query interrupt received," 571 if (printk_ratelimit())
572 pr_info(PREFIX "non-query interrupt received,"
573 " switching to interrupt mode\n");
574 } else {
575 /* hush, STORM switches the mode every transaction */
576 pr_debug(PREFIX "non-query interrupt received,"
571 " switching to interrupt mode\n"); 577 " switching to interrupt mode\n");
578 }
572 set_bit(EC_FLAGS_GPE_MODE, &ec->flags); 579 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
573 } 580 }
574 return ACPI_INTERRUPT_HANDLED; 581 return ACPI_INTERRUPT_HANDLED;
@@ -723,10 +730,15 @@ static acpi_status
723acpi_ec_register_query_methods(acpi_handle handle, u32 level, 730acpi_ec_register_query_methods(acpi_handle handle, u32 level,
724 void *context, void **return_value) 731 void *context, void **return_value)
725{ 732{
726 struct acpi_namespace_node *node = handle; 733 char node_name[5];
734 struct acpi_buffer buffer = { sizeof(node_name), node_name };
727 struct acpi_ec *ec = context; 735 struct acpi_ec *ec = context;
728 int value = 0; 736 int value = 0;
729 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) { 737 acpi_status status;
738
739 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
740
741 if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) {
730 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); 742 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
731 } 743 }
732 return AE_OK; 744 return AE_OK;
@@ -736,7 +748,7 @@ static acpi_status
736ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) 748ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
737{ 749{
738 acpi_status status; 750 acpi_status status;
739 unsigned long long tmp; 751 unsigned long long tmp = 0;
740 752
741 struct acpi_ec *ec = context; 753 struct acpi_ec *ec = context;
742 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 754 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
@@ -751,6 +763,7 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
751 return status; 763 return status;
752 ec->gpe = tmp; 764 ec->gpe = tmp;
753 /* Use the global lock for all EC transactions? */ 765 /* Use the global lock for all EC transactions? */
766 tmp = 0;
754 acpi_evaluate_integer(handle, "_GLK", NULL, &tmp); 767 acpi_evaluate_integer(handle, "_GLK", NULL, &tmp);
755 ec->global_lock = tmp; 768 ec->global_lock = tmp;
756 ec->handle = handle; 769 ec->handle = handle;
@@ -868,7 +881,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
868 if (ACPI_FAILURE(status)) 881 if (ACPI_FAILURE(status))
869 return -ENODEV; 882 return -ENODEV;
870 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 883 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
871 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 884 acpi_enable_gpe(NULL, ec->gpe);
872 status = acpi_install_address_space_handler(ec->handle, 885 status = acpi_install_address_space_handler(ec->handle,
873 ACPI_ADR_SPACE_EC, 886 ACPI_ADR_SPACE_EC,
874 &acpi_ec_space_handler, 887 &acpi_ec_space_handler,
@@ -944,8 +957,8 @@ static const struct acpi_device_id ec_device_ids[] = {
944 957
945int __init acpi_ec_ecdt_probe(void) 958int __init acpi_ec_ecdt_probe(void)
946{ 959{
947 int ret;
948 acpi_status status; 960 acpi_status status;
961 struct acpi_ec *saved_ec = NULL;
949 struct acpi_table_ecdt *ecdt_ptr; 962 struct acpi_table_ecdt *ecdt_ptr;
950 963
951 boot_ec = make_acpi_ec(); 964 boot_ec = make_acpi_ec();
@@ -960,42 +973,55 @@ int __init acpi_ec_ecdt_probe(void)
960 pr_info(PREFIX "EC description table is found, configuring boot EC\n"); 973 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
961 boot_ec->command_addr = ecdt_ptr->control.address; 974 boot_ec->command_addr = ecdt_ptr->control.address;
962 boot_ec->data_addr = ecdt_ptr->data.address; 975 boot_ec->data_addr = ecdt_ptr->data.address;
963 if (dmi_check_system(ec_dmi_table)) {
964 /*
965 * If the board falls into ec_dmi_table, it means
966 * that ECDT table gives the incorrect command/status
967 * & data I/O address. Just fix it.
968 */
969 boot_ec->data_addr = ecdt_ptr->control.address;
970 boot_ec->command_addr = ecdt_ptr->data.address;
971 }
972 boot_ec->gpe = ecdt_ptr->gpe; 976 boot_ec->gpe = ecdt_ptr->gpe;
973 boot_ec->handle = ACPI_ROOT_OBJECT; 977 boot_ec->handle = ACPI_ROOT_OBJECT;
974 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); 978 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
979 /* Don't trust ECDT, which comes from ASUSTek */
980 if (!dmi_name_in_vendors("ASUS"))
981 goto install;
982 saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
983 if (!saved_ec)
984 return -ENOMEM;
985 memcpy(saved_ec, boot_ec, sizeof(*saved_ec));
986 /* fall through */
987 }
988 /* This workaround is needed only on some broken machines,
989 * which require early EC, but fail to provide ECDT */
990 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
991 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
992 boot_ec, NULL);
993 /* Check that acpi_get_devices actually find something */
994 if (ACPI_FAILURE(status) || !boot_ec->handle)
995 goto error;
996 if (saved_ec) {
997 /* try to find good ECDT from ASUSTek */
998 if (saved_ec->command_addr != boot_ec->command_addr ||
999 saved_ec->data_addr != boot_ec->data_addr ||
1000 saved_ec->gpe != boot_ec->gpe ||
1001 saved_ec->handle != boot_ec->handle)
1002 pr_info(PREFIX "ASUSTek keeps feeding us with broken "
1003 "ECDT tables, which are very hard to workaround. "
1004 "Trying to use DSDT EC info instead. Please send "
1005 "output of acpidump to linux-acpi@vger.kernel.org\n");
1006 kfree(saved_ec);
1007 saved_ec = NULL;
975 } else { 1008 } else {
976 /* This workaround is needed only on some broken machines,
977 * which require early EC, but fail to provide ECDT */
978 acpi_handle x;
979 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
980 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
981 boot_ec, NULL);
982 /* Check that acpi_get_devices actually find something */
983 if (ACPI_FAILURE(status) || !boot_ec->handle)
984 goto error;
985 /* We really need to limit this workaround, the only ASUS, 1009 /* We really need to limit this workaround, the only ASUS,
986 * which needs it, has fake EC._INI method, so use it as flag. 1010 * which needs it, has fake EC._INI method, so use it as flag.
987 * Keep boot_ec struct as it will be needed soon. 1011 * Keep boot_ec struct as it will be needed soon.
988 */ 1012 */
989 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x))) 1013 acpi_handle dummy;
1014 if (!dmi_name_in_vendors("ASUS") ||
1015 ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI",
1016 &dummy)))
990 return -ENODEV; 1017 return -ENODEV;
991 } 1018 }
992 1019install:
993 ret = ec_install_handlers(boot_ec); 1020 if (!ec_install_handlers(boot_ec)) {
994 if (!ret) {
995 first_ec = boot_ec; 1021 first_ec = boot_ec;
996 return 0; 1022 return 0;
997 } 1023 }
998 error: 1024error:
999 kfree(boot_ec); 1025 kfree(boot_ec);
1000 boot_ec = NULL; 1026 boot_ec = NULL;
1001 return -ENODEV; 1027 return -ENODEV;
@@ -1007,7 +1033,7 @@ static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1007 /* Stop using GPE */ 1033 /* Stop using GPE */
1008 set_bit(EC_FLAGS_NO_GPE, &ec->flags); 1034 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
1009 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 1035 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
1010 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 1036 acpi_disable_gpe(NULL, ec->gpe);
1011 return 0; 1037 return 0;
1012} 1038}
1013 1039
@@ -1016,7 +1042,7 @@ static int acpi_ec_resume(struct acpi_device *device)
1016 struct acpi_ec *ec = acpi_driver_data(device); 1042 struct acpi_ec *ec = acpi_driver_data(device);
1017 /* Enable use of GPE back */ 1043 /* Enable use of GPE back */
1018 clear_bit(EC_FLAGS_NO_GPE, &ec->flags); 1044 clear_bit(EC_FLAGS_NO_GPE, &ec->flags);
1019 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 1045 acpi_enable_gpe(NULL, ec->gpe);
1020 return 0; 1046 return 0;
1021} 1047}
1022 1048
diff --git a/drivers/acpi/events/Makefile b/drivers/acpi/events/Makefile
deleted file mode 100644
index d29f2ee449cc..000000000000
--- a/drivers/acpi/events/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := evevent.o evregion.o evsci.o evxfevnt.o \
6 evmisc.o evrgnini.o evxface.o evxfregn.o \
7 evgpe.o evgpeblk.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/executer/Makefile b/drivers/acpi/executer/Makefile
deleted file mode 100644
index e09998aa012f..000000000000
--- a/drivers/acpi/executer/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
6 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
7 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
8 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o
9
10EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 60d54d1f6b19..eaaee1660bdf 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -34,7 +34,6 @@
34#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
36 36
37#define ACPI_FAN_COMPONENT 0x00200000
38#define ACPI_FAN_CLASS "fan" 37#define ACPI_FAN_CLASS "fan"
39#define ACPI_FAN_FILE_STATE "state" 38#define ACPI_FAN_FILE_STATE "state"
40 39
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 24649ada08df..5479b9f42513 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -140,6 +140,46 @@ struct device *acpi_get_physical_device(acpi_handle handle)
140 140
141EXPORT_SYMBOL(acpi_get_physical_device); 141EXPORT_SYMBOL(acpi_get_physical_device);
142 142
143/* ToDo: When a PCI bridge is found, return the PCI device behind the bridge
144 * This should work in general, but did not on a Lenovo T61 for the
145 * graphics card. But this must be fixed when the PCI device is
146 * bound and the kernel device struct is attached to the acpi device
147 * Note: A success call will increase reference count by one
148 * Do call put_device(dev) on the returned device then
149 */
150struct device *acpi_get_physical_pci_device(acpi_handle handle)
151{
152 struct device *dev;
153 long long device_id;
154 acpi_status status;
155
156 status =
157 acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
158
159 if (ACPI_FAILURE(status))
160 return NULL;
161
162 /* We need to attempt to determine whether the _ADR refers to a
163 PCI device or not. There's no terribly good way to do this,
164 so the best we can hope for is to assume that there'll never
165 be a device in the host bridge */
166 if (device_id >= 0x10000) {
167 /* It looks like a PCI device. Does it exist? */
168 dev = acpi_get_physical_device(handle);
169 } else {
170 /* It doesn't look like a PCI device. Does its parent
171 exist? */
172 acpi_handle phandle;
173 if (acpi_get_parent(handle, &phandle))
174 return NULL;
175 dev = acpi_get_physical_device(phandle);
176 }
177 if (!dev)
178 return NULL;
179 return dev;
180}
181EXPORT_SYMBOL(acpi_get_physical_pci_device);
182
143static int acpi_bind_one(struct device *dev, acpi_handle handle) 183static int acpi_bind_one(struct device *dev, acpi_handle handle)
144{ 184{
145 struct acpi_device *acpi_dev; 185 struct acpi_device *acpi_dev;
@@ -215,12 +255,12 @@ static int acpi_platform_notify(struct device *dev)
215 } 255 }
216 type = acpi_get_bus_type(dev->bus); 256 type = acpi_get_bus_type(dev->bus);
217 if (!type) { 257 if (!type) {
218 DBG("No ACPI bus support for %s\n", dev->bus_id); 258 DBG("No ACPI bus support for %s\n", dev_name(dev));
219 ret = -EINVAL; 259 ret = -EINVAL;
220 goto end; 260 goto end;
221 } 261 }
222 if ((ret = type->find_device(dev, &handle)) != 0) 262 if ((ret = type->find_device(dev, &handle)) != 0)
223 DBG("Can't get handler for %s\n", dev->bus_id); 263 DBG("Can't get handler for %s\n", dev_name(dev));
224 end: 264 end:
225 if (!ret) 265 if (!ret)
226 acpi_bind_one(dev, handle); 266 acpi_bind_one(dev, handle);
@@ -231,10 +271,10 @@ static int acpi_platform_notify(struct device *dev)
231 271
232 acpi_get_name(dev->archdata.acpi_handle, 272 acpi_get_name(dev->archdata.acpi_handle,
233 ACPI_FULL_PATHNAME, &buffer); 273 ACPI_FULL_PATHNAME, &buffer);
234 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); 274 DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer);
235 kfree(buffer.pointer); 275 kfree(buffer.pointer);
236 } else 276 } else
237 DBG("Device %s -> No ACPI support\n", dev->bus_id); 277 DBG("Device %s -> No ACPI support\n", dev_name(dev));
238#endif 278#endif
239 279
240 return ret; 280 return ret;
diff --git a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile
deleted file mode 100644
index 438ad373b9ad..000000000000
--- a/drivers/acpi/hardware/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o
6
7obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
deleted file mode 100644
index 371a2daf837f..000000000000
--- a/drivers/acpi/namespace/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \
6 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
7 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
8 nsparse.o nspredef.o
9
10obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
11
12EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 25ceae9191ef..c5e292aab0e3 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -29,7 +29,6 @@
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
32#include <acpi/acmacros.h>
33 32
34#define ACPI_NUMA 0x80000000 33#define ACPI_NUMA 0x80000000
35#define _COMPONENT ACPI_NUMA 34#define _COMPONENT ACPI_NUMA
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 4be252145cb4..d1dd5160daa9 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -35,7 +35,6 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/kmod.h> 36#include <linux/kmod.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/dmi.h>
39#include <linux/workqueue.h> 38#include <linux/workqueue.h>
40#include <linux/nmi.h> 39#include <linux/nmi.h>
41#include <linux/acpi.h> 40#include <linux/acpi.h>
@@ -97,54 +96,44 @@ static DEFINE_SPINLOCK(acpi_res_lock);
97static char osi_additional_string[OSI_STRING_LENGTH_MAX]; 96static char osi_additional_string[OSI_STRING_LENGTH_MAX];
98 97
99/* 98/*
100 * "Ode to _OSI(Linux)" 99 * The story of _OSI(Linux)
101 * 100 *
102 * osi_linux -- Control response to BIOS _OSI(Linux) query. 101 * From pre-history through Linux-2.6.22,
102 * Linux responded TRUE upon a BIOS OSI(Linux) query.
103 * 103 *
104 * As Linux evolves, the features that it supports change. 104 * Unfortunately, reference BIOS writers got wind of this
105 * So an OSI string such as "Linux" is not specific enough 105 * and put OSI(Linux) in their example code, quickly exposing
106 * to be useful across multiple versions of Linux. It 106 * this string as ill-conceived and opening the door to
107 * doesn't identify any particular feature, interface, 107 * an un-bounded number of BIOS incompatibilities.
108 * or even any particular version of Linux...
109 * 108 *
110 * Unfortunately, Linux-2.6.22 and earlier responded "yes" 109 * For example, OSI(Linux) was used on resume to re-POST a
111 * to a BIOS _OSI(Linux) query. When 110 * video card on one system, because Linux at that time
112 * a reference mobile BIOS started using it, its use 111 * could not do a speedy restore in its native driver.
113 * started to spread to many vendor platforms. 112 * But then upon gaining quick native restore capability,
114 * As it is not supportable, we need to halt that spread. 113 * Linux has no way to tell the BIOS to skip the time-consuming
114 * POST -- putting Linux at a permanent performance disadvantage.
115 * On another system, the BIOS writer used OSI(Linux)
116 * to infer native OS support for IPMI! On other systems,
117 * OSI(Linux) simply got in the way of Linux claiming to
118 * be compatible with other operating systems, exposing
119 * BIOS issues such as skipped device initialization.
115 * 120 *
116 * Today, most BIOS references to _OSI(Linux) are noise -- 121 * So "Linux" turned out to be a really poor chose of
117 * they have no functional effect and are just dead code 122 * OSI string, and from Linux-2.6.23 onward we respond FALSE.
118 * carried over from the reference BIOS.
119 *
120 * The next most common case is that _OSI(Linux) harms Linux,
121 * usually by causing the BIOS to follow paths that are
122 * not tested during Windows validation.
123 *
124 * Finally, there is a short list of platforms
125 * where OSI(Linux) benefits Linux.
126 *
127 * In Linux-2.6.23, OSI(Linux) is first disabled by default.
128 * DMI is used to disable the dmesg warning about OSI(Linux)
129 * on platforms where it is known to have no effect.
130 * But a dmesg warning remains for systems where
131 * we do not know if OSI(Linux) is good or bad for the system.
132 * DMI is also used to enable OSI(Linux) for the machines
133 * that are known to need it.
134 * 123 *
135 * BIOS writers should NOT query _OSI(Linux) on future systems. 124 * BIOS writers should NOT query _OSI(Linux) on future systems.
136 * It will be ignored by default, and to get Linux to 125 * Linux will complain on the console when it sees it, and return FALSE.
137 * not ignore it will require a kernel source update to 126 * To get Linux to return TRUE for your system will require
138 * add a DMI entry, or a boot-time "acpi_osi=Linux" invocation. 127 * a kernel source update to add a DMI entry,
128 * or boot with "acpi_osi=Linux"
139 */ 129 */
140#define OSI_LINUX_ENABLE 0
141 130
142static struct osi_linux { 131static struct osi_linux {
143 unsigned int enable:1; 132 unsigned int enable:1;
144 unsigned int dmi:1; 133 unsigned int dmi:1;
145 unsigned int cmdline:1; 134 unsigned int cmdline:1;
146 unsigned int known:1; 135 unsigned int known:1;
147} osi_linux = { OSI_LINUX_ENABLE, 0, 0, 0}; 136} osi_linux = { 0, 0, 0, 0};
148 137
149static void __init acpi_request_region (struct acpi_generic_address *addr, 138static void __init acpi_request_region (struct acpi_generic_address *addr,
150 unsigned int length, char *desc) 139 unsigned int length, char *desc)
@@ -239,10 +228,10 @@ void acpi_os_vprintf(const char *fmt, va_list args)
239 if (acpi_in_debugger) { 228 if (acpi_in_debugger) {
240 kdb_printf("%s", buffer); 229 kdb_printf("%s", buffer);
241 } else { 230 } else {
242 printk("%s", buffer); 231 printk(KERN_CONT "%s", buffer);
243 } 232 }
244#else 233#else
245 printk("%s", buffer); 234 printk(KERN_CONT "%s", buffer);
246#endif 235#endif
247} 236}
248 237
@@ -285,12 +274,19 @@ EXPORT_SYMBOL_GPL(acpi_os_map_memory);
285 274
286void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) 275void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
287{ 276{
288 if (acpi_gbl_permanent_mmap) { 277 if (acpi_gbl_permanent_mmap)
289 iounmap(virt); 278 iounmap(virt);
290 } 279 else
280 __acpi_unmap_table(virt, size);
291} 281}
292EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); 282EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
293 283
284void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
285{
286 if (!acpi_gbl_permanent_mmap)
287 __acpi_unmap_table(virt, size);
288}
289
294#ifdef ACPI_FUTURE_USAGE 290#ifdef ACPI_FUTURE_USAGE
295acpi_status 291acpi_status
296acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) 292acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
@@ -737,7 +733,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
737 733
738 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); 734 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
739 if (!dpc) 735 if (!dpc)
740 return_ACPI_STATUS(AE_NO_MEMORY); 736 return AE_NO_MEMORY;
741 737
742 dpc->function = function; 738 dpc->function = function;
743 dpc->context = context; 739 dpc->context = context;
@@ -758,7 +754,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
758 status = AE_ERROR; 754 status = AE_ERROR;
759 kfree(dpc); 755 kfree(dpc);
760 } 756 }
761 return_ACPI_STATUS(status); 757 return status;
762} 758}
763 759
764acpi_status acpi_os_execute(acpi_execute_type type, 760acpi_status acpi_os_execute(acpi_execute_type type,
@@ -1296,34 +1292,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1296 return (AE_OK); 1292 return (AE_OK);
1297} 1293}
1298 1294
1299/**
1300 * acpi_dmi_dump - dump DMI slots needed for blacklist entry
1301 *
1302 * Returns 0 on success
1303 */
1304static int acpi_dmi_dump(void)
1305{
1306
1307 if (!dmi_available)
1308 return -1;
1309
1310 printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n",
1311 dmi_get_system_info(DMI_SYS_VENDOR));
1312 printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n",
1313 dmi_get_system_info(DMI_PRODUCT_NAME));
1314 printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n",
1315 dmi_get_system_info(DMI_PRODUCT_VERSION));
1316 printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n",
1317 dmi_get_system_info(DMI_BOARD_NAME));
1318 printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n",
1319 dmi_get_system_info(DMI_BIOS_VENDOR));
1320 printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n",
1321 dmi_get_system_info(DMI_BIOS_DATE));
1322
1323 return 0;
1324}
1325
1326
1327/****************************************************************************** 1295/******************************************************************************
1328 * 1296 *
1329 * FUNCTION: acpi_os_validate_interface 1297 * FUNCTION: acpi_os_validate_interface
@@ -1350,27 +1318,60 @@ acpi_os_validate_interface (char *interface)
1350 osi_linux.cmdline ? " via cmdline" : 1318 osi_linux.cmdline ? " via cmdline" :
1351 osi_linux.dmi ? " via DMI" : ""); 1319 osi_linux.dmi ? " via DMI" : "");
1352 1320
1353 if (!osi_linux.dmi) {
1354 if (acpi_dmi_dump())
1355 printk(KERN_NOTICE PREFIX
1356 "[please extract dmidecode output]\n");
1357 printk(KERN_NOTICE PREFIX
1358 "Please send DMI info above to "
1359 "linux-acpi@vger.kernel.org\n");
1360 }
1361 if (!osi_linux.known && !osi_linux.cmdline) {
1362 printk(KERN_NOTICE PREFIX
1363 "If \"acpi_osi=%sLinux\" works better, "
1364 "please notify linux-acpi@vger.kernel.org\n",
1365 osi_linux.enable ? "!" : "");
1366 }
1367
1368 if (osi_linux.enable) 1321 if (osi_linux.enable)
1369 return AE_OK; 1322 return AE_OK;
1370 } 1323 }
1371 return AE_SUPPORT; 1324 return AE_SUPPORT;
1372} 1325}
1373 1326
1327#ifdef CONFIG_X86
1328
1329struct aml_port_desc {
1330 uint start;
1331 uint end;
1332 char* name;
1333 char warned;
1334};
1335
1336static struct aml_port_desc aml_invalid_port_list[] = {
1337 {0x20, 0x21, "PIC0", 0},
1338 {0xA0, 0xA1, "PIC1", 0},
1339 {0x4D0, 0x4D1, "ELCR", 0}
1340};
1341
1342/*
1343 * valid_aml_io_address()
1344 *
1345 * if valid, return true
1346 * else invalid, warn once, return false
1347 */
1348static bool valid_aml_io_address(uint address, uint length)
1349{
1350 int i;
1351 int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc);
1352
1353 for (i = 0; i < entries; ++i) {
1354 if ((address >= aml_invalid_port_list[i].start &&
1355 address <= aml_invalid_port_list[i].end) ||
1356 (address + length >= aml_invalid_port_list[i].start &&
1357 address + length <= aml_invalid_port_list[i].end))
1358 {
1359 if (!aml_invalid_port_list[i].warned)
1360 {
1361 printk(KERN_ERR "ACPI: Denied BIOS AML access"
1362 " to invalid port 0x%x+0x%x (%s)\n",
1363 address, length,
1364 aml_invalid_port_list[i].name);
1365 aml_invalid_port_list[i].warned = 1;
1366 }
1367 return false; /* invalid */
1368 }
1369 }
1370 return true; /* valid */
1371}
1372#else
1373static inline bool valid_aml_io_address(uint address, uint length) { return true; }
1374#endif
1374/****************************************************************************** 1375/******************************************************************************
1375 * 1376 *
1376 * FUNCTION: acpi_os_validate_address 1377 * FUNCTION: acpi_os_validate_address
@@ -1400,6 +1401,8 @@ acpi_os_validate_address (
1400 1401
1401 switch (space_id) { 1402 switch (space_id) {
1402 case ACPI_ADR_SPACE_SYSTEM_IO: 1403 case ACPI_ADR_SPACE_SYSTEM_IO:
1404 if (!valid_aml_io_address(address, length))
1405 return AE_AML_ILLEGAL_ADDRESS;
1403 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 1406 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
1404 /* Only interference checks against SystemIO and SytemMemory 1407 /* Only interference checks against SystemIO and SytemMemory
1405 are needed */ 1408 are needed */
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
deleted file mode 100644
index db24ee09cf11..000000000000
--- a/drivers/acpi/parser/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \
6 psopcode.o psscope.o psutils.o psxface.o
7
8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 4b252ea0e952..95650f83ce2e 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -99,7 +99,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
99 */ 99 */
100 100
101 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
102 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 102 "Device %s has PCI address %04x:%02x:%02x.%d\n",
103 acpi_device_bid(device), id->segment, id->bus, 103 acpi_device_bid(device), id->segment, id->bus,
104 id->device, id->function)); 104 id->device, id->function));
105 105
@@ -111,12 +111,11 @@ EXPORT_SYMBOL(acpi_get_pci_id);
111int acpi_pci_bind(struct acpi_device *device) 111int acpi_pci_bind(struct acpi_device *device)
112{ 112{
113 int result = 0; 113 int result = 0;
114 acpi_status status = AE_OK; 114 acpi_status status;
115 struct acpi_pci_data *data = NULL; 115 struct acpi_pci_data *data;
116 struct acpi_pci_data *pdata = NULL; 116 struct acpi_pci_data *pdata;
117 char *pathname = NULL; 117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
118 struct acpi_buffer buffer = { 0, NULL }; 118 acpi_handle handle;
119 acpi_handle handle = NULL;
120 struct pci_dev *dev; 119 struct pci_dev *dev;
121 struct pci_bus *bus; 120 struct pci_bus *bus;
122 121
@@ -124,21 +123,18 @@ int acpi_pci_bind(struct acpi_device *device)
124 if (!device || !device->parent) 123 if (!device || !device->parent)
125 return -EINVAL; 124 return -EINVAL;
126 125
127 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
128 if (!pathname)
129 return -ENOMEM;
130 buffer.length = ACPI_PATHNAME_MAX;
131 buffer.pointer = pathname;
132
133 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 126 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
134 if (!data) { 127 if (!data)
135 kfree(pathname);
136 return -ENOMEM; 128 return -ENOMEM;
129
130 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
131 if (ACPI_FAILURE(status)) {
132 kfree(data);
133 return -ENODEV;
137 } 134 }
138 135
139 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
140 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
141 pathname)); 137 (char *)buffer.pointer));
142 138
143 /* 139 /*
144 * Segment & Bus 140 * Segment & Bus
@@ -166,7 +162,7 @@ int acpi_pci_bind(struct acpi_device *device)
166 data->id.device = device->pnp.bus_address >> 16; 162 data->id.device = device->pnp.bus_address >> 16;
167 data->id.function = device->pnp.bus_address & 0xFFFF; 163 data->id.function = device->pnp.bus_address & 0xFFFF;
168 164
169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 165 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %04x:%02x:%02x.%d\n",
170 data->id.segment, data->id.bus, data->id.device, 166 data->id.segment, data->id.bus, data->id.device,
171 data->id.function)); 167 data->id.function));
172 168
@@ -196,7 +192,7 @@ int acpi_pci_bind(struct acpi_device *device)
196 } 192 }
197 if (!data->dev) { 193 if (!data->dev) {
198 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 194 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
199 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 195 "Device %04x:%02x:%02x.%d not present in PCI namespace\n",
200 data->id.segment, data->id.bus, 196 data->id.segment, data->id.bus,
201 data->id.device, data->id.function)); 197 data->id.device, data->id.function));
202 result = -ENODEV; 198 result = -ENODEV;
@@ -204,7 +200,7 @@ int acpi_pci_bind(struct acpi_device *device)
204 } 200 }
205 if (!data->dev->bus) { 201 if (!data->dev->bus) {
206 printk(KERN_ERR PREFIX 202 printk(KERN_ERR PREFIX
207 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 203 "Device %04x:%02x:%02x.%d has invalid 'bus' field\n",
208 data->id.segment, data->id.bus, 204 data->id.segment, data->id.bus,
209 data->id.device, data->id.function); 205 data->id.device, data->id.function);
210 result = -ENODEV; 206 result = -ENODEV;
@@ -219,7 +215,7 @@ int acpi_pci_bind(struct acpi_device *device)
219 */ 215 */
220 if (data->dev->subordinate) { 216 if (data->dev->subordinate) {
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 217 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
222 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 218 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
223 data->id.segment, data->id.bus, 219 data->id.segment, data->id.bus,
224 data->id.device, data->id.function)); 220 data->id.device, data->id.function));
225 data->bus = data->dev->subordinate; 221 data->bus = data->dev->subordinate;
@@ -262,7 +258,7 @@ int acpi_pci_bind(struct acpi_device *device)
262 } 258 }
263 259
264 end: 260 end:
265 kfree(pathname); 261 kfree(buffer.pointer);
266 if (result) 262 if (result)
267 kfree(data); 263 kfree(data);
268 264
@@ -272,25 +268,21 @@ int acpi_pci_bind(struct acpi_device *device)
272static int acpi_pci_unbind(struct acpi_device *device) 268static int acpi_pci_unbind(struct acpi_device *device)
273{ 269{
274 int result = 0; 270 int result = 0;
275 acpi_status status = AE_OK; 271 acpi_status status;
276 struct acpi_pci_data *data = NULL; 272 struct acpi_pci_data *data;
277 char *pathname = NULL; 273 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
278 struct acpi_buffer buffer = { 0, NULL };
279 274
280 275
281 if (!device || !device->parent) 276 if (!device || !device->parent)
282 return -EINVAL; 277 return -EINVAL;
283 278
284 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 279 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
285 if (!pathname) 280 if (ACPI_FAILURE(status))
286 return -ENOMEM; 281 return -ENODEV;
287 282
288 buffer.length = ACPI_PATHNAME_MAX;
289 buffer.pointer = pathname;
290 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
292 pathname)); 284 (char *) buffer.pointer));
293 kfree(pathname); 285 kfree(buffer.pointer);
294 286
295 status = 287 status =
296 acpi_get_data(device->handle, acpi_pci_data_handler, 288 acpi_get_data(device->handle, acpi_pci_data_handler,
@@ -322,50 +314,44 @@ acpi_pci_bind_root(struct acpi_device *device,
322 struct acpi_pci_id *id, struct pci_bus *bus) 314 struct acpi_pci_id *id, struct pci_bus *bus)
323{ 315{
324 int result = 0; 316 int result = 0;
325 acpi_status status = AE_OK; 317 acpi_status status;
326 struct acpi_pci_data *data = NULL; 318 struct acpi_pci_data *data = NULL;
327 char *pathname = NULL; 319 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
328 struct acpi_buffer buffer = { 0, NULL };
329
330 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
331 if (!pathname)
332 return -ENOMEM;
333
334 buffer.length = ACPI_PATHNAME_MAX;
335 buffer.pointer = pathname;
336 320
337 if (!device || !id || !bus) { 321 if (!device || !id || !bus) {
338 kfree(pathname);
339 return -EINVAL; 322 return -EINVAL;
340 } 323 }
341 324
342 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 325 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
343 if (!data) { 326 if (!data)
344 kfree(pathname);
345 return -ENOMEM; 327 return -ENOMEM;
346 }
347 328
348 data->id = *id; 329 data->id = *id;
349 data->bus = bus; 330 data->bus = bus;
350 device->ops.bind = acpi_pci_bind; 331 device->ops.bind = acpi_pci_bind;
351 device->ops.unbind = acpi_pci_unbind; 332 device->ops.unbind = acpi_pci_unbind;
352 333
353 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 334 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
335 if (ACPI_FAILURE(status)) {
336 kfree (data);
337 return -ENODEV;
338 }
354 339
355 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 340 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
356 "%02x:%02x\n", pathname, id->segment, id->bus)); 341 "%04x:%02x\n", (char *)buffer.pointer,
342 id->segment, id->bus));
357 343
358 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 344 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
359 if (ACPI_FAILURE(status)) { 345 if (ACPI_FAILURE(status)) {
360 ACPI_EXCEPTION((AE_INFO, status, 346 ACPI_EXCEPTION((AE_INFO, status,
361 "Unable to attach ACPI-PCI context to device %s", 347 "Unable to attach ACPI-PCI context to device %s",
362 pathname)); 348 (char *)buffer.pointer));
363 result = -ENODEV; 349 result = -ENODEV;
364 goto end; 350 goto end;
365 } 351 }
366 352
367 end: 353 end:
368 kfree(pathname); 354 kfree(buffer.pointer);
369 if (result != 0) 355 if (result != 0)
370 kfree(data); 356 kfree(data);
371 357
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 11acaee14d66..891bdf6679f3 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -4,6 +4,8 @@
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de> 6 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
7 * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
8 * Bjorn Helgaas <bjorn.helgaas@hp.com>
7 * 9 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * 11 *
@@ -41,29 +43,36 @@
41#define _COMPONENT ACPI_PCI_COMPONENT 43#define _COMPONENT ACPI_PCI_COMPONENT
42ACPI_MODULE_NAME("pci_irq"); 44ACPI_MODULE_NAME("pci_irq");
43 45
44static struct acpi_prt_list acpi_prt; 46struct acpi_prt_entry {
47 struct list_head list;
48 struct acpi_pci_id id;
49 u8 pin;
50 acpi_handle link;
51 u32 index; /* GSI, or link _CRS index */
52};
53
54static LIST_HEAD(acpi_prt_list);
45static DEFINE_SPINLOCK(acpi_prt_lock); 55static DEFINE_SPINLOCK(acpi_prt_lock);
46 56
57static inline char pin_name(int pin)
58{
59 return 'A' + pin - 1;
60}
61
47/* -------------------------------------------------------------------------- 62/* --------------------------------------------------------------------------
48 PCI IRQ Routing Table (PRT) Support 63 PCI IRQ Routing Table (PRT) Support
49 -------------------------------------------------------------------------- */ 64 -------------------------------------------------------------------------- */
50 65
51static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, 66static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
52 int bus, 67 int pin)
53 int device, int pin)
54{ 68{
55 struct acpi_prt_entry *entry = NULL; 69 struct acpi_prt_entry *entry;
56 70 int segment = pci_domain_nr(dev->bus);
57 if (!acpi_prt.count) 71 int bus = dev->bus->number;
58 return NULL; 72 int device = PCI_SLOT(dev->devfn);
59 73
60 /*
61 * Parse through all PRT entries looking for a match on the specified
62 * PCI device's segment, bus, device, and pin (don't care about func).
63 *
64 */
65 spin_lock(&acpi_prt_lock); 74 spin_lock(&acpi_prt_lock);
66 list_for_each_entry(entry, &acpi_prt.entries, node) { 75 list_for_each_entry(entry, &acpi_prt_list, list) {
67 if ((segment == entry->id.segment) 76 if ((segment == entry->id.segment)
68 && (bus == entry->id.bus) 77 && (bus == entry->id.bus)
69 && (device == entry->id.device) 78 && (device == entry->id.device)
@@ -72,7 +81,6 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
72 return entry; 81 return entry;
73 } 82 }
74 } 83 }
75
76 spin_unlock(&acpi_prt_lock); 84 spin_unlock(&acpi_prt_lock);
77 return NULL; 85 return NULL;
78} 86}
@@ -124,25 +132,27 @@ struct prt_quirk {
124 char *actual_source; 132 char *actual_source;
125}; 133};
126 134
135#define PCI_INTX_PIN(c) (c - 'A' + 1)
136
127/* 137/*
128 * These systems have incorrect _PRT entries. The BIOS claims the PCI 138 * These systems have incorrect _PRT entries. The BIOS claims the PCI
129 * interrupt at the listed segment/bus/device/pin is connected to the first 139 * interrupt at the listed segment/bus/device/pin is connected to the first
130 * link device, but it is actually connected to the second. 140 * link device, but it is actually connected to the second.
131 */ 141 */
132static struct prt_quirk prt_quirks[] = { 142static struct prt_quirk prt_quirks[] = {
133 { medion_md9580, 0, 0, 9, 'A', 143 { medion_md9580, 0, 0, 9, PCI_INTX_PIN('A'),
134 "\\_SB_.PCI0.ISA_.LNKA", 144 "\\_SB_.PCI0.ISA_.LNKA",
135 "\\_SB_.PCI0.ISA_.LNKB"}, 145 "\\_SB_.PCI0.ISA_.LNKB"},
136 { dell_optiplex, 0, 0, 0xd, 'A', 146 { dell_optiplex, 0, 0, 0xd, PCI_INTX_PIN('A'),
137 "\\_SB_.LNKB", 147 "\\_SB_.LNKB",
138 "\\_SB_.LNKA"}, 148 "\\_SB_.LNKA"},
139 { hp_t5710, 0, 0, 1, 'A', 149 { hp_t5710, 0, 0, 1, PCI_INTX_PIN('A'),
140 "\\_SB_.PCI0.LNK1", 150 "\\_SB_.PCI0.LNK1",
141 "\\_SB_.PCI0.LNK3"}, 151 "\\_SB_.PCI0.LNK3"},
142}; 152};
143 153
144static void 154static void do_prt_fixups(struct acpi_prt_entry *entry,
145do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt) 155 struct acpi_pci_routing_table *prt)
146{ 156{
147 int i; 157 int i;
148 struct prt_quirk *quirk; 158 struct prt_quirk *quirk;
@@ -158,42 +168,43 @@ do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt)
158 entry->id.segment == quirk->segment && 168 entry->id.segment == quirk->segment &&
159 entry->id.bus == quirk->bus && 169 entry->id.bus == quirk->bus &&
160 entry->id.device == quirk->device && 170 entry->id.device == quirk->device &&
161 entry->pin + 'A' == quirk->pin && 171 entry->pin == quirk->pin &&
162 !strcmp(prt->source, quirk->source) && 172 !strcmp(prt->source, quirk->source) &&
163 strlen(prt->source) >= strlen(quirk->actual_source)) { 173 strlen(prt->source) >= strlen(quirk->actual_source)) {
164 printk(KERN_WARNING PREFIX "firmware reports " 174 printk(KERN_WARNING PREFIX "firmware reports "
165 "%04x:%02x:%02x PCI INT %c connected to %s; " 175 "%04x:%02x:%02x PCI INT %c connected to %s; "
166 "changing to %s\n", 176 "changing to %s\n",
167 entry->id.segment, entry->id.bus, 177 entry->id.segment, entry->id.bus,
168 entry->id.device, 'A' + entry->pin, 178 entry->id.device, pin_name(entry->pin),
169 prt->source, quirk->actual_source); 179 prt->source, quirk->actual_source);
170 strcpy(prt->source, quirk->actual_source); 180 strcpy(prt->source, quirk->actual_source);
171 } 181 }
172 } 182 }
173} 183}
174 184
175static int 185static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
176acpi_pci_irq_add_entry(acpi_handle handle, 186 struct acpi_pci_routing_table *prt)
177 int segment, int bus, struct acpi_pci_routing_table *prt)
178{ 187{
179 struct acpi_prt_entry *entry = NULL; 188 struct acpi_prt_entry *entry;
180
181
182 if (!prt)
183 return -EINVAL;
184 189
185 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); 190 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
186 if (!entry) 191 if (!entry)
187 return -ENOMEM; 192 return -ENOMEM;
188 193
194 /*
195 * Note that the _PRT uses 0=INTA, 1=INTB, etc, while PCI uses
196 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
197 * it here.
198 */
189 entry->id.segment = segment; 199 entry->id.segment = segment;
190 entry->id.bus = bus; 200 entry->id.bus = bus;
191 entry->id.device = (prt->address >> 16) & 0xFFFF; 201 entry->id.device = (prt->address >> 16) & 0xFFFF;
192 entry->id.function = prt->address & 0xFFFF; 202 entry->pin = prt->pin + 1;
193 entry->pin = prt->pin;
194 203
195 do_prt_fixups(entry, prt); 204 do_prt_fixups(entry, prt);
196 205
206 entry->index = prt->source_index;
207
197 /* 208 /*
198 * Type 1: Dynamic 209 * Type 1: Dynamic
199 * --------------- 210 * ---------------
@@ -207,10 +218,9 @@ acpi_pci_irq_add_entry(acpi_handle handle,
207 * (e.g. exists somewhere 'below' this _PRT entry in the ACPI 218 * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
208 * namespace). 219 * namespace).
209 */ 220 */
210 if (prt->source[0]) { 221 if (prt->source[0])
211 acpi_get_handle(handle, prt->source, &entry->link.handle); 222 acpi_get_handle(handle, prt->source, &entry->link);
212 entry->link.index = prt->source_index; 223
213 }
214 /* 224 /*
215 * Type 2: Static 225 * Type 2: Static
216 * -------------- 226 * --------------
@@ -218,84 +228,38 @@ acpi_pci_irq_add_entry(acpi_handle handle,
218 * the IRQ value, which is hardwired to specific interrupt inputs on 228 * the IRQ value, which is hardwired to specific interrupt inputs on
219 * the interrupt controller. 229 * the interrupt controller.
220 */ 230 */
221 else
222 entry->link.index = prt->source_index;
223 231
224 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, 232 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
225 " %02X:%02X:%02X[%c] -> %s[%d]\n", 233 " %04x:%02x:%02x[%c] -> %s[%d]\n",
226 entry->id.segment, entry->id.bus, 234 entry->id.segment, entry->id.bus,
227 entry->id.device, ('A' + entry->pin), prt->source, 235 entry->id.device, pin_name(entry->pin),
228 entry->link.index)); 236 prt->source, entry->index));
229 237
230 spin_lock(&acpi_prt_lock); 238 spin_lock(&acpi_prt_lock);
231 list_add_tail(&entry->node, &acpi_prt.entries); 239 list_add_tail(&entry->list, &acpi_prt_list);
232 acpi_prt.count++;
233 spin_unlock(&acpi_prt_lock); 240 spin_unlock(&acpi_prt_lock);
234 241
235 return 0; 242 return 0;
236} 243}
237 244
238static void
239acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
240{
241 if (segment == entry->id.segment && bus == entry->id.bus) {
242 acpi_prt.count--;
243 list_del(&entry->node);
244 kfree(entry);
245 }
246}
247
248int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) 245int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
249{ 246{
250 acpi_status status = AE_OK; 247 acpi_status status;
251 char *pathname = NULL; 248 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
252 struct acpi_buffer buffer = { 0, NULL }; 249 struct acpi_pci_routing_table *entry;
253 struct acpi_pci_routing_table *prt = NULL;
254 struct acpi_pci_routing_table *entry = NULL;
255 static int first_time = 1;
256
257
258 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
259 if (!pathname)
260 return -ENOMEM;
261 250
262 if (first_time) { 251 /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
263 acpi_prt.count = 0; 252 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
264 INIT_LIST_HEAD(&acpi_prt.entries); 253 if (ACPI_FAILURE(status))
265 first_time = 0; 254 return -ENODEV;
266 }
267
268 /*
269 * NOTE: We're given a 'handle' to the _PRT object's parent device
270 * (either a PCI root bridge or PCI-PCI bridge).
271 */
272
273 buffer.length = ACPI_PATHNAME_MAX;
274 buffer.pointer = pathname;
275 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
276 255
277 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", 256 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
278 pathname); 257 (char *) buffer.pointer);
279 258
280 /* 259 kfree(buffer.pointer);
281 * Evaluate this _PRT and add its entries to our global list (acpi_prt).
282 */
283 260
284 buffer.length = 0; 261 buffer.length = ACPI_ALLOCATE_BUFFER;
285 buffer.pointer = NULL; 262 buffer.pointer = NULL;
286 kfree(pathname);
287 status = acpi_get_irq_routing_table(handle, &buffer);
288 if (status != AE_BUFFER_OVERFLOW) {
289 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
290 acpi_format_exception(status)));
291 return -ENODEV;
292 }
293
294 prt = kzalloc(buffer.length, GFP_KERNEL);
295 if (!prt) {
296 return -ENOMEM;
297 }
298 buffer.pointer = prt;
299 263
300 status = acpi_get_irq_routing_table(handle, &buffer); 264 status = acpi_get_irq_routing_table(handle, &buffer);
301 if (ACPI_FAILURE(status)) { 265 if (ACPI_FAILURE(status)) {
@@ -305,36 +269,30 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
305 return -ENODEV; 269 return -ENODEV;
306 } 270 }
307 271
308 entry = prt; 272 entry = buffer.pointer;
309
310 while (entry && (entry->length > 0)) { 273 while (entry && (entry->length > 0)) {
311 acpi_pci_irq_add_entry(handle, segment, bus, entry); 274 acpi_pci_irq_add_entry(handle, segment, bus, entry);
312 entry = (struct acpi_pci_routing_table *) 275 entry = (struct acpi_pci_routing_table *)
313 ((unsigned long)entry + entry->length); 276 ((unsigned long)entry + entry->length);
314 } 277 }
315 278
316 kfree(prt); 279 kfree(buffer.pointer);
317
318 return 0; 280 return 0;
319} 281}
320 282
321void acpi_pci_irq_del_prt(int segment, int bus) 283void acpi_pci_irq_del_prt(int segment, int bus)
322{ 284{
323 struct list_head *node = NULL, *n = NULL; 285 struct acpi_prt_entry *entry, *tmp;
324 struct acpi_prt_entry *entry = NULL;
325
326 if (!acpi_prt.count) {
327 return;
328 }
329 286
330 printk(KERN_DEBUG 287 printk(KERN_DEBUG
331 "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment, 288 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
332 bus); 289 segment, bus);
333 spin_lock(&acpi_prt_lock); 290 spin_lock(&acpi_prt_lock);
334 list_for_each_safe(node, n, &acpi_prt.entries) { 291 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
335 entry = list_entry(node, struct acpi_prt_entry, node); 292 if (segment == entry->id.segment && bus == entry->id.bus) {
336 293 list_del(&entry->list);
337 acpi_pci_irq_del_entry(segment, bus, entry); 294 kfree(entry);
295 }
338 } 296 }
339 spin_unlock(&acpi_prt_lock); 297 spin_unlock(&acpi_prt_lock);
340} 298}
@@ -342,106 +300,26 @@ void acpi_pci_irq_del_prt(int segment, int bus)
342/* -------------------------------------------------------------------------- 300/* --------------------------------------------------------------------------
343 PCI Interrupt Routing Support 301 PCI Interrupt Routing Support
344 -------------------------------------------------------------------------- */ 302 -------------------------------------------------------------------------- */
345typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); 303static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
346
347static int
348acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
349 int *triggering, int *polarity, char **link)
350{
351 int irq;
352
353
354 if (entry->link.handle) {
355 irq = acpi_pci_link_allocate_irq(entry->link.handle,
356 entry->link.index, triggering,
357 polarity, link);
358 if (irq < 0) {
359 printk(KERN_WARNING PREFIX
360 "Invalid IRQ link routing entry\n");
361 return -1;
362 }
363 } else {
364 irq = entry->link.index;
365 *triggering = ACPI_LEVEL_SENSITIVE;
366 *polarity = ACPI_ACTIVE_LOW;
367 }
368
369 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
370 return irq;
371}
372
373static int
374acpi_pci_free_irq(struct acpi_prt_entry *entry,
375 int *triggering, int *polarity, char **link)
376{
377 int irq;
378
379 if (entry->link.handle) {
380 irq = acpi_pci_link_free_irq(entry->link.handle);
381 } else {
382 irq = entry->link.index;
383 }
384 return irq;
385}
386
387/*
388 * acpi_pci_irq_lookup
389 * success: return IRQ >= 0
390 * failure: return -1
391 */
392static int
393acpi_pci_irq_lookup(struct pci_bus *bus,
394 int device,
395 int pin,
396 int *triggering,
397 int *polarity, char **link, irq_lookup_func func)
398{ 304{
399 struct acpi_prt_entry *entry = NULL; 305 struct acpi_prt_entry *entry;
400 int segment = pci_domain_nr(bus); 306 struct pci_dev *bridge;
401 int bus_nr = bus->number; 307 u8 bridge_pin, orig_pin = pin;
402 int ret; 308
403 309 entry = acpi_pci_irq_find_prt_entry(dev, pin);
404 310 if (entry) {
405 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 311 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s[%c] _PRT entry\n",
406 "Searching for PRT entry for %02x:%02x:%02x[%c]\n", 312 pci_name(dev), pin_name(pin)));
407 segment, bus_nr, device, ('A' + pin))); 313 return entry;
408
409 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
410 if (!entry) {
411 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
412 return -1;
413 } 314 }
414 315
415 ret = func(entry, triggering, polarity, link);
416 return ret;
417}
418
419/*
420 * acpi_pci_irq_derive
421 * success: return IRQ >= 0
422 * failure: return < 0
423 */
424static int
425acpi_pci_irq_derive(struct pci_dev *dev,
426 int pin,
427 int *triggering,
428 int *polarity, char **link, irq_lookup_func func)
429{
430 struct pci_dev *bridge = dev;
431 int irq = -1;
432 u8 bridge_pin = 0, orig_pin = pin;
433
434
435 if (!dev)
436 return -EINVAL;
437
438 /* 316 /*
439 * Attempt to derive an IRQ for this device from a parent bridge's 317 * Attempt to derive an IRQ for this device from a parent bridge's
440 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). 318 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
441 */ 319 */
442 while (irq < 0 && bridge->bus->self) { 320 bridge = dev->bus->self;
443 pin = (pin + PCI_SLOT(bridge->devfn)) % 4; 321 while (bridge) {
444 bridge = bridge->bus->self; 322 pin = (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
445 323
446 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { 324 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
447 /* PC card has the same IRQ as its cardbridge */ 325 /* PC card has the same IRQ as its cardbridge */
@@ -450,50 +328,40 @@ acpi_pci_irq_derive(struct pci_dev *dev,
450 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 328 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
451 "No interrupt pin configured for device %s\n", 329 "No interrupt pin configured for device %s\n",
452 pci_name(bridge))); 330 pci_name(bridge)));
453 return -1; 331 return NULL;
454 } 332 }
455 /* Pin is from 0 to 3 */
456 bridge_pin--;
457 pin = bridge_pin; 333 pin = bridge_pin;
458 } 334 }
459 335
460 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 336 entry = acpi_pci_irq_find_prt_entry(bridge, pin);
461 pin, triggering, polarity, 337 if (entry) {
462 link, func); 338 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
463 } 339 "Derived GSI for %s INT %c from %s\n",
340 pci_name(dev), pin_name(orig_pin),
341 pci_name(bridge)));
342 return entry;
343 }
464 344
465 if (irq < 0) { 345 dev = bridge;
466 dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n", 346 bridge = dev->bus->self;
467 'A' + orig_pin);
468 return -1;
469 } 347 }
470 348
471 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", 349 dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n",
472 irq, pci_name(dev), pci_name(bridge))); 350 pin_name(orig_pin));
473 351 return NULL;
474 return irq;
475} 352}
476 353
477/*
478 * acpi_pci_irq_enable
479 * success: return 0
480 * failure: return < 0
481 */
482
483int acpi_pci_irq_enable(struct pci_dev *dev) 354int acpi_pci_irq_enable(struct pci_dev *dev)
484{ 355{
485 int irq = 0; 356 struct acpi_prt_entry *entry;
486 u8 pin = 0; 357 int gsi;
358 u8 pin;
487 int triggering = ACPI_LEVEL_SENSITIVE; 359 int triggering = ACPI_LEVEL_SENSITIVE;
488 int polarity = ACPI_ACTIVE_LOW; 360 int polarity = ACPI_ACTIVE_LOW;
489 char *link = NULL; 361 char *link = NULL;
490 char link_desc[16]; 362 char link_desc[16];
491 int rc; 363 int rc;
492 364
493
494 if (!dev)
495 return -EINVAL;
496
497 pin = dev->pin; 365 pin = dev->pin;
498 if (!pin) { 366 if (!pin) {
499 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -501,31 +369,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
501 pci_name(dev))); 369 pci_name(dev)));
502 return 0; 370 return 0;
503 } 371 }
504 pin--;
505
506 if (!dev->bus) {
507 dev_err(&dev->dev, "invalid (NULL) 'bus' field\n");
508 return -ENODEV;
509 }
510
511 /*
512 * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT
513 * values override any BIOS-assigned IRQs set during boot.
514 */
515 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
516 &triggering, &polarity, &link,
517 acpi_pci_allocate_irq);
518 372
519 /* 373 entry = acpi_pci_irq_lookup(dev, pin);
520 * If no PRT entry was found, we'll try to derive an IRQ from the 374 if (!entry) {
521 * device's parent bridge.
522 */
523 if (irq < 0)
524 irq = acpi_pci_irq_derive(dev, pin, &triggering,
525 &polarity, &link,
526 acpi_pci_allocate_irq);
527
528 if (irq < 0) {
529 /* 375 /*
530 * IDE legacy mode controller IRQs are magic. Why do compat 376 * IDE legacy mode controller IRQs are magic. Why do compat
531 * extensions always make such a nasty mess. 377 * extensions always make such a nasty mess.
@@ -534,12 +380,24 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
534 (dev->class & 0x05) == 0) 380 (dev->class & 0x05) == 0)
535 return 0; 381 return 0;
536 } 382 }
383
384 if (entry) {
385 if (entry->link)
386 gsi = acpi_pci_link_allocate_irq(entry->link,
387 entry->index,
388 &triggering, &polarity,
389 &link);
390 else
391 gsi = entry->index;
392 } else
393 gsi = -1;
394
537 /* 395 /*
538 * No IRQ known to the ACPI subsystem - maybe the BIOS / 396 * No IRQ known to the ACPI subsystem - maybe the BIOS /
539 * driver reported one, then use it. Exit in any case. 397 * driver reported one, then use it. Exit in any case.
540 */ 398 */
541 if (irq < 0) { 399 if (gsi < 0) {
542 dev_warn(&dev->dev, "PCI INT %c: no GSI", 'A' + pin); 400 dev_warn(&dev->dev, "PCI INT %c: no GSI", pin_name(pin));
543 /* Interrupt Line values above 0xF are forbidden */ 401 /* Interrupt Line values above 0xF are forbidden */
544 if (dev->irq > 0 && (dev->irq <= 0xF)) { 402 if (dev->irq > 0 && (dev->irq <= 0xF)) {
545 printk(" - using IRQ %d\n", dev->irq); 403 printk(" - using IRQ %d\n", dev->irq);
@@ -552,10 +410,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
552 } 410 }
553 } 411 }
554 412
555 rc = acpi_register_gsi(irq, triggering, polarity); 413 rc = acpi_register_gsi(gsi, triggering, polarity);
556 if (rc < 0) { 414 if (rc < 0) {
557 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n", 415 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
558 'A' + pin); 416 pin_name(pin));
559 return rc; 417 return rc;
560 } 418 }
561 dev->irq = rc; 419 dev->irq = rc;
@@ -566,7 +424,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
566 link_desc[0] = '\0'; 424 link_desc[0] = '\0';
567 425
568 dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n", 426 dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
569 'A' + pin, link_desc, irq, 427 pin_name(pin), link_desc, gsi,
570 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 428 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
571 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 429 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
572 430
@@ -580,42 +438,28 @@ void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
580 438
581void acpi_pci_irq_disable(struct pci_dev *dev) 439void acpi_pci_irq_disable(struct pci_dev *dev)
582{ 440{
583 int gsi = 0; 441 struct acpi_prt_entry *entry;
584 u8 pin = 0; 442 int gsi;
585 int triggering = ACPI_LEVEL_SENSITIVE; 443 u8 pin;
586 int polarity = ACPI_ACTIVE_LOW;
587
588
589 if (!dev || !dev->bus)
590 return;
591 444
592 pin = dev->pin; 445 pin = dev->pin;
593 if (!pin) 446 if (!pin)
594 return; 447 return;
595 pin--;
596 448
597 /* 449 entry = acpi_pci_irq_lookup(dev, pin);
598 * First we check the PCI IRQ routing table (PRT) for an IRQ. 450 if (!entry)
599 */
600 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
601 &triggering, &polarity, NULL,
602 acpi_pci_free_irq);
603 /*
604 * If no PRT entry was found, we'll try to derive an IRQ from the
605 * device's parent bridge.
606 */
607 if (gsi < 0)
608 gsi = acpi_pci_irq_derive(dev, pin,
609 &triggering, &polarity, NULL,
610 acpi_pci_free_irq);
611 if (gsi < 0)
612 return; 451 return;
613 452
453 if (entry->link)
454 gsi = acpi_pci_link_free_irq(entry->link);
455 else
456 gsi = entry->index;
457
614 /* 458 /*
615 * TBD: It might be worth clearing dev->irq by magic constant 459 * TBD: It might be worth clearing dev->irq by magic constant
616 * (e.g. PCI_UNDEFINED_IRQ). 460 * (e.g. PCI_UNDEFINED_IRQ).
617 */ 461 */
618 462
619 dev_info(&dev->dev, "PCI INT %c disabled\n", 'A' + pin); 463 dev_info(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
620 acpi_unregister_gsi(gsi); 464 acpi_unregister_gsi(gsi);
621} 465}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index fcfdef7b4fdd..6c772ca76bd1 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -531,7 +531,7 @@ int __init acpi_irq_penalty_init(void)
531 return 0; 531 return 0;
532} 532}
533 533
534static int acpi_irq_balance; /* 0: static, 1: balance */ 534static int acpi_irq_balance = -1; /* 0: static, 1: balance */
535 535
536static int acpi_pci_link_allocate(struct acpi_pci_link *link) 536static int acpi_pci_link_allocate(struct acpi_pci_link *link)
537{ 537{
@@ -593,7 +593,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
593 return -ENODEV; 593 return -ENODEV;
594 } else { 594 } else {
595 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 595 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
596 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 596 printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
597 acpi_device_name(link->device), 597 acpi_device_name(link->device),
598 acpi_device_bid(link->device), link->irq.active); 598 acpi_device_bid(link->device), link->irq.active);
599 } 599 }
@@ -796,10 +796,6 @@ static int irqrouter_resume(struct sys_device *dev)
796 struct list_head *node = NULL; 796 struct list_head *node = NULL;
797 struct acpi_pci_link *link = NULL; 797 struct acpi_pci_link *link = NULL;
798 798
799
800 /* Make sure SCI is enabled again (Apple firmware bug?) */
801 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1);
802
803 list_for_each(node, &acpi_link.entries) { 799 list_for_each(node, &acpi_link.entries) {
804 link = list_entry(node, struct acpi_pci_link, node); 800 link = list_entry(node, struct acpi_pci_link, node);
805 if (!link) { 801 if (!link) {
@@ -912,7 +908,7 @@ static int __init acpi_irq_nobalance_set(char *str)
912 908
913__setup("acpi_irq_nobalance", acpi_irq_nobalance_set); 909__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
914 910
915int __init acpi_irq_balance_set(char *str) 911static int __init acpi_irq_balance_set(char *str)
916{ 912{
917 acpi_irq_balance = 1; 913 acpi_irq_balance = 1;
918 return 1; 914 return 1;
@@ -950,10 +946,17 @@ device_initcall(irqrouter_init_sysfs);
950 946
951static int __init acpi_pci_link_init(void) 947static int __init acpi_pci_link_init(void)
952{ 948{
953
954 if (acpi_noirq) 949 if (acpi_noirq)
955 return 0; 950 return 0;
956 951
952 if (acpi_irq_balance == -1) {
953 /* no command line switch: enable balancing in IOAPIC mode */
954 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
955 acpi_irq_balance = 1;
956 else
957 acpi_irq_balance = 0;
958 }
959
957 acpi_link.count = 0; 960 acpi_link.count = 0;
958 INIT_LIST_HEAD(&acpi_link.entries); 961 INIT_LIST_HEAD(&acpi_link.entries);
959 962
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1b8f67d21d53..5b38a026d122 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -31,6 +31,7 @@
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/pm.h> 32#include <linux/pm.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci-acpi.h>
34#include <linux/acpi.h> 35#include <linux/acpi.h>
35#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
@@ -193,6 +194,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
193 unsigned long long value = 0; 194 unsigned long long value = 0;
194 acpi_handle handle = NULL; 195 acpi_handle handle = NULL;
195 struct acpi_device *child; 196 struct acpi_device *child;
197 u32 flags, base_flags;
196 198
197 199
198 if (!device) 200 if (!device)
@@ -210,6 +212,13 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
210 212
211 device->ops.bind = acpi_pci_bind; 213 device->ops.bind = acpi_pci_bind;
212 214
215 /*
216 * All supported architectures that use ACPI have support for
217 * PCI domains, so we indicate this in _OSC support capabilities.
218 */
219 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
220 pci_acpi_osc_support(device->handle, flags);
221
213 /* 222 /*
214 * Segment 223 * Segment
215 * ------- 224 * -------
@@ -335,6 +344,17 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
335 list_for_each_entry(child, &device->children, node) 344 list_for_each_entry(child, &device->children, node)
336 acpi_pci_bridge_scan(child); 345 acpi_pci_bridge_scan(child);
337 346
347 /* Indicate support for various _OSC capabilities. */
348 if (pci_ext_cfg_avail(root->bus->self))
349 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
350 if (pcie_aspm_enabled())
351 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
352 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
353 if (pci_msi_enabled())
354 flags |= OSC_MSI_SUPPORT;
355 if (flags != base_flags)
356 pci_acpi_osc_support(device->handle, flags);
357
338 end: 358 end:
339 if (result) { 359 if (result) {
340 if (!list_empty(&root->node)) 360 if (!list_empty(&root->node))
@@ -376,15 +396,9 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
376 396
377static int __init acpi_pci_root_init(void) 397static int __init acpi_pci_root_init(void)
378{ 398{
379
380 if (acpi_pci_disabled) 399 if (acpi_pci_disabled)
381 return 0; 400 return 0;
382 401
383 /* DEBUG:
384 acpi_dbg_layer = ACPI_PCI_COMPONENT;
385 acpi_dbg_level = 0xFFFFFFFF;
386 */
387
388 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) 402 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
389 return -ENODEV; 403 return -ENODEV;
390 404
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index a1718e56103b..c926e7d4a0d6 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -44,9 +44,8 @@
44#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
46 46
47#define _COMPONENT ACPI_POWER_COMPONENT 47#define _COMPONENT ACPI_POWER_COMPONENT
48ACPI_MODULE_NAME("power"); 48ACPI_MODULE_NAME("power");
49#define ACPI_POWER_COMPONENT 0x00800000
50#define ACPI_POWER_CLASS "power_resource" 49#define ACPI_POWER_CLASS "power_resource"
51#define ACPI_POWER_DEVICE_NAME "Power Resource" 50#define ACPI_POWER_DEVICE_NAME "Power Resource"
52#define ACPI_POWER_FILE_INFO "info" 51#define ACPI_POWER_FILE_INFO "info"
@@ -140,6 +139,8 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
140{ 139{
141 acpi_status status = AE_OK; 140 acpi_status status = AE_OK;
142 unsigned long long sta = 0; 141 unsigned long long sta = 0;
142 char node_name[5];
143 struct acpi_buffer buffer = { sizeof(node_name), node_name };
143 144
144 145
145 if (!handle || !state) 146 if (!handle || !state)
@@ -152,8 +153,11 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
152 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: 153 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
153 ACPI_POWER_RESOURCE_STATE_OFF; 154 ACPI_POWER_RESOURCE_STATE_OFF;
154 155
156 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
157
155 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 158 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
156 acpi_ut_get_node_name(handle), state ? "on" : "off")); 159 node_name,
160 *state ? "on" : "off"));
157 161
158 return 0; 162 return 0;
159} 163}
@@ -516,11 +520,6 @@ int acpi_power_transition(struct acpi_device *device, int state)
516 cl = &device->power.states[device->power.state].resources; 520 cl = &device->power.states[device->power.state].resources;
517 tl = &device->power.states[state].resources; 521 tl = &device->power.states[state].resources;
518 522
519 if (!cl->count && !tl->count) {
520 result = -ENODEV;
521 goto end;
522 }
523
524 /* TBD: Resources must be ordered. */ 523 /* TBD: Resources must be ordered. */
525 524
526 /* 525 /*
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/proc.c
index 631ee2ee2ca0..428c911dba08 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/proc.c
@@ -28,8 +28,6 @@ static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
28{ 28{
29 int i; 29 int i;
30 30
31 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
32
33 for (i = 0; i <= ACPI_STATE_S5; i++) { 31 for (i = 0; i <= ACPI_STATE_S5; i++) {
34 if (sleep_states[i]) { 32 if (sleep_states[i]) {
35 seq_printf(seq, "S%d ", i); 33 seq_printf(seq, "S%d ", i);
@@ -86,49 +84,44 @@ acpi_system_write_sleep(struct file *file,
86 84
87#ifdef HAVE_ACPI_LEGACY_ALARM 85#ifdef HAVE_ACPI_LEGACY_ALARM
88 86
87static u32 cmos_bcd_read(int offset, int rtc_control);
88
89static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) 89static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
90{ 90{
91 u32 sec, min, hr; 91 u32 sec, min, hr;
92 u32 day, mo, yr, cent = 0; 92 u32 day, mo, yr, cent = 0;
93 u32 today = 0;
93 unsigned char rtc_control = 0; 94 unsigned char rtc_control = 0;
94 unsigned long flags; 95 unsigned long flags;
95 96
96 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
97
98 spin_lock_irqsave(&rtc_lock, flags); 97 spin_lock_irqsave(&rtc_lock, flags);
99 98
100 sec = CMOS_READ(RTC_SECONDS_ALARM);
101 min = CMOS_READ(RTC_MINUTES_ALARM);
102 hr = CMOS_READ(RTC_HOURS_ALARM);
103 rtc_control = CMOS_READ(RTC_CONTROL); 99 rtc_control = CMOS_READ(RTC_CONTROL);
100 sec = cmos_bcd_read(RTC_SECONDS_ALARM, rtc_control);
101 min = cmos_bcd_read(RTC_MINUTES_ALARM, rtc_control);
102 hr = cmos_bcd_read(RTC_HOURS_ALARM, rtc_control);
104 103
105 /* If we ever get an FACP with proper values... */ 104 /* If we ever get an FACP with proper values... */
106 if (acpi_gbl_FADT.day_alarm) 105 if (acpi_gbl_FADT.day_alarm) {
107 /* ACPI spec: only low 6 its should be cared */ 106 /* ACPI spec: only low 6 its should be cared */
108 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F; 107 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F;
109 else 108 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
110 day = CMOS_READ(RTC_DAY_OF_MONTH); 109 day = bcd2bin(day);
110 } else
111 day = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
111 if (acpi_gbl_FADT.month_alarm) 112 if (acpi_gbl_FADT.month_alarm)
112 mo = CMOS_READ(acpi_gbl_FADT.month_alarm); 113 mo = cmos_bcd_read(acpi_gbl_FADT.month_alarm, rtc_control);
113 else 114 else {
114 mo = CMOS_READ(RTC_MONTH); 115 mo = cmos_bcd_read(RTC_MONTH, rtc_control);
116 today = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
117 }
115 if (acpi_gbl_FADT.century) 118 if (acpi_gbl_FADT.century)
116 cent = CMOS_READ(acpi_gbl_FADT.century); 119 cent = cmos_bcd_read(acpi_gbl_FADT.century, rtc_control);
117 120
118 yr = CMOS_READ(RTC_YEAR); 121 yr = cmos_bcd_read(RTC_YEAR, rtc_control);
119 122
120 spin_unlock_irqrestore(&rtc_lock, flags); 123 spin_unlock_irqrestore(&rtc_lock, flags);
121 124
122 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
123 sec = bcd2bin(sec);
124 min = bcd2bin(min);
125 hr = bcd2bin(hr);
126 day = bcd2bin(day);
127 mo = bcd2bin(mo);
128 yr = bcd2bin(yr);
129 cent = bcd2bin(cent);
130 }
131
132 /* we're trusting the FADT (see above) */ 125 /* we're trusting the FADT (see above) */
133 if (!acpi_gbl_FADT.century) 126 if (!acpi_gbl_FADT.century)
134 /* If we're not trusting the FADT, we should at least make it 127 /* If we're not trusting the FADT, we should at least make it
@@ -153,6 +146,20 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
153 else 146 else
154 yr += cent * 100; 147 yr += cent * 100;
155 148
149 /*
150 * Show correct dates for alarms up to a month into the future.
151 * This solves issues for nearly all situations with the common
152 * 30-day alarm clocks in PC hardware.
153 */
154 if (day < today) {
155 if (mo < 12) {
156 mo += 1;
157 } else {
158 mo = 1;
159 yr += 1;
160 }
161 }
162
156 seq_printf(seq, "%4.4u-", yr); 163 seq_printf(seq, "%4.4u-", yr);
157 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 164 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
158 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 165 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
@@ -227,13 +234,11 @@ acpi_system_write_alarm(struct file *file,
227 int adjust = 0; 234 int adjust = 0;
228 unsigned char rtc_control = 0; 235 unsigned char rtc_control = 0;
229 236
230 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
231
232 if (count > sizeof(alarm_string) - 1) 237 if (count > sizeof(alarm_string) - 1)
233 return_VALUE(-EINVAL); 238 return -EINVAL;
234 239
235 if (copy_from_user(alarm_string, buffer, count)) 240 if (copy_from_user(alarm_string, buffer, count))
236 return_VALUE(-EFAULT); 241 return -EFAULT;
237 242
238 alarm_string[count] = '\0'; 243 alarm_string[count] = '\0';
239 244
@@ -334,7 +339,7 @@ acpi_system_write_alarm(struct file *file,
334 339
335 result = 0; 340 result = 0;
336 end: 341 end:
337 return_VALUE(result ? result : count); 342 return result ? result : count;
338} 343}
339#endif /* HAVE_ACPI_LEGACY_ALARM */ 344#endif /* HAVE_ACPI_LEGACY_ALARM */
340 345
@@ -367,7 +372,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
367 if (ldev) 372 if (ldev)
368 seq_printf(seq, "%s:%s", 373 seq_printf(seq, "%s:%s",
369 ldev->bus ? ldev->bus->name : "no-bus", 374 ldev->bus ? ldev->bus->name : "no-bus",
370 ldev->bus_id); 375 dev_name(ldev));
371 seq_printf(seq, "\n"); 376 seq_printf(seq, "\n");
372 put_device(ldev); 377 put_device(ldev);
373 378
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 24a362f8034c..0cc2fd31e376 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -59,7 +59,6 @@
59#include <acpi/acpi_drivers.h> 59#include <acpi/acpi_drivers.h>
60#include <acpi/processor.h> 60#include <acpi/processor.h>
61 61
62#define ACPI_PROCESSOR_COMPONENT 0x01000000
63#define ACPI_PROCESSOR_CLASS "processor" 62#define ACPI_PROCESSOR_CLASS "processor"
64#define ACPI_PROCESSOR_DEVICE_NAME "Processor" 63#define ACPI_PROCESSOR_DEVICE_NAME "Processor"
65#define ACPI_PROCESSOR_FILE_INFO "info" 64#define ACPI_PROCESSOR_FILE_INFO "info"
@@ -89,6 +88,7 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr);
89 88
90 89
91static const struct acpi_device_id processor_device_ids[] = { 90static const struct acpi_device_id processor_device_ids[] = {
91 {ACPI_PROCESSOR_OBJECT_HID, 0},
92 {ACPI_PROCESSOR_HID, 0}, 92 {ACPI_PROCESSOR_HID, 0},
93 {"", 0}, 93 {"", 0},
94}; 94};
@@ -409,7 +409,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device)
409/* Use the acpiid in MADT to map cpus in case of SMP */ 409/* Use the acpiid in MADT to map cpus in case of SMP */
410 410
411#ifndef CONFIG_SMP 411#ifndef CONFIG_SMP
412static int get_cpu_id(acpi_handle handle, u32 acpi_id) {return -1;} 412static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; }
413#else 413#else
414 414
415static struct acpi_table_madt *madt; 415static struct acpi_table_madt *madt;
@@ -428,27 +428,35 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
428} 428}
429 429
430static int map_lsapic_id(struct acpi_subtable_header *entry, 430static int map_lsapic_id(struct acpi_subtable_header *entry,
431 u32 acpi_id, int *apic_id) 431 int device_declaration, u32 acpi_id, int *apic_id)
432{ 432{
433 struct acpi_madt_local_sapic *lsapic = 433 struct acpi_madt_local_sapic *lsapic =
434 (struct acpi_madt_local_sapic *)entry; 434 (struct acpi_madt_local_sapic *)entry;
435 u32 tmp = (lsapic->id << 8) | lsapic->eid;
436
435 /* Only check enabled APICs*/ 437 /* Only check enabled APICs*/
436 if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { 438 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
437 /* First check against id */ 439 return 0;
438 if (lsapic->processor_id == acpi_id) { 440
439 *apic_id = (lsapic->id << 8) | lsapic->eid; 441 /* Device statement declaration type */
440 return 1; 442 if (device_declaration) {
441 /* Check against optional uid */ 443 if (entry->length < 16)
442 } else if (entry->length >= 16 && 444 printk(KERN_ERR PREFIX
443 lsapic->uid == acpi_id) { 445 "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n",
444 *apic_id = lsapic->uid; 446 tmp);
445 return 1; 447 else if (lsapic->uid == acpi_id)
446 } 448 goto found;
447 } 449 /* Processor statement declaration type */
450 } else if (lsapic->processor_id == acpi_id)
451 goto found;
452
448 return 0; 453 return 0;
454found:
455 *apic_id = tmp;
456 return 1;
449} 457}
450 458
451static int map_madt_entry(u32 acpi_id) 459static int map_madt_entry(int type, u32 acpi_id)
452{ 460{
453 unsigned long madt_end, entry; 461 unsigned long madt_end, entry;
454 int apic_id = -1; 462 int apic_id = -1;
@@ -469,7 +477,7 @@ static int map_madt_entry(u32 acpi_id)
469 if (map_lapic_id(header, acpi_id, &apic_id)) 477 if (map_lapic_id(header, acpi_id, &apic_id))
470 break; 478 break;
471 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 479 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
472 if (map_lsapic_id(header, acpi_id, &apic_id)) 480 if (map_lsapic_id(header, type, acpi_id, &apic_id))
473 break; 481 break;
474 } 482 }
475 entry += header->length; 483 entry += header->length;
@@ -477,7 +485,7 @@ static int map_madt_entry(u32 acpi_id)
477 return apic_id; 485 return apic_id;
478} 486}
479 487
480static int map_mat_entry(acpi_handle handle, u32 acpi_id) 488static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
481{ 489{
482 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 490 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
483 union acpi_object *obj; 491 union acpi_object *obj;
@@ -500,7 +508,7 @@ static int map_mat_entry(acpi_handle handle, u32 acpi_id)
500 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { 508 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
501 map_lapic_id(header, acpi_id, &apic_id); 509 map_lapic_id(header, acpi_id, &apic_id);
502 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 510 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
503 map_lsapic_id(header, acpi_id, &apic_id); 511 map_lsapic_id(header, type, acpi_id, &apic_id);
504 } 512 }
505 513
506exit: 514exit:
@@ -509,14 +517,14 @@ exit:
509 return apic_id; 517 return apic_id;
510} 518}
511 519
512static int get_cpu_id(acpi_handle handle, u32 acpi_id) 520static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id)
513{ 521{
514 int i; 522 int i;
515 int apic_id = -1; 523 int apic_id = -1;
516 524
517 apic_id = map_mat_entry(handle, acpi_id); 525 apic_id = map_mat_entry(handle, type, acpi_id);
518 if (apic_id == -1) 526 if (apic_id == -1)
519 apic_id = map_madt_entry(acpi_id); 527 apic_id = map_madt_entry(type, acpi_id);
520 if (apic_id == -1) 528 if (apic_id == -1)
521 return apic_id; 529 return apic_id;
522 530
@@ -532,15 +540,16 @@ static int get_cpu_id(acpi_handle handle, u32 acpi_id)
532 Driver Interface 540 Driver Interface
533 -------------------------------------------------------------------------- */ 541 -------------------------------------------------------------------------- */
534 542
535static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) 543static int acpi_processor_get_info(struct acpi_device *device)
536{ 544{
537 acpi_status status = 0; 545 acpi_status status = 0;
538 union acpi_object object = { 0 }; 546 union acpi_object object = { 0 };
539 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 547 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
540 int cpu_index; 548 struct acpi_processor *pr;
549 int cpu_index, device_declaration = 0;
541 static int cpu0_initialized; 550 static int cpu0_initialized;
542 551
543 552 pr = acpi_driver_data(device);
544 if (!pr) 553 if (!pr)
545 return -EINVAL; 554 return -EINVAL;
546 555
@@ -561,22 +570,23 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid)
561 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 570 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
562 "No bus mastering arbitration control\n")); 571 "No bus mastering arbitration control\n"));
563 572
564 /* Check if it is a Device with HID and UID */ 573 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_HID)) {
565 if (has_uid) { 574 /*
575 * Declared with "Device" statement; match _UID.
576 * Note that we don't handle string _UIDs yet.
577 */
566 unsigned long long value; 578 unsigned long long value;
567 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, 579 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
568 NULL, &value); 580 NULL, &value);
569 if (ACPI_FAILURE(status)) { 581 if (ACPI_FAILURE(status)) {
570 printk(KERN_ERR PREFIX "Evaluating processor _UID\n"); 582 printk(KERN_ERR PREFIX
583 "Evaluating processor _UID [%#x]\n", status);
571 return -ENODEV; 584 return -ENODEV;
572 } 585 }
586 device_declaration = 1;
573 pr->acpi_id = value; 587 pr->acpi_id = value;
574 } else { 588 } else {
575 /* 589 /* Declared with "Processor" statement; match ProcessorID */
576 * Evalute the processor object. Note that it is common on SMP to
577 * have the first (boot) processor with a valid PBLK address while
578 * all others have a NULL address.
579 */
580 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 590 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
581 if (ACPI_FAILURE(status)) { 591 if (ACPI_FAILURE(status)) {
582 printk(KERN_ERR PREFIX "Evaluating processor object\n"); 592 printk(KERN_ERR PREFIX "Evaluating processor object\n");
@@ -584,12 +594,13 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid)
584 } 594 }
585 595
586 /* 596 /*
587 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. 597 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
588 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c 598 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
589 */ 599 * arch/xxx/acpi.c
600 */
590 pr->acpi_id = object.processor.proc_id; 601 pr->acpi_id = object.processor.proc_id;
591 } 602 }
592 cpu_index = get_cpu_id(pr->handle, pr->acpi_id); 603 cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id);
593 604
594 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 605 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
595 if (!cpu0_initialized && (cpu_index == -1) && 606 if (!cpu0_initialized && (cpu_index == -1) &&
@@ -661,7 +672,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
661 672
662 pr = acpi_driver_data(device); 673 pr = acpi_driver_data(device);
663 674
664 result = acpi_processor_get_info(pr, device->flags.unique_id); 675 result = acpi_processor_get_info(device);
665 if (result) { 676 if (result) {
666 /* Processor is physically not present */ 677 /* Processor is physically not present */
667 return 0; 678 return 0;
@@ -761,20 +772,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
761 acpi_bus_generate_proc_event(device, event, 772 acpi_bus_generate_proc_event(device, event,
762 pr->performance_platform_limit); 773 pr->performance_platform_limit);
763 acpi_bus_generate_netlink_event(device->pnp.device_class, 774 acpi_bus_generate_netlink_event(device->pnp.device_class,
764 device->dev.bus_id, event, 775 dev_name(&device->dev), event,
765 pr->performance_platform_limit); 776 pr->performance_platform_limit);
766 break; 777 break;
767 case ACPI_PROCESSOR_NOTIFY_POWER: 778 case ACPI_PROCESSOR_NOTIFY_POWER:
768 acpi_processor_cst_has_changed(pr); 779 acpi_processor_cst_has_changed(pr);
769 acpi_bus_generate_proc_event(device, event, 0); 780 acpi_bus_generate_proc_event(device, event, 0);
770 acpi_bus_generate_netlink_event(device->pnp.device_class, 781 acpi_bus_generate_netlink_event(device->pnp.device_class,
771 device->dev.bus_id, event, 0); 782 dev_name(&device->dev), event, 0);
772 break; 783 break;
773 case ACPI_PROCESSOR_NOTIFY_THROTTLING: 784 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
774 acpi_processor_tstate_has_changed(pr); 785 acpi_processor_tstate_has_changed(pr);
775 acpi_bus_generate_proc_event(device, event, 0); 786 acpi_bus_generate_proc_event(device, event, 0);
776 acpi_bus_generate_netlink_event(device->pnp.device_class, 787 acpi_bus_generate_netlink_event(device->pnp.device_class,
777 device->dev.bus_id, event, 0); 788 dev_name(&device->dev), event, 0);
778 default: 789 default:
779 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 790 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
780 "Unsupported event [0x%x]\n", event)); 791 "Unsupported event [0x%x]\n", event));
@@ -815,6 +826,11 @@ static int acpi_processor_add(struct acpi_device *device)
815 if (!pr) 826 if (!pr)
816 return -ENOMEM; 827 return -ENOMEM;
817 828
829 if (!alloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
830 kfree(pr);
831 return -ENOMEM;
832 }
833
818 pr->handle = device->handle; 834 pr->handle = device->handle;
819 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); 835 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
820 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); 836 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
@@ -834,10 +850,8 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
834 850
835 pr = acpi_driver_data(device); 851 pr = acpi_driver_data(device);
836 852
837 if (pr->id >= nr_cpu_ids) { 853 if (pr->id >= nr_cpu_ids)
838 kfree(pr); 854 goto free;
839 return 0;
840 }
841 855
842 if (type == ACPI_BUS_REMOVAL_EJECT) { 856 if (type == ACPI_BUS_REMOVAL_EJECT) {
843 if (acpi_processor_handle_eject(pr)) 857 if (acpi_processor_handle_eject(pr))
@@ -862,6 +876,9 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
862 876
863 per_cpu(processors, pr->id) = NULL; 877 per_cpu(processors, pr->id) = NULL;
864 per_cpu(processor_device_array, pr->id) = NULL; 878 per_cpu(processor_device_array, pr->id) = NULL;
879
880free:
881 free_cpumask_var(pr->throttling.shared_cpu_map);
865 kfree(pr); 882 kfree(pr);
866 883
867 return 0; 884 return 0;
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 81b40ed5379e..7bc22a471fe3 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -41,6 +41,7 @@
41#include <linux/pm_qos_params.h> 41#include <linux/pm_qos_params.h>
42#include <linux/clockchips.h> 42#include <linux/clockchips.h>
43#include <linux/cpuidle.h> 43#include <linux/cpuidle.h>
44#include <linux/irqflags.h>
44 45
45/* 46/*
46 * Include the apic definitions for x86 to have the APIC timer related defines 47 * Include the apic definitions for x86 to have the APIC timer related defines
@@ -59,50 +60,23 @@
59#include <acpi/processor.h> 60#include <acpi/processor.h>
60#include <asm/processor.h> 61#include <asm/processor.h>
61 62
62#define ACPI_PROCESSOR_COMPONENT 0x01000000
63#define ACPI_PROCESSOR_CLASS "processor" 63#define ACPI_PROCESSOR_CLASS "processor"
64#define _COMPONENT ACPI_PROCESSOR_COMPONENT 64#define _COMPONENT ACPI_PROCESSOR_COMPONENT
65ACPI_MODULE_NAME("processor_idle"); 65ACPI_MODULE_NAME("processor_idle");
66#define ACPI_PROCESSOR_FILE_POWER "power" 66#define ACPI_PROCESSOR_FILE_POWER "power"
67#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) 67#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
68#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) 68#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY)
69#ifndef CONFIG_CPU_IDLE
70#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */
71#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */
72static void (*pm_idle_save) (void) __read_mostly;
73#else
74#define C2_OVERHEAD 1 /* 1us */ 69#define C2_OVERHEAD 1 /* 1us */
75#define C3_OVERHEAD 1 /* 1us */ 70#define C3_OVERHEAD 1 /* 1us */
76#endif
77#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) 71#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
78 72
79static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; 73static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
80#ifdef CONFIG_CPU_IDLE
81module_param(max_cstate, uint, 0000); 74module_param(max_cstate, uint, 0000);
82#else
83module_param(max_cstate, uint, 0644);
84#endif
85static unsigned int nocst __read_mostly; 75static unsigned int nocst __read_mostly;
86module_param(nocst, uint, 0000); 76module_param(nocst, uint, 0000);
87 77
88#ifndef CONFIG_CPU_IDLE
89/*
90 * bm_history -- bit-mask with a bit per jiffy of bus-master activity
91 * 1000 HZ: 0xFFFFFFFF: 32 jiffies = 32ms
92 * 800 HZ: 0xFFFFFFFF: 32 jiffies = 40ms
93 * 100 HZ: 0x0000000F: 4 jiffies = 40ms
94 * reduce history for more aggressive entry into C3
95 */
96static unsigned int bm_history __read_mostly =
97 (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1));
98module_param(bm_history, uint, 0644);
99
100static int acpi_processor_set_power_policy(struct acpi_processor *pr);
101
102#else /* CONFIG_CPU_IDLE */
103static unsigned int latency_factor __read_mostly = 2; 78static unsigned int latency_factor __read_mostly = 2;
104module_param(latency_factor, uint, 0644); 79module_param(latency_factor, uint, 0644);
105#endif
106 80
107/* 81/*
108 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. 82 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3.
@@ -224,71 +198,6 @@ static void acpi_safe_halt(void)
224 current_thread_info()->status |= TS_POLLING; 198 current_thread_info()->status |= TS_POLLING;
225} 199}
226 200
227#ifndef CONFIG_CPU_IDLE
228
229static void
230acpi_processor_power_activate(struct acpi_processor *pr,
231 struct acpi_processor_cx *new)
232{
233 struct acpi_processor_cx *old;
234
235 if (!pr || !new)
236 return;
237
238 old = pr->power.state;
239
240 if (old)
241 old->promotion.count = 0;
242 new->demotion.count = 0;
243
244 /* Cleanup from old state. */
245 if (old) {
246 switch (old->type) {
247 case ACPI_STATE_C3:
248 /* Disable bus master reload */
249 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
250 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
251 break;
252 }
253 }
254
255 /* Prepare to use new state. */
256 switch (new->type) {
257 case ACPI_STATE_C3:
258 /* Enable bus master reload */
259 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
260 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
261 break;
262 }
263
264 pr->power.state = new;
265
266 return;
267}
268
269static atomic_t c3_cpu_count;
270
271/* Common C-state entry for C2, C3, .. */
272static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
273{
274 /* Don't trace irqs off for idle */
275 stop_critical_timings();
276 if (cstate->entry_method == ACPI_CSTATE_FFH) {
277 /* Call into architectural FFH based C-state */
278 acpi_processor_ffh_cstate_enter(cstate);
279 } else {
280 int unused;
281 /* IO port based C-state */
282 inb(cstate->address);
283 /* Dummy wait op - must do something useless after P_LVL2 read
284 because chipsets cannot guarantee that STPCLK# signal
285 gets asserted in time to freeze execution properly. */
286 unused = inl(acpi_gbl_FADT.xpm_timer_block.address);
287 }
288 start_critical_timings();
289}
290#endif /* !CONFIG_CPU_IDLE */
291
292#ifdef ARCH_APICTIMER_STOPS_ON_C3 201#ifdef ARCH_APICTIMER_STOPS_ON_C3
293 202
294/* 203/*
@@ -375,436 +284,21 @@ static int tsc_halts_in_c(int state)
375{ 284{
376 switch (boot_cpu_data.x86_vendor) { 285 switch (boot_cpu_data.x86_vendor) {
377 case X86_VENDOR_AMD: 286 case X86_VENDOR_AMD:
287 case X86_VENDOR_INTEL:
378 /* 288 /*
379 * AMD Fam10h TSC will tick in all 289 * AMD Fam10h TSC will tick in all
380 * C/P/S0/S1 states when this bit is set. 290 * C/P/S0/S1 states when this bit is set.
381 */ 291 */
382 if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 292 if (boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
383 return 0; 293 return 0;
294
384 /*FALL THROUGH*/ 295 /*FALL THROUGH*/
385 case X86_VENDOR_INTEL:
386 /* Several cases known where TSC halts in C2 too */
387 default: 296 default:
388 return state > ACPI_STATE_C1; 297 return state > ACPI_STATE_C1;
389 } 298 }
390} 299}
391#endif 300#endif
392 301
393#ifndef CONFIG_CPU_IDLE
394static void acpi_processor_idle(void)
395{
396 struct acpi_processor *pr = NULL;
397 struct acpi_processor_cx *cx = NULL;
398 struct acpi_processor_cx *next_state = NULL;
399 int sleep_ticks = 0;
400 u32 t1, t2 = 0;
401
402 /*
403 * Interrupts must be disabled during bus mastering calculations and
404 * for C2/C3 transitions.
405 */
406 local_irq_disable();
407
408 pr = __get_cpu_var(processors);
409 if (!pr) {
410 local_irq_enable();
411 return;
412 }
413
414 /*
415 * Check whether we truly need to go idle, or should
416 * reschedule:
417 */
418 if (unlikely(need_resched())) {
419 local_irq_enable();
420 return;
421 }
422
423 cx = pr->power.state;
424 if (!cx || acpi_idle_suspend) {
425 if (pm_idle_save) {
426 pm_idle_save(); /* enables IRQs */
427 } else {
428 acpi_safe_halt();
429 local_irq_enable();
430 }
431
432 return;
433 }
434
435 /*
436 * Check BM Activity
437 * -----------------
438 * Check for bus mastering activity (if required), record, and check
439 * for demotion.
440 */
441 if (pr->flags.bm_check) {
442 u32 bm_status = 0;
443 unsigned long diff = jiffies - pr->power.bm_check_timestamp;
444
445 if (diff > 31)
446 diff = 31;
447
448 pr->power.bm_activity <<= diff;
449
450 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status);
451 if (bm_status) {
452 pr->power.bm_activity |= 0x1;
453 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1);
454 }
455 /*
456 * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect
457 * the true state of bus mastering activity; forcing us to
458 * manually check the BMIDEA bit of each IDE channel.
459 */
460 else if (errata.piix4.bmisx) {
461 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
462 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
463 pr->power.bm_activity |= 0x1;
464 }
465
466 pr->power.bm_check_timestamp = jiffies;
467
468 /*
469 * If bus mastering is or was active this jiffy, demote
470 * to avoid a faulty transition. Note that the processor
471 * won't enter a low-power state during this call (to this
472 * function) but should upon the next.
473 *
474 * TBD: A better policy might be to fallback to the demotion
475 * state (use it for this quantum only) istead of
476 * demoting -- and rely on duration as our sole demotion
477 * qualification. This may, however, introduce DMA
478 * issues (e.g. floppy DMA transfer overrun/underrun).
479 */
480 if ((pr->power.bm_activity & 0x1) &&
481 cx->demotion.threshold.bm) {
482 local_irq_enable();
483 next_state = cx->demotion.state;
484 goto end;
485 }
486 }
487
488#ifdef CONFIG_HOTPLUG_CPU
489 /*
490 * Check for P_LVL2_UP flag before entering C2 and above on
491 * an SMP system. We do it here instead of doing it at _CST/P_LVL
492 * detection phase, to work cleanly with logical CPU hotplug.
493 */
494 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
495 !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
496 cx = &pr->power.states[ACPI_STATE_C1];
497#endif
498
499 /*
500 * Sleep:
501 * ------
502 * Invoke the current Cx state to put the processor to sleep.
503 */
504 if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
505 current_thread_info()->status &= ~TS_POLLING;
506 /*
507 * TS_POLLING-cleared state must be visible before we
508 * test NEED_RESCHED:
509 */
510 smp_mb();
511 if (need_resched()) {
512 current_thread_info()->status |= TS_POLLING;
513 local_irq_enable();
514 return;
515 }
516 }
517
518 switch (cx->type) {
519
520 case ACPI_STATE_C1:
521 /*
522 * Invoke C1.
523 * Use the appropriate idle routine, the one that would
524 * be used without acpi C-states.
525 */
526 if (pm_idle_save) {
527 pm_idle_save(); /* enables IRQs */
528 } else {
529 acpi_safe_halt();
530 local_irq_enable();
531 }
532
533 /*
534 * TBD: Can't get time duration while in C1, as resumes
535 * go to an ISR rather than here. Need to instrument
536 * base interrupt handler.
537 *
538 * Note: the TSC better not stop in C1, sched_clock() will
539 * skew otherwise.
540 */
541 sleep_ticks = 0xFFFFFFFF;
542
543 break;
544
545 case ACPI_STATE_C2:
546 /* Get start time (ticks) */
547 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
548 /* Tell the scheduler that we are going deep-idle: */
549 sched_clock_idle_sleep_event();
550 /* Invoke C2 */
551 acpi_state_timer_broadcast(pr, cx, 1);
552 acpi_cstate_enter(cx);
553 /* Get end time (ticks) */
554 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
555
556#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
557 /* TSC halts in C2, so notify users */
558 if (tsc_halts_in_c(ACPI_STATE_C2))
559 mark_tsc_unstable("possible TSC halt in C2");
560#endif
561 /* Compute time (ticks) that we were actually asleep */
562 sleep_ticks = ticks_elapsed(t1, t2);
563
564 /* Tell the scheduler how much we idled: */
565 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
566
567 /* Re-enable interrupts */
568 local_irq_enable();
569 /* Do not account our idle-switching overhead: */
570 sleep_ticks -= cx->latency_ticks + C2_OVERHEAD;
571
572 current_thread_info()->status |= TS_POLLING;
573 acpi_state_timer_broadcast(pr, cx, 0);
574 break;
575
576 case ACPI_STATE_C3:
577 acpi_unlazy_tlb(smp_processor_id());
578 /*
579 * Must be done before busmaster disable as we might
580 * need to access HPET !
581 */
582 acpi_state_timer_broadcast(pr, cx, 1);
583 /*
584 * disable bus master
585 * bm_check implies we need ARB_DIS
586 * !bm_check implies we need cache flush
587 * bm_control implies whether we can do ARB_DIS
588 *
589 * That leaves a case where bm_check is set and bm_control is
590 * not set. In that case we cannot do much, we enter C3
591 * without doing anything.
592 */
593 if (pr->flags.bm_check && pr->flags.bm_control) {
594 if (atomic_inc_return(&c3_cpu_count) ==
595 num_online_cpus()) {
596 /*
597 * All CPUs are trying to go to C3
598 * Disable bus master arbitration
599 */
600 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
601 }
602 } else if (!pr->flags.bm_check) {
603 /* SMP with no shared cache... Invalidate cache */
604 ACPI_FLUSH_CPU_CACHE();
605 }
606
607 /* Get start time (ticks) */
608 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
609 /* Invoke C3 */
610 /* Tell the scheduler that we are going deep-idle: */
611 sched_clock_idle_sleep_event();
612 acpi_cstate_enter(cx);
613 /* Get end time (ticks) */
614 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
615 if (pr->flags.bm_check && pr->flags.bm_control) {
616 /* Enable bus master arbitration */
617 atomic_dec(&c3_cpu_count);
618 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
619 }
620
621#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
622 /* TSC halts in C3, so notify users */
623 if (tsc_halts_in_c(ACPI_STATE_C3))
624 mark_tsc_unstable("TSC halts in C3");
625#endif
626 /* Compute time (ticks) that we were actually asleep */
627 sleep_ticks = ticks_elapsed(t1, t2);
628 /* Tell the scheduler how much we idled: */
629 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
630
631 /* Re-enable interrupts */
632 local_irq_enable();
633 /* Do not account our idle-switching overhead: */
634 sleep_ticks -= cx->latency_ticks + C3_OVERHEAD;
635
636 current_thread_info()->status |= TS_POLLING;
637 acpi_state_timer_broadcast(pr, cx, 0);
638 break;
639
640 default:
641 local_irq_enable();
642 return;
643 }
644 cx->usage++;
645 if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0))
646 cx->time += sleep_ticks;
647
648 next_state = pr->power.state;
649
650#ifdef CONFIG_HOTPLUG_CPU
651 /* Don't do promotion/demotion */
652 if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) &&
653 !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) {
654 next_state = cx;
655 goto end;
656 }
657#endif
658
659 /*
660 * Promotion?
661 * ----------
662 * Track the number of longs (time asleep is greater than threshold)
663 * and promote when the count threshold is reached. Note that bus
664 * mastering activity may prevent promotions.
665 * Do not promote above max_cstate.
666 */
667 if (cx->promotion.state &&
668 ((cx->promotion.state - pr->power.states) <= max_cstate)) {
669 if (sleep_ticks > cx->promotion.threshold.ticks &&
670 cx->promotion.state->latency <=
671 pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) {
672 cx->promotion.count++;
673 cx->demotion.count = 0;
674 if (cx->promotion.count >=
675 cx->promotion.threshold.count) {
676 if (pr->flags.bm_check) {
677 if (!
678 (pr->power.bm_activity & cx->
679 promotion.threshold.bm)) {
680 next_state =
681 cx->promotion.state;
682 goto end;
683 }
684 } else {
685 next_state = cx->promotion.state;
686 goto end;
687 }
688 }
689 }
690 }
691
692 /*
693 * Demotion?
694 * ---------
695 * Track the number of shorts (time asleep is less than time threshold)
696 * and demote when the usage threshold is reached.
697 */
698 if (cx->demotion.state) {
699 if (sleep_ticks < cx->demotion.threshold.ticks) {
700 cx->demotion.count++;
701 cx->promotion.count = 0;
702 if (cx->demotion.count >= cx->demotion.threshold.count) {
703 next_state = cx->demotion.state;
704 goto end;
705 }
706 }
707 }
708
709 end:
710 /*
711 * Demote if current state exceeds max_cstate
712 * or if the latency of the current state is unacceptable
713 */
714 if ((pr->power.state - pr->power.states) > max_cstate ||
715 pr->power.state->latency >
716 pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) {
717 if (cx->demotion.state)
718 next_state = cx->demotion.state;
719 }
720
721 /*
722 * New Cx State?
723 * -------------
724 * If we're going to start using a new Cx state we must clean up
725 * from the previous and prepare to use the new.
726 */
727 if (next_state != pr->power.state)
728 acpi_processor_power_activate(pr, next_state);
729}
730
731static int acpi_processor_set_power_policy(struct acpi_processor *pr)
732{
733 unsigned int i;
734 unsigned int state_is_set = 0;
735 struct acpi_processor_cx *lower = NULL;
736 struct acpi_processor_cx *higher = NULL;
737 struct acpi_processor_cx *cx;
738
739
740 if (!pr)
741 return -EINVAL;
742
743 /*
744 * This function sets the default Cx state policy (OS idle handler).
745 * Our scheme is to promote quickly to C2 but more conservatively
746 * to C3. We're favoring C2 for its characteristics of low latency
747 * (quick response), good power savings, and ability to allow bus
748 * mastering activity. Note that the Cx state policy is completely
749 * customizable and can be altered dynamically.
750 */
751
752 /* startup state */
753 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
754 cx = &pr->power.states[i];
755 if (!cx->valid)
756 continue;
757
758 if (!state_is_set)
759 pr->power.state = cx;
760 state_is_set++;
761 break;
762 }
763
764 if (!state_is_set)
765 return -ENODEV;
766
767 /* demotion */
768 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
769 cx = &pr->power.states[i];
770 if (!cx->valid)
771 continue;
772
773 if (lower) {
774 cx->demotion.state = lower;
775 cx->demotion.threshold.ticks = cx->latency_ticks;
776 cx->demotion.threshold.count = 1;
777 if (cx->type == ACPI_STATE_C3)
778 cx->demotion.threshold.bm = bm_history;
779 }
780
781 lower = cx;
782 }
783
784 /* promotion */
785 for (i = (ACPI_PROCESSOR_MAX_POWER - 1); i > 0; i--) {
786 cx = &pr->power.states[i];
787 if (!cx->valid)
788 continue;
789
790 if (higher) {
791 cx->promotion.state = higher;
792 cx->promotion.threshold.ticks = cx->latency_ticks;
793 if (cx->type >= ACPI_STATE_C2)
794 cx->promotion.threshold.count = 4;
795 else
796 cx->promotion.threshold.count = 10;
797 if (higher->type == ACPI_STATE_C3)
798 cx->promotion.threshold.bm = bm_history;
799 }
800
801 higher = cx;
802 }
803
804 return 0;
805}
806#endif /* !CONFIG_CPU_IDLE */
807
808static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 302static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
809{ 303{
810 304
@@ -1047,11 +541,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
1047 */ 541 */
1048 cx->valid = 1; 542 cx->valid = 1;
1049 543
1050#ifndef CONFIG_CPU_IDLE
1051 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
1052#else
1053 cx->latency_ticks = cx->latency; 544 cx->latency_ticks = cx->latency;
1054#endif
1055 545
1056 return; 546 return;
1057} 547}
@@ -1121,7 +611,6 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
1121 " for C3 to be enabled on SMP systems\n")); 611 " for C3 to be enabled on SMP systems\n"));
1122 return; 612 return;
1123 } 613 }
1124 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
1125 } 614 }
1126 615
1127 /* 616 /*
@@ -1132,11 +621,16 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
1132 */ 621 */
1133 cx->valid = 1; 622 cx->valid = 1;
1134 623
1135#ifndef CONFIG_CPU_IDLE
1136 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
1137#else
1138 cx->latency_ticks = cx->latency; 624 cx->latency_ticks = cx->latency;
1139#endif 625 /*
626 * On older chipsets, BM_RLD needs to be set
627 * in order for Bus Master activity to wake the
628 * system from C3. Newer chipsets handle DMA
629 * during C3 automatically and BM_RLD is a NOP.
630 * In either case, the proper way to
631 * handle BM_RLD is to set it and leave it set.
632 */
633 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
1140 634
1141 return; 635 return;
1142} 636}
@@ -1201,20 +695,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
1201 695
1202 pr->power.count = acpi_processor_power_verify(pr); 696 pr->power.count = acpi_processor_power_verify(pr);
1203 697
1204#ifndef CONFIG_CPU_IDLE
1205 /*
1206 * Set Default Policy
1207 * ------------------
1208 * Now that we know which states are supported, set the default
1209 * policy. Note that this policy can be changed dynamically
1210 * (e.g. encourage deeper sleeps to conserve battery life when
1211 * not on AC).
1212 */
1213 result = acpi_processor_set_power_policy(pr);
1214 if (result)
1215 return result;
1216#endif
1217
1218 /* 698 /*
1219 * if one state of type C2 or C3 is available, mark this 699 * if one state of type C2 or C3 is available, mark this
1220 * CPU as being "idle manageable" 700 * CPU as being "idle manageable"
@@ -1312,69 +792,6 @@ static const struct file_operations acpi_processor_power_fops = {
1312 .release = single_release, 792 .release = single_release,
1313}; 793};
1314 794
1315#ifndef CONFIG_CPU_IDLE
1316
1317int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1318{
1319 int result = 0;
1320
1321 if (boot_option_idle_override)
1322 return 0;
1323
1324 if (!pr)
1325 return -EINVAL;
1326
1327 if (nocst) {
1328 return -ENODEV;
1329 }
1330
1331 if (!pr->flags.power_setup_done)
1332 return -ENODEV;
1333
1334 /*
1335 * Fall back to the default idle loop, when pm_idle_save had
1336 * been initialized.
1337 */
1338 if (pm_idle_save) {
1339 pm_idle = pm_idle_save;
1340 /* Relies on interrupts forcing exit from idle. */
1341 synchronize_sched();
1342 }
1343
1344 pr->flags.power = 0;
1345 result = acpi_processor_get_power_info(pr);
1346 if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
1347 pm_idle = acpi_processor_idle;
1348
1349 return result;
1350}
1351
1352#ifdef CONFIG_SMP
1353static void smp_callback(void *v)
1354{
1355 /* we already woke the CPU up, nothing more to do */
1356}
1357
1358/*
1359 * This function gets called when a part of the kernel has a new latency
1360 * requirement. This means we need to get all processors out of their C-state,
1361 * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that
1362 * wakes them all right up.
1363 */
1364static int acpi_processor_latency_notify(struct notifier_block *b,
1365 unsigned long l, void *v)
1366{
1367 smp_call_function(smp_callback, NULL, 1);
1368 return NOTIFY_OK;
1369}
1370
1371static struct notifier_block acpi_processor_latency_notifier = {
1372 .notifier_call = acpi_processor_latency_notify,
1373};
1374
1375#endif
1376
1377#else /* CONFIG_CPU_IDLE */
1378 795
1379/** 796/**
1380 * acpi_idle_bm_check - checks if bus master activity was detected 797 * acpi_idle_bm_check - checks if bus master activity was detected
@@ -1383,7 +800,7 @@ static int acpi_idle_bm_check(void)
1383{ 800{
1384 u32 bm_status = 0; 801 u32 bm_status = 0;
1385 802
1386 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); 803 acpi_get_register_unlocked(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status);
1387 if (bm_status) 804 if (bm_status)
1388 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); 805 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1);
1389 /* 806 /*
@@ -1400,25 +817,6 @@ static int acpi_idle_bm_check(void)
1400} 817}
1401 818
1402/** 819/**
1403 * acpi_idle_update_bm_rld - updates the BM_RLD bit depending on target state
1404 * @pr: the processor
1405 * @target: the new target state
1406 */
1407static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr,
1408 struct acpi_processor_cx *target)
1409{
1410 if (pr->flags.bm_rld_set && target->type != ACPI_STATE_C3) {
1411 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
1412 pr->flags.bm_rld_set = 0;
1413 }
1414
1415 if (!pr->flags.bm_rld_set && target->type == ACPI_STATE_C3) {
1416 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
1417 pr->flags.bm_rld_set = 1;
1418 }
1419}
1420
1421/**
1422 * acpi_idle_do_entry - a helper function that does C2 and C3 type entry 820 * acpi_idle_do_entry - a helper function that does C2 and C3 type entry
1423 * @cx: cstate data 821 * @cx: cstate data
1424 * 822 *
@@ -1473,9 +871,6 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1473 return 0; 871 return 0;
1474 } 872 }
1475 873
1476 if (pr->flags.bm_check)
1477 acpi_idle_update_bm_rld(pr, cx);
1478
1479 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 874 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1480 acpi_idle_do_entry(cx); 875 acpi_idle_do_entry(cx);
1481 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 876 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -1527,9 +922,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1527 */ 922 */
1528 acpi_state_timer_broadcast(pr, cx, 1); 923 acpi_state_timer_broadcast(pr, cx, 1);
1529 924
1530 if (pr->flags.bm_check)
1531 acpi_idle_update_bm_rld(pr, cx);
1532
1533 if (cx->type == ACPI_STATE_C3) 925 if (cx->type == ACPI_STATE_C3)
1534 ACPI_FLUSH_CPU_CACHE(); 926 ACPI_FLUSH_CPU_CACHE();
1535 927
@@ -1621,8 +1013,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1621 */ 1013 */
1622 acpi_state_timer_broadcast(pr, cx, 1); 1014 acpi_state_timer_broadcast(pr, cx, 1);
1623 1015
1624 acpi_idle_update_bm_rld(pr, cx);
1625
1626 /* 1016 /*
1627 * disable bus master 1017 * disable bus master
1628 * bm_check implies we need ARB_DIS 1018 * bm_check implies we need ARB_DIS
@@ -1795,8 +1185,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1795 return ret; 1185 return ret;
1796} 1186}
1797 1187
1798#endif /* CONFIG_CPU_IDLE */
1799
1800int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, 1188int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1801 struct acpi_device *device) 1189 struct acpi_device *device)
1802{ 1190{
@@ -1825,10 +1213,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1825 "ACPI: processor limited to max C-state %d\n", 1213 "ACPI: processor limited to max C-state %d\n",
1826 max_cstate); 1214 max_cstate);
1827 first_run++; 1215 first_run++;
1828#if !defined(CONFIG_CPU_IDLE) && defined(CONFIG_SMP)
1829 pm_qos_add_notifier(PM_QOS_CPU_DMA_LATENCY,
1830 &acpi_processor_latency_notifier);
1831#endif
1832 } 1216 }
1833 1217
1834 if (!pr) 1218 if (!pr)
@@ -1852,11 +1236,9 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1852 * platforms that only support C1. 1236 * platforms that only support C1.
1853 */ 1237 */
1854 if (pr->flags.power) { 1238 if (pr->flags.power) {
1855#ifdef CONFIG_CPU_IDLE
1856 acpi_processor_setup_cpuidle(pr); 1239 acpi_processor_setup_cpuidle(pr);
1857 if (cpuidle_register_device(&pr->power.dev)) 1240 if (cpuidle_register_device(&pr->power.dev))
1858 return -EIO; 1241 return -EIO;
1859#endif
1860 1242
1861 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); 1243 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id);
1862 for (i = 1; i <= pr->power.count; i++) 1244 for (i = 1; i <= pr->power.count; i++)
@@ -1864,13 +1246,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1864 printk(" C%d[C%d]", i, 1246 printk(" C%d[C%d]", i,
1865 pr->power.states[i].type); 1247 pr->power.states[i].type);
1866 printk(")\n"); 1248 printk(")\n");
1867
1868#ifndef CONFIG_CPU_IDLE
1869 if (pr->id == 0) {
1870 pm_idle_save = pm_idle;
1871 pm_idle = acpi_processor_idle;
1872 }
1873#endif
1874 } 1249 }
1875 1250
1876 /* 'power' [R] */ 1251 /* 'power' [R] */
@@ -1889,34 +1264,12 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1889 if (boot_option_idle_override) 1264 if (boot_option_idle_override)
1890 return 0; 1265 return 0;
1891 1266
1892#ifdef CONFIG_CPU_IDLE
1893 cpuidle_unregister_device(&pr->power.dev); 1267 cpuidle_unregister_device(&pr->power.dev);
1894#endif
1895 pr->flags.power_setup_done = 0; 1268 pr->flags.power_setup_done = 0;
1896 1269
1897 if (acpi_device_dir(device)) 1270 if (acpi_device_dir(device))
1898 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1271 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1899 acpi_device_dir(device)); 1272 acpi_device_dir(device));
1900 1273
1901#ifndef CONFIG_CPU_IDLE
1902
1903 /* Unregister the idle handler when processor #0 is removed. */
1904 if (pr->id == 0) {
1905 if (pm_idle_save)
1906 pm_idle = pm_idle_save;
1907
1908 /*
1909 * We are about to unload the current idle thread pm callback
1910 * (pm_idle), Wait for all processors to update cached/local
1911 * copies of pm_idle before proceeding.
1912 */
1913 cpu_idle_wait();
1914#ifdef CONFIG_SMP
1915 pm_qos_remove_notifier(PM_QOS_CPU_DMA_LATENCY,
1916 &acpi_processor_latency_notifier);
1917#endif
1918 }
1919#endif
1920
1921 return 0; 1274 return 0;
1922} 1275}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index dbcf260ea93f..9cc769b587ff 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -31,22 +31,14 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33 33
34#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
37#include <linux/mutex.h>
38
39#include <asm/uaccess.h>
40#endif
41
42#ifdef CONFIG_X86 34#ifdef CONFIG_X86
43#include <asm/cpufeature.h> 35#include <asm/cpufeature.h>
44#endif 36#endif
45 37
46#include <acpi/acpi_bus.h> 38#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h>
47#include <acpi/processor.h> 40#include <acpi/processor.h>
48 41
49#define ACPI_PROCESSOR_COMPONENT 0x01000000
50#define ACPI_PROCESSOR_CLASS "processor" 42#define ACPI_PROCESSOR_CLASS "processor"
51#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" 43#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
52#define _COMPONENT ACPI_PROCESSOR_COMPONENT 44#define _COMPONENT ACPI_PROCESSOR_COMPONENT
@@ -434,96 +426,6 @@ int acpi_processor_notify_smm(struct module *calling_module)
434 426
435EXPORT_SYMBOL(acpi_processor_notify_smm); 427EXPORT_SYMBOL(acpi_processor_notify_smm);
436 428
437#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
438/* /proc/acpi/processor/../performance interface (DEPRECATED) */
439
440static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
441static struct file_operations acpi_processor_perf_fops = {
442 .owner = THIS_MODULE,
443 .open = acpi_processor_perf_open_fs,
444 .read = seq_read,
445 .llseek = seq_lseek,
446 .release = single_release,
447};
448
449static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
450{
451 struct acpi_processor *pr = seq->private;
452 int i;
453
454
455 if (!pr)
456 goto end;
457
458 if (!pr->performance) {
459 seq_puts(seq, "<not supported>\n");
460 goto end;
461 }
462
463 seq_printf(seq, "state count: %d\n"
464 "active state: P%d\n",
465 pr->performance->state_count, pr->performance->state);
466
467 seq_puts(seq, "states:\n");
468 for (i = 0; i < pr->performance->state_count; i++)
469 seq_printf(seq,
470 " %cP%d: %d MHz, %d mW, %d uS\n",
471 (i == pr->performance->state ? '*' : ' '), i,
472 (u32) pr->performance->states[i].core_frequency,
473 (u32) pr->performance->states[i].power,
474 (u32) pr->performance->states[i].transition_latency);
475
476 end:
477 return 0;
478}
479
480static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
481{
482 return single_open(file, acpi_processor_perf_seq_show,
483 PDE(inode)->data);
484}
485
486static void acpi_cpufreq_add_file(struct acpi_processor *pr)
487{
488 struct acpi_device *device = NULL;
489
490
491 if (acpi_bus_get_device(pr->handle, &device))
492 return;
493
494 /* add file 'performance' [R/W] */
495 proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
496 acpi_device_dir(device),
497 &acpi_processor_perf_fops, acpi_driver_data(device));
498 return;
499}
500
501static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
502{
503 struct acpi_device *device = NULL;
504
505
506 if (acpi_bus_get_device(pr->handle, &device))
507 return;
508
509 /* remove file 'performance' */
510 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
511 acpi_device_dir(device));
512
513 return;
514}
515
516#else
517static void acpi_cpufreq_add_file(struct acpi_processor *pr)
518{
519 return;
520}
521static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
522{
523 return;
524}
525#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
526
527static int acpi_processor_get_psd(struct acpi_processor *pr) 429static int acpi_processor_get_psd(struct acpi_processor *pr)
528{ 430{
529 int result = 0; 431 int result = 0;
@@ -588,12 +490,15 @@ int acpi_processor_preregister_performance(
588 int count, count_target; 490 int count, count_target;
589 int retval = 0; 491 int retval = 0;
590 unsigned int i, j; 492 unsigned int i, j;
591 cpumask_t covered_cpus; 493 cpumask_var_t covered_cpus;
592 struct acpi_processor *pr; 494 struct acpi_processor *pr;
593 struct acpi_psd_package *pdomain; 495 struct acpi_psd_package *pdomain;
594 struct acpi_processor *match_pr; 496 struct acpi_processor *match_pr;
595 struct acpi_psd_package *match_pdomain; 497 struct acpi_psd_package *match_pdomain;
596 498
499 if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))
500 return -ENOMEM;
501
597 mutex_lock(&performance_mutex); 502 mutex_lock(&performance_mutex);
598 503
599 retval = 0; 504 retval = 0;
@@ -617,7 +522,7 @@ int acpi_processor_preregister_performance(
617 } 522 }
618 523
619 pr->performance = percpu_ptr(performance, i); 524 pr->performance = percpu_ptr(performance, i);
620 cpu_set(i, pr->performance->shared_cpu_map); 525 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
621 if (acpi_processor_get_psd(pr)) { 526 if (acpi_processor_get_psd(pr)) {
622 retval = -EINVAL; 527 retval = -EINVAL;
623 continue; 528 continue;
@@ -650,18 +555,18 @@ int acpi_processor_preregister_performance(
650 } 555 }
651 } 556 }
652 557
653 cpus_clear(covered_cpus); 558 cpumask_clear(covered_cpus);
654 for_each_possible_cpu(i) { 559 for_each_possible_cpu(i) {
655 pr = per_cpu(processors, i); 560 pr = per_cpu(processors, i);
656 if (!pr) 561 if (!pr)
657 continue; 562 continue;
658 563
659 if (cpu_isset(i, covered_cpus)) 564 if (cpumask_test_cpu(i, covered_cpus))
660 continue; 565 continue;
661 566
662 pdomain = &(pr->performance->domain_info); 567 pdomain = &(pr->performance->domain_info);
663 cpu_set(i, pr->performance->shared_cpu_map); 568 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
664 cpu_set(i, covered_cpus); 569 cpumask_set_cpu(i, covered_cpus);
665 if (pdomain->num_processors <= 1) 570 if (pdomain->num_processors <= 1)
666 continue; 571 continue;
667 572
@@ -699,8 +604,8 @@ int acpi_processor_preregister_performance(
699 goto err_ret; 604 goto err_ret;
700 } 605 }
701 606
702 cpu_set(j, covered_cpus); 607 cpumask_set_cpu(j, covered_cpus);
703 cpu_set(j, pr->performance->shared_cpu_map); 608 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
704 count++; 609 count++;
705 } 610 }
706 611
@@ -718,8 +623,8 @@ int acpi_processor_preregister_performance(
718 623
719 match_pr->performance->shared_type = 624 match_pr->performance->shared_type =
720 pr->performance->shared_type; 625 pr->performance->shared_type;
721 match_pr->performance->shared_cpu_map = 626 cpumask_copy(match_pr->performance->shared_cpu_map,
722 pr->performance->shared_cpu_map; 627 pr->performance->shared_cpu_map);
723 } 628 }
724 } 629 }
725 630
@@ -731,26 +636,25 @@ err_ret:
731 636
732 /* Assume no coordination on any error parsing domain info */ 637 /* Assume no coordination on any error parsing domain info */
733 if (retval) { 638 if (retval) {
734 cpus_clear(pr->performance->shared_cpu_map); 639 cpumask_clear(pr->performance->shared_cpu_map);
735 cpu_set(i, pr->performance->shared_cpu_map); 640 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
736 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; 641 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
737 } 642 }
738 pr->performance = NULL; /* Will be set for real in register */ 643 pr->performance = NULL; /* Will be set for real in register */
739 } 644 }
740 645
741 mutex_unlock(&performance_mutex); 646 mutex_unlock(&performance_mutex);
647 free_cpumask_var(covered_cpus);
742 return retval; 648 return retval;
743} 649}
744EXPORT_SYMBOL(acpi_processor_preregister_performance); 650EXPORT_SYMBOL(acpi_processor_preregister_performance);
745 651
746
747int 652int
748acpi_processor_register_performance(struct acpi_processor_performance 653acpi_processor_register_performance(struct acpi_processor_performance
749 *performance, unsigned int cpu) 654 *performance, unsigned int cpu)
750{ 655{
751 struct acpi_processor *pr; 656 struct acpi_processor *pr;
752 657
753
754 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 658 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
755 return -EINVAL; 659 return -EINVAL;
756 660
@@ -777,8 +681,6 @@ acpi_processor_register_performance(struct acpi_processor_performance
777 return -EIO; 681 return -EIO;
778 } 682 }
779 683
780 acpi_cpufreq_add_file(pr);
781
782 mutex_unlock(&performance_mutex); 684 mutex_unlock(&performance_mutex);
783 return 0; 685 return 0;
784} 686}
@@ -791,7 +693,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
791{ 693{
792 struct acpi_processor *pr; 694 struct acpi_processor *pr;
793 695
794
795 mutex_lock(&performance_mutex); 696 mutex_lock(&performance_mutex);
796 697
797 pr = per_cpu(processors, cpu); 698 pr = per_cpu(processors, cpu);
@@ -804,8 +705,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
804 kfree(pr->performance->states); 705 kfree(pr->performance->states);
805 pr->performance = NULL; 706 pr->performance = NULL;
806 707
807 acpi_cpufreq_remove_file(pr);
808
809 mutex_unlock(&performance_mutex); 708 mutex_unlock(&performance_mutex);
810 709
811 return; 710 return;
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index ef34b18f95ca..b1eb376fae45 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -40,7 +40,6 @@
40#include <acpi/processor.h> 40#include <acpi/processor.h>
41#include <acpi/acpi_drivers.h> 41#include <acpi/acpi_drivers.h>
42 42
43#define ACPI_PROCESSOR_COMPONENT 0x01000000
44#define ACPI_PROCESSOR_CLASS "processor" 43#define ACPI_PROCESSOR_CLASS "processor"
45#define _COMPONENT ACPI_PROCESSOR_COMPONENT 44#define _COMPONENT ACPI_PROCESSOR_COMPONENT
46ACPI_MODULE_NAME("processor_thermal"); 45ACPI_MODULE_NAME("processor_thermal");
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 3da2df93d924..d27838171f4a 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -38,9 +38,9 @@
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
39 39
40#include <acpi/acpi_bus.h> 40#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h>
41#include <acpi/processor.h> 42#include <acpi/processor.h>
42 43
43#define ACPI_PROCESSOR_COMPONENT 0x01000000
44#define ACPI_PROCESSOR_CLASS "processor" 44#define ACPI_PROCESSOR_CLASS "processor"
45#define _COMPONENT ACPI_PROCESSOR_COMPONENT 45#define _COMPONENT ACPI_PROCESSOR_COMPONENT
46ACPI_MODULE_NAME("processor_throttling"); 46ACPI_MODULE_NAME("processor_throttling");
@@ -61,11 +61,14 @@ static int acpi_processor_update_tsd_coord(void)
61 int count, count_target; 61 int count, count_target;
62 int retval = 0; 62 int retval = 0;
63 unsigned int i, j; 63 unsigned int i, j;
64 cpumask_t covered_cpus; 64 cpumask_var_t covered_cpus;
65 struct acpi_processor *pr, *match_pr; 65 struct acpi_processor *pr, *match_pr;
66 struct acpi_tsd_package *pdomain, *match_pdomain; 66 struct acpi_tsd_package *pdomain, *match_pdomain;
67 struct acpi_processor_throttling *pthrottling, *match_pthrottling; 67 struct acpi_processor_throttling *pthrottling, *match_pthrottling;
68 68
69 if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))
70 return -ENOMEM;
71
69 /* 72 /*
70 * Now that we have _TSD data from all CPUs, lets setup T-state 73 * Now that we have _TSD data from all CPUs, lets setup T-state
71 * coordination between all CPUs. 74 * coordination between all CPUs.
@@ -91,19 +94,19 @@ static int acpi_processor_update_tsd_coord(void)
91 if (retval) 94 if (retval)
92 goto err_ret; 95 goto err_ret;
93 96
94 cpus_clear(covered_cpus); 97 cpumask_clear(covered_cpus);
95 for_each_possible_cpu(i) { 98 for_each_possible_cpu(i) {
96 pr = per_cpu(processors, i); 99 pr = per_cpu(processors, i);
97 if (!pr) 100 if (!pr)
98 continue; 101 continue;
99 102
100 if (cpu_isset(i, covered_cpus)) 103 if (cpumask_test_cpu(i, covered_cpus))
101 continue; 104 continue;
102 pthrottling = &pr->throttling; 105 pthrottling = &pr->throttling;
103 106
104 pdomain = &(pthrottling->domain_info); 107 pdomain = &(pthrottling->domain_info);
105 cpu_set(i, pthrottling->shared_cpu_map); 108 cpumask_set_cpu(i, pthrottling->shared_cpu_map);
106 cpu_set(i, covered_cpus); 109 cpumask_set_cpu(i, covered_cpus);
107 /* 110 /*
108 * If the number of processor in the TSD domain is 1, it is 111 * If the number of processor in the TSD domain is 1, it is
109 * unnecessary to parse the coordination for this CPU. 112 * unnecessary to parse the coordination for this CPU.
@@ -144,8 +147,8 @@ static int acpi_processor_update_tsd_coord(void)
144 goto err_ret; 147 goto err_ret;
145 } 148 }
146 149
147 cpu_set(j, covered_cpus); 150 cpumask_set_cpu(j, covered_cpus);
148 cpu_set(j, pthrottling->shared_cpu_map); 151 cpumask_set_cpu(j, pthrottling->shared_cpu_map);
149 count++; 152 count++;
150 } 153 }
151 for_each_possible_cpu(j) { 154 for_each_possible_cpu(j) {
@@ -165,12 +168,14 @@ static int acpi_processor_update_tsd_coord(void)
165 * If some CPUS have the same domain, they 168 * If some CPUS have the same domain, they
166 * will have the same shared_cpu_map. 169 * will have the same shared_cpu_map.
167 */ 170 */
168 match_pthrottling->shared_cpu_map = 171 cpumask_copy(match_pthrottling->shared_cpu_map,
169 pthrottling->shared_cpu_map; 172 pthrottling->shared_cpu_map);
170 } 173 }
171 } 174 }
172 175
173err_ret: 176err_ret:
177 free_cpumask_var(covered_cpus);
178
174 for_each_possible_cpu(i) { 179 for_each_possible_cpu(i) {
175 pr = per_cpu(processors, i); 180 pr = per_cpu(processors, i);
176 if (!pr) 181 if (!pr)
@@ -182,8 +187,8 @@ err_ret:
182 */ 187 */
183 if (retval) { 188 if (retval) {
184 pthrottling = &(pr->throttling); 189 pthrottling = &(pr->throttling);
185 cpus_clear(pthrottling->shared_cpu_map); 190 cpumask_clear(pthrottling->shared_cpu_map);
186 cpu_set(i, pthrottling->shared_cpu_map); 191 cpumask_set_cpu(i, pthrottling->shared_cpu_map);
187 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; 192 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
188 } 193 }
189 } 194 }
@@ -567,7 +572,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
567 pthrottling = &pr->throttling; 572 pthrottling = &pr->throttling;
568 pthrottling->tsd_valid_flag = 1; 573 pthrottling->tsd_valid_flag = 1;
569 pthrottling->shared_type = pdomain->coord_type; 574 pthrottling->shared_type = pdomain->coord_type;
570 cpu_set(pr->id, pthrottling->shared_cpu_map); 575 cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map);
571 /* 576 /*
572 * If the coordination type is not defined in ACPI spec, 577 * If the coordination type is not defined in ACPI spec,
573 * the tsd_valid_flag will be clear and coordination type 578 * the tsd_valid_flag will be clear and coordination type
@@ -826,7 +831,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
826 831
827static int acpi_processor_get_throttling(struct acpi_processor *pr) 832static int acpi_processor_get_throttling(struct acpi_processor *pr)
828{ 833{
829 cpumask_t saved_mask; 834 cpumask_var_t saved_mask;
830 int ret; 835 int ret;
831 836
832 if (!pr) 837 if (!pr)
@@ -834,14 +839,20 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
834 839
835 if (!pr->flags.throttling) 840 if (!pr->flags.throttling)
836 return -ENODEV; 841 return -ENODEV;
842
843 if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
844 return -ENOMEM;
845
837 /* 846 /*
838 * Migrate task to the cpu pointed by pr. 847 * Migrate task to the cpu pointed by pr.
839 */ 848 */
840 saved_mask = current->cpus_allowed; 849 cpumask_copy(saved_mask, &current->cpus_allowed);
841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 850 /* FIXME: use work_on_cpu() */
851 set_cpus_allowed_ptr(current, cpumask_of(pr->id));
842 ret = pr->throttling.acpi_processor_get_throttling(pr); 852 ret = pr->throttling.acpi_processor_get_throttling(pr);
843 /* restore the previous state */ 853 /* restore the previous state */
844 set_cpus_allowed_ptr(current, &saved_mask); 854 set_cpus_allowed_ptr(current, saved_mask);
855 free_cpumask_var(saved_mask);
845 856
846 return ret; 857 return ret;
847} 858}
@@ -986,13 +997,13 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
986 997
987int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 998int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
988{ 999{
989 cpumask_t saved_mask; 1000 cpumask_var_t saved_mask;
990 int ret = 0; 1001 int ret = 0;
991 unsigned int i; 1002 unsigned int i;
992 struct acpi_processor *match_pr; 1003 struct acpi_processor *match_pr;
993 struct acpi_processor_throttling *p_throttling; 1004 struct acpi_processor_throttling *p_throttling;
994 struct throttling_tstate t_state; 1005 struct throttling_tstate t_state;
995 cpumask_t online_throttling_cpus; 1006 cpumask_var_t online_throttling_cpus;
996 1007
997 if (!pr) 1008 if (!pr)
998 return -EINVAL; 1009 return -EINVAL;
@@ -1003,17 +1014,25 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1003 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 1014 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
1004 return -EINVAL; 1015 return -EINVAL;
1005 1016
1006 saved_mask = current->cpus_allowed; 1017 if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
1018 return -ENOMEM;
1019
1020 if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) {
1021 free_cpumask_var(saved_mask);
1022 return -ENOMEM;
1023 }
1024
1025 cpumask_copy(saved_mask, &current->cpus_allowed);
1007 t_state.target_state = state; 1026 t_state.target_state = state;
1008 p_throttling = &(pr->throttling); 1027 p_throttling = &(pr->throttling);
1009 cpus_and(online_throttling_cpus, cpu_online_map, 1028 cpumask_and(online_throttling_cpus, cpu_online_mask,
1010 p_throttling->shared_cpu_map); 1029 p_throttling->shared_cpu_map);
1011 /* 1030 /*
1012 * The throttling notifier will be called for every 1031 * The throttling notifier will be called for every
1013 * affected cpu in order to get one proper T-state. 1032 * affected cpu in order to get one proper T-state.
1014 * The notifier event is THROTTLING_PRECHANGE. 1033 * The notifier event is THROTTLING_PRECHANGE.
1015 */ 1034 */
1016 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1035 for_each_cpu(i, online_throttling_cpus) {
1017 t_state.cpu = i; 1036 t_state.cpu = i;
1018 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, 1037 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE,
1019 &t_state); 1038 &t_state);
@@ -1025,7 +1044,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1025 * it can be called only for the cpu pointed by pr. 1044 * it can be called only for the cpu pointed by pr.
1026 */ 1045 */
1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1046 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 1047 /* FIXME: use work_on_cpu() */
1048 set_cpus_allowed_ptr(current, cpumask_of(pr->id));
1029 ret = p_throttling->acpi_processor_set_throttling(pr, 1049 ret = p_throttling->acpi_processor_set_throttling(pr,
1030 t_state.target_state); 1050 t_state.target_state);
1031 } else { 1051 } else {
@@ -1034,7 +1054,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1034 * it is necessary to set T-state for every affected 1054 * it is necessary to set T-state for every affected
1035 * cpus. 1055 * cpus.
1036 */ 1056 */
1037 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1057 for_each_cpu(i, online_throttling_cpus) {
1038 match_pr = per_cpu(processors, i); 1058 match_pr = per_cpu(processors, i);
1039 /* 1059 /*
1040 * If the pointer is invalid, we will report the 1060 * If the pointer is invalid, we will report the
@@ -1056,7 +1076,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1056 continue; 1076 continue;
1057 } 1077 }
1058 t_state.cpu = i; 1078 t_state.cpu = i;
1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); 1079 /* FIXME: use work_on_cpu() */
1080 set_cpus_allowed_ptr(current, cpumask_of(i));
1060 ret = match_pr->throttling. 1081 ret = match_pr->throttling.
1061 acpi_processor_set_throttling( 1082 acpi_processor_set_throttling(
1062 match_pr, t_state.target_state); 1083 match_pr, t_state.target_state);
@@ -1068,13 +1089,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1068 * affected cpu to update the T-states. 1089 * affected cpu to update the T-states.
1069 * The notifier event is THROTTLING_POSTCHANGE 1090 * The notifier event is THROTTLING_POSTCHANGE
1070 */ 1091 */
1071 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1092 for_each_cpu(i, online_throttling_cpus) {
1072 t_state.cpu = i; 1093 t_state.cpu = i;
1073 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, 1094 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE,
1074 &t_state); 1095 &t_state);
1075 } 1096 }
1076 /* restore the previous state */ 1097 /* restore the previous state */
1077 set_cpus_allowed_ptr(current, &saved_mask); 1098 /* FIXME: use work_on_cpu() */
1099 set_cpus_allowed_ptr(current, saved_mask);
1100 free_cpumask_var(online_throttling_cpus);
1101 free_cpumask_var(saved_mask);
1078 return ret; 1102 return ret;
1079} 1103}
1080 1104
@@ -1120,7 +1144,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
1120 if (acpi_processor_get_tsd(pr)) { 1144 if (acpi_processor_get_tsd(pr)) {
1121 pthrottling = &pr->throttling; 1145 pthrottling = &pr->throttling;
1122 pthrottling->tsd_valid_flag = 0; 1146 pthrottling->tsd_valid_flag = 0;
1123 cpu_set(pr->id, pthrottling->shared_cpu_map); 1147 cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map);
1124 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; 1148 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
1125 } 1149 }
1126 1150
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index 755baf2ca70a..93f91142d7ad 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -15,28 +15,9 @@ void acpi_reboot(void)
15 15
16 rr = &acpi_gbl_FADT.reset_register; 16 rr = &acpi_gbl_FADT.reset_register;
17 17
18 /* 18 /* Is the reset register supported? */
19 * Is the ACPI reset register supported? 19 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
20 * 20 rr->bit_width != 8 || rr->bit_offset != 0)
21 * According to ACPI 3.0, FADT.flags.RESET_REG_SUP indicates
22 * whether the ACPI reset mechanism is supported.
23 *
24 * However, some boxes have this bit clear, yet a valid
25 * ACPI_RESET_REG & RESET_VALUE, and ACPI reboot is the only
26 * mechanism that works for them after S3.
27 *
28 * This suggests that other operating systems may not be checking
29 * the RESET_REG_SUP bit, and are using other means to decide
30 * whether to use the ACPI reboot mechanism or not.
31 *
32 * So when acpi reboot is requested,
33 * only the reset_register is checked. If the following
34 * conditions are met, it indicates that the reset register is supported.
35 * a. reset_register is not zero
36 * b. the access width is eight
37 * c. the bit_offset is zero
38 */
39 if (!(rr->address) || rr->bit_width != 8 || rr->bit_offset != 0)
40 return; 21 return;
41 22
42 reset_value = acpi_gbl_FADT.reset_value; 23 reset_value = acpi_gbl_FADT.reset_value;
@@ -61,7 +42,7 @@ void acpi_reboot(void)
61 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 42 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
62 case ACPI_ADR_SPACE_SYSTEM_IO: 43 case ACPI_ADR_SPACE_SYSTEM_IO:
63 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n"); 44 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
64 acpi_hw_low_level_write(8, reset_value, rr); 45 acpi_reset();
65 break; 46 break;
66 } 47 }
67 /* Wait ten seconds */ 48 /* Wait ten seconds */
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
deleted file mode 100644
index 8de4f69dfa09..000000000000
--- a/drivers/acpi/resources/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
6 rscalc.o rsirq.o rsmemory.o rsutils.o
7
8obj-$(ACPI_FUTURE_USAGE) += rsdump.o
9
10EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index e53e590252c0..0619734895b2 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -10,7 +10,6 @@
10 10
11#include <acpi/acpi_bus.h> 11#include <acpi/acpi_bus.h>
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <acpi/actypes.h>
14#include <linux/wait.h> 13#include <linux/wait.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index a9dda8e0f9f9..c54d7b6c4066 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -10,7 +10,6 @@
10#include <linux/kthread.h> 10#include <linux/kthread.h>
11 11
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */
14 13
15#define _COMPONENT ACPI_BUS_COMPONENT 14#define _COMPONENT ACPI_BUS_COMPONENT
16ACPI_MODULE_NAME("scan"); 15ACPI_MODULE_NAME("scan");
@@ -109,8 +108,7 @@ static int acpi_bus_hot_remove_device(void *context)
109 return 0; 108 return 0;
110 109
111 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 110 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
112 "Hot-removing device %s...\n", device->dev.bus_id)); 111 "Hot-removing device %s...\n", dev_name(&device->dev)));
113
114 112
115 if (acpi_bus_trim(device, 1)) { 113 if (acpi_bus_trim(device, 1)) {
116 printk(KERN_ERR PREFIX 114 printk(KERN_ERR PREFIX
@@ -460,7 +458,7 @@ static int acpi_device_register(struct acpi_device *device,
460 acpi_device_bus_id->instance_no = 0; 458 acpi_device_bus_id->instance_no = 0;
461 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); 459 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
462 } 460 }
463 sprintf(device->dev.bus_id, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); 461 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no);
464 462
465 if (device->parent) { 463 if (device->parent) {
466 list_add_tail(&device->node, &device->parent->children); 464 list_add_tail(&device->node, &device->parent->children);
@@ -484,7 +482,8 @@ static int acpi_device_register(struct acpi_device *device,
484 482
485 result = acpi_device_setup_files(device); 483 result = acpi_device_setup_files(device);
486 if(result) 484 if(result)
487 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", device->dev.bus_id); 485 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n",
486 dev_name(&device->dev));
488 487
489 device->removal_type = ACPI_BUS_REMOVAL_NORMAL; 488 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
490 return 0; 489 return 0;
@@ -751,16 +750,6 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
751 if (!acpi_match_device_ids(device, button_device_ids)) 750 if (!acpi_match_device_ids(device, button_device_ids))
752 device->wakeup.flags.run_wake = 1; 751 device->wakeup.flags.run_wake = 1;
753 752
754 /*
755 * Don't set Power button GPE as run_wake
756 * if Fixed Power button is used
757 */
758 if (!strcmp(device->pnp.hardware_id, "PNP0C0C") &&
759 !(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
760 device->wakeup.flags.run_wake = 0;
761 device->wakeup.flags.valid = 0;
762 }
763
764 end: 753 end:
765 if (ACPI_FAILURE(status)) 754 if (ACPI_FAILURE(status))
766 device->flags.wake_capable = 0; 755 device->flags.wake_capable = 0;
@@ -919,36 +908,6 @@ static void acpi_device_get_busid(struct acpi_device *device,
919 } 908 }
920} 909}
921 910
922static int
923acpi_video_bus_match(struct acpi_device *device)
924{
925 acpi_handle h_dummy;
926
927 if (!device)
928 return -EINVAL;
929
930 /* Since there is no HID, CID for ACPI Video drivers, we have
931 * to check well known required nodes for each feature we support.
932 */
933
934 /* Does this device able to support video switching ? */
935 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) &&
936 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy)))
937 return 0;
938
939 /* Does this device able to retrieve a video ROM ? */
940 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy)))
941 return 0;
942
943 /* Does this device able to configure which video head to be POSTed ? */
944 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) &&
945 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) &&
946 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy)))
947 return 0;
948
949 return -ENODEV;
950}
951
952/* 911/*
953 * acpi_bay_match - see if a device is an ejectable driver bay 912 * acpi_bay_match - see if a device is an ejectable driver bay
954 * 913 *
@@ -1031,7 +990,7 @@ static void acpi_device_set_id(struct acpi_device *device,
1031 will get autoloaded and the device might still match 990 will get autoloaded and the device might still match
1032 against another driver. 991 against another driver.
1033 */ 992 */
1034 if (ACPI_SUCCESS(acpi_video_bus_match(device))) 993 if (acpi_is_video_device(device))
1035 cid_add = ACPI_VIDEO_HID; 994 cid_add = ACPI_VIDEO_HID;
1036 else if (ACPI_SUCCESS(acpi_bay_match(device))) 995 else if (ACPI_SUCCESS(acpi_bay_match(device)))
1037 cid_add = ACPI_BAY_HID; 996 cid_add = ACPI_BAY_HID;
@@ -1043,7 +1002,7 @@ static void acpi_device_set_id(struct acpi_device *device,
1043 hid = ACPI_POWER_HID; 1002 hid = ACPI_POWER_HID;
1044 break; 1003 break;
1045 case ACPI_BUS_TYPE_PROCESSOR: 1004 case ACPI_BUS_TYPE_PROCESSOR:
1046 hid = ACPI_PROCESSOR_HID; 1005 hid = ACPI_PROCESSOR_OBJECT_HID;
1047 break; 1006 break;
1048 case ACPI_BUS_TYPE_SYSTEM: 1007 case ACPI_BUS_TYPE_SYSTEM:
1049 hid = ACPI_SYSTEM_HID; 1008 hid = ACPI_SYSTEM_HID;
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep.c
index 80c0868d0480..519266654f06 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep.c
@@ -95,7 +95,7 @@ void __init acpi_old_suspend_ordering(void)
95 */ 95 */
96static int acpi_pm_disable_gpes(void) 96static int acpi_pm_disable_gpes(void)
97{ 97{
98 acpi_hw_disable_all_gpes(); 98 acpi_disable_all_gpes();
99 return 0; 99 return 0;
100} 100}
101 101
@@ -123,7 +123,7 @@ static int acpi_pm_prepare(void)
123 int error = __acpi_pm_prepare(); 123 int error = __acpi_pm_prepare();
124 124
125 if (!error) 125 if (!error)
126 acpi_hw_disable_all_gpes(); 126 acpi_disable_all_gpes();
127 return error; 127 return error;
128} 128}
129 129
@@ -168,6 +168,18 @@ static void acpi_pm_end(void)
168#endif /* CONFIG_ACPI_SLEEP */ 168#endif /* CONFIG_ACPI_SLEEP */
169 169
170#ifdef CONFIG_SUSPEND 170#ifdef CONFIG_SUSPEND
171/*
172 * According to the ACPI specification the BIOS should make sure that ACPI is
173 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
174 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
175 * on such systems during resume. Unfortunately that doesn't help in
176 * particularly pathological cases in which SCI_EN has to be set directly on
177 * resume, although the specification states very clearly that this flag is
178 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
179 * cases.
180 */
181static bool set_sci_en_on_resume;
182
171extern void do_suspend_lowlevel(void); 183extern void do_suspend_lowlevel(void);
172 184
173static u32 acpi_suspend_states[] = { 185static u32 acpi_suspend_states[] = {
@@ -235,7 +247,11 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
235 } 247 }
236 248
237 /* If ACPI is not enabled by the BIOS, we need to enable it here. */ 249 /* If ACPI is not enabled by the BIOS, we need to enable it here. */
238 acpi_enable(); 250 if (set_sci_en_on_resume)
251 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1);
252 else
253 acpi_enable();
254
239 /* Reprogram control registers and execute _BFS */ 255 /* Reprogram control registers and execute _BFS */
240 acpi_leave_sleep_state_prep(acpi_state); 256 acpi_leave_sleep_state_prep(acpi_state);
241 257
@@ -251,7 +267,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
251 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire. 267 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
252 * acpi_leave_sleep_state will reenable specific GPEs later 268 * acpi_leave_sleep_state will reenable specific GPEs later
253 */ 269 */
254 acpi_hw_disable_all_gpes(); 270 acpi_disable_all_gpes();
255 271
256 local_irq_restore(flags); 272 local_irq_restore(flags);
257 printk(KERN_DEBUG "Back to C!\n"); 273 printk(KERN_DEBUG "Back to C!\n");
@@ -323,6 +339,12 @@ static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
323 return 0; 339 return 0;
324} 340}
325 341
342static int __init init_set_sci_en_on_resume(const struct dmi_system_id *d)
343{
344 set_sci_en_on_resume = true;
345 return 0;
346}
347
326static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 348static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
327 { 349 {
328 .callback = init_old_suspend_ordering, 350 .callback = init_old_suspend_ordering,
@@ -340,11 +362,41 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
340 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), 362 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
341 }, 363 },
342 }, 364 },
365 {
366 .callback = init_set_sci_en_on_resume,
367 .ident = "Apple MacBook 1,1",
368 .matches = {
369 DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
370 DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"),
371 },
372 },
373 {
374 .callback = init_set_sci_en_on_resume,
375 .ident = "Apple MacMini 1,1",
376 .matches = {
377 DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
378 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
379 },
380 },
343 {}, 381 {},
344}; 382};
345#endif /* CONFIG_SUSPEND */ 383#endif /* CONFIG_SUSPEND */
346 384
347#ifdef CONFIG_HIBERNATION 385#ifdef CONFIG_HIBERNATION
386/*
387 * The ACPI specification wants us to save NVS memory regions during hibernation
388 * and to restore them during the subsequent resume. However, it is not certain
389 * if this mechanism is going to work on all machines, so we allow the user to
390 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
391 * option.
392 */
393static bool s4_no_nvs;
394
395void __init acpi_s4_no_nvs(void)
396{
397 s4_no_nvs = true;
398}
399
348static unsigned long s4_hardware_signature; 400static unsigned long s4_hardware_signature;
349static struct acpi_table_facs *facs; 401static struct acpi_table_facs *facs;
350static bool nosigcheck; 402static bool nosigcheck;
@@ -356,9 +408,25 @@ void __init acpi_no_s4_hw_signature(void)
356 408
357static int acpi_hibernation_begin(void) 409static int acpi_hibernation_begin(void)
358{ 410{
359 acpi_target_sleep_state = ACPI_STATE_S4; 411 int error;
360 acpi_sleep_tts_switch(acpi_target_sleep_state); 412
361 return 0; 413 error = s4_no_nvs ? 0 : hibernate_nvs_alloc();
414 if (!error) {
415 acpi_target_sleep_state = ACPI_STATE_S4;
416 acpi_sleep_tts_switch(acpi_target_sleep_state);
417 }
418
419 return error;
420}
421
422static int acpi_hibernation_pre_snapshot(void)
423{
424 int error = acpi_pm_prepare();
425
426 if (!error)
427 hibernate_nvs_save();
428
429 return error;
362} 430}
363 431
364static int acpi_hibernation_enter(void) 432static int acpi_hibernation_enter(void)
@@ -379,6 +447,12 @@ static int acpi_hibernation_enter(void)
379 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 447 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
380} 448}
381 449
450static void acpi_hibernation_finish(void)
451{
452 hibernate_nvs_free();
453 acpi_pm_finish();
454}
455
382static void acpi_hibernation_leave(void) 456static void acpi_hibernation_leave(void)
383{ 457{
384 /* 458 /*
@@ -394,18 +468,20 @@ static void acpi_hibernation_leave(void)
394 "cannot resume!\n"); 468 "cannot resume!\n");
395 panic("ACPI S4 hardware signature mismatch"); 469 panic("ACPI S4 hardware signature mismatch");
396 } 470 }
471 /* Restore the NVS memory area */
472 hibernate_nvs_restore();
397} 473}
398 474
399static void acpi_pm_enable_gpes(void) 475static void acpi_pm_enable_gpes(void)
400{ 476{
401 acpi_hw_enable_all_runtime_gpes(); 477 acpi_enable_all_runtime_gpes();
402} 478}
403 479
404static struct platform_hibernation_ops acpi_hibernation_ops = { 480static struct platform_hibernation_ops acpi_hibernation_ops = {
405 .begin = acpi_hibernation_begin, 481 .begin = acpi_hibernation_begin,
406 .end = acpi_pm_end, 482 .end = acpi_pm_end,
407 .pre_snapshot = acpi_pm_prepare, 483 .pre_snapshot = acpi_hibernation_pre_snapshot,
408 .finish = acpi_pm_finish, 484 .finish = acpi_hibernation_finish,
409 .prepare = acpi_pm_prepare, 485 .prepare = acpi_pm_prepare,
410 .enter = acpi_hibernation_enter, 486 .enter = acpi_hibernation_enter,
411 .leave = acpi_hibernation_leave, 487 .leave = acpi_hibernation_leave,
@@ -431,8 +507,22 @@ static int acpi_hibernation_begin_old(void)
431 507
432 error = acpi_sleep_prepare(ACPI_STATE_S4); 508 error = acpi_sleep_prepare(ACPI_STATE_S4);
433 509
510 if (!error) {
511 if (!s4_no_nvs)
512 error = hibernate_nvs_alloc();
513 if (!error)
514 acpi_target_sleep_state = ACPI_STATE_S4;
515 }
516 return error;
517}
518
519static int acpi_hibernation_pre_snapshot_old(void)
520{
521 int error = acpi_pm_disable_gpes();
522
434 if (!error) 523 if (!error)
435 acpi_target_sleep_state = ACPI_STATE_S4; 524 hibernate_nvs_save();
525
436 return error; 526 return error;
437} 527}
438 528
@@ -443,8 +533,8 @@ static int acpi_hibernation_begin_old(void)
443static struct platform_hibernation_ops acpi_hibernation_ops_old = { 533static struct platform_hibernation_ops acpi_hibernation_ops_old = {
444 .begin = acpi_hibernation_begin_old, 534 .begin = acpi_hibernation_begin_old,
445 .end = acpi_pm_end, 535 .end = acpi_pm_end,
446 .pre_snapshot = acpi_pm_disable_gpes, 536 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
447 .finish = acpi_pm_finish, 537 .finish = acpi_hibernation_finish,
448 .prepare = acpi_pm_disable_gpes, 538 .prepare = acpi_pm_disable_gpes,
449 .enter = acpi_hibernation_enter, 539 .enter = acpi_hibernation_enter,
450 .leave = acpi_hibernation_leave, 540 .leave = acpi_hibernation_leave,
@@ -584,13 +674,13 @@ static void acpi_power_off_prepare(void)
584{ 674{
585 /* Prepare to power off the system */ 675 /* Prepare to power off the system */
586 acpi_sleep_prepare(ACPI_STATE_S5); 676 acpi_sleep_prepare(ACPI_STATE_S5);
587 acpi_hw_disable_all_gpes(); 677 acpi_disable_all_gpes();
588} 678}
589 679
590static void acpi_power_off(void) 680static void acpi_power_off(void)
591{ 681{
592 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 682 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
593 printk("%s called\n", __func__); 683 printk(KERN_DEBUG "%s called\n", __func__);
594 local_irq_disable(); 684 local_irq_disable();
595 acpi_enable_wakeup_device(ACPI_STATE_S5); 685 acpi_enable_wakeup_device(ACPI_STATE_S5);
596 acpi_enter_sleep_state(ACPI_STATE_S5); 686 acpi_enter_sleep_state(ACPI_STATE_S5);
@@ -633,7 +723,7 @@ int __init acpi_sleep_init(void)
633 sleep_states[ACPI_STATE_S4] = 1; 723 sleep_states[ACPI_STATE_S4] = 1;
634 printk(" S4"); 724 printk(" S4");
635 if (!nosigcheck) { 725 if (!nosigcheck) {
636 acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 726 acpi_get_table(ACPI_SIG_FACS, 1,
637 (struct acpi_table_header **)&facs); 727 (struct acpi_table_header **)&facs);
638 if (facs) 728 if (facs)
639 s4_hardware_signature = 729 s4_hardware_signature =
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep.h
index cfaf8f5b0a14..cfaf8f5b0a14 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep.h
diff --git a/drivers/acpi/sleep/Makefile b/drivers/acpi/sleep/Makefile
deleted file mode 100644
index f1fb888c2d29..000000000000
--- a/drivers/acpi/sleep/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1obj-y := wakeup.o
2obj-y += main.o
3obj-$(CONFIG_ACPI_SLEEP) += proc.o
4
5EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 1d74171b7940..391d0358a592 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -78,9 +78,15 @@ static ssize_t acpi_table_show(struct kobject *kobj,
78 container_of(bin_attr, struct acpi_table_attr, attr); 78 container_of(bin_attr, struct acpi_table_attr, attr);
79 struct acpi_table_header *table_header = NULL; 79 struct acpi_table_header *table_header = NULL;
80 acpi_status status; 80 acpi_status status;
81 char name[ACPI_NAME_SIZE];
82
83 if (strncmp(table_attr->name, "NULL", 4))
84 memcpy(name, table_attr->name, ACPI_NAME_SIZE);
85 else
86 memcpy(name, "\0\0\0\0", 4);
81 87
82 status = 88 status =
83 acpi_get_table(table_attr->name, table_attr->instance, 89 acpi_get_table(name, table_attr->instance,
84 &table_header); 90 &table_header);
85 if (ACPI_FAILURE(status)) 91 if (ACPI_FAILURE(status))
86 return -ENODEV; 92 return -ENODEV;
@@ -95,21 +101,24 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
95 struct acpi_table_header *header = NULL; 101 struct acpi_table_header *header = NULL;
96 struct acpi_table_attr *attr = NULL; 102 struct acpi_table_attr *attr = NULL;
97 103
98 memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE); 104 if (table_header->signature[0] != '\0')
105 memcpy(table_attr->name, table_header->signature,
106 ACPI_NAME_SIZE);
107 else
108 memcpy(table_attr->name, "NULL", 4);
99 109
100 list_for_each_entry(attr, &acpi_table_attr_list, node) { 110 list_for_each_entry(attr, &acpi_table_attr_list, node) {
101 if (!memcmp(table_header->signature, attr->name, 111 if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE))
102 ACPI_NAME_SIZE))
103 if (table_attr->instance < attr->instance) 112 if (table_attr->instance < attr->instance)
104 table_attr->instance = attr->instance; 113 table_attr->instance = attr->instance;
105 } 114 }
106 table_attr->instance++; 115 table_attr->instance++;
107 116
108 if (table_attr->instance > 1 || (table_attr->instance == 1 && 117 if (table_attr->instance > 1 || (table_attr->instance == 1 &&
109 !acpi_get_table(table_header-> 118 !acpi_get_table
110 signature, 2, 119 (table_header->signature, 2, &header)))
111 &header))) 120 sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",
112 sprintf(table_attr->name + 4, "%d", table_attr->instance); 121 table_attr->instance);
113 122
114 table_attr->attr.size = 0; 123 table_attr->attr.size = 0;
115 table_attr->attr.read = acpi_table_show; 124 table_attr->attr.read = acpi_table_show;
@@ -167,7 +176,6 @@ static int acpi_system_sysfs_init(void)
167#define COUNT_ERROR 2 /* other */ 176#define COUNT_ERROR 2 /* other */
168#define NUM_COUNTERS_EXTRA 3 177#define NUM_COUNTERS_EXTRA 3
169 178
170#define ACPI_EVENT_VALID 0x01
171struct event_counter { 179struct event_counter {
172 u32 count; 180 u32 count;
173 u32 flags; 181 u32 flags;
@@ -184,65 +192,6 @@ static struct attribute_group interrupt_stats_attr_group = {
184}; 192};
185static struct kobj_attribute *counter_attrs; 193static struct kobj_attribute *counter_attrs;
186 194
187static int count_num_gpes(void)
188{
189 int count = 0;
190 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
191 struct acpi_gpe_block_info *gpe_block;
192 acpi_cpu_flags flags;
193
194 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
195
196 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
197 while (gpe_xrupt_info) {
198 gpe_block = gpe_xrupt_info->gpe_block_list_head;
199 while (gpe_block) {
200 count += gpe_block->register_count *
201 ACPI_GPE_REGISTER_WIDTH;
202 gpe_block = gpe_block->next;
203 }
204 gpe_xrupt_info = gpe_xrupt_info->next;
205 }
206 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
207
208 return count;
209}
210
211static int get_gpe_device(int index, acpi_handle *handle)
212{
213 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
214 struct acpi_gpe_block_info *gpe_block;
215 acpi_cpu_flags flags;
216 struct acpi_namespace_node *node;
217
218 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
219
220 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
221 while (gpe_xrupt_info) {
222 gpe_block = gpe_xrupt_info->gpe_block_list_head;
223 node = gpe_block->node;
224 while (gpe_block) {
225 index -= gpe_block->register_count *
226 ACPI_GPE_REGISTER_WIDTH;
227 if (index < 0) {
228 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
229 /* return NULL if it's FADT GPE */
230 if (node->type != ACPI_TYPE_DEVICE)
231 *handle = NULL;
232 else
233 *handle = node;
234 return 0;
235 }
236 node = gpe_block->node;
237 gpe_block = gpe_block->next;
238 }
239 gpe_xrupt_info = gpe_xrupt_info->next;
240 }
241 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
242
243 return -ENODEV;
244}
245
246static void delete_gpe_attr_array(void) 195static void delete_gpe_attr_array(void)
247{ 196{
248 struct event_counter *tmp = all_counters; 197 struct event_counter *tmp = all_counters;
@@ -301,7 +250,7 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle)
301 goto end; 250 goto end;
302 251
303 if (index < num_gpes) { 252 if (index < num_gpes) {
304 result = get_gpe_device(index, handle); 253 result = acpi_get_gpe_device(index, handle);
305 if (result) { 254 if (result) {
306 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 255 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
307 "Invalid GPE 0x%x\n", index)); 256 "Invalid GPE 0x%x\n", index));
@@ -312,12 +261,6 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle)
312 } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) 261 } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
313 result = acpi_get_event_status(index - num_gpes, status); 262 result = acpi_get_event_status(index - num_gpes, status);
314 263
315 /*
316 * sleep/power button GPE/Fixed Event is enabled after acpi_system_init,
317 * check the status at runtime and mark it as valid once it's enabled
318 */
319 if (!result && (*status & ACPI_EVENT_FLAG_ENABLED))
320 all_counters[index].flags |= ACPI_EVENT_VALID;
321end: 264end:
322 return result; 265 return result;
323} 266}
@@ -346,12 +289,14 @@ static ssize_t counter_show(struct kobject *kobj,
346 if (result) 289 if (result)
347 goto end; 290 goto end;
348 291
349 if (!(all_counters[index].flags & ACPI_EVENT_VALID)) 292 if (!(status & ACPI_EVENT_FLAG_HANDLE))
350 size += sprintf(buf + size, " invalid"); 293 size += sprintf(buf + size, " invalid");
351 else if (status & ACPI_EVENT_FLAG_ENABLED) 294 else if (status & ACPI_EVENT_FLAG_ENABLED)
352 size += sprintf(buf + size, " enable"); 295 size += sprintf(buf + size, " enabled");
296 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED)
297 size += sprintf(buf + size, " wake_enabled");
353 else 298 else
354 size += sprintf(buf + size, " disable"); 299 size += sprintf(buf + size, " disabled");
355 300
356end: 301end:
357 size += sprintf(buf + size, "\n"); 302 size += sprintf(buf + size, "\n");
@@ -385,7 +330,7 @@ static ssize_t counter_set(struct kobject *kobj,
385 if (result) 330 if (result)
386 goto end; 331 goto end;
387 332
388 if (!(all_counters[index].flags & ACPI_EVENT_VALID)) { 333 if (!(status & ACPI_EVENT_FLAG_HANDLE)) {
389 printk(KERN_WARNING PREFIX 334 printk(KERN_WARNING PREFIX
390 "Can not change Invalid GPE/Fixed Event status\n"); 335 "Can not change Invalid GPE/Fixed Event status\n");
391 return -EINVAL; 336 return -EINVAL;
@@ -394,10 +339,10 @@ static ssize_t counter_set(struct kobject *kobj,
394 if (index < num_gpes) { 339 if (index < num_gpes) {
395 if (!strcmp(buf, "disable\n") && 340 if (!strcmp(buf, "disable\n") &&
396 (status & ACPI_EVENT_FLAG_ENABLED)) 341 (status & ACPI_EVENT_FLAG_ENABLED))
397 result = acpi_disable_gpe(handle, index, ACPI_NOT_ISR); 342 result = acpi_disable_gpe(handle, index);
398 else if (!strcmp(buf, "enable\n") && 343 else if (!strcmp(buf, "enable\n") &&
399 !(status & ACPI_EVENT_FLAG_ENABLED)) 344 !(status & ACPI_EVENT_FLAG_ENABLED))
400 result = acpi_enable_gpe(handle, index, ACPI_NOT_ISR); 345 result = acpi_enable_gpe(handle, index);
401 else if (!strcmp(buf, "clear\n") && 346 else if (!strcmp(buf, "clear\n") &&
402 (status & ACPI_EVENT_FLAG_SET)) 347 (status & ACPI_EVENT_FLAG_SET))
403 result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); 348 result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR);
@@ -432,7 +377,7 @@ void acpi_irq_stats_init(void)
432 if (all_counters) 377 if (all_counters)
433 return; 378 return;
434 379
435 num_gpes = count_num_gpes(); 380 num_gpes = acpi_current_gpe_count;
436 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; 381 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
437 382
438 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), 383 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 775c97a282bd..fec1ae36d431 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -181,14 +181,15 @@ acpi_table_parse_entries(char *id,
181 struct acpi_subtable_header *entry; 181 struct acpi_subtable_header *entry;
182 unsigned int count = 0; 182 unsigned int count = 0;
183 unsigned long table_end; 183 unsigned long table_end;
184 acpi_size tbl_size;
184 185
185 if (!handler) 186 if (!handler)
186 return -EINVAL; 187 return -EINVAL;
187 188
188 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 189 if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
189 acpi_get_table(id, acpi_apic_instance, &table_header); 190 acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
190 else 191 else
191 acpi_get_table(id, 0, &table_header); 192 acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
192 193
193 if (!table_header) { 194 if (!table_header) {
194 printk(KERN_WARNING PREFIX "%4.4s not present\n", id); 195 printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
@@ -206,8 +207,10 @@ acpi_table_parse_entries(char *id,
206 table_end) { 207 table_end) {
207 if (entry->type == entry_id 208 if (entry->type == entry_id
208 && (!max_entries || count++ < max_entries)) 209 && (!max_entries || count++ < max_entries))
209 if (handler(entry, table_end)) 210 if (handler(entry, table_end)) {
211 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
210 return -EINVAL; 212 return -EINVAL;
213 }
211 214
212 entry = (struct acpi_subtable_header *) 215 entry = (struct acpi_subtable_header *)
213 ((unsigned long)entry + entry->length); 216 ((unsigned long)entry + entry->length);
@@ -217,6 +220,7 @@ acpi_table_parse_entries(char *id,
217 "%i found\n", id, entry_id, count - max_entries, count); 220 "%i found\n", id, entry_id, count - max_entries, count);
218 } 221 }
219 222
223 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
220 return count; 224 return count;
221} 225}
222 226
@@ -241,17 +245,19 @@ acpi_table_parse_madt(enum acpi_madt_type id,
241int __init acpi_table_parse(char *id, acpi_table_handler handler) 245int __init acpi_table_parse(char *id, acpi_table_handler handler)
242{ 246{
243 struct acpi_table_header *table = NULL; 247 struct acpi_table_header *table = NULL;
248 acpi_size tbl_size;
244 249
245 if (!handler) 250 if (!handler)
246 return -EINVAL; 251 return -EINVAL;
247 252
248 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 253 if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
249 acpi_get_table(id, acpi_apic_instance, &table); 254 acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size);
250 else 255 else
251 acpi_get_table(id, 0, &table); 256 acpi_get_table_with_size(id, 0, &table, &tbl_size);
252 257
253 if (table) { 258 if (table) {
254 handler(table); 259 handler(table);
260 early_acpi_os_unmap_memory(table, tbl_size);
255 return 0; 261 return 0;
256 } else 262 } else
257 return 1; 263 return 1;
@@ -265,8 +271,9 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler)
265static void __init check_multiple_madt(void) 271static void __init check_multiple_madt(void)
266{ 272{
267 struct acpi_table_header *table = NULL; 273 struct acpi_table_header *table = NULL;
274 acpi_size tbl_size;
268 275
269 acpi_get_table(ACPI_SIG_MADT, 2, &table); 276 acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size);
270 if (table) { 277 if (table) {
271 printk(KERN_WARNING PREFIX 278 printk(KERN_WARNING PREFIX
272 "BIOS bug: multiple APIC/MADT found," 279 "BIOS bug: multiple APIC/MADT found,"
@@ -275,6 +282,7 @@ static void __init check_multiple_madt(void)
275 "If \"acpi_apic_instance=%d\" works better, " 282 "If \"acpi_apic_instance=%d\" works better, "
276 "notify linux-acpi@vger.kernel.org\n", 283 "notify linux-acpi@vger.kernel.org\n",
277 acpi_apic_instance ? 0 : 2); 284 acpi_apic_instance ? 0 : 2);
285 early_acpi_os_unmap_memory(table, tbl_size);
278 286
279 } else 287 } else
280 acpi_apic_instance = 0; 288 acpi_apic_instance = 0;
@@ -293,7 +301,12 @@ static void __init check_multiple_madt(void)
293 301
294int __init acpi_table_init(void) 302int __init acpi_table_init(void)
295{ 303{
296 acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); 304 acpi_status status;
305
306 status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
307 if (ACPI_FAILURE(status))
308 return 1;
309
297 check_multiple_madt(); 310 check_multiple_madt();
298 return 0; 311 return 0;
299} 312}
diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile
deleted file mode 100644
index 7385efa61622..000000000000
--- a/drivers/acpi/tables/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
6
7EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index ad6cae938f0b..99e6f1f8ea45 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -47,7 +47,6 @@
47#include <acpi/acpi_bus.h> 47#include <acpi/acpi_bus.h>
48#include <acpi/acpi_drivers.h> 48#include <acpi/acpi_drivers.h>
49 49
50#define ACPI_THERMAL_COMPONENT 0x04000000
51#define ACPI_THERMAL_CLASS "thermal_zone" 50#define ACPI_THERMAL_CLASS "thermal_zone"
52#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" 51#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
53#define ACPI_THERMAL_FILE_STATE "state" 52#define ACPI_THERMAL_FILE_STATE "state"
@@ -417,7 +416,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
417 } 416 }
418 417
419 /* Passive (optional) */ 418 /* Passive (optional) */
420 if (flag & ACPI_TRIPS_PASSIVE) { 419 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
420 (flag == ACPI_TRIPS_INIT)) {
421 valid = tz->trips.passive.flags.valid; 421 valid = tz->trips.passive.flags.valid;
422 if (psv == -1) { 422 if (psv == -1) {
423 status = AE_SUPPORT; 423 status = AE_SUPPORT;
@@ -463,8 +463,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
463 memset(&devices, 0, sizeof(struct acpi_handle_list)); 463 memset(&devices, 0, sizeof(struct acpi_handle_list));
464 status = acpi_evaluate_reference(tz->device->handle, "_PSL", 464 status = acpi_evaluate_reference(tz->device->handle, "_PSL",
465 NULL, &devices); 465 NULL, &devices);
466 if (ACPI_FAILURE(status)) 466 if (ACPI_FAILURE(status)) {
467 printk(KERN_WARNING PREFIX
468 "Invalid passive threshold\n");
467 tz->trips.passive.flags.valid = 0; 469 tz->trips.passive.flags.valid = 0;
470 }
468 else 471 else
469 tz->trips.passive.flags.valid = 1; 472 tz->trips.passive.flags.valid = 1;
470 473
@@ -488,7 +491,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
488 if (act == -1) 491 if (act == -1)
489 break; /* disable all active trip points */ 492 break; /* disable all active trip points */
490 493
491 if (flag & ACPI_TRIPS_ACTIVE) { 494 if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) &&
495 tz->trips.active[i].flags.valid)) {
492 status = acpi_evaluate_integer(tz->device->handle, 496 status = acpi_evaluate_integer(tz->device->handle,
493 name, NULL, &tmp); 497 name, NULL, &tmp);
494 if (ACPI_FAILURE(status)) { 498 if (ACPI_FAILURE(status)) {
@@ -522,8 +526,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
522 memset(&devices, 0, sizeof(struct acpi_handle_list)); 526 memset(&devices, 0, sizeof(struct acpi_handle_list));
523 status = acpi_evaluate_reference(tz->device->handle, 527 status = acpi_evaluate_reference(tz->device->handle,
524 name, NULL, &devices); 528 name, NULL, &devices);
525 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status)) {
530 printk(KERN_WARNING PREFIX
531 "Invalid active%d threshold\n", i);
526 tz->trips.active[i].flags.valid = 0; 532 tz->trips.active[i].flags.valid = 0;
533 }
527 else 534 else
528 tz->trips.active[i].flags.valid = 1; 535 tz->trips.active[i].flags.valid = 1;
529 536
@@ -576,7 +583,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
576 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, 583 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
577 tz->trips.critical.flags.enabled); 584 tz->trips.critical.flags.enabled);
578 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 585 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
579 tz->device->dev.bus_id, 586 dev_name(&tz->device->dev),
580 ACPI_THERMAL_NOTIFY_CRITICAL, 587 ACPI_THERMAL_NOTIFY_CRITICAL,
581 tz->trips.critical.flags.enabled); 588 tz->trips.critical.flags.enabled);
582 589
@@ -605,7 +612,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
605 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, 612 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
606 tz->trips.hot.flags.enabled); 613 tz->trips.hot.flags.enabled);
607 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 614 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
608 tz->device->dev.bus_id, 615 dev_name(&tz->device->dev),
609 ACPI_THERMAL_NOTIFY_HOT, 616 ACPI_THERMAL_NOTIFY_HOT,
610 tz->trips.hot.flags.enabled); 617 tz->trips.hot.flags.enabled);
611 618
@@ -1592,14 +1599,14 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1592 acpi_thermal_check(tz); 1599 acpi_thermal_check(tz);
1593 acpi_bus_generate_proc_event(device, event, 0); 1600 acpi_bus_generate_proc_event(device, event, 0);
1594 acpi_bus_generate_netlink_event(device->pnp.device_class, 1601 acpi_bus_generate_netlink_event(device->pnp.device_class,
1595 device->dev.bus_id, event, 0); 1602 dev_name(&device->dev), event, 0);
1596 break; 1603 break;
1597 case ACPI_THERMAL_NOTIFY_DEVICES: 1604 case ACPI_THERMAL_NOTIFY_DEVICES:
1598 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); 1605 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
1599 acpi_thermal_check(tz); 1606 acpi_thermal_check(tz);
1600 acpi_bus_generate_proc_event(device, event, 0); 1607 acpi_bus_generate_proc_event(device, event, 0);
1601 acpi_bus_generate_netlink_event(device->pnp.device_class, 1608 acpi_bus_generate_netlink_event(device->pnp.device_class,
1602 device->dev.bus_id, event, 0); 1609 dev_name(&device->dev), event, 0);
1603 break; 1610 break;
1604 default: 1611 default:
1605 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1612 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
deleted file mode 100644
index 66aac06f2ac5..000000000000
--- a/drivers/acpi/toshiba_acpi.c
+++ /dev/null
@@ -1,861 +0,0 @@
1/*
2 * toshiba_acpi.c - Toshiba Laptop ACPI Extras
3 *
4 *
5 * Copyright (C) 2002-2004 John Belmonte
6 * Copyright (C) 2008 Philip Langdale
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 *
23 * The devolpment page for this driver is located at
24 * http://memebeam.org/toys/ToshibaAcpiDriver.
25 *
26 * Credits:
27 * Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
28 * engineering the Windows drivers
29 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
30 * Rob Miller - TV out and hotkeys help
31 *
32 *
33 * TODO
34 *
35 */
36
37#define TOSHIBA_ACPI_VERSION "0.19"
38#define PROC_INTERFACE_VERSION 1
39
40#include <linux/kernel.h>
41#include <linux/module.h>
42#include <linux/init.h>
43#include <linux/types.h>
44#include <linux/proc_fs.h>
45#include <linux/backlight.h>
46#include <linux/platform_device.h>
47#include <linux/rfkill.h>
48#include <linux/input-polldev.h>
49
50#include <asm/uaccess.h>
51
52#include <acpi/acpi_drivers.h>
53
54MODULE_AUTHOR("John Belmonte");
55MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
56MODULE_LICENSE("GPL");
57
58#define MY_LOGPREFIX "toshiba_acpi: "
59#define MY_ERR KERN_ERR MY_LOGPREFIX
60#define MY_NOTICE KERN_NOTICE MY_LOGPREFIX
61#define MY_INFO KERN_INFO MY_LOGPREFIX
62
63/* Toshiba ACPI method paths */
64#define METHOD_LCD_BRIGHTNESS "\\_SB_.PCI0.VGA_.LCD_._BCM"
65#define METHOD_HCI_1 "\\_SB_.VALD.GHCI"
66#define METHOD_HCI_2 "\\_SB_.VALZ.GHCI"
67#define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX"
68
69/* Toshiba HCI interface definitions
70 *
71 * HCI is Toshiba's "Hardware Control Interface" which is supposed to
72 * be uniform across all their models. Ideally we would just call
73 * dedicated ACPI methods instead of using this primitive interface.
74 * However the ACPI methods seem to be incomplete in some areas (for
75 * example they allow setting, but not reading, the LCD brightness value),
76 * so this is still useful.
77 */
78
79#define HCI_WORDS 6
80
81/* operations */
82#define HCI_SET 0xff00
83#define HCI_GET 0xfe00
84
85/* return codes */
86#define HCI_SUCCESS 0x0000
87#define HCI_FAILURE 0x1000
88#define HCI_NOT_SUPPORTED 0x8000
89#define HCI_EMPTY 0x8c00
90
91/* registers */
92#define HCI_FAN 0x0004
93#define HCI_SYSTEM_EVENT 0x0016
94#define HCI_VIDEO_OUT 0x001c
95#define HCI_HOTKEY_EVENT 0x001e
96#define HCI_LCD_BRIGHTNESS 0x002a
97#define HCI_WIRELESS 0x0056
98
99/* field definitions */
100#define HCI_LCD_BRIGHTNESS_BITS 3
101#define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
102#define HCI_LCD_BRIGHTNESS_LEVELS (1 << HCI_LCD_BRIGHTNESS_BITS)
103#define HCI_VIDEO_OUT_LCD 0x1
104#define HCI_VIDEO_OUT_CRT 0x2
105#define HCI_VIDEO_OUT_TV 0x4
106#define HCI_WIRELESS_KILL_SWITCH 0x01
107#define HCI_WIRELESS_BT_PRESENT 0x0f
108#define HCI_WIRELESS_BT_ATTACH 0x40
109#define HCI_WIRELESS_BT_POWER 0x80
110
111static const struct acpi_device_id toshiba_device_ids[] = {
112 {"TOS6200", 0},
113 {"TOS6208", 0},
114 {"TOS1900", 0},
115 {"", 0},
116};
117MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
118
119/* utility
120 */
121
122static __inline__ void _set_bit(u32 * word, u32 mask, int value)
123{
124 *word = (*word & ~mask) | (mask * value);
125}
126
127/* acpi interface wrappers
128 */
129
130static int is_valid_acpi_path(const char *methodName)
131{
132 acpi_handle handle;
133 acpi_status status;
134
135 status = acpi_get_handle(NULL, (char *)methodName, &handle);
136 return !ACPI_FAILURE(status);
137}
138
139static int write_acpi_int(const char *methodName, int val)
140{
141 struct acpi_object_list params;
142 union acpi_object in_objs[1];
143 acpi_status status;
144
145 params.count = ARRAY_SIZE(in_objs);
146 params.pointer = in_objs;
147 in_objs[0].type = ACPI_TYPE_INTEGER;
148 in_objs[0].integer.value = val;
149
150 status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
151 return (status == AE_OK);
152}
153
154#if 0
155static int read_acpi_int(const char *methodName, int *pVal)
156{
157 struct acpi_buffer results;
158 union acpi_object out_objs[1];
159 acpi_status status;
160
161 results.length = sizeof(out_objs);
162 results.pointer = out_objs;
163
164 status = acpi_evaluate_object(0, (char *)methodName, 0, &results);
165 *pVal = out_objs[0].integer.value;
166
167 return (status == AE_OK) && (out_objs[0].type == ACPI_TYPE_INTEGER);
168}
169#endif
170
171static const char *method_hci /*= 0*/ ;
172
173/* Perform a raw HCI call. Here we don't care about input or output buffer
174 * format.
175 */
176static acpi_status hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
177{
178 struct acpi_object_list params;
179 union acpi_object in_objs[HCI_WORDS];
180 struct acpi_buffer results;
181 union acpi_object out_objs[HCI_WORDS + 1];
182 acpi_status status;
183 int i;
184
185 params.count = HCI_WORDS;
186 params.pointer = in_objs;
187 for (i = 0; i < HCI_WORDS; ++i) {
188 in_objs[i].type = ACPI_TYPE_INTEGER;
189 in_objs[i].integer.value = in[i];
190 }
191
192 results.length = sizeof(out_objs);
193 results.pointer = out_objs;
194
195 status = acpi_evaluate_object(NULL, (char *)method_hci, &params,
196 &results);
197 if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) {
198 for (i = 0; i < out_objs->package.count; ++i) {
199 out[i] = out_objs->package.elements[i].integer.value;
200 }
201 }
202
203 return status;
204}
205
206/* common hci tasks (get or set one or two value)
207 *
208 * In addition to the ACPI status, the HCI system returns a result which
209 * may be useful (such as "not supported").
210 */
211
212static acpi_status hci_write1(u32 reg, u32 in1, u32 * result)
213{
214 u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 };
215 u32 out[HCI_WORDS];
216 acpi_status status = hci_raw(in, out);
217 *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
218 return status;
219}
220
221static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result)
222{
223 u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 };
224 u32 out[HCI_WORDS];
225 acpi_status status = hci_raw(in, out);
226 *out1 = out[2];
227 *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
228 return status;
229}
230
231static acpi_status hci_write2(u32 reg, u32 in1, u32 in2, u32 *result)
232{
233 u32 in[HCI_WORDS] = { HCI_SET, reg, in1, in2, 0, 0 };
234 u32 out[HCI_WORDS];
235 acpi_status status = hci_raw(in, out);
236 *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
237 return status;
238}
239
240static acpi_status hci_read2(u32 reg, u32 *out1, u32 *out2, u32 *result)
241{
242 u32 in[HCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 };
243 u32 out[HCI_WORDS];
244 acpi_status status = hci_raw(in, out);
245 *out1 = out[2];
246 *out2 = out[3];
247 *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
248 return status;
249}
250
251struct toshiba_acpi_dev {
252 struct platform_device *p_dev;
253 struct rfkill *rfk_dev;
254 struct input_polled_dev *poll_dev;
255
256 const char *bt_name;
257 const char *rfk_name;
258
259 bool last_rfk_state;
260
261 struct mutex mutex;
262};
263
264static struct toshiba_acpi_dev toshiba_acpi = {
265 .bt_name = "Toshiba Bluetooth",
266 .rfk_name = "Toshiba RFKill Switch",
267 .last_rfk_state = false,
268};
269
270/* Bluetooth rfkill handlers */
271
272static u32 hci_get_bt_present(bool *present)
273{
274 u32 hci_result;
275 u32 value, value2;
276
277 value = 0;
278 value2 = 0;
279 hci_read2(HCI_WIRELESS, &value, &value2, &hci_result);
280 if (hci_result == HCI_SUCCESS)
281 *present = (value & HCI_WIRELESS_BT_PRESENT) ? true : false;
282
283 return hci_result;
284}
285
286static u32 hci_get_bt_on(bool *on)
287{
288 u32 hci_result;
289 u32 value, value2;
290
291 value = 0;
292 value2 = 0x0001;
293 hci_read2(HCI_WIRELESS, &value, &value2, &hci_result);
294 if (hci_result == HCI_SUCCESS)
295 *on = (value & HCI_WIRELESS_BT_POWER) &&
296 (value & HCI_WIRELESS_BT_ATTACH);
297
298 return hci_result;
299}
300
301static u32 hci_get_radio_state(bool *radio_state)
302{
303 u32 hci_result;
304 u32 value, value2;
305
306 value = 0;
307 value2 = 0x0001;
308 hci_read2(HCI_WIRELESS, &value, &value2, &hci_result);
309
310 *radio_state = value & HCI_WIRELESS_KILL_SWITCH;
311 return hci_result;
312}
313
314static int bt_rfkill_toggle_radio(void *data, enum rfkill_state state)
315{
316 u32 result1, result2;
317 u32 value;
318 bool radio_state;
319 struct toshiba_acpi_dev *dev = data;
320
321 value = (state == RFKILL_STATE_UNBLOCKED);
322
323 if (hci_get_radio_state(&radio_state) != HCI_SUCCESS)
324 return -EFAULT;
325
326 switch (state) {
327 case RFKILL_STATE_UNBLOCKED:
328 if (!radio_state)
329 return -EPERM;
330 break;
331 case RFKILL_STATE_SOFT_BLOCKED:
332 break;
333 default:
334 return -EINVAL;
335 }
336
337 mutex_lock(&dev->mutex);
338 hci_write2(HCI_WIRELESS, value, HCI_WIRELESS_BT_POWER, &result1);
339 hci_write2(HCI_WIRELESS, value, HCI_WIRELESS_BT_ATTACH, &result2);
340 mutex_unlock(&dev->mutex);
341
342 if (result1 != HCI_SUCCESS || result2 != HCI_SUCCESS)
343 return -EFAULT;
344
345 return 0;
346}
347
348static void bt_poll_rfkill(struct input_polled_dev *poll_dev)
349{
350 bool state_changed;
351 bool new_rfk_state;
352 bool value;
353 u32 hci_result;
354 struct toshiba_acpi_dev *dev = poll_dev->private;
355
356 hci_result = hci_get_radio_state(&value);
357 if (hci_result != HCI_SUCCESS)
358 return; /* Can't do anything useful */
359
360 new_rfk_state = value;
361
362 mutex_lock(&dev->mutex);
363 state_changed = new_rfk_state != dev->last_rfk_state;
364 dev->last_rfk_state = new_rfk_state;
365 mutex_unlock(&dev->mutex);
366
367 if (unlikely(state_changed)) {
368 rfkill_force_state(dev->rfk_dev,
369 new_rfk_state ?
370 RFKILL_STATE_SOFT_BLOCKED :
371 RFKILL_STATE_HARD_BLOCKED);
372 input_report_switch(poll_dev->input, SW_RFKILL_ALL,
373 new_rfk_state);
374 input_sync(poll_dev->input);
375 }
376}
377
378static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ;
379static struct backlight_device *toshiba_backlight_device;
380static int force_fan;
381static int last_key_event;
382static int key_event_valid;
383
384typedef struct _ProcItem {
385 const char *name;
386 char *(*read_func) (char *);
387 unsigned long (*write_func) (const char *, unsigned long);
388} ProcItem;
389
390/* proc file handlers
391 */
392
393static int
394dispatch_read(char *page, char **start, off_t off, int count, int *eof,
395 ProcItem * item)
396{
397 char *p = page;
398 int len;
399
400 if (off == 0)
401 p = item->read_func(p);
402
403 /* ISSUE: I don't understand this code */
404 len = (p - page);
405 if (len <= off + count)
406 *eof = 1;
407 *start = page + off;
408 len -= off;
409 if (len > count)
410 len = count;
411 if (len < 0)
412 len = 0;
413 return len;
414}
415
416static int
417dispatch_write(struct file *file, const char __user * buffer,
418 unsigned long count, ProcItem * item)
419{
420 int result;
421 char *tmp_buffer;
422
423 /* Arg buffer points to userspace memory, which can't be accessed
424 * directly. Since we're making a copy, zero-terminate the
425 * destination so that sscanf can be used on it safely.
426 */
427 tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
428 if (!tmp_buffer)
429 return -ENOMEM;
430
431 if (copy_from_user(tmp_buffer, buffer, count)) {
432 result = -EFAULT;
433 } else {
434 tmp_buffer[count] = 0;
435 result = item->write_func(tmp_buffer, count);
436 }
437 kfree(tmp_buffer);
438 return result;
439}
440
441static int get_lcd(struct backlight_device *bd)
442{
443 u32 hci_result;
444 u32 value;
445
446 hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result);
447 if (hci_result == HCI_SUCCESS) {
448 return (value >> HCI_LCD_BRIGHTNESS_SHIFT);
449 } else
450 return -EFAULT;
451}
452
453static char *read_lcd(char *p)
454{
455 int value = get_lcd(NULL);
456
457 if (value >= 0) {
458 p += sprintf(p, "brightness: %d\n", value);
459 p += sprintf(p, "brightness_levels: %d\n",
460 HCI_LCD_BRIGHTNESS_LEVELS);
461 } else {
462 printk(MY_ERR "Error reading LCD brightness\n");
463 }
464
465 return p;
466}
467
468static int set_lcd(int value)
469{
470 u32 hci_result;
471
472 value = value << HCI_LCD_BRIGHTNESS_SHIFT;
473 hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result);
474 if (hci_result != HCI_SUCCESS)
475 return -EFAULT;
476
477 return 0;
478}
479
480static int set_lcd_status(struct backlight_device *bd)
481{
482 return set_lcd(bd->props.brightness);
483}
484
485static unsigned long write_lcd(const char *buffer, unsigned long count)
486{
487 int value;
488 int ret;
489
490 if (sscanf(buffer, " brightness : %i", &value) == 1 &&
491 value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) {
492 ret = set_lcd(value);
493 if (ret == 0)
494 ret = count;
495 } else {
496 ret = -EINVAL;
497 }
498 return ret;
499}
500
501static char *read_video(char *p)
502{
503 u32 hci_result;
504 u32 value;
505
506 hci_read1(HCI_VIDEO_OUT, &value, &hci_result);
507 if (hci_result == HCI_SUCCESS) {
508 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
509 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
510 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0;
511 p += sprintf(p, "lcd_out: %d\n", is_lcd);
512 p += sprintf(p, "crt_out: %d\n", is_crt);
513 p += sprintf(p, "tv_out: %d\n", is_tv);
514 } else {
515 printk(MY_ERR "Error reading video out status\n");
516 }
517
518 return p;
519}
520
521static unsigned long write_video(const char *buffer, unsigned long count)
522{
523 int value;
524 int remain = count;
525 int lcd_out = -1;
526 int crt_out = -1;
527 int tv_out = -1;
528 u32 hci_result;
529 u32 video_out;
530
531 /* scan expression. Multiple expressions may be delimited with ;
532 *
533 * NOTE: to keep scanning simple, invalid fields are ignored
534 */
535 while (remain) {
536 if (sscanf(buffer, " lcd_out : %i", &value) == 1)
537 lcd_out = value & 1;
538 else if (sscanf(buffer, " crt_out : %i", &value) == 1)
539 crt_out = value & 1;
540 else if (sscanf(buffer, " tv_out : %i", &value) == 1)
541 tv_out = value & 1;
542 /* advance to one character past the next ; */
543 do {
544 ++buffer;
545 --remain;
546 }
547 while (remain && *(buffer - 1) != ';');
548 }
549
550 hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result);
551 if (hci_result == HCI_SUCCESS) {
552 unsigned int new_video_out = video_out;
553 if (lcd_out != -1)
554 _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out);
555 if (crt_out != -1)
556 _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out);
557 if (tv_out != -1)
558 _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out);
559 /* To avoid unnecessary video disruption, only write the new
560 * video setting if something changed. */
561 if (new_video_out != video_out)
562 write_acpi_int(METHOD_VIDEO_OUT, new_video_out);
563 } else {
564 return -EFAULT;
565 }
566
567 return count;
568}
569
570static char *read_fan(char *p)
571{
572 u32 hci_result;
573 u32 value;
574
575 hci_read1(HCI_FAN, &value, &hci_result);
576 if (hci_result == HCI_SUCCESS) {
577 p += sprintf(p, "running: %d\n", (value > 0));
578 p += sprintf(p, "force_on: %d\n", force_fan);
579 } else {
580 printk(MY_ERR "Error reading fan status\n");
581 }
582
583 return p;
584}
585
586static unsigned long write_fan(const char *buffer, unsigned long count)
587{
588 int value;
589 u32 hci_result;
590
591 if (sscanf(buffer, " force_on : %i", &value) == 1 &&
592 value >= 0 && value <= 1) {
593 hci_write1(HCI_FAN, value, &hci_result);
594 if (hci_result != HCI_SUCCESS)
595 return -EFAULT;
596 else
597 force_fan = value;
598 } else {
599 return -EINVAL;
600 }
601
602 return count;
603}
604
605static char *read_keys(char *p)
606{
607 u32 hci_result;
608 u32 value;
609
610 if (!key_event_valid) {
611 hci_read1(HCI_SYSTEM_EVENT, &value, &hci_result);
612 if (hci_result == HCI_SUCCESS) {
613 key_event_valid = 1;
614 last_key_event = value;
615 } else if (hci_result == HCI_EMPTY) {
616 /* better luck next time */
617 } else if (hci_result == HCI_NOT_SUPPORTED) {
618 /* This is a workaround for an unresolved issue on
619 * some machines where system events sporadically
620 * become disabled. */
621 hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result);
622 printk(MY_NOTICE "Re-enabled hotkeys\n");
623 } else {
624 printk(MY_ERR "Error reading hotkey status\n");
625 goto end;
626 }
627 }
628
629 p += sprintf(p, "hotkey_ready: %d\n", key_event_valid);
630 p += sprintf(p, "hotkey: 0x%04x\n", last_key_event);
631
632 end:
633 return p;
634}
635
636static unsigned long write_keys(const char *buffer, unsigned long count)
637{
638 int value;
639
640 if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && value == 0) {
641 key_event_valid = 0;
642 } else {
643 return -EINVAL;
644 }
645
646 return count;
647}
648
649static char *read_version(char *p)
650{
651 p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION);
652 p += sprintf(p, "proc_interface: %d\n",
653 PROC_INTERFACE_VERSION);
654 return p;
655}
656
657/* proc and module init
658 */
659
660#define PROC_TOSHIBA "toshiba"
661
662static ProcItem proc_items[] = {
663 {"lcd", read_lcd, write_lcd},
664 {"video", read_video, write_video},
665 {"fan", read_fan, write_fan},
666 {"keys", read_keys, write_keys},
667 {"version", read_version, NULL},
668 {NULL}
669};
670
671static acpi_status __init add_device(void)
672{
673 struct proc_dir_entry *proc;
674 ProcItem *item;
675
676 for (item = proc_items; item->name; ++item) {
677 proc = create_proc_read_entry(item->name,
678 S_IFREG | S_IRUGO | S_IWUSR,
679 toshiba_proc_dir,
680 (read_proc_t *) dispatch_read,
681 item);
682 if (proc)
683 proc->owner = THIS_MODULE;
684 if (proc && item->write_func)
685 proc->write_proc = (write_proc_t *) dispatch_write;
686 }
687
688 return AE_OK;
689}
690
691static acpi_status remove_device(void)
692{
693 ProcItem *item;
694
695 for (item = proc_items; item->name; ++item)
696 remove_proc_entry(item->name, toshiba_proc_dir);
697 return AE_OK;
698}
699
700static struct backlight_ops toshiba_backlight_data = {
701 .get_brightness = get_lcd,
702 .update_status = set_lcd_status,
703};
704
705static void toshiba_acpi_exit(void)
706{
707 if (toshiba_acpi.poll_dev) {
708 input_unregister_polled_device(toshiba_acpi.poll_dev);
709 input_free_polled_device(toshiba_acpi.poll_dev);
710 }
711
712 if (toshiba_acpi.rfk_dev)
713 rfkill_unregister(toshiba_acpi.rfk_dev);
714
715 if (toshiba_backlight_device)
716 backlight_device_unregister(toshiba_backlight_device);
717
718 remove_device();
719
720 if (toshiba_proc_dir)
721 remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
722
723 platform_device_unregister(toshiba_acpi.p_dev);
724
725 return;
726}
727
728static int __init toshiba_acpi_init(void)
729{
730 acpi_status status = AE_OK;
731 u32 hci_result;
732 bool bt_present;
733 bool bt_on;
734 bool radio_on;
735 int ret = 0;
736
737 if (acpi_disabled)
738 return -ENODEV;
739
740 /* simple device detection: look for HCI method */
741 if (is_valid_acpi_path(METHOD_HCI_1))
742 method_hci = METHOD_HCI_1;
743 else if (is_valid_acpi_path(METHOD_HCI_2))
744 method_hci = METHOD_HCI_2;
745 else
746 return -ENODEV;
747
748 printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n",
749 TOSHIBA_ACPI_VERSION);
750 printk(MY_INFO " HCI method: %s\n", method_hci);
751
752 mutex_init(&toshiba_acpi.mutex);
753
754 toshiba_acpi.p_dev = platform_device_register_simple("toshiba_acpi",
755 -1, NULL, 0);
756 if (IS_ERR(toshiba_acpi.p_dev)) {
757 ret = PTR_ERR(toshiba_acpi.p_dev);
758 printk(MY_ERR "unable to register platform device\n");
759 toshiba_acpi.p_dev = NULL;
760 toshiba_acpi_exit();
761 return ret;
762 }
763
764 force_fan = 0;
765 key_event_valid = 0;
766
767 /* enable event fifo */
768 hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result);
769
770 toshiba_proc_dir = proc_mkdir(PROC_TOSHIBA, acpi_root_dir);
771 if (!toshiba_proc_dir) {
772 toshiba_acpi_exit();
773 return -ENODEV;
774 } else {
775 toshiba_proc_dir->owner = THIS_MODULE;
776 status = add_device();
777 if (ACPI_FAILURE(status)) {
778 toshiba_acpi_exit();
779 return -ENODEV;
780 }
781 }
782
783 toshiba_backlight_device = backlight_device_register("toshiba",
784 &toshiba_acpi.p_dev->dev,
785 NULL,
786 &toshiba_backlight_data);
787 if (IS_ERR(toshiba_backlight_device)) {
788 ret = PTR_ERR(toshiba_backlight_device);
789
790 printk(KERN_ERR "Could not register toshiba backlight device\n");
791 toshiba_backlight_device = NULL;
792 toshiba_acpi_exit();
793 return ret;
794 }
795 toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
796
797 /* Register rfkill switch for Bluetooth */
798 if (hci_get_bt_present(&bt_present) == HCI_SUCCESS && bt_present) {
799 toshiba_acpi.rfk_dev = rfkill_allocate(&toshiba_acpi.p_dev->dev,
800 RFKILL_TYPE_BLUETOOTH);
801 if (!toshiba_acpi.rfk_dev) {
802 printk(MY_ERR "unable to allocate rfkill device\n");
803 toshiba_acpi_exit();
804 return -ENOMEM;
805 }
806
807 toshiba_acpi.rfk_dev->name = toshiba_acpi.bt_name;
808 toshiba_acpi.rfk_dev->toggle_radio = bt_rfkill_toggle_radio;
809 toshiba_acpi.rfk_dev->user_claim_unsupported = 1;
810 toshiba_acpi.rfk_dev->data = &toshiba_acpi;
811
812 if (hci_get_bt_on(&bt_on) == HCI_SUCCESS && bt_on) {
813 toshiba_acpi.rfk_dev->state = RFKILL_STATE_UNBLOCKED;
814 } else if (hci_get_radio_state(&radio_on) == HCI_SUCCESS &&
815 radio_on) {
816 toshiba_acpi.rfk_dev->state = RFKILL_STATE_SOFT_BLOCKED;
817 } else {
818 toshiba_acpi.rfk_dev->state = RFKILL_STATE_HARD_BLOCKED;
819 }
820
821 ret = rfkill_register(toshiba_acpi.rfk_dev);
822 if (ret) {
823 printk(MY_ERR "unable to register rfkill device\n");
824 toshiba_acpi_exit();
825 return -ENOMEM;
826 }
827 }
828
829 /* Register input device for kill switch */
830 toshiba_acpi.poll_dev = input_allocate_polled_device();
831 if (!toshiba_acpi.poll_dev) {
832 printk(MY_ERR "unable to allocate kill-switch input device\n");
833 toshiba_acpi_exit();
834 return -ENOMEM;
835 }
836 toshiba_acpi.poll_dev->private = &toshiba_acpi;
837 toshiba_acpi.poll_dev->poll = bt_poll_rfkill;
838 toshiba_acpi.poll_dev->poll_interval = 1000; /* msecs */
839
840 toshiba_acpi.poll_dev->input->name = toshiba_acpi.rfk_name;
841 toshiba_acpi.poll_dev->input->id.bustype = BUS_HOST;
842 toshiba_acpi.poll_dev->input->id.vendor = 0x0930; /* Toshiba USB ID */
843 set_bit(EV_SW, toshiba_acpi.poll_dev->input->evbit);
844 set_bit(SW_RFKILL_ALL, toshiba_acpi.poll_dev->input->swbit);
845 input_report_switch(toshiba_acpi.poll_dev->input, SW_RFKILL_ALL, TRUE);
846 input_sync(toshiba_acpi.poll_dev->input);
847
848 ret = input_register_polled_device(toshiba_acpi.poll_dev);
849 if (ret) {
850 printk(MY_ERR "unable to register kill-switch input device\n");
851 rfkill_free(toshiba_acpi.rfk_dev);
852 toshiba_acpi.rfk_dev = NULL;
853 toshiba_acpi_exit();
854 return ret;
855 }
856
857 return 0;
858}
859
860module_init(toshiba_acpi_init);
861module_exit(toshiba_acpi_exit);
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
deleted file mode 100644
index 88eff14c4894..000000000000
--- a/drivers/acpi/utilities/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utcache.o utresrc.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
deleted file mode 100644
index 245fa80cf600..000000000000
--- a/drivers/acpi/utilities/utcache.c
+++ /dev/null
@@ -1,314 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utcache - local cache allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utcache")
48#ifdef ACPI_USE_LOCAL_CACHE
49/*******************************************************************************
50 *
51 * FUNCTION: acpi_os_create_cache
52 *
53 * PARAMETERS: cache_name - Ascii name for the cache
54 * object_size - Size of each cached object
55 * max_depth - Maximum depth of the cache (in objects)
56 * return_cache - Where the new cache object is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Create a cache object
61 *
62 ******************************************************************************/
63acpi_status
64acpi_os_create_cache(char *cache_name,
65 u16 object_size,
66 u16 max_depth, struct acpi_memory_list ** return_cache)
67{
68 struct acpi_memory_list *cache;
69
70 ACPI_FUNCTION_ENTRY();
71
72 if (!cache_name || !return_cache || (object_size < 16)) {
73 return (AE_BAD_PARAMETER);
74 }
75
76 /* Create the cache object */
77
78 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
79 if (!cache) {
80 return (AE_NO_MEMORY);
81 }
82
83 /* Populate the cache object and return it */
84
85 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
86 cache->link_offset = 8;
87 cache->list_name = cache_name;
88 cache->object_size = object_size;
89 cache->max_depth = max_depth;
90
91 *return_cache = cache;
92 return (AE_OK);
93}
94
95/*******************************************************************************
96 *
97 * FUNCTION: acpi_os_purge_cache
98 *
99 * PARAMETERS: Cache - Handle to cache object
100 *
101 * RETURN: Status
102 *
103 * DESCRIPTION: Free all objects within the requested cache.
104 *
105 ******************************************************************************/
106
107acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
108{
109 char *next;
110
111 ACPI_FUNCTION_ENTRY();
112
113 if (!cache) {
114 return (AE_BAD_PARAMETER);
115 }
116
117 /* Walk the list of objects in this cache */
118
119 while (cache->list_head) {
120
121 /* Delete and unlink one cached state object */
122
123 next = *(ACPI_CAST_INDIRECT_PTR(char,
124 &(((char *)cache->
125 list_head)[cache->
126 link_offset])));
127 ACPI_FREE(cache->list_head);
128
129 cache->list_head = next;
130 cache->current_depth--;
131 }
132
133 return (AE_OK);
134}
135
136/*******************************************************************************
137 *
138 * FUNCTION: acpi_os_delete_cache
139 *
140 * PARAMETERS: Cache - Handle to cache object
141 *
142 * RETURN: Status
143 *
144 * DESCRIPTION: Free all objects within the requested cache and delete the
145 * cache object.
146 *
147 ******************************************************************************/
148
149acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
150{
151 acpi_status status;
152
153 ACPI_FUNCTION_ENTRY();
154
155 /* Purge all objects in the cache */
156
157 status = acpi_os_purge_cache(cache);
158 if (ACPI_FAILURE(status)) {
159 return (status);
160 }
161
162 /* Now we can delete the cache object */
163
164 ACPI_FREE(cache);
165 return (AE_OK);
166}
167
168/*******************************************************************************
169 *
170 * FUNCTION: acpi_os_release_object
171 *
172 * PARAMETERS: Cache - Handle to cache object
173 * Object - The object to be released
174 *
175 * RETURN: None
176 *
177 * DESCRIPTION: Release an object to the specified cache. If cache is full,
178 * the object is deleted.
179 *
180 ******************************************************************************/
181
182acpi_status
183acpi_os_release_object(struct acpi_memory_list * cache, void *object)
184{
185 acpi_status status;
186
187 ACPI_FUNCTION_ENTRY();
188
189 if (!cache || !object) {
190 return (AE_BAD_PARAMETER);
191 }
192
193 /* If cache is full, just free this object */
194
195 if (cache->current_depth >= cache->max_depth) {
196 ACPI_FREE(object);
197 ACPI_MEM_TRACKING(cache->total_freed++);
198 }
199
200 /* Otherwise put this object back into the cache */
201
202 else {
203 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
204 if (ACPI_FAILURE(status)) {
205 return (status);
206 }
207
208 /* Mark the object as cached */
209
210 ACPI_MEMSET(object, 0xCA, cache->object_size);
211 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
212
213 /* Put the object at the head of the cache list */
214
215 *(ACPI_CAST_INDIRECT_PTR(char,
216 &(((char *)object)[cache->
217 link_offset]))) =
218 cache->list_head;
219 cache->list_head = object;
220 cache->current_depth++;
221
222 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
223 }
224
225 return (AE_OK);
226}
227
228/*******************************************************************************
229 *
230 * FUNCTION: acpi_os_acquire_object
231 *
232 * PARAMETERS: Cache - Handle to cache object
233 *
234 * RETURN: the acquired object. NULL on error
235 *
236 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
237 * the object is allocated.
238 *
239 ******************************************************************************/
240
241void *acpi_os_acquire_object(struct acpi_memory_list *cache)
242{
243 acpi_status status;
244 void *object;
245
246 ACPI_FUNCTION_NAME(os_acquire_object);
247
248 if (!cache) {
249 return (NULL);
250 }
251
252 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
253 if (ACPI_FAILURE(status)) {
254 return (NULL);
255 }
256
257 ACPI_MEM_TRACKING(cache->requests++);
258
259 /* Check the cache first */
260
261 if (cache->list_head) {
262
263 /* There is an object available, use it */
264
265 object = cache->list_head;
266 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
267 &(((char *)
268 object)[cache->
269 link_offset])));
270
271 cache->current_depth--;
272
273 ACPI_MEM_TRACKING(cache->hits++);
274 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
275 "Object %p from %s cache\n", object,
276 cache->list_name));
277
278 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
279 if (ACPI_FAILURE(status)) {
280 return (NULL);
281 }
282
283 /* Clear (zero) the previously used Object */
284
285 ACPI_MEMSET(object, 0, cache->object_size);
286 } else {
287 /* The cache is empty, create a new object */
288
289 ACPI_MEM_TRACKING(cache->total_allocated++);
290
291#ifdef ACPI_DBG_TRACK_ALLOCATIONS
292 if ((cache->total_allocated - cache->total_freed) >
293 cache->max_occupied) {
294 cache->max_occupied =
295 cache->total_allocated - cache->total_freed;
296 }
297#endif
298
299 /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
300
301 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
302 if (ACPI_FAILURE(status)) {
303 return (NULL);
304 }
305
306 object = ACPI_ALLOCATE_ZEROED(cache->object_size);
307 if (!object) {
308 return (NULL);
309 }
310 }
311
312 return (object);
313}
314#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index e827be36ee8d..f844941089bb 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -259,34 +259,26 @@ acpi_evaluate_integer(acpi_handle handle,
259 struct acpi_object_list *arguments, unsigned long long *data) 259 struct acpi_object_list *arguments, unsigned long long *data)
260{ 260{
261 acpi_status status = AE_OK; 261 acpi_status status = AE_OK;
262 union acpi_object *element; 262 union acpi_object element;
263 struct acpi_buffer buffer = { 0, NULL }; 263 struct acpi_buffer buffer = { 0, NULL };
264 264
265
266 if (!data) 265 if (!data)
267 return AE_BAD_PARAMETER; 266 return AE_BAD_PARAMETER;
268 267
269 element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
270 if (!element)
271 return AE_NO_MEMORY;
272
273 buffer.length = sizeof(union acpi_object); 268 buffer.length = sizeof(union acpi_object);
274 buffer.pointer = element; 269 buffer.pointer = &element;
275 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); 270 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
276 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
277 acpi_util_eval_error(handle, pathname, status); 272 acpi_util_eval_error(handle, pathname, status);
278 kfree(element);
279 return status; 273 return status;
280 } 274 }
281 275
282 if (element->type != ACPI_TYPE_INTEGER) { 276 if (element.type != ACPI_TYPE_INTEGER) {
283 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 277 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
284 kfree(element);
285 return AE_BAD_DATA; 278 return AE_BAD_DATA;
286 } 279 }
287 280
288 *data = element->integer.value; 281 *data = element.integer.value;
289 kfree(element);
290 282
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data)); 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data));
292 284
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index a29b0ccac65a..bb5ed059114a 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -36,12 +36,12 @@
36#include <linux/backlight.h> 36#include <linux/backlight.h>
37#include <linux/thermal.h> 37#include <linux/thermal.h>
38#include <linux/video_output.h> 38#include <linux/video_output.h>
39#include <linux/sort.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
41#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
42#include <acpi/acpi_drivers.h> 43#include <acpi/acpi_drivers.h>
43 44
44#define ACPI_VIDEO_COMPONENT 0x08000000
45#define ACPI_VIDEO_CLASS "video" 45#define ACPI_VIDEO_CLASS "video"
46#define ACPI_VIDEO_BUS_NAME "Video Bus" 46#define ACPI_VIDEO_BUS_NAME "Video Bus"
47#define ACPI_VIDEO_DEVICE_NAME "Video Device" 47#define ACPI_VIDEO_DEVICE_NAME "Video Device"
@@ -482,6 +482,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
482 int status = AE_OK; 482 int status = AE_OK;
483 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 483 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
484 struct acpi_object_list args = { 1, &arg0 }; 484 struct acpi_object_list args = { 1, &arg0 };
485 int state;
485 486
486 487
487 arg0.integer.value = level; 488 arg0.integer.value = level;
@@ -490,6 +491,10 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
490 status = acpi_evaluate_object(device->dev->handle, "_BCM", 491 status = acpi_evaluate_object(device->dev->handle, "_BCM",
491 &args, NULL); 492 &args, NULL);
492 device->brightness->curr = level; 493 device->brightness->curr = level;
494 for (state = 2; state < device->brightness->count; state++)
495 if (level == device->brightness->levels[state])
496 device->backlight->props.brightness = state - 2;
497
493 return status; 498 return status;
494} 499}
495 500
@@ -627,6 +632,16 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
627} 632}
628 633
629/* 634/*
635 * Simple comparison function used to sort backlight levels.
636 */
637
638static int
639acpi_video_cmp_level(const void *a, const void *b)
640{
641 return *(int *)a - *(int *)b;
642}
643
644/*
630 * Arg: 645 * Arg:
631 * device : video output device (LCD, CRT, ..) 646 * device : video output device (LCD, CRT, ..)
632 * 647 *
@@ -677,6 +692,10 @@ acpi_video_init_brightness(struct acpi_video_device *device)
677 count++; 692 count++;
678 } 693 }
679 694
695 /* don't sort the first two brightness levels */
696 sort(&br->levels[2], count - 2, sizeof(br->levels[2]),
697 acpi_video_cmp_level, NULL);
698
680 if (count < 2) 699 if (count < 2)
681 goto out_free_levels; 700 goto out_free_levels;
682 701
@@ -739,7 +758,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
739 device->cap._DSS = 1; 758 device->cap._DSS = 1;
740 } 759 }
741 760
742 max_level = acpi_video_init_brightness(device); 761 if (acpi_video_backlight_support())
762 max_level = acpi_video_init_brightness(device);
743 763
744 if (device->cap._BCL && device->cap._BCM && max_level > 0) { 764 if (device->cap._BCL && device->cap._BCM && max_level > 0) {
745 int result; 765 int result;
@@ -785,18 +805,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
785 printk(KERN_ERR PREFIX "Create sysfs link\n"); 805 printk(KERN_ERR PREFIX "Create sysfs link\n");
786 806
787 } 807 }
788 if (device->cap._DCS && device->cap._DSS){ 808
789 static int count = 0; 809 if (acpi_video_display_switch_support()) {
790 char *name; 810
791 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); 811 if (device->cap._DCS && device->cap._DSS) {
792 if (!name) 812 static int count;
793 return; 813 char *name;
794 sprintf(name, "acpi_video%d", count++); 814 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
795 device->output_dev = video_output_register(name, 815 if (!name)
796 NULL, device, &acpi_output_properties); 816 return;
797 kfree(name); 817 sprintf(name, "acpi_video%d", count++);
818 device->output_dev = video_output_register(name,
819 NULL, device, &acpi_output_properties);
820 kfree(name);
821 }
798 } 822 }
799 return;
800} 823}
801 824
802/* 825/*
@@ -842,11 +865,16 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
842static int acpi_video_bus_check(struct acpi_video_bus *video) 865static int acpi_video_bus_check(struct acpi_video_bus *video)
843{ 866{
844 acpi_status status = -ENOENT; 867 acpi_status status = -ENOENT;
845 868 struct device *dev;
846 869
847 if (!video) 870 if (!video)
848 return -EINVAL; 871 return -EINVAL;
849 872
873 dev = acpi_get_physical_pci_device(video->device->handle);
874 if (!dev)
875 return -ENODEV;
876 put_device(dev);
877
850 /* Since there is no HID, CID and so on for VGA driver, we have 878 /* Since there is no HID, CID and so on for VGA driver, we have
851 * to check well known required nodes. 879 * to check well known required nodes.
852 */ 880 */
@@ -992,7 +1020,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
992 } 1020 }
993 1021
994 seq_printf(seq, "levels: "); 1022 seq_printf(seq, "levels: ");
995 for (i = 0; i < dev->brightness->count; i++) 1023 for (i = 2; i < dev->brightness->count; i++)
996 seq_printf(seq, " %d", dev->brightness->levels[i]); 1024 seq_printf(seq, " %d", dev->brightness->levels[i]);
997 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); 1025 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
998 1026
@@ -1031,7 +1059,7 @@ acpi_video_device_write_brightness(struct file *file,
1031 return -EFAULT; 1059 return -EFAULT;
1032 1060
1033 /* validate through the list of available levels */ 1061 /* validate through the list of available levels */
1034 for (i = 0; i < dev->brightness->count; i++) 1062 for (i = 2; i < dev->brightness->count; i++)
1035 if (level == dev->brightness->levels[i]) { 1063 if (level == dev->brightness->levels[i]) {
1036 if (ACPI_SUCCESS 1064 if (ACPI_SUCCESS
1037 (acpi_video_device_lcd_set_level(dev, level))) 1065 (acpi_video_device_lcd_set_level(dev, level)))
@@ -1232,7 +1260,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1232 printk(KERN_WARNING PREFIX 1260 printk(KERN_WARNING PREFIX
1233 "This indicates a BIOS bug. Please contact the manufacturer.\n"); 1261 "This indicates a BIOS bug. Please contact the manufacturer.\n");
1234 } 1262 }
1235 printk("%llx\n", options); 1263 printk(KERN_WARNING "%llx\n", options);
1236 seq_printf(seq, "can POST: <integrated video>"); 1264 seq_printf(seq, "can POST: <integrated video>");
1237 if (options & 2) 1265 if (options & 2)
1238 seq_printf(seq, " <PCI video>"); 1266 seq_printf(seq, " <PCI video>");
@@ -1684,7 +1712,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1684 max = max_below = 0; 1712 max = max_below = 0;
1685 min = min_above = 255; 1713 min = min_above = 255;
1686 /* Find closest level to level_current */ 1714 /* Find closest level to level_current */
1687 for (i = 0; i < device->brightness->count; i++) { 1715 for (i = 2; i < device->brightness->count; i++) {
1688 l = device->brightness->levels[i]; 1716 l = device->brightness->levels[i];
1689 if (abs(l - level_current) < abs(delta)) { 1717 if (abs(l - level_current) < abs(delta)) {
1690 delta = l - level_current; 1718 delta = l - level_current;
@@ -1694,7 +1722,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1694 } 1722 }
1695 /* Ajust level_current to closest available level */ 1723 /* Ajust level_current to closest available level */
1696 level_current += delta; 1724 level_current += delta;
1697 for (i = 0; i < device->brightness->count; i++) { 1725 for (i = 2; i < device->brightness->count; i++) {
1698 l = device->brightness->levels[i]; 1726 l = device->brightness->levels[i];
1699 if (l < min) 1727 if (l < min)
1700 min = l; 1728 min = l;
@@ -1978,6 +2006,12 @@ static int acpi_video_bus_add(struct acpi_device *device)
1978 device->pnp.bus_id[3] = '0' + instance; 2006 device->pnp.bus_id[3] = '0' + instance;
1979 instance ++; 2007 instance ++;
1980 } 2008 }
2009 /* a hack to fix the duplicate name "VGA" problem on Pa 3553 */
2010 if (!strcmp(device->pnp.bus_id, "VGA")) {
2011 if (instance)
2012 device->pnp.bus_id[3] = '0' + instance;
2013 instance++;
2014 }
1981 2015
1982 video->device = device; 2016 video->device = device;
1983 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); 2017 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
@@ -2094,12 +2128,6 @@ static int __init acpi_video_init(void)
2094{ 2128{
2095 int result = 0; 2129 int result = 0;
2096 2130
2097
2098 /*
2099 acpi_dbg_level = 0xFFFFFFFF;
2100 acpi_dbg_layer = 0x08000000;
2101 */
2102
2103 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 2131 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
2104 if (!acpi_video_dir) 2132 if (!acpi_video_dir)
2105 return -ENODEV; 2133 return -ENODEV;
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
new file mode 100644
index 000000000000..50e3d2dbf3af
--- /dev/null
+++ b/drivers/acpi/video_detect.c
@@ -0,0 +1,267 @@
1/*
2 * Copyright (C) 2008 SuSE Linux Products GmbH
3 * Thomas Renninger <trenn@suse.de>
4 *
5 * May be copied or modified under the terms of the GNU General Public License
6 *
7 * video_detect.c:
8 * Provides acpi_is_video_device() for early scanning of ACPI devices in scan.c
9 * There a Linux specific (Spec does not provide a HID for video devices) is
10 * assinged
11 *
12 * After PCI devices are glued with ACPI devices
13 * acpi_get_physical_pci_device() can be called to identify ACPI graphics
14 * devices for which a real graphics card is plugged in
15 *
16 * Now acpi_video_get_capabilities() can be called to check which
17 * capabilities the graphics cards plugged in support. The check for general
18 * video capabilities will be triggered by the first caller of
19 * acpi_video_get_capabilities(NULL); which will happen when the first
20 * backlight (or display output) switching supporting driver calls:
21 * acpi_video_backlight_support();
22 *
23 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B)
24 * are available, video.ko should be used to handle the device.
25 *
26 * Otherwise vendor specific drivers like thinkpad_acpi, asus_acpi,
27 * sony_acpi,... can take care about backlight brightness and display output
28 * switching.
29 *
30 * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m)
31 * this file will not be compiled, acpi_video_get_capabilities() and
32 * acpi_video_backlight_support() will always return 0 and vendor specific
33 * drivers always can handle backlight.
34 *
35 */
36
37#include <linux/acpi.h>
38#include <linux/dmi.h>
39
40ACPI_MODULE_NAME("video");
41#define _COMPONENT ACPI_VIDEO_COMPONENT
42
43static long acpi_video_support;
44static bool acpi_video_caps_checked;
45
46static acpi_status
47acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
48 void **retyurn_value)
49{
50 long *cap = context;
51 acpi_handle h_dummy;
52
53 if (ACPI_SUCCESS(acpi_get_handle(handle, "_BCM", &h_dummy)) &&
54 ACPI_SUCCESS(acpi_get_handle(handle, "_BCL", &h_dummy))) {
55 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight "
56 "support\n"));
57 *cap |= ACPI_VIDEO_BACKLIGHT;
58 /* We have backlight support, no need to scan further */
59 return AE_CTRL_TERMINATE;
60 }
61 return 0;
62}
63
64/* Returns true if the device is a video device which can be handled by
65 * video.ko.
66 * The device will get a Linux specific CID added in scan.c to
67 * identify the device as an ACPI graphics device
68 * Be aware that the graphics device may not be physically present
69 * Use acpi_video_get_capabilities() to detect general ACPI video
70 * capabilities of present cards
71 */
72long acpi_is_video_device(struct acpi_device *device)
73{
74 acpi_handle h_dummy;
75 long video_caps = 0;
76
77 if (!device)
78 return 0;
79
80 /* Does this device able to support video switching ? */
81 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) &&
82 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy)))
83 video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING;
84
85 /* Does this device able to retrieve a video ROM ? */
86 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy)))
87 video_caps |= ACPI_VIDEO_ROM_AVAILABLE;
88
89 /* Does this device able to configure which video head to be POSTed ? */
90 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) &&
91 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) &&
92 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy)))
93 video_caps |= ACPI_VIDEO_DEVICE_POSTING;
94
95 /* Only check for backlight functionality if one of the above hit. */
96 if (video_caps)
97 acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle,
98 ACPI_UINT32_MAX, acpi_backlight_cap_match,
99 &video_caps, NULL);
100
101 return video_caps;
102}
103EXPORT_SYMBOL(acpi_is_video_device);
104
105static acpi_status
106find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
107{
108 long *cap = context;
109 struct device *dev;
110 struct acpi_device *acpi_dev;
111
112 const struct acpi_device_id video_ids[] = {
113 {ACPI_VIDEO_HID, 0},
114 {"", 0},
115 };
116 if (acpi_bus_get_device(handle, &acpi_dev))
117 return AE_OK;
118
119 if (!acpi_match_device_ids(acpi_dev, video_ids)) {
120 dev = acpi_get_physical_pci_device(handle);
121 if (!dev)
122 return AE_OK;
123 put_device(dev);
124 *cap |= acpi_is_video_device(acpi_dev);
125 }
126 return AE_OK;
127}
128
129/*
130 * Returns the video capabilities of a specific ACPI graphics device
131 *
132 * if NULL is passed as argument all ACPI devices are enumerated and
133 * all graphics capabilities of physically present devices are
134 * summerized and returned. This is cached and done only once.
135 */
136long acpi_video_get_capabilities(acpi_handle graphics_handle)
137{
138 long caps = 0;
139 struct acpi_device *tmp_dev;
140 acpi_status status;
141
142 if (acpi_video_caps_checked && graphics_handle == NULL)
143 return acpi_video_support;
144
145 if (!graphics_handle) {
146 /* Only do the global walk through all graphics devices once */
147 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
148 ACPI_UINT32_MAX, find_video,
149 &caps, NULL);
150 /* There might be boot param flags set already... */
151 acpi_video_support |= caps;
152 acpi_video_caps_checked = 1;
153 /* Add blacklists here. Be careful to use the right *DMI* bits
154 * to still be able to override logic via boot params, e.g.:
155 *
156 * if (dmi_name_in_vendors("XY")) {
157 * acpi_video_support |=
158 * ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR;
159 * acpi_video_support |=
160 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
161 *}
162 */
163 } else {
164 status = acpi_bus_get_device(graphics_handle, &tmp_dev);
165 if (ACPI_FAILURE(status)) {
166 ACPI_EXCEPTION((AE_INFO, status, "Invalid device"));
167 return 0;
168 }
169 acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle,
170 ACPI_UINT32_MAX, find_video,
171 &caps, NULL);
172 }
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n",
174 graphics_handle ? caps : acpi_video_support,
175 graphics_handle ? "on device " : "in general",
176 graphics_handle ? acpi_device_bid(tmp_dev) : ""));
177 return caps;
178}
179EXPORT_SYMBOL(acpi_video_get_capabilities);
180
181/* Returns true if video.ko can do backlight switching */
182int acpi_video_backlight_support(void)
183{
184 /*
185 * We must check whether the ACPI graphics device is physically plugged
186 * in. Therefore this must be called after binding PCI and ACPI devices
187 */
188 if (!acpi_video_caps_checked)
189 acpi_video_get_capabilities(NULL);
190
191 /* First check for boot param -> highest prio */
192 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR)
193 return 0;
194 else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO)
195 return 1;
196
197 /* Then check for DMI blacklist -> second highest prio */
198 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VENDOR)
199 return 0;
200 else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VIDEO)
201 return 1;
202
203 /* Then go the default way */
204 return acpi_video_support & ACPI_VIDEO_BACKLIGHT;
205}
206EXPORT_SYMBOL(acpi_video_backlight_support);
207
208/*
209 * Returns true if video.ko can do display output switching.
210 * This does not work well/at all with binary graphics drivers
211 * which disable system io ranges and do it on their own.
212 */
213int acpi_video_display_switch_support(void)
214{
215 if (!acpi_video_caps_checked)
216 acpi_video_get_capabilities(NULL);
217
218 if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR)
219 return 0;
220 else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO)
221 return 1;
222
223 if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR)
224 return 0;
225 else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO)
226 return 1;
227
228 return acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING;
229}
230EXPORT_SYMBOL(acpi_video_display_switch_support);
231
232/*
233 * Use acpi_display_output=vendor/video or acpi_backlight=vendor/video
234 * To force that backlight or display output switching is processed by vendor
235 * specific acpi drivers or video.ko driver.
236 */
237static int __init acpi_backlight(char *str)
238{
239 if (str == NULL || *str == '\0')
240 return 1;
241 else {
242 if (!strcmp("vendor", str))
243 acpi_video_support |=
244 ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR;
245 if (!strcmp("video", str))
246 acpi_video_support |=
247 ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO;
248 }
249 return 1;
250}
251__setup("acpi_backlight=", acpi_backlight);
252
253static int __init acpi_display_output(char *str)
254{
255 if (str == NULL || *str == '\0')
256 return 1;
257 else {
258 if (!strcmp("vendor", str))
259 acpi_video_support |=
260 ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR;
261 if (!strcmp("video", str))
262 acpi_video_support |=
263 ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO;
264 }
265 return 1;
266}
267__setup("acpi_display_output=", acpi_display_output);
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/wakeup.c
index 38655eb132dc..2d34806d45dd 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -8,7 +8,6 @@
8#include <acpi/acpi_drivers.h> 8#include <acpi/acpi_drivers.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/types.h> 10#include <linux/types.h>
11#include <acpi/acevents.h>
12#include "sleep.h" 11#include "sleep.h"
13 12
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 13#define _COMPONENT ACPI_SYSTEM_COMPONENT
@@ -28,8 +27,6 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
28{ 27{
29 struct list_head *node, *next; 28 struct list_head *node, *next;
30 29
31 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep");
32
33 spin_lock(&acpi_device_lock); 30 spin_lock(&acpi_device_lock);
34 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 31 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
35 struct acpi_device *dev = container_of(node, 32 struct acpi_device *dev = container_of(node,
@@ -61,7 +58,6 @@ void acpi_enable_wakeup_device(u8 sleep_state)
61 * Caution: this routine must be invoked when interrupt is disabled 58 * Caution: this routine must be invoked when interrupt is disabled
62 * Refer ACPI2.0: P212 59 * Refer ACPI2.0: P212
63 */ 60 */
64 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
65 spin_lock(&acpi_device_lock); 61 spin_lock(&acpi_device_lock);
66 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 62 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
67 struct acpi_device *dev = 63 struct acpi_device *dev =
@@ -88,7 +84,7 @@ void acpi_enable_wakeup_device(u8 sleep_state)
88 spin_unlock(&acpi_device_lock); 84 spin_unlock(&acpi_device_lock);
89 if (!dev->wakeup.flags.run_wake) 85 if (!dev->wakeup.flags.run_wake)
90 acpi_enable_gpe(dev->wakeup.gpe_device, 86 acpi_enable_gpe(dev->wakeup.gpe_device,
91 dev->wakeup.gpe_number, ACPI_ISR); 87 dev->wakeup.gpe_number);
92 spin_lock(&acpi_device_lock); 88 spin_lock(&acpi_device_lock);
93 } 89 }
94 spin_unlock(&acpi_device_lock); 90 spin_unlock(&acpi_device_lock);
@@ -103,8 +99,6 @@ void acpi_disable_wakeup_device(u8 sleep_state)
103{ 99{
104 struct list_head *node, *next; 100 struct list_head *node, *next;
105 101
106 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device");
107
108 spin_lock(&acpi_device_lock); 102 spin_lock(&acpi_device_lock);
109 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 103 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
110 struct acpi_device *dev = 104 struct acpi_device *dev =
@@ -122,7 +116,7 @@ void acpi_disable_wakeup_device(u8 sleep_state)
122 ACPI_GPE_TYPE_WAKE_RUN); 116 ACPI_GPE_TYPE_WAKE_RUN);
123 /* Re-enable it, since set_gpe_type will disable it */ 117 /* Re-enable it, since set_gpe_type will disable it */
124 acpi_enable_gpe(dev->wakeup.gpe_device, 118 acpi_enable_gpe(dev->wakeup.gpe_device,
125 dev->wakeup.gpe_number, ACPI_NOT_ISR); 119 dev->wakeup.gpe_number);
126 spin_lock(&acpi_device_lock); 120 spin_lock(&acpi_device_lock);
127 } 121 }
128 continue; 122 continue;
@@ -133,7 +127,7 @@ void acpi_disable_wakeup_device(u8 sleep_state)
133 /* Never disable run-wake GPE */ 127 /* Never disable run-wake GPE */
134 if (!dev->wakeup.flags.run_wake) { 128 if (!dev->wakeup.flags.run_wake) {
135 acpi_disable_gpe(dev->wakeup.gpe_device, 129 acpi_disable_gpe(dev->wakeup.gpe_device,
136 dev->wakeup.gpe_number, ACPI_NOT_ISR); 130 dev->wakeup.gpe_number);
137 acpi_clear_gpe(dev->wakeup.gpe_device, 131 acpi_clear_gpe(dev->wakeup.gpe_device,
138 dev->wakeup.gpe_number, ACPI_NOT_ISR); 132 dev->wakeup.gpe_number, ACPI_NOT_ISR);
139 } 133 }
@@ -162,7 +156,7 @@ static int __init acpi_wakeup_device_init(void)
162 dev->wakeup.gpe_number, 156 dev->wakeup.gpe_number,
163 ACPI_GPE_TYPE_WAKE_RUN); 157 ACPI_GPE_TYPE_WAKE_RUN);
164 acpi_enable_gpe(dev->wakeup.gpe_device, 158 acpi_enable_gpe(dev->wakeup.gpe_device,
165 dev->wakeup.gpe_number, ACPI_NOT_ISR); 159 dev->wakeup.gpe_number);
166 dev->wakeup.state.enabled = 1; 160 dev->wakeup.state.enabled = 1;
167 spin_lock(&acpi_device_lock); 161 spin_lock(&acpi_device_lock);
168 } 162 }
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c
deleted file mode 100644
index 47cd7baf9b1b..000000000000
--- a/drivers/acpi/wmi.c
+++ /dev/null
@@ -1,747 +0,0 @@
1/*
2 * ACPI-WMI mapping driver
3 *
4 * Copyright (C) 2007-2008 Carlos Corbacho <carlos@strangeworlds.co.uk>
5 *
6 * GUID parsing code from ldm.c is:
7 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
8 * Copyright (c) 2001-2007 Anton Altaparmakov
9 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
10 *
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or (at
16 * your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 *
27 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 */
29
30#include <linux/kernel.h>
31#include <linux/init.h>
32#include <linux/types.h>
33#include <linux/list.h>
34#include <linux/acpi.h>
35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h>
37
38ACPI_MODULE_NAME("wmi");
39MODULE_AUTHOR("Carlos Corbacho");
40MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
41MODULE_LICENSE("GPL");
42
43#define ACPI_WMI_CLASS "wmi"
44
45#undef PREFIX
46#define PREFIX "ACPI: WMI: "
47
48static DEFINE_MUTEX(wmi_data_lock);
49
50struct guid_block {
51 char guid[16];
52 union {
53 char object_id[2];
54 struct {
55 unsigned char notify_id;
56 unsigned char reserved;
57 };
58 };
59 u8 instance_count;
60 u8 flags;
61};
62
63struct wmi_block {
64 struct list_head list;
65 struct guid_block gblock;
66 acpi_handle handle;
67 wmi_notify_handler handler;
68 void *handler_data;
69};
70
71static struct wmi_block wmi_blocks;
72
73/*
74 * If the GUID data block is marked as expensive, we must enable and
75 * explicitily disable data collection.
76 */
77#define ACPI_WMI_EXPENSIVE 0x1
78#define ACPI_WMI_METHOD 0x2 /* GUID is a method */
79#define ACPI_WMI_STRING 0x4 /* GUID takes & returns a string */
80#define ACPI_WMI_EVENT 0x8 /* GUID is an event */
81
82static int acpi_wmi_remove(struct acpi_device *device, int type);
83static int acpi_wmi_add(struct acpi_device *device);
84
85static const struct acpi_device_id wmi_device_ids[] = {
86 {"PNP0C14", 0},
87 {"pnp0c14", 0},
88 {"", 0},
89};
90MODULE_DEVICE_TABLE(acpi, wmi_device_ids);
91
92static struct acpi_driver acpi_wmi_driver = {
93 .name = "wmi",
94 .class = ACPI_WMI_CLASS,
95 .ids = wmi_device_ids,
96 .ops = {
97 .add = acpi_wmi_add,
98 .remove = acpi_wmi_remove,
99 },
100};
101
102/*
103 * GUID parsing functions
104 */
105
106/**
107 * wmi_parse_hexbyte - Convert a ASCII hex number to a byte
108 * @src: Pointer to at least 2 characters to convert.
109 *
110 * Convert a two character ASCII hex string to a number.
111 *
112 * Return: 0-255 Success, the byte was parsed correctly
113 * -1 Error, an invalid character was supplied
114 */
115static int wmi_parse_hexbyte(const u8 *src)
116{
117 unsigned int x; /* For correct wrapping */
118 int h;
119
120 /* high part */
121 x = src[0];
122 if (x - '0' <= '9' - '0') {
123 h = x - '0';
124 } else if (x - 'a' <= 'f' - 'a') {
125 h = x - 'a' + 10;
126 } else if (x - 'A' <= 'F' - 'A') {
127 h = x - 'A' + 10;
128 } else {
129 return -1;
130 }
131 h <<= 4;
132
133 /* low part */
134 x = src[1];
135 if (x - '0' <= '9' - '0')
136 return h | (x - '0');
137 if (x - 'a' <= 'f' - 'a')
138 return h | (x - 'a' + 10);
139 if (x - 'A' <= 'F' - 'A')
140 return h | (x - 'A' + 10);
141 return -1;
142}
143
144/**
145 * wmi_swap_bytes - Rearrange GUID bytes to match GUID binary
146 * @src: Memory block holding binary GUID (16 bytes)
147 * @dest: Memory block to hold byte swapped binary GUID (16 bytes)
148 *
149 * Byte swap a binary GUID to match it's real GUID value
150 */
151static void wmi_swap_bytes(u8 *src, u8 *dest)
152{
153 int i;
154
155 for (i = 0; i <= 3; i++)
156 memcpy(dest + i, src + (3 - i), 1);
157
158 for (i = 0; i <= 1; i++)
159 memcpy(dest + 4 + i, src + (5 - i), 1);
160
161 for (i = 0; i <= 1; i++)
162 memcpy(dest + 6 + i, src + (7 - i), 1);
163
164 memcpy(dest + 8, src + 8, 8);
165}
166
167/**
168 * wmi_parse_guid - Convert GUID from ASCII to binary
169 * @src: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
170 * @dest: Memory block to hold binary GUID (16 bytes)
171 *
172 * N.B. The GUID need not be NULL terminated.
173 *
174 * Return: 'true' @dest contains binary GUID
175 * 'false' @dest contents are undefined
176 */
177static bool wmi_parse_guid(const u8 *src, u8 *dest)
178{
179 static const int size[] = { 4, 2, 2, 2, 6 };
180 int i, j, v;
181
182 if (src[8] != '-' || src[13] != '-' ||
183 src[18] != '-' || src[23] != '-')
184 return false;
185
186 for (j = 0; j < 5; j++, src++) {
187 for (i = 0; i < size[j]; i++, src += 2, *dest++ = v) {
188 v = wmi_parse_hexbyte(src);
189 if (v < 0)
190 return false;
191 }
192 }
193
194 return true;
195}
196
197static bool find_guid(const char *guid_string, struct wmi_block **out)
198{
199 char tmp[16], guid_input[16];
200 struct wmi_block *wblock;
201 struct guid_block *block;
202 struct list_head *p;
203
204 wmi_parse_guid(guid_string, tmp);
205 wmi_swap_bytes(tmp, guid_input);
206
207 list_for_each(p, &wmi_blocks.list) {
208 wblock = list_entry(p, struct wmi_block, list);
209 block = &wblock->gblock;
210
211 if (memcmp(block->guid, guid_input, 16) == 0) {
212 if (out)
213 *out = wblock;
214 return 1;
215 }
216 }
217 return 0;
218}
219
220static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
221{
222 struct guid_block *block = NULL;
223 char method[5];
224 struct acpi_object_list input;
225 union acpi_object params[1];
226 acpi_status status;
227 acpi_handle handle;
228
229 block = &wblock->gblock;
230 handle = wblock->handle;
231
232 if (!block)
233 return AE_NOT_EXIST;
234
235 input.count = 1;
236 input.pointer = params;
237 params[0].type = ACPI_TYPE_INTEGER;
238 params[0].integer.value = enable;
239
240 snprintf(method, 5, "WE%02X", block->notify_id);
241 status = acpi_evaluate_object(handle, method, &input, NULL);
242
243 if (status != AE_OK && status != AE_NOT_FOUND)
244 return status;
245 else
246 return AE_OK;
247}
248
249/*
250 * Exported WMI functions
251 */
252/**
253 * wmi_evaluate_method - Evaluate a WMI method
254 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
255 * @instance: Instance index
256 * @method_id: Method ID to call
257 * &in: Buffer containing input for the method call
258 * &out: Empty buffer to return the method results
259 *
260 * Call an ACPI-WMI method
261 */
262acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
263u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
264{
265 struct guid_block *block = NULL;
266 struct wmi_block *wblock = NULL;
267 acpi_handle handle;
268 acpi_status status;
269 struct acpi_object_list input;
270 union acpi_object params[3];
271 char method[4] = "WM";
272
273 if (!find_guid(guid_string, &wblock))
274 return AE_ERROR;
275
276 block = &wblock->gblock;
277 handle = wblock->handle;
278
279 if (!(block->flags & ACPI_WMI_METHOD))
280 return AE_BAD_DATA;
281
282 if (block->instance_count < instance)
283 return AE_BAD_PARAMETER;
284
285 input.count = 2;
286 input.pointer = params;
287 params[0].type = ACPI_TYPE_INTEGER;
288 params[0].integer.value = instance;
289 params[1].type = ACPI_TYPE_INTEGER;
290 params[1].integer.value = method_id;
291
292 if (in) {
293 input.count = 3;
294
295 if (block->flags & ACPI_WMI_STRING) {
296 params[2].type = ACPI_TYPE_STRING;
297 } else {
298 params[2].type = ACPI_TYPE_BUFFER;
299 }
300 params[2].buffer.length = in->length;
301 params[2].buffer.pointer = in->pointer;
302 }
303
304 strncat(method, block->object_id, 2);
305
306 status = acpi_evaluate_object(handle, method, &input, out);
307
308 return status;
309}
310EXPORT_SYMBOL_GPL(wmi_evaluate_method);
311
312/**
313 * wmi_query_block - Return contents of a WMI block
314 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
315 * @instance: Instance index
316 * &out: Empty buffer to return the contents of the data block to
317 *
318 * Return the contents of an ACPI-WMI data block to a buffer
319 */
320acpi_status wmi_query_block(const char *guid_string, u8 instance,
321struct acpi_buffer *out)
322{
323 struct guid_block *block = NULL;
324 struct wmi_block *wblock = NULL;
325 acpi_handle handle, wc_handle;
326 acpi_status status, wc_status = AE_ERROR;
327 struct acpi_object_list input, wc_input;
328 union acpi_object wc_params[1], wq_params[1];
329 char method[4];
330 char wc_method[4] = "WC";
331
332 if (!guid_string || !out)
333 return AE_BAD_PARAMETER;
334
335 if (!find_guid(guid_string, &wblock))
336 return AE_ERROR;
337
338 block = &wblock->gblock;
339 handle = wblock->handle;
340
341 if (block->instance_count < instance)
342 return AE_BAD_PARAMETER;
343
344 /* Check GUID is a data block */
345 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
346 return AE_ERROR;
347
348 input.count = 1;
349 input.pointer = wq_params;
350 wq_params[0].type = ACPI_TYPE_INTEGER;
351 wq_params[0].integer.value = instance;
352
353 /*
354 * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method first to
355 * enable collection.
356 */
357 if (block->flags & ACPI_WMI_EXPENSIVE) {
358 wc_input.count = 1;
359 wc_input.pointer = wc_params;
360 wc_params[0].type = ACPI_TYPE_INTEGER;
361 wc_params[0].integer.value = 1;
362
363 strncat(wc_method, block->object_id, 2);
364
365 /*
366 * Some GUIDs break the specification by declaring themselves
367 * expensive, but have no corresponding WCxx method. So we
368 * should not fail if this happens.
369 */
370 wc_status = acpi_get_handle(handle, wc_method, &wc_handle);
371 if (ACPI_SUCCESS(wc_status))
372 wc_status = acpi_evaluate_object(handle, wc_method,
373 &wc_input, NULL);
374 }
375
376 strcpy(method, "WQ");
377 strncat(method, block->object_id, 2);
378
379 status = acpi_evaluate_object(handle, method, &input, out);
380
381 /*
382 * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method, even if
383 * the WQxx method failed - we should disable collection anyway.
384 */
385 if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
386 wc_params[0].integer.value = 0;
387 status = acpi_evaluate_object(handle,
388 wc_method, &wc_input, NULL);
389 }
390
391 return status;
392}
393EXPORT_SYMBOL_GPL(wmi_query_block);
394
395/**
396 * wmi_set_block - Write to a WMI block
397 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
398 * @instance: Instance index
399 * &in: Buffer containing new values for the data block
400 *
401 * Write the contents of the input buffer to an ACPI-WMI data block
402 */
403acpi_status wmi_set_block(const char *guid_string, u8 instance,
404const struct acpi_buffer *in)
405{
406 struct guid_block *block = NULL;
407 struct wmi_block *wblock = NULL;
408 acpi_handle handle;
409 struct acpi_object_list input;
410 union acpi_object params[2];
411 char method[4] = "WS";
412
413 if (!guid_string || !in)
414 return AE_BAD_DATA;
415
416 if (!find_guid(guid_string, &wblock))
417 return AE_ERROR;
418
419 block = &wblock->gblock;
420 handle = wblock->handle;
421
422 if (block->instance_count < instance)
423 return AE_BAD_PARAMETER;
424
425 /* Check GUID is a data block */
426 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
427 return AE_ERROR;
428
429 input.count = 2;
430 input.pointer = params;
431 params[0].type = ACPI_TYPE_INTEGER;
432 params[0].integer.value = instance;
433
434 if (block->flags & ACPI_WMI_STRING) {
435 params[1].type = ACPI_TYPE_STRING;
436 } else {
437 params[1].type = ACPI_TYPE_BUFFER;
438 }
439 params[1].buffer.length = in->length;
440 params[1].buffer.pointer = in->pointer;
441
442 strncat(method, block->object_id, 2);
443
444 return acpi_evaluate_object(handle, method, &input, NULL);
445}
446EXPORT_SYMBOL_GPL(wmi_set_block);
447
448/**
449 * wmi_install_notify_handler - Register handler for WMI events
450 * @handler: Function to handle notifications
451 * @data: Data to be returned to handler when event is fired
452 *
453 * Register a handler for events sent to the ACPI-WMI mapper device.
454 */
455acpi_status wmi_install_notify_handler(const char *guid,
456wmi_notify_handler handler, void *data)
457{
458 struct wmi_block *block;
459 acpi_status status;
460
461 if (!guid || !handler)
462 return AE_BAD_PARAMETER;
463
464 find_guid(guid, &block);
465 if (!block)
466 return AE_NOT_EXIST;
467
468 if (block->handler)
469 return AE_ALREADY_ACQUIRED;
470
471 block->handler = handler;
472 block->handler_data = data;
473
474 status = wmi_method_enable(block, 1);
475
476 return status;
477}
478EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
479
480/**
481 * wmi_uninstall_notify_handler - Unregister handler for WMI events
482 *
483 * Unregister handler for events sent to the ACPI-WMI mapper device.
484 */
485acpi_status wmi_remove_notify_handler(const char *guid)
486{
487 struct wmi_block *block;
488 acpi_status status;
489
490 if (!guid)
491 return AE_BAD_PARAMETER;
492
493 find_guid(guid, &block);
494 if (!block)
495 return AE_NOT_EXIST;
496
497 if (!block->handler)
498 return AE_NULL_ENTRY;
499
500 status = wmi_method_enable(block, 0);
501
502 block->handler = NULL;
503 block->handler_data = NULL;
504
505 return status;
506}
507EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
508
509/**
510 * wmi_get_event_data - Get WMI data associated with an event
511 *
512 * @event - Event to find
513 * &out - Buffer to hold event data
514 *
515 * Returns extra data associated with an event in WMI.
516 */
517acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
518{
519 struct acpi_object_list input;
520 union acpi_object params[1];
521 struct guid_block *gblock;
522 struct wmi_block *wblock;
523 struct list_head *p;
524
525 input.count = 1;
526 input.pointer = params;
527 params[0].type = ACPI_TYPE_INTEGER;
528 params[0].integer.value = event;
529
530 list_for_each(p, &wmi_blocks.list) {
531 wblock = list_entry(p, struct wmi_block, list);
532 gblock = &wblock->gblock;
533
534 if ((gblock->flags & ACPI_WMI_EVENT) &&
535 (gblock->notify_id == event))
536 return acpi_evaluate_object(wblock->handle, "_WED",
537 &input, out);
538 }
539
540 return AE_NOT_FOUND;
541}
542EXPORT_SYMBOL_GPL(wmi_get_event_data);
543
544/**
545 * wmi_has_guid - Check if a GUID is available
546 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
547 *
548 * Check if a given GUID is defined by _WDG
549 */
550bool wmi_has_guid(const char *guid_string)
551{
552 return find_guid(guid_string, NULL);
553}
554EXPORT_SYMBOL_GPL(wmi_has_guid);
555
556/*
557 * Parse the _WDG method for the GUID data blocks
558 */
559static __init acpi_status parse_wdg(acpi_handle handle)
560{
561 struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
562 union acpi_object *obj;
563 struct guid_block *gblock;
564 struct wmi_block *wblock;
565 acpi_status status;
566 u32 i, total;
567
568 status = acpi_evaluate_object(handle, "_WDG", NULL, &out);
569
570 if (ACPI_FAILURE(status))
571 return status;
572
573 obj = (union acpi_object *) out.pointer;
574
575 if (obj->type != ACPI_TYPE_BUFFER)
576 return AE_ERROR;
577
578 total = obj->buffer.length / sizeof(struct guid_block);
579
580 gblock = kzalloc(obj->buffer.length, GFP_KERNEL);
581 if (!gblock)
582 return AE_NO_MEMORY;
583
584 memcpy(gblock, obj->buffer.pointer, obj->buffer.length);
585
586 for (i = 0; i < total; i++) {
587 wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
588 if (!wblock)
589 return AE_NO_MEMORY;
590
591 wblock->gblock = gblock[i];
592 wblock->handle = handle;
593 list_add_tail(&wblock->list, &wmi_blocks.list);
594 }
595
596 kfree(out.pointer);
597 kfree(gblock);
598
599 return status;
600}
601
602/*
603 * WMI can have EmbeddedControl access regions. In which case, we just want to
604 * hand these off to the EC driver.
605 */
606static acpi_status
607acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
608 u32 bits, acpi_integer * value,
609 void *handler_context, void *region_context)
610{
611 int result = 0, i = 0;
612 u8 temp = 0;
613
614 if ((address > 0xFF) || !value)
615 return AE_BAD_PARAMETER;
616
617 if (function != ACPI_READ && function != ACPI_WRITE)
618 return AE_BAD_PARAMETER;
619
620 if (bits != 8)
621 return AE_BAD_PARAMETER;
622
623 if (function == ACPI_READ) {
624 result = ec_read(address, &temp);
625 (*value) |= ((acpi_integer)temp) << i;
626 } else {
627 temp = 0xff & ((*value) >> i);
628 result = ec_write(address, temp);
629 }
630
631 switch (result) {
632 case -EINVAL:
633 return AE_BAD_PARAMETER;
634 break;
635 case -ENODEV:
636 return AE_NOT_FOUND;
637 break;
638 case -ETIME:
639 return AE_TIME;
640 break;
641 default:
642 return AE_OK;
643 }
644}
645
646static void acpi_wmi_notify(acpi_handle handle, u32 event, void *data)
647{
648 struct guid_block *block;
649 struct wmi_block *wblock;
650 struct list_head *p;
651 struct acpi_device *device = data;
652
653 list_for_each(p, &wmi_blocks.list) {
654 wblock = list_entry(p, struct wmi_block, list);
655 block = &wblock->gblock;
656
657 if ((block->flags & ACPI_WMI_EVENT) &&
658 (block->notify_id == event)) {
659 if (wblock->handler)
660 wblock->handler(event, wblock->handler_data);
661
662 acpi_bus_generate_netlink_event(
663 device->pnp.device_class, device->dev.bus_id,
664 event, 0);
665 break;
666 }
667 }
668}
669
670static int acpi_wmi_remove(struct acpi_device *device, int type)
671{
672 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
673 acpi_wmi_notify);
674
675 acpi_remove_address_space_handler(device->handle,
676 ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);
677
678 return 0;
679}
680
681static int __init acpi_wmi_add(struct acpi_device *device)
682{
683 acpi_status status;
684 int result = 0;
685
686 status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
687 acpi_wmi_notify, device);
688 if (ACPI_FAILURE(status)) {
689 printk(KERN_ERR PREFIX "Error installing notify handler\n");
690 return -ENODEV;
691 }
692
693 status = acpi_install_address_space_handler(device->handle,
694 ACPI_ADR_SPACE_EC,
695 &acpi_wmi_ec_space_handler,
696 NULL, NULL);
697 if (ACPI_FAILURE(status))
698 return -ENODEV;
699
700 status = parse_wdg(device->handle);
701 if (ACPI_FAILURE(status)) {
702 printk(KERN_ERR PREFIX "Error installing EC region handler\n");
703 return -ENODEV;
704 }
705
706 return result;
707}
708
709static int __init acpi_wmi_init(void)
710{
711 acpi_status result;
712
713 INIT_LIST_HEAD(&wmi_blocks.list);
714
715 if (acpi_disabled)
716 return -ENODEV;
717
718 result = acpi_bus_register_driver(&acpi_wmi_driver);
719
720 if (result < 0) {
721 printk(KERN_INFO PREFIX "Error loading mapper\n");
722 } else {
723 printk(KERN_INFO PREFIX "Mapper loaded\n");
724 }
725
726 return result;
727}
728
729static void __exit acpi_wmi_exit(void)
730{
731 struct list_head *p, *tmp;
732 struct wmi_block *wblock;
733
734 acpi_bus_unregister_driver(&acpi_wmi_driver);
735
736 list_for_each_safe(p, tmp, &wmi_blocks.list) {
737 wblock = list_entry(p, struct wmi_block, list);
738
739 list_del(p);
740 kfree(wblock);
741 }
742
743 printk(KERN_INFO PREFIX "Mapper unloaded\n");
744}
745
746subsys_initcall(acpi_wmi_init);
747module_exit(acpi_wmi_exit);