aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-parameters.txt46
-rw-r--r--arch/ia64/include/asm/acpi-ext.h1
-rw-r--r--arch/ia64/include/asm/sn/acpi.h2
-rw-r--r--arch/ia64/kernel/acpi.c1
-rw-r--r--arch/ia64/sn/kernel/io_acpi_init.c103
-rw-r--r--arch/ia64/sn/kernel/io_common.c5
-rw-r--r--arch/x86/kernel/acpi/boot.c17
-rw-r--r--arch/x86/kernel/acpi/cstate.c4
-rw-r--r--arch/x86/kernel/acpi/sleep.c2
-rw-r--r--arch/x86/kernel/e820.c21
-rw-r--r--drivers/acpi/Makefile22
-rw-r--r--drivers/acpi/acpica/Makefile44
-rw-r--r--drivers/acpi/acpica/accommon.h63
-rw-r--r--drivers/acpi/acpica/acconfig.h (renamed from include/acpi/acconfig.h)8
-rw-r--r--drivers/acpi/acpica/acdebug.h (renamed from include/acpi/acdebug.h)0
-rw-r--r--drivers/acpi/acpica/acdispat.h (renamed from include/acpi/acdispat.h)0
-rw-r--r--drivers/acpi/acpica/acevents.h (renamed from include/acpi/acevents.h)6
-rw-r--r--drivers/acpi/acpica/acglobal.h (renamed from include/acpi/acglobal.h)9
-rw-r--r--drivers/acpi/acpica/achware.h (renamed from include/acpi/achware.h)22
-rw-r--r--drivers/acpi/acpica/acinterp.h (renamed from include/acpi/acinterp.h)0
-rw-r--r--drivers/acpi/acpica/aclocal.h (renamed from include/acpi/aclocal.h)86
-rw-r--r--drivers/acpi/acpica/acmacros.h (renamed from include/acpi/acmacros.h)122
-rw-r--r--drivers/acpi/acpica/acnamesp.h (renamed from include/acpi/acnamesp.h)5
-rw-r--r--drivers/acpi/acpica/acobject.h (renamed from include/acpi/acobject.h)0
-rw-r--r--drivers/acpi/acpica/acopcode.h (renamed from include/acpi/acopcode.h)0
-rw-r--r--drivers/acpi/acpica/acparser.h (renamed from include/acpi/acparser.h)0
-rw-r--r--drivers/acpi/acpica/acpredef.h (renamed from include/acpi/acpredef.h)0
-rw-r--r--drivers/acpi/acpica/acresrc.h (renamed from include/acpi/acresrc.h)0
-rw-r--r--drivers/acpi/acpica/acstruct.h (renamed from include/acpi/acstruct.h)0
-rw-r--r--drivers/acpi/acpica/actables.h (renamed from include/acpi/actables.h)2
-rw-r--r--drivers/acpi/acpica/acutils.h (renamed from include/acpi/acutils.h)36
-rw-r--r--drivers/acpi/acpica/amlcode.h (renamed from include/acpi/amlcode.h)0
-rw-r--r--drivers/acpi/acpica/amlresrc.h (renamed from include/acpi/amlresrc.h)0
-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)53
-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)170
-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)7
-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)9
-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)9
-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)5
-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)252
-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)30
-rw-r--r--drivers/acpi/acpica/tbxface.c (renamed from drivers/acpi/tables/tbxface.c)5
-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)11
-rw-r--r--drivers/acpi/acpica/utglobal.c (renamed from drivers/acpi/utilities/utglobal.c)12
-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)3
-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/battery.c5
-rw-r--r--drivers/acpi/cm_sbs.c3
-rw-r--r--drivers/acpi/debug.c1
-rw-r--r--drivers/acpi/dispatcher/Makefile9
-rw-r--r--drivers/acpi/ec.c57
-rw-r--r--drivers/acpi/events/Makefile9
-rw-r--r--drivers/acpi/executer/Makefile10
-rw-r--r--drivers/acpi/hardware/Makefile9
-rw-r--r--drivers/acpi/main.c (renamed from drivers/acpi/sleep/main.c)79
-rw-r--r--drivers/acpi/namespace/Makefile12
-rw-r--r--drivers/acpi/numa.c1
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/parser/Makefile8
-rw-r--r--drivers/acpi/pci_link.c6
-rw-r--r--drivers/acpi/power.c6
-rw-r--r--drivers/acpi/proc.c (renamed from drivers/acpi/sleep/proc.c)65
-rw-r--r--drivers/acpi/reboot.c2
-rw-r--r--drivers/acpi/resources/Makefile10
-rw-r--r--drivers/acpi/sbshc.c1
-rw-r--r--drivers/acpi/scan.c1
-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.c63
-rw-r--r--drivers/acpi/tables/Makefile7
-rw-r--r--drivers/acpi/utilities/Makefile9
-rw-r--r--drivers/acpi/utilities/utcache.c314
-rw-r--r--drivers/acpi/video.c20
-rw-r--r--drivers/acpi/video_detect.c4
-rw-r--r--drivers/acpi/wakeup.c (renamed from drivers/acpi/sleep/wakeup.c)6
-rw-r--r--drivers/ata/libata-acpi.c6
-rw-r--r--drivers/ata/pata_acpi.c6
-rw-r--r--drivers/char/tpm/tpm_bios.c2
-rw-r--r--drivers/cpuidle/governors/menu.c10
-rw-r--r--drivers/ide/ide-acpi.c6
-rw-r--r--drivers/misc/Kconfig6
-rw-r--r--drivers/misc/fujitsu-laptop.c419
-rw-r--r--drivers/misc/panasonic-laptop.c22
-rw-r--r--drivers/misc/sony-laptop.c15
-rw-r--r--drivers/misc/tc1100-wmi.c1
-rw-r--r--drivers/misc/thinkpad_acpi.c1
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c1
-rw-r--r--drivers/pci/hotplug/pciehp.h1
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pnp/pnpacpi/core.c1
-rw-r--r--include/acpi/acdisasm.h445
-rw-r--r--include/acpi/acexcep.h6
-rw-r--r--include/acpi/acoutput.h103
-rw-r--r--include/acpi/acpi.h31
-rw-r--r--include/acpi/acpiosxf.h13
-rw-r--r--include/acpi/acpixf.h100
-rw-r--r--include/acpi/acrestyp.h405
-rw-r--r--include/acpi/actbl.h25
-rw-r--r--include/acpi/actbl1.h2
-rw-r--r--include/acpi/actypes.h557
-rw-r--r--include/acpi/platform/acenv.h45
-rw-r--r--include/acpi/platform/aclinux.h1
-rw-r--r--include/linux/acpi.h1
-rw-r--r--include/linux/pci_hotplug.h1
-rw-r--r--include/linux/suspend.h13
-rw-r--r--kernel/power/disk.c6
-rw-r--r--kernel/power/snapshot.c370
-rw-r--r--kernel/power/swsusp.c122
203 files changed, 3936 insertions, 3401 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index fb849020aea9..fcc48bf722a8 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -141,6 +141,7 @@ and is between 256 and 4096 characters. It is defined in the file
141 ht -- run only enough ACPI to enable Hyper Threading 141 ht -- run only enough ACPI to enable Hyper Threading
142 strict -- Be less tolerant of platforms that are not 142 strict -- Be less tolerant of platforms that are not
143 strictly ACPI specification compliant. 143 strictly ACPI specification compliant.
144 rsdt -- prefer RSDT over (default) XSDT
144 145
145 See also Documentation/power/pm.txt, pci=noacpi 146 See also Documentation/power/pm.txt, pci=noacpi
146 147
@@ -151,16 +152,20 @@ and is between 256 and 4096 characters. It is defined in the file
151 default: 0 152 default: 0
152 153
153 acpi_sleep= [HW,ACPI] Sleep options 154 acpi_sleep= [HW,ACPI] Sleep options
154 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig, old_ordering } 155 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig,
155 See Documentation/power/video.txt for s3_bios and s3_mode. 156 old_ordering, s4_nonvs }
157 See Documentation/power/video.txt for information on
158 s3_bios and s3_mode.
156 s3_beep is for debugging; it makes the PC's speaker beep 159 s3_beep is for debugging; it makes the PC's speaker beep
157 as soon as the kernel's real-mode entry point is called. 160 as soon as the kernel's real-mode entry point is called.
158 s4_nohwsig prevents ACPI hardware signature from being 161 s4_nohwsig prevents ACPI hardware signature from being
159 used during resume from hibernation. 162 used during resume from hibernation.
160 old_ordering causes the ACPI 1.0 ordering of the _PTS 163 old_ordering causes the ACPI 1.0 ordering of the _PTS
161 control method, wrt putting devices into low power 164 control method, with respect to putting devices into
162 states, to be enforced (the ACPI 2.0 ordering of _PTS is 165 low power states, to be enforced (the ACPI 2.0 ordering
163 used by default). 166 of _PTS is used by default).
167 s4_nonvs prevents the kernel from saving/restoring the
168 ACPI NVS memory during hibernation.
164 169
165 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode 170 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
166 Format: { level | edge | high | low } 171 Format: { level | edge | high | low }
@@ -195,7 +200,7 @@ and is between 256 and 4096 characters. It is defined in the file
195 acpi_skip_timer_override [HW,ACPI] 200 acpi_skip_timer_override [HW,ACPI]
196 Recognize and ignore IRQ0/pin2 Interrupt Override. 201 Recognize and ignore IRQ0/pin2 Interrupt Override.
197 For broken nForce2 BIOS resulting in XT-PIC timer. 202 For broken nForce2 BIOS resulting in XT-PIC timer.
198 acpi_use_timer_override [HW,ACPI} 203 acpi_use_timer_override [HW,ACPI]
199 Use timer override. For some broken Nvidia NF5 boards 204 Use timer override. For some broken Nvidia NF5 boards
200 that require a timer override, but don't have 205 that require a timer override, but don't have
201 HPET 206 HPET
@@ -878,17 +883,19 @@ and is between 256 and 4096 characters. It is defined in the file
878 See Documentation/ide/ide.txt. 883 See Documentation/ide/ide.txt.
879 884
880 idle= [X86] 885 idle= [X86]
881 Format: idle=poll or idle=mwait, idle=halt, idle=nomwait 886 Format: idle=poll, idle=mwait, idle=halt, idle=nomwait
882 Poll forces a polling idle loop that can slightly improves the performance 887 Poll forces a polling idle loop that can slightly
883 of waking up a idle CPU, but will use a lot of power and make the system 888 improve the performance of waking up a idle CPU, but
884 run hot. Not recommended. 889 will use a lot of power and make the system run hot.
885 idle=mwait. On systems which support MONITOR/MWAIT but the kernel chose 890 Not recommended.
886 to not use it because it doesn't save as much power as a normal idle 891 idle=mwait: On systems which support MONITOR/MWAIT but
887 loop use the MONITOR/MWAIT idle loop anyways. Performance should be the same 892 the kernel chose to not use it because it doesn't save
888 as idle=poll. 893 as much power as a normal idle loop, use the
889 idle=halt. Halt is forced to be used for CPU idle. 894 MONITOR/MWAIT idle loop anyways. Performance should be
895 the same as idle=poll.
896 idle=halt: Halt is forced to be used for CPU idle.
890 In such case C2/C3 won't be used again. 897 In such case C2/C3 won't be used again.
891 idle=nomwait. Disable mwait for CPU C-states 898 idle=nomwait: Disable mwait for CPU C-states
892 899
893 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem 900 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem
894 Claim all unknown PCI IDE storage controllers. 901 Claim all unknown PCI IDE storage controllers.
@@ -1074,8 +1081,8 @@ and is between 256 and 4096 characters. It is defined in the file
1074 lapic [X86-32,APIC] Enable the local APIC even if BIOS 1081 lapic [X86-32,APIC] Enable the local APIC even if BIOS
1075 disabled it. 1082 disabled it.
1076 1083
1077 lapic_timer_c2_ok [X86-32,x86-64,APIC] trust the local apic timer in 1084 lapic_timer_c2_ok [X86-32,x86-64,APIC] trust the local apic timer
1078 C2 power state. 1085 in C2 power state.
1079 1086
1080 libata.dma= [LIBATA] DMA control 1087 libata.dma= [LIBATA] DMA control
1081 libata.dma=0 Disable all PATA and SATA DMA 1088 libata.dma=0 Disable all PATA and SATA DMA
@@ -2303,7 +2310,8 @@ and is between 256 and 4096 characters. It is defined in the file
2303 2310
2304 thermal.psv= [HW,ACPI] 2311 thermal.psv= [HW,ACPI]
2305 -1: disable all passive trip points 2312 -1: disable all passive trip points
2306 <degrees C>: override all passive trip points to this value 2313 <degrees C>: override all passive trip points to this
2314 value
2307 2315
2308 thermal.tzp= [HW,ACPI] 2316 thermal.tzp= [HW,ACPI]
2309 Specify global default ACPI thermal zone polling rate 2317 Specify global default ACPI thermal zone polling rate
diff --git a/arch/ia64/include/asm/acpi-ext.h b/arch/ia64/include/asm/acpi-ext.h
index 734d137dda6e..7f8362b379eb 100644
--- a/arch/ia64/include/asm/acpi-ext.h
+++ b/arch/ia64/include/asm/acpi-ext.h
@@ -14,7 +14,6 @@
14#define _ASM_IA64_ACPI_EXT_H 14#define _ASM_IA64_ACPI_EXT_H
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17#include <acpi/actypes.h>
18 17
19extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length); 18extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length);
20 19
diff --git a/arch/ia64/include/asm/sn/acpi.h b/arch/ia64/include/asm/sn/acpi.h
index 9ce2801cbd57..fd480db25565 100644
--- a/arch/ia64/include/asm/sn/acpi.h
+++ b/arch/ia64/include/asm/sn/acpi.h
@@ -9,8 +9,6 @@
9#ifndef _ASM_IA64_SN_ACPI_H 9#ifndef _ASM_IA64_SN_ACPI_H
10#define _ASM_IA64_SN_ACPI_H 10#define _ASM_IA64_SN_ACPI_H
11 11
12#include "acpi/acglobal.h"
13
14extern int sn_acpi_rev; 12extern int sn_acpi_rev;
15#define SN_ACPI_BASE_SUPPORT() (sn_acpi_rev >= 0x20101) 13#define SN_ACPI_BASE_SUPPORT() (sn_acpi_rev >= 0x20101)
16 14
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 0553648b7595..d541671caf4a 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -65,6 +65,7 @@ EXPORT_SYMBOL(pm_idle);
65void (*pm_power_off) (void); 65void (*pm_power_off) (void);
66EXPORT_SYMBOL(pm_power_off); 66EXPORT_SYMBOL(pm_power_off);
67 67
68u32 acpi_rsdt_forced;
68unsigned int acpi_cpei_override; 69unsigned int acpi_cpei_override;
69unsigned int acpi_cpei_phys_cpuid; 70unsigned int acpi_cpei_phys_cpuid;
70 71
diff --git a/arch/ia64/sn/kernel/io_acpi_init.c b/arch/ia64/sn/kernel/io_acpi_init.c
index bc610a6c7851..c5a214026a77 100644
--- a/arch/ia64/sn/kernel/io_acpi_init.c
+++ b/arch/ia64/sn/kernel/io_acpi_init.c
@@ -13,7 +13,6 @@
13#include <asm/sn/sn_sal.h> 13#include <asm/sn/sn_sal.h>
14#include "xtalk/hubdev.h" 14#include "xtalk/hubdev.h"
15#include <linux/acpi.h> 15#include <linux/acpi.h>
16#include <acpi/acnamesp.h>
17 16
18 17
19/* 18/*
@@ -64,6 +63,7 @@ static acpi_status __init
64sn_acpi_hubdev_init(acpi_handle handle, u32 depth, void *context, void **ret) 63sn_acpi_hubdev_init(acpi_handle handle, u32 depth, void *context, void **ret)
65{ 64{
66 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 65 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
66 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
67 u64 addr; 67 u64 addr;
68 struct hubdev_info *hubdev; 68 struct hubdev_info *hubdev;
69 struct hubdev_info *hubdev_ptr; 69 struct hubdev_info *hubdev_ptr;
@@ -77,11 +77,12 @@ sn_acpi_hubdev_init(acpi_handle handle, u32 depth, void *context, void **ret)
77 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS, 77 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
78 &sn_uuid, &buffer); 78 &sn_uuid, &buffer);
79 if (ACPI_FAILURE(status)) { 79 if (ACPI_FAILURE(status)) {
80 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
80 printk(KERN_ERR 81 printk(KERN_ERR
81 "sn_acpi_hubdev_init: acpi_get_vendor_resource() " 82 "sn_acpi_hubdev_init: acpi_get_vendor_resource() "
82 "(0x%x) failed for: ", status); 83 "(0x%x) failed for: %s\n", status,
83 acpi_ns_print_node_pathname(handle, NULL); 84 (char *)name_buffer.pointer);
84 printk("\n"); 85 kfree(name_buffer.pointer);
85 return AE_OK; /* Continue walking namespace */ 86 return AE_OK; /* Continue walking namespace */
86 } 87 }
87 88
@@ -89,11 +90,12 @@ sn_acpi_hubdev_init(acpi_handle handle, u32 depth, void *context, void **ret)
89 vendor = &resource->data.vendor_typed; 90 vendor = &resource->data.vendor_typed;
90 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) != 91 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) !=
91 sizeof(struct hubdev_info *)) { 92 sizeof(struct hubdev_info *)) {
93 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
92 printk(KERN_ERR 94 printk(KERN_ERR
93 "sn_acpi_hubdev_init: Invalid vendor data length: %d for: ", 95 "sn_acpi_hubdev_init: Invalid vendor data length: "
94 vendor->byte_length); 96 "%d for: %s\n",
95 acpi_ns_print_node_pathname(handle, NULL); 97 vendor->byte_length, (char *)name_buffer.pointer);
96 printk("\n"); 98 kfree(name_buffer.pointer);
97 goto exit; 99 goto exit;
98 } 100 }
99 101
@@ -120,6 +122,7 @@ sn_get_bussoft_ptr(struct pci_bus *bus)
120{ 122{
121 u64 addr; 123 u64 addr;
122 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 124 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
125 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
123 acpi_handle handle; 126 acpi_handle handle;
124 struct pcibus_bussoft *prom_bussoft_ptr; 127 struct pcibus_bussoft *prom_bussoft_ptr;
125 struct acpi_resource *resource; 128 struct acpi_resource *resource;
@@ -131,11 +134,11 @@ sn_get_bussoft_ptr(struct pci_bus *bus)
131 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS, 134 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
132 &sn_uuid, &buffer); 135 &sn_uuid, &buffer);
133 if (ACPI_FAILURE(status)) { 136 if (ACPI_FAILURE(status)) {
137 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
134 printk(KERN_ERR "%s: " 138 printk(KERN_ERR "%s: "
135 "acpi_get_vendor_resource() failed (0x%x) for: ", 139 "acpi_get_vendor_resource() failed (0x%x) for: %s\n",
136 __func__, status); 140 __func__, status, (char *)name_buffer.pointer);
137 acpi_ns_print_node_pathname(handle, NULL); 141 kfree(name_buffer.pointer);
138 printk("\n");
139 return NULL; 142 return NULL;
140 } 143 }
141 resource = buffer.pointer; 144 resource = buffer.pointer;
@@ -168,6 +171,7 @@ sn_extract_device_info(acpi_handle handle, struct pcidev_info **pcidev_info,
168{ 171{
169 u64 addr; 172 u64 addr;
170 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 173 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
174 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
171 struct sn_irq_info *irq_info, *irq_info_prom; 175 struct sn_irq_info *irq_info, *irq_info_prom;
172 struct pcidev_info *pcidev_ptr, *pcidev_prom_ptr; 176 struct pcidev_info *pcidev_ptr, *pcidev_prom_ptr;
173 struct acpi_resource *resource; 177 struct acpi_resource *resource;
@@ -182,11 +186,11 @@ sn_extract_device_info(acpi_handle handle, struct pcidev_info **pcidev_info,
182 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS, 186 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
183 &sn_uuid, &buffer); 187 &sn_uuid, &buffer);
184 if (ACPI_FAILURE(status)) { 188 if (ACPI_FAILURE(status)) {
189 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
185 printk(KERN_ERR 190 printk(KERN_ERR
186 "%s: acpi_get_vendor_resource() failed (0x%x) for: ", 191 "%s: acpi_get_vendor_resource() failed (0x%x) for: %s\n",
187 __func__, status); 192 __func__, status, (char *)name_buffer.pointer);
188 acpi_ns_print_node_pathname(handle, NULL); 193 kfree(name_buffer.pointer);
189 printk("\n");
190 return 1; 194 return 1;
191 } 195 }
192 196
@@ -194,11 +198,12 @@ sn_extract_device_info(acpi_handle handle, struct pcidev_info **pcidev_info,
194 vendor = &resource->data.vendor_typed; 198 vendor = &resource->data.vendor_typed;
195 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) != 199 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) !=
196 sizeof(struct pci_devdev_info *)) { 200 sizeof(struct pci_devdev_info *)) {
201 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
197 printk(KERN_ERR 202 printk(KERN_ERR
198 "%s: Invalid vendor data length: %d for: ", 203 "%s: Invalid vendor data length: %d for: %s\n",
199 __func__, vendor->byte_length); 204 __func__, vendor->byte_length,
200 acpi_ns_print_node_pathname(handle, NULL); 205 (char *)name_buffer.pointer);
201 printk("\n"); 206 kfree(name_buffer.pointer);
202 ret = 1; 207 ret = 1;
203 goto exit; 208 goto exit;
204 } 209 }
@@ -239,6 +244,9 @@ get_host_devfn(acpi_handle device_handle, acpi_handle rootbus_handle)
239 acpi_handle parent; 244 acpi_handle parent;
240 int slot; 245 int slot;
241 acpi_status status; 246 acpi_status status;
247 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
248
249 acpi_get_name(device_handle, ACPI_FULL_PATHNAME, &name_buffer);
242 250
243 /* 251 /*
244 * Do an upward search to find the root bus device, and 252 * Do an upward search to find the root bus device, and
@@ -249,9 +257,8 @@ get_host_devfn(acpi_handle device_handle, acpi_handle rootbus_handle)
249 status = acpi_get_parent(child, &parent); 257 status = acpi_get_parent(child, &parent);
250 if (ACPI_FAILURE(status)) { 258 if (ACPI_FAILURE(status)) {
251 printk(KERN_ERR "%s: acpi_get_parent() failed " 259 printk(KERN_ERR "%s: acpi_get_parent() failed "
252 "(0x%x) for: ", __func__, status); 260 "(0x%x) for: %s\n", __func__, status,
253 acpi_ns_print_node_pathname(child, NULL); 261 (char *)name_buffer.pointer);
254 printk("\n");
255 panic("%s: Unable to find host devfn\n", __func__); 262 panic("%s: Unable to find host devfn\n", __func__);
256 } 263 }
257 if (parent == rootbus_handle) 264 if (parent == rootbus_handle)
@@ -259,22 +266,20 @@ get_host_devfn(acpi_handle device_handle, acpi_handle rootbus_handle)
259 child = parent; 266 child = parent;
260 } 267 }
261 if (!child) { 268 if (!child) {
262 printk(KERN_ERR "%s: Unable to find root bus for: ", 269 printk(KERN_ERR "%s: Unable to find root bus for: %s\n",
263 __func__); 270 __func__, (char *)name_buffer.pointer);
264 acpi_ns_print_node_pathname(device_handle, NULL);
265 printk("\n");
266 BUG(); 271 BUG();
267 } 272 }
268 273
269 status = acpi_evaluate_integer(child, METHOD_NAME__ADR, NULL, &adr); 274 status = acpi_evaluate_integer(child, METHOD_NAME__ADR, NULL, &adr);
270 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
271 printk(KERN_ERR "%s: Unable to get _ADR (0x%x) for: ", 276 printk(KERN_ERR "%s: Unable to get _ADR (0x%x) for: %s\n",
272 __func__, status); 277 __func__, status, (char *)name_buffer.pointer);
273 acpi_ns_print_node_pathname(child, NULL);
274 printk("\n");
275 panic("%s: Unable to find host devfn\n", __func__); 278 panic("%s: Unable to find host devfn\n", __func__);
276 } 279 }
277 280
281 kfree(name_buffer.pointer);
282
278 slot = (adr >> 16) & 0xffff; 283 slot = (adr >> 16) & 0xffff;
279 function = adr & 0xffff; 284 function = adr & 0xffff;
280 devfn = PCI_DEVFN(slot, function); 285 devfn = PCI_DEVFN(slot, function);
@@ -300,27 +305,28 @@ find_matching_device(acpi_handle handle, u32 lvl, void *context, void **rv)
300 int function; 305 int function;
301 int slot; 306 int slot;
302 struct sn_pcidev_match *info = context; 307 struct sn_pcidev_match *info = context;
308 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
303 309
304 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, 310 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
305 &adr); 311 &adr);
306 if (ACPI_SUCCESS(status)) { 312 if (ACPI_SUCCESS(status)) {
307 status = acpi_get_parent(handle, &parent); 313 status = acpi_get_parent(handle, &parent);
308 if (ACPI_FAILURE(status)) { 314 if (ACPI_FAILURE(status)) {
315 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
309 printk(KERN_ERR 316 printk(KERN_ERR
310 "%s: acpi_get_parent() failed (0x%x) for: ", 317 "%s: acpi_get_parent() failed (0x%x) for: %s\n",
311 __func__, status); 318 __func__, status, (char *)name_buffer.pointer);
312 acpi_ns_print_node_pathname(handle, NULL); 319 kfree(name_buffer.pointer);
313 printk("\n");
314 return AE_OK; 320 return AE_OK;
315 } 321 }
316 status = acpi_evaluate_integer(parent, METHOD_NAME__BBN, 322 status = acpi_evaluate_integer(parent, METHOD_NAME__BBN,
317 NULL, &bbn); 323 NULL, &bbn);
318 if (ACPI_FAILURE(status)) { 324 if (ACPI_FAILURE(status)) {
325 acpi_get_name(handle, ACPI_FULL_PATHNAME, &name_buffer);
319 printk(KERN_ERR 326 printk(KERN_ERR
320 "%s: Failed to find _BBN in parent of: ", 327 "%s: Failed to find _BBN in parent of: %s\n",
321 __func__); 328 __func__, (char *)name_buffer.pointer);
322 acpi_ns_print_node_pathname(handle, NULL); 329 kfree(name_buffer.pointer);
323 printk("\n");
324 return AE_OK; 330 return AE_OK;
325 } 331 }
326 332
@@ -350,24 +356,27 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,
350 acpi_handle rootbus_handle; 356 acpi_handle rootbus_handle;
351 unsigned long long segment; 357 unsigned long long segment;
352 acpi_status status; 358 acpi_status status;
359 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
353 360
354 rootbus_handle = PCI_CONTROLLER(dev)->acpi_handle; 361 rootbus_handle = PCI_CONTROLLER(dev)->acpi_handle;
355 status = acpi_evaluate_integer(rootbus_handle, METHOD_NAME__SEG, NULL, 362 status = acpi_evaluate_integer(rootbus_handle, METHOD_NAME__SEG, NULL,
356 &segment); 363 &segment);
357 if (ACPI_SUCCESS(status)) { 364 if (ACPI_SUCCESS(status)) {
358 if (segment != pci_domain_nr(dev)) { 365 if (segment != pci_domain_nr(dev)) {
366 acpi_get_name(rootbus_handle, ACPI_FULL_PATHNAME,
367 &name_buffer);
359 printk(KERN_ERR 368 printk(KERN_ERR
360 "%s: Segment number mismatch, 0x%llx vs 0x%x for: ", 369 "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n",
361 __func__, segment, pci_domain_nr(dev)); 370 __func__, segment, pci_domain_nr(dev),
362 acpi_ns_print_node_pathname(rootbus_handle, NULL); 371 (char *)name_buffer.pointer);
363 printk("\n"); 372 kfree(name_buffer.pointer);
364 return 1; 373 return 1;
365 } 374 }
366 } else { 375 } else {
367 printk(KERN_ERR "%s: Unable to get __SEG from: ", 376 acpi_get_name(rootbus_handle, ACPI_FULL_PATHNAME, &name_buffer);
368 __func__); 377 printk(KERN_ERR "%s: Unable to get __SEG from: %s\n",
369 acpi_ns_print_node_pathname(rootbus_handle, NULL); 378 __func__, (char *)name_buffer.pointer);
370 printk("\n"); 379 kfree(name_buffer.pointer);
371 return 1; 380 return 1;
372 } 381 }
373 382
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 8a924a5661dd..0d4ffa4da1da 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -26,7 +26,6 @@
26#include <linux/acpi.h> 26#include <linux/acpi.h>
27#include <asm/sn/sn2/sn_hwperf.h> 27#include <asm/sn/sn2/sn_hwperf.h>
28#include <asm/sn/acpi.h> 28#include <asm/sn/acpi.h>
29#include "acpi/acglobal.h"
30 29
31extern void sn_init_cpei_timer(void); 30extern void sn_init_cpei_timer(void);
32extern void register_sn_procfs(void); 31extern void register_sn_procfs(void);
@@ -473,7 +472,7 @@ sn_io_early_init(void)
473 { 472 {
474 struct acpi_table_header *header = NULL; 473 struct acpi_table_header *header = NULL;
475 474
476 acpi_get_table_by_index(ACPI_TABLE_INDEX_DSDT, &header); 475 acpi_get_table(ACPI_SIG_DSDT, 1, &header);
477 BUG_ON(header == NULL); 476 BUG_ON(header == NULL);
478 sn_acpi_rev = header->oem_revision; 477 sn_acpi_rev = header->oem_revision;
479 } 478 }
@@ -505,7 +504,7 @@ sn_io_early_init(void)
505 504
506 { 505 {
507 struct acpi_table_header *header; 506 struct acpi_table_header *header;
508 (void)acpi_get_table_by_index(ACPI_TABLE_INDEX_DSDT, &header); 507 (void)acpi_get_table(ACPI_SIG_DSDT, 1, &header);
509 printk(KERN_INFO "ACPI DSDT OEM Rev 0x%x\n", 508 printk(KERN_INFO "ACPI DSDT OEM Rev 0x%x\n",
510 header->oem_revision); 509 header->oem_revision);
511 } 510 }
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 29dc0c89d4af..d37593c2f438 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -47,7 +47,7 @@
47#endif 47#endif
48 48
49static int __initdata acpi_force = 0; 49static int __initdata acpi_force = 0;
50 50u32 acpi_rsdt_forced;
51#ifdef CONFIG_ACPI 51#ifdef CONFIG_ACPI
52int acpi_disabled = 0; 52int acpi_disabled = 0;
53#else 53#else
@@ -1374,6 +1374,17 @@ static void __init acpi_process_madt(void)
1374 "Invalid BIOS MADT, disabling ACPI\n"); 1374 "Invalid BIOS MADT, disabling ACPI\n");
1375 disable_acpi(); 1375 disable_acpi();
1376 } 1376 }
1377 } else {
1378 /*
1379 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1380 * In the event an MPS table was found, forget it.
1381 * Boot with "acpi=off" to use MPS on such a system.
1382 */
1383 if (smp_found_config) {
1384 printk(KERN_WARNING PREFIX
1385 "No APIC-table, disabling MPS\n");
1386 smp_found_config = 0;
1387 }
1377 } 1388 }
1378 1389
1379 /* 1390 /*
@@ -1809,6 +1820,10 @@ static int __init parse_acpi(char *arg)
1809 disable_acpi(); 1820 disable_acpi();
1810 acpi_ht = 1; 1821 acpi_ht = 1;
1811 } 1822 }
1823 /* acpi=rsdt use RSDT instead of XSDT */
1824 else if (strcmp(arg, "rsdt") == 0) {
1825 acpi_rsdt_forced = 1;
1826 }
1812 /* "acpi=noirq" disables ACPI interrupt routing */ 1827 /* "acpi=noirq" disables ACPI interrupt routing */
1813 else if (strcmp(arg, "noirq") == 0) { 1828 else if (strcmp(arg, "noirq") == 0) {
1814 acpi_noirq_set(); 1829 acpi_noirq_set();
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index c2502eb9aa83..a4805b3b4095 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -56,6 +56,7 @@ static struct cstate_entry *cpu_cstate_entry; /* per CPU ptr */
56static short mwait_supported[ACPI_PROCESSOR_MAX_POWER]; 56static short mwait_supported[ACPI_PROCESSOR_MAX_POWER];
57 57
58#define MWAIT_SUBSTATE_MASK (0xf) 58#define MWAIT_SUBSTATE_MASK (0xf)
59#define MWAIT_CSTATE_MASK (0xf)
59#define MWAIT_SUBSTATE_SIZE (4) 60#define MWAIT_SUBSTATE_SIZE (4)
60 61
61#define CPUID_MWAIT_LEAF (5) 62#define CPUID_MWAIT_LEAF (5)
@@ -98,7 +99,8 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
98 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); 99 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
99 100
100 /* Check whether this particular cx_type (in CST) is supported or not */ 101 /* Check whether this particular cx_type (in CST) is supported or not */
101 cstate_type = (cx->address >> MWAIT_SUBSTATE_SIZE) + 1; 102 cstate_type = ((cx->address >> MWAIT_SUBSTATE_SIZE) &
103 MWAIT_CSTATE_MASK) + 1;
102 edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE); 104 edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE);
103 num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK; 105 num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK;
104 106
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 806b4e9051b4..707c1f6f95fa 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -159,6 +159,8 @@ static int __init acpi_sleep_setup(char *str)
159#endif 159#endif
160 if (strncmp(str, "old_ordering", 12) == 0) 160 if (strncmp(str, "old_ordering", 12) == 0)
161 acpi_old_suspend_ordering(); 161 acpi_old_suspend_ordering();
162 if (strncmp(str, "s4_nonvs", 8) == 0)
163 acpi_s4_no_nvs();
162 str = strchr(str, ','); 164 str = strchr(str, ',');
163 if (str != NULL) 165 if (str != NULL)
164 str += strspn(str, ", \t"); 166 str += strspn(str, ", \t");
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 65a13943e098..e85826829cf2 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -665,6 +665,27 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
665} 665}
666#endif 666#endif
667 667
668#ifdef CONFIG_HIBERNATION
669/**
670 * Mark ACPI NVS memory region, so that we can save/restore it during
671 * hibernation and the subsequent resume.
672 */
673static int __init e820_mark_nvs_memory(void)
674{
675 int i;
676
677 for (i = 0; i < e820.nr_map; i++) {
678 struct e820entry *ei = &e820.map[i];
679
680 if (ei->type == E820_NVS)
681 hibernate_nvs_register(ei->addr, ei->size);
682 }
683
684 return 0;
685}
686core_initcall(e820_mark_nvs_memory);
687#endif
688
668/* 689/*
669 * Early reserved memory areas. 690 * Early reserved memory areas.
670 */ 691 */
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 3c0c93300f12..5d23c13ac7d4 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 += main.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,7 +32,6 @@ 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.
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/include/acpi/acconfig.h b/drivers/acpi/acpica/acconfig.h
index 29feee27f0ea..e6777fb883d2 100644
--- a/include/acpi/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -61,10 +61,6 @@
61 * 61 *
62 */ 62 */
63 63
64/* Current ACPICA subsystem version in YYYYMMDD format */
65
66#define ACPI_CA_VERSION 0x20080926
67
68/* 64/*
69 * OS name, used for the _OS object. The _OS object is essentially obsolete, 65 * OS name, used for the _OS object. The _OS object is essentially obsolete,
70 * but there is a large base of ASL/AML code in existing machines that check 66 * but there is a large base of ASL/AML code in existing machines that check
@@ -119,6 +115,10 @@
119 115
120#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 116#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4
121 117
118/* Maximum number of While() loop iterations before forced abort */
119
120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF
121
122/****************************************************************************** 122/******************************************************************************
123 * 123 *
124 * ACPI Specification constants (Do not change unless the specification changes) 124 * ACPI Specification constants (Do not change unless the specification changes)
diff --git a/include/acpi/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 62c59df3b86c..62c59df3b86c 100644
--- a/include/acpi/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
diff --git a/include/acpi/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 6291904be01e..6291904be01e 100644
--- a/include/acpi/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
diff --git a/include/acpi/acevents.h b/drivers/acpi/acpica/acevents.h
index d5d099bf349c..07e20135f01b 100644
--- a/include/acpi/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -93,11 +93,13 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
93 */ 93 */
94u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info); 94u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info);
95 95
96acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback); 96acpi_status
97acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context);
97 98
98acpi_status 99acpi_status
99acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 100acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
100 struct acpi_gpe_block_info *gpe_block); 101 struct acpi_gpe_block_info *gpe_block,
102 void *context);
101 103
102acpi_status 104acpi_status
103acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, 105acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
diff --git a/include/acpi/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 15dda46b70d1..ddb40f5c68fc 100644
--- a/include/acpi/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -102,6 +102,12 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
102 */ 102 */
103ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE); 103ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
104 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
105/***************************************************************************** 111/*****************************************************************************
106 * 112 *
107 * Debug support 113 * Debug support
@@ -140,7 +146,7 @@ ACPI_EXTERN u32 acpi_gbl_trace_flags;
140 */ 146 */
141ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list; 147ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
142ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT; 148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
143extern u8 acpi_gbl_permanent_mmap; 149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
144 150
145/* These addresses are calculated from FADT address values */ 151/* These addresses are calculated from FADT address values */
146 152
@@ -326,6 +332,7 @@ ACPI_EXTERN struct acpi_fixed_event_handler
326ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 332ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
327ACPI_EXTERN struct acpi_gpe_block_info 333ACPI_EXTERN struct acpi_gpe_block_info
328*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 334*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
335ACPI_EXTERN u32 acpi_current_gpe_count;
329 336
330/***************************************************************************** 337/*****************************************************************************
331 * 338 *
diff --git a/include/acpi/achware.h b/drivers/acpi/acpica/achware.h
index 97a72b193276..58c69dc49ab4 100644
--- a/include/acpi/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -44,11 +44,7 @@
44#ifndef __ACHWARE_H__ 44#ifndef __ACHWARE_H__
45#define __ACHWARE_H__ 45#define __ACHWARE_H__
46 46
47/* PM Timer ticks per second (HZ) */ 47/* Values for the _SST predefined method */
48
49#define PM_TIMER_FREQUENCY 3579545
50
51/* Values for the _SST reserved method */
52 48
53#define ACPI_SST_INDICATOR_OFF 0 49#define ACPI_SST_INDICATOR_OFF 0
54#define ACPI_SST_WORKING 1 50#define ACPI_SST_WORKING 1
@@ -56,8 +52,6 @@
56#define ACPI_SST_SLEEPING 3 52#define ACPI_SST_SLEEPING 3
57#define ACPI_SST_SLEEP_CONTEXT 4 53#define ACPI_SST_SLEEP_CONTEXT 4
58 54
59/* Prototypes */
60
61/* 55/*
62 * hwacpi - high level functions 56 * hwacpi - high level functions
63 */ 57 */
@@ -75,13 +69,6 @@ acpi_hw_register_read(u32 register_id, u32 * return_value);
75 69
76acpi_status acpi_hw_register_write(u32 register_id, u32 value); 70acpi_status acpi_hw_register_write(u32 register_id, u32 value);
77 71
78acpi_status
79acpi_hw_low_level_read(u32 width,
80 u32 * value, struct acpi_generic_address *reg);
81
82acpi_status
83acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address *reg);
84
85acpi_status acpi_hw_clear_acpi_status(void); 72acpi_status acpi_hw_clear_acpi_status(void);
86 73
87/* 74/*
@@ -94,13 +81,13 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
94 81
95acpi_status 82acpi_status
96acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 83acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
97 struct acpi_gpe_block_info *gpe_block); 84 struct acpi_gpe_block_info *gpe_block, void *context);
98 85
99acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info); 86acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info);
100 87
101acpi_status 88acpi_status
102acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 89acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
103 struct acpi_gpe_block_info *gpe_block); 90 struct acpi_gpe_block_info *gpe_block, void *context);
104 91
105acpi_status 92acpi_status
106acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, 93acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
@@ -114,7 +101,8 @@ acpi_status acpi_hw_enable_all_wakeup_gpes(void);
114 101
115acpi_status 102acpi_status
116acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 103acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
117 struct acpi_gpe_block_info *gpe_block); 104 struct acpi_gpe_block_info *gpe_block,
105 void *context);
118 106
119#ifdef ACPI_FUTURE_USAGE 107#ifdef ACPI_FUTURE_USAGE
120/* 108/*
diff --git a/include/acpi/acinterp.h b/drivers/acpi/acpica/acinterp.h
index e8db7a3143a5..e8db7a3143a5 100644
--- a/include/acpi/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
diff --git a/include/acpi/aclocal.h b/drivers/acpi/acpica/aclocal.h
index ecab527cf78e..492d02761bb7 100644
--- a/include/acpi/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -46,8 +46,6 @@
46 46
47/* acpisrc:struct_defs -- for acpisrc conversion */ 47/* acpisrc:struct_defs -- for acpisrc conversion */
48 48
49#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
50#define ACPI_DO_NOT_WAIT 0
51#define ACPI_SERIALIZED 0xFF 49#define ACPI_SERIALIZED 0xFF
52 50
53typedef u32 acpi_mutex_handle; 51typedef u32 acpi_mutex_handle;
@@ -120,11 +118,6 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
120#define ACPI_MAX_LOCK 1 118#define ACPI_MAX_LOCK 1
121#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 119#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1
122 120
123/* Owner IDs are used to track namespace nodes for selective deletion */
124
125typedef u8 acpi_owner_id;
126#define ACPI_OWNER_ID_MAX 0xFF
127
128/* This Thread ID means that the mutex is not in use (unlocked) */ 121/* This Thread ID means that the mutex is not in use (unlocked) */
129 122
130#define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0 123#define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
@@ -165,11 +158,6 @@ typedef enum {
165 ACPI_IMODE_EXECUTE = 0x03 158 ACPI_IMODE_EXECUTE = 0x03
166} acpi_interpreter_mode; 159} acpi_interpreter_mode;
167 160
168union acpi_name_union {
169 u32 integer;
170 char ascii[4];
171};
172
173/* 161/*
174 * The Namespace Node describes a named object that appears in the AML. 162 * The Namespace Node describes a named object that appears in the AML.
175 * descriptor_type is used to differentiate between internal descriptors. 163 * descriptor_type is used to differentiate between internal descriptors.
@@ -216,26 +204,6 @@ struct acpi_namespace_node {
216#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */ 204#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */
217#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */ 205#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
218 206
219/*
220 * ACPI Table Descriptor. One per ACPI table
221 */
222struct acpi_table_desc {
223 acpi_physical_address address;
224 struct acpi_table_header *pointer;
225 u32 length; /* Length fixed at 32 bits */
226 union acpi_name_union signature;
227 acpi_owner_id owner_id;
228 u8 flags;
229};
230
231/* Flags for above */
232
233#define ACPI_TABLE_ORIGIN_UNKNOWN (0)
234#define ACPI_TABLE_ORIGIN_MAPPED (1)
235#define ACPI_TABLE_ORIGIN_ALLOCATED (2)
236#define ACPI_TABLE_ORIGIN_MASK (3)
237#define ACPI_TABLE_IS_LOADED (4)
238
239/* One internal RSDT for table management */ 207/* One internal RSDT for table management */
240 208
241struct acpi_internal_rsdt { 209struct acpi_internal_rsdt {
@@ -266,15 +234,6 @@ struct acpi_ns_search_data {
266 struct acpi_namespace_node *node; 234 struct acpi_namespace_node *node;
267}; 235};
268 236
269/*
270 * Predefined Namespace items
271 */
272struct acpi_predefined_names {
273 char *name;
274 u8 type;
275 char *val;
276};
277
278/* Object types used during package copies */ 237/* Object types used during package copies */
279 238
280#define ACPI_COPY_TYPE_SIMPLE 0 239#define ACPI_COPY_TYPE_SIMPLE 0
@@ -487,10 +446,15 @@ struct acpi_gpe_walk_info {
487 struct acpi_gpe_block_info *gpe_block; 446 struct acpi_gpe_block_info *gpe_block;
488}; 447};
489 448
490typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info * 449struct acpi_gpe_device_info {
491 gpe_xrupt_info, 450 u32 index;
492 struct acpi_gpe_block_info * 451 u32 next_block_base_index;
493 gpe_block); 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);
494 458
495/* Information about each particular fixed event */ 459/* Information about each particular fixed event */
496 460
@@ -566,6 +530,7 @@ struct acpi_control_state {
566 union acpi_parse_object *predicate_op; 530 union acpi_parse_object *predicate_op;
567 u8 *aml_predicate_start; /* Start of if/while predicate */ 531 u8 *aml_predicate_start; /* Start of if/while predicate */
568 u8 *package_end; /* End of if/while block */ 532 u8 *package_end; /* End of if/while block */
533 u32 loop_count; /* While() loop counter */
569}; 534};
570 535
571/* 536/*
@@ -671,6 +636,12 @@ union acpi_parse_value {
671 union acpi_parse_object *arg; /* arguments and contained ops */ 636 union acpi_parse_object *arg; /* arguments and contained ops */
672}; 637};
673 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
674#define ACPI_PARSE_COMMON \ 645#define ACPI_PARSE_COMMON \
675 union acpi_parse_object *parent; /* Parent op */\ 646 union acpi_parse_object *parent; /* Parent op */\
676 u8 descriptor_type; /* To differentiate various internal objs */\ 647 u8 descriptor_type; /* To differentiate various internal objs */\
@@ -790,9 +761,6 @@ struct acpi_parse_state {
790 * 761 *
791 ****************************************************************************/ 762 ****************************************************************************/
792 763
793#define PCI_ROOT_HID_STRING "PNP0A03"
794#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
795
796struct acpi_bit_register_info { 764struct acpi_bit_register_info {
797 u8 parent_register; 765 u8 parent_register;
798 u8 bit_position; 766 u8 bit_position;
@@ -1019,26 +987,4 @@ struct acpi_debug_mem_block {
1019#define ACPI_MEM_LIST_MAX 1 987#define ACPI_MEM_LIST_MAX 1
1020#define ACPI_NUM_MEM_LISTS 2 988#define ACPI_NUM_MEM_LISTS 2
1021 989
1022struct acpi_memory_list {
1023 char *list_name;
1024 void *list_head;
1025 u16 object_size;
1026 u16 max_depth;
1027 u16 current_depth;
1028 u16 link_offset;
1029
1030#ifdef ACPI_DBG_TRACK_ALLOCATIONS
1031
1032 /* Statistics for debug memory tracking only */
1033
1034 u32 total_allocated;
1035 u32 total_freed;
1036 u32 max_occupied;
1037 u32 total_size;
1038 u32 current_total_size;
1039 u32 requests;
1040 u32 hits;
1041#endif
1042};
1043
1044#endif /* __ACLOCAL_H__ */ 990#endif /* __ACLOCAL_H__ */
diff --git a/include/acpi/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 1954c9d1d012..9c127e8e2d6d 100644
--- a/include/acpi/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -45,23 +45,6 @@
45#define __ACMACROS_H__ 45#define __ACMACROS_H__
46 46
47/* 47/*
48 * Data manipulation macros
49 */
50#define ACPI_LOWORD(l) ((u16)(u32)(l))
51#define ACPI_HIWORD(l) ((u16)((((u32)(l)) >> 16) & 0xFFFF))
52#define ACPI_LOBYTE(l) ((u8)(u16)(l))
53#define ACPI_HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF))
54
55#define ACPI_SET_BIT(target,bit) ((target) |= (bit))
56#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit))
57#define ACPI_MIN(a,b) (((a)<(b))?(a):(b))
58#define ACPI_MAX(a,b) (((a)>(b))?(a):(b))
59
60/* Size calculation */
61
62#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
63
64/*
65 * Extract data using a pointer. Any more than a byte and we 48 * Extract data using a pointer. Any more than a byte and we
66 * get into potential aligment issues -- see the STORE macros below. 49 * get into potential aligment issues -- see the STORE macros below.
67 * Use with care. 50 * Use with care.
@@ -76,39 +59,6 @@
76#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) 59#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr)
77 60
78/* 61/*
79 * Pointer manipulation
80 */
81#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p))
82#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p))
83#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b)))
84#define ACPI_PTR_DIFF(a, b) (acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))
85
86/* Pointer/Integer type conversions */
87
88#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL, (acpi_size) i)
89#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL)
90#define ACPI_OFFSET(d, f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL)
91#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i)
92#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
93
94#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
95#define ACPI_COMPARE_NAME(a, b) (*ACPI_CAST_PTR (u32, (a)) == *ACPI_CAST_PTR (u32, (b)))
96#else
97#define ACPI_COMPARE_NAME(a, b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
98#endif
99
100/*
101 * Full 64-bit integer must be available on both 32-bit and 64-bit platforms
102 */
103struct acpi_integer_overlay {
104 u32 lo_dword;
105 u32 hi_dword;
106};
107
108#define ACPI_LODWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->lo_dword)
109#define ACPI_HIDWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->hi_dword)
110
111/*
112 * printf() format helpers 62 * printf() format helpers
113 */ 63 */
114 64
@@ -209,7 +159,7 @@ struct acpi_integer_overlay {
209/* 159/*
210 * The hardware does not support unaligned transfers. We must move the 160 * The hardware does not support unaligned transfers. We must move the
211 * data one byte at a time. These macros work whether the source or 161 * data one byte at a time. These macros work whether the source or
212 * the destination (or both) is/are unaligned. (Little-endian move) 162 * the destination (or both) is/are unaligned. (Little-endian move)
213 */ 163 */
214 164
215/* 16-bit source, 16/32/64 destination */ 165/* 16-bit source, 16/32/64 destination */
@@ -357,12 +307,6 @@ struct acpi_integer_overlay {
357 {(u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type} 307 {(u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
358#endif 308#endif
359 309
360#ifdef ACPI_DISASSEMBLER
361#define ACPI_DISASM_ONLY_MEMBERS(a) a;
362#else
363#define ACPI_DISASM_ONLY_MEMBERS(a)
364#endif
365
366#define ARG_TYPE_WIDTH 5 310#define ARG_TYPE_WIDTH 5
367#define ARG_1(x) ((u32)(x)) 311#define ARG_1(x) ((u32)(x))
368#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH)) 312#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH))
@@ -388,32 +332,16 @@ struct acpi_integer_overlay {
388#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) 332#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
389#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) 333#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
390 334
391#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
392/*
393 * Module name is include in both debug and non-debug versions primarily for
394 * error messages. The __FILE__ macro is not very useful for this, because it
395 * often includes the entire pathname to the module
396 */
397#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name;
398#else
399#define ACPI_MODULE_NAME(name)
400#endif
401
402/* 335/*
403 * Ascii error messages can be configured out 336 * Ascii error messages can be configured out
404 */ 337 */
405#ifndef ACPI_NO_ERROR_MESSAGES 338#ifndef ACPI_NO_ERROR_MESSAGES
406#define AE_INFO _acpi_module_name, __LINE__
407 339
408/* 340/*
409 * Error reporting. Callers module and line number are inserted by AE_INFO, 341 * Error reporting. Callers module and line number are inserted by AE_INFO,
410 * the plist contains a set of parens to allow variable-length lists. 342 * the plist contains a set of parens to allow variable-length lists.
411 * These macros are used for both the debug and non-debug versions of the code. 343 * These macros are used for both the debug and non-debug versions of the code.
412 */ 344 */
413#define ACPI_INFO(plist) acpi_ut_info plist
414#define ACPI_WARNING(plist) acpi_ut_warning plist
415#define ACPI_EXCEPTION(plist) acpi_ut_exception plist
416#define ACPI_ERROR(plist) acpi_ut_error plist
417#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e); 345#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
418#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); 346#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
419 347
@@ -421,13 +349,9 @@ struct acpi_integer_overlay {
421 349
422/* No error messages */ 350/* No error messages */
423 351
424#define ACPI_INFO(plist)
425#define ACPI_WARNING(plist)
426#define ACPI_EXCEPTION(plist)
427#define ACPI_ERROR(plist)
428#define ACPI_ERROR_NAMESPACE(s, e) 352#define ACPI_ERROR_NAMESPACE(s, e)
429#define ACPI_ERROR_METHOD(s, n, p, e) 353#define ACPI_ERROR_METHOD(s, n, p, e)
430#endif 354#endif /* ACPI_NO_ERROR_MESSAGES */
431 355
432/* 356/*
433 * Debug macros that are conditionally compiled 357 * Debug macros that are conditionally compiled
@@ -435,36 +359,8 @@ struct acpi_integer_overlay {
435#ifdef ACPI_DEBUG_OUTPUT 359#ifdef ACPI_DEBUG_OUTPUT
436 360
437/* 361/*
438 * Common parameters used for debug output functions:
439 * line number, function name, module(file) name, component ID
440 */
441#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
442
443/*
444 * Function entry tracing 362 * Function entry tracing
445 */ 363 */
446
447/*
448 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
449 * define it now. This is the case where there the compiler does not support
450 * a __func__ macro or equivalent.
451 */
452#ifndef ACPI_GET_FUNCTION_NAME
453#define ACPI_GET_FUNCTION_NAME _acpi_function_name
454/*
455 * The Name parameter should be the procedure name as a quoted string.
456 * The function name is also used by the function exit macros below.
457 * Note: (const char) is used to be compatible with the debug interfaces
458 * and macros such as __func__.
459 */
460#define ACPI_FUNCTION_NAME(name) static const char _acpi_function_name[] = #name;
461
462#else
463/* Compiler supports __func__ (or equivalent) -- Ignore this macro */
464
465#define ACPI_FUNCTION_NAME(name)
466#endif
467
468#ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE 364#ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE
469 365
470#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 366#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
@@ -584,15 +480,6 @@ struct acpi_integer_overlay {
584#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) 480#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
585#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) 481#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
586 482
587/*
588 * Master debug print macros
589 * Print iff:
590 * 1) Debug print for the current component is enabled
591 * 2) Debug error level or trace level for the print statement is enabled
592 */
593#define ACPI_DEBUG_PRINT(plist) acpi_ut_debug_print plist
594#define ACPI_DEBUG_PRINT_RAW(plist) acpi_ut_debug_print_raw plist
595
596#else 483#else
597/* 484/*
598 * This is the non-debug case -- make everything go away, 485 * This is the non-debug case -- make everything go away,
@@ -603,7 +490,6 @@ struct acpi_integer_overlay {
603 490
604#define ACPI_DEBUG_DEFINE(a) do { } while(0) 491#define ACPI_DEBUG_DEFINE(a) do { } while(0)
605#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0) 492#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
606#define ACPI_FUNCTION_NAME(a) do { } while(0)
607#define ACPI_FUNCTION_TRACE(a) do { } while(0) 493#define ACPI_FUNCTION_TRACE(a) do { } while(0)
608#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0) 494#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0)
609#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0) 495#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0)
@@ -619,8 +505,6 @@ struct acpi_integer_overlay {
619#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0) 505#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0)
620#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0) 506#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
621#define ACPI_DUMP_BUFFER(a, b) do { } while(0) 507#define ACPI_DUMP_BUFFER(a, b) do { } while(0)
622#define ACPI_DEBUG_PRINT(pl) do { } while(0)
623#define ACPI_DEBUG_PRINT_RAW(pl) do { } while(0)
624 508
625#define return_VOID return 509#define return_VOID return
626#define return_ACPI_STATUS(s) return(s) 510#define return_ACPI_STATUS(s) return(s)
@@ -629,7 +513,7 @@ struct acpi_integer_overlay {
629#define return_UINT32(s) return(s) 513#define return_UINT32(s) return(s)
630#define return_PTR(s) return(s) 514#define return_PTR(s) return(s)
631 515
632#endif 516#endif /* ACPI_DEBUG_OUTPUT */
633 517
634/* 518/*
635 * Some code only gets executed when the debugger is built in. 519 * Some code only gets executed when the debugger is built in.
diff --git a/include/acpi/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index db4e6f677855..46cb5b46d280 100644
--- a/include/acpi/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -182,7 +182,9 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
182 */ 182 */
183acpi_status 183acpi_status
184acpi_ns_check_predefined_names(struct acpi_namespace_node *node, 184acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
185 union acpi_operand_object *return_object); 185 u32 user_param_count,
186 acpi_status return_status,
187 union acpi_operand_object **return_object);
186 188
187const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct 189const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
188 acpi_namespace_node 190 acpi_namespace_node
@@ -191,6 +193,7 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
191void 193void
192acpi_ns_check_parameter_count(char *pathname, 194acpi_ns_check_parameter_count(char *pathname,
193 struct acpi_namespace_node *node, 195 struct acpi_namespace_node *node,
196 u32 user_param_count,
194 const union acpi_predefined_info *info); 197 const union acpi_predefined_info *info);
195 198
196/* 199/*
diff --git a/include/acpi/acobject.h b/drivers/acpi/acpica/acobject.h
index eb6f038b03d9..eb6f038b03d9 100644
--- a/include/acpi/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
diff --git a/include/acpi/acopcode.h b/drivers/acpi/acpica/acopcode.h
index dfdf63327885..dfdf63327885 100644
--- a/include/acpi/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
diff --git a/include/acpi/acparser.h b/drivers/acpi/acpica/acparser.h
index 23ee0fbf5619..23ee0fbf5619 100644
--- a/include/acpi/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
diff --git a/include/acpi/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 16a9ca9a66e4..16a9ca9a66e4 100644
--- a/include/acpi/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
diff --git a/include/acpi/acresrc.h b/drivers/acpi/acpica/acresrc.h
index eef5bd7a59fa..eef5bd7a59fa 100644
--- a/include/acpi/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
diff --git a/include/acpi/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 7980a26bad35..7980a26bad35 100644
--- a/include/acpi/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
diff --git a/include/acpi/actables.h b/drivers/acpi/acpica/actables.h
index 0cbe1b9ab522..7ce6e33c7f78 100644
--- a/include/acpi/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -94,6 +94,8 @@ void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
94/* 94/*
95 * tbutils - table manager utilities 95 * tbutils - table manager utilities
96 */ 96 */
97acpi_status acpi_tb_initialize_facs(void);
98
97u8 acpi_tb_tables_loaded(void); 99u8 acpi_tb_tables_loaded(void);
98 100
99void 101void
diff --git a/include/acpi/acutils.h b/drivers/acpi/acpica/acutils.h
index d8307b2987e3..80d8813484fe 100644
--- a/include/acpi/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -297,42 +297,6 @@ void acpi_ut_report_info(char *module_name, u32 line_number);
297 297
298void acpi_ut_report_warning(char *module_name, u32 line_number); 298void acpi_ut_report_warning(char *module_name, u32 line_number);
299 299
300/* Error and message reporting interfaces */
301
302void ACPI_INTERNAL_VAR_XFACE
303acpi_ut_debug_print(u32 requested_debug_level,
304 u32 line_number,
305 const char *function_name,
306 const char *module_name,
307 u32 component_id,
308 const char *format, ...) ACPI_PRINTF_LIKE(6);
309
310void ACPI_INTERNAL_VAR_XFACE
311acpi_ut_debug_print_raw(u32 requested_debug_level,
312 u32 line_number,
313 const char *function_name,
314 const char *module_name,
315 u32 component_id,
316 const char *format, ...) ACPI_PRINTF_LIKE(6);
317
318void ACPI_INTERNAL_VAR_XFACE
319acpi_ut_error(const char *module_name,
320 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
321
322void ACPI_INTERNAL_VAR_XFACE
323acpi_ut_exception(const char *module_name,
324 u32 line_number,
325 acpi_status status,
326 const char *format, ...) ACPI_PRINTF_LIKE(4);
327
328void ACPI_INTERNAL_VAR_XFACE
329acpi_ut_warning(const char *module_name,
330 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
331
332void ACPI_INTERNAL_VAR_XFACE
333acpi_ut_info(const char *module_name,
334 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
335
336/* 300/*
337 * utdelete - Object deletion and reference counts 301 * utdelete - Object deletion and reference counts
338 */ 302 */
diff --git a/include/acpi/amlcode.h b/drivers/acpi/acpica/amlcode.h
index ff851c5df698..ff851c5df698 100644
--- a/include/acpi/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
diff --git a/include/acpi/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 7b070e42b7c5..7b070e42b7c5 100644
--- a/include/acpi/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
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 f45c74fe745e..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:
@@ -295,7 +296,7 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
295 * 296 *
296 * FUNCTION: acpi_ev_get_gpe_event_info 297 * FUNCTION: acpi_ev_get_gpe_event_info
297 * 298 *
298 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 299 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
299 * gpe_number - Raw GPE number 300 * gpe_number - Raw GPE number
300 * 301 *
301 * 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
@@ -372,7 +373,7 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
372 * 373 *
373 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 374 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
374 * 375 *
375 * DESCRIPTION: Detect if any GP events have occurred. This function is 376 * DESCRIPTION: Detect if any GP events have occurred. This function is
376 * executed at interrupt level. 377 * executed at interrupt level.
377 * 378 *
378 ******************************************************************************/ 379 ******************************************************************************/
@@ -400,8 +401,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
400 401
401 /* 402 /*
402 * 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
403 * Note: Not necessary to obtain the hardware lock, since the GPE registers 404 * Note: Not necessary to obtain the hardware lock, since the GPE
404 * are owned by the gpe_lock. 405 * registers are owned by the gpe_lock.
405 */ 406 */
406 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 407 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
407 408
@@ -410,9 +411,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
410 gpe_block = gpe_xrupt_list->gpe_block_list_head; 411 gpe_block = gpe_xrupt_list->gpe_block_list_head;
411 while (gpe_block) { 412 while (gpe_block) {
412 /* 413 /*
413 * 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
414 * in this GPE block, saving all of them. 415 * block, saving all of them. Find all currently active GP events.
415 * Find all currently active GP events.
416 */ 416 */
417 for (i = 0; i < gpe_block->register_count; i++) { 417 for (i = 0; i < gpe_block->register_count; i++) {
418 418
@@ -423,10 +423,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
423 /* Read the Status Register */ 423 /* Read the Status Register */
424 424
425 status = 425 status =
426 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 426 acpi_read(&status_reg,
427 &status_reg, 427 &gpe_register_info->status_address);
428 &gpe_register_info->
429 status_address);
430 if (ACPI_FAILURE(status)) { 428 if (ACPI_FAILURE(status)) {
431 goto unlock_and_exit; 429 goto unlock_and_exit;
432 } 430 }
@@ -434,10 +432,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
434 /* Read the Enable Register */ 432 /* Read the Enable Register */
435 433
436 status = 434 status =
437 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 435 acpi_read(&enable_reg,
438 &enable_reg, 436 &gpe_register_info->enable_address);
439 &gpe_register_info->
440 enable_address);
441 if (ACPI_FAILURE(status)) { 437 if (ACPI_FAILURE(status)) {
442 goto unlock_and_exit; 438 goto unlock_and_exit;
443 } 439 }
@@ -527,8 +523,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
527 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); 523 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
528 524
529 /* 525 /*
530 * 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
531 * info to prevent a race condition with remove_handler/remove_block. 527 * prevent a race condition with remove_handler/remove_block.
532 */ 528 */
533 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, 529 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
534 sizeof(struct acpi_gpe_event_info)); 530 sizeof(struct acpi_gpe_event_info));
@@ -539,8 +535,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
539 } 535 }
540 536
541 /* 537 /*
542 * Must check for control method type dispatch one more 538 * Must check for control method type dispatch one more time to avoid a
543 * time to avoid race with ev_gpe_install_handler 539 * race with ev_gpe_install_handler
544 */ 540 */
545 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 541 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
546 ACPI_GPE_DISPATCH_METHOD) { 542 ACPI_GPE_DISPATCH_METHOD) {
@@ -584,8 +580,8 @@ static void acpi_ev_asynch_enable_gpe(void *context)
584 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 580 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
585 ACPI_GPE_LEVEL_TRIGGERED) { 581 ACPI_GPE_LEVEL_TRIGGERED) {
586 /* 582 /*
587 * GPE is level-triggered, we clear the GPE status bit after 583 * GPE is level-triggered, we clear the GPE status bit after handling
588 * handling the event. 584 * the event.
589 */ 585 */
590 status = acpi_hw_clear_gpe(gpe_event_info); 586 status = acpi_hw_clear_gpe(gpe_event_info);
591 if (ACPI_FAILURE(status)) { 587 if (ACPI_FAILURE(status)) {
@@ -624,7 +620,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
624 acpi_os_gpe_count(gpe_number); 620 acpi_os_gpe_count(gpe_number);
625 621
626 /* 622 /*
627 * If edge-triggered, clear the GPE status bit now. Note that 623 * If edge-triggered, clear the GPE status bit now. Note that
628 * level-triggered events are cleared after the GPE is serviced. 624 * level-triggered events are cleared after the GPE is serviced.
629 */ 625 */
630 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 626 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
@@ -650,7 +646,8 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
650 646
651 /* 647 /*
652 * Invoke the installed handler (at interrupt level) 648 * Invoke the installed handler (at interrupt level)
653 * Ignore return status for now. TBD: leave GPE disabled on error? 649 * Ignore return status for now.
650 * TBD: leave GPE disabled on error?
654 */ 651 */
655 (void)gpe_event_info->dispatch.handler->address(gpe_event_info-> 652 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
656 dispatch. 653 dispatch.
@@ -708,7 +705,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
708 gpe_number)); 705 gpe_number));
709 706
710 /* 707 /*
711 * Disable the GPE. The GPE will remain disabled until the ACPI 708 * Disable the GPE. The GPE will remain disabled until the ACPICA
712 * Core Subsystem is restarted, or a handler is installed. 709 * Core Subsystem is restarted, or a handler is installed.
713 */ 710 */
714 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 41554f736b68..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].
@@ -343,8 +350,8 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
343 } 350 }
344 351
345 /* 352 /*
346 * Disable the requested fixed event (by writing a zero to the 353 * Disable the requested fixed event (by writing a zero to the enable
347 * enable register bit) 354 * register bit)
348 */ 355 */
349 status = 356 status =
350 acpi_set_register(acpi_gbl_fixed_event_info[event]. 357 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -396,8 +403,8 @@ acpi_status acpi_clear_event(u32 event)
396 } 403 }
397 404
398 /* 405 /*
399 * Clear the requested fixed event (By writing a one to the 406 * Clear the requested fixed event (By writing a one to the status
400 * status register bit) 407 * register bit)
401 */ 408 */
402 status = 409 status =
403 acpi_set_register(acpi_gbl_fixed_event_info[event]. 410 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -717,3 +724,148 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
717} 724}
718 725
719ACPI_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 a7dc87ecee37..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")
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 60e8c47128e9..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")
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 1c118ba78adb..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")
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 08b8d73e6ee5..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")
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 2817158fb6a1..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 /*
@@ -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..9684cc827930 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
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/acpica/tbxface.c
index fd7770aa1061..c3e841f3cde9 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")
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..da9450bc60f7 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")
@@ -129,7 +130,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
129 130
130 /* The interface is supported */ 131 /* The interface is supported */
131 132
132 return_ACPI_STATUS(AE_CTRL_TERMINATE); 133 return_ACPI_STATUS(AE_OK);
133 } 134 }
134 } 135 }
135 136
@@ -143,13 +144,13 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
143 144
144 /* The interface is supported */ 145 /* The interface is supported */
145 146
146 return_ACPI_STATUS(AE_CTRL_TERMINATE); 147 return_ACPI_STATUS(AE_OK);
147 } 148 }
148 149
149 /* The interface is not supported */ 150 /* The interface is not supported */
150 151
151 return_desc->integer.value = 0; 152 return_desc->integer.value = 0;
152 return_ACPI_STATUS(AE_CTRL_TERMINATE); 153 return_ACPI_STATUS(AE_OK);
153} 154}
154 155
155/******************************************************************************* 156/*******************************************************************************
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 17ed5ac840f7..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 *
@@ -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 4bef3cfbaccb..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")
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/battery.c b/drivers/acpi/battery.c
index 1423b0c0cd2e..65132f920459 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -471,7 +471,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
471 471
472static int acpi_battery_update(struct acpi_battery *battery) 472static int acpi_battery_update(struct acpi_battery *battery)
473{ 473{
474 int result; 474 int result, old_present = acpi_battery_present(battery);
475 result = acpi_battery_get_status(battery); 475 result = acpi_battery_get_status(battery);
476 if (result) 476 if (result)
477 return result; 477 return result;
@@ -482,7 +482,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
482 return 0; 482 return 0;
483 } 483 }
484#endif 484#endif
485 if (!battery->update_time) { 485 if (!battery->update_time ||
486 old_present != acpi_battery_present(battery)) {
486 result = acpi_battery_get_info(battery); 487 result = acpi_battery_get_info(battery);
487 if (result) 488 if (result)
488 return result; 489 return result;
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index 307963bd1043..332fe4b21708 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -27,9 +27,6 @@
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"
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index c48396892008..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");
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/ec.c b/drivers/acpi/ec.c
index 30f3ef236ecb..8dfcbb8aff73 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"
@@ -370,7 +369,7 @@ unlock:
370 * Note: samsung nv5000 doesn't work with ec burst mode. 369 * Note: samsung nv5000 doesn't work with ec burst mode.
371 * http://bugzilla.kernel.org/show_bug.cgi?id=4980 370 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
372 */ 371 */
373int acpi_ec_burst_enable(struct acpi_ec *ec) 372static int acpi_ec_burst_enable(struct acpi_ec *ec)
374{ 373{
375 u8 d; 374 u8 d;
376 struct transaction t = {.command = ACPI_EC_BURST_ENABLE, 375 struct transaction t = {.command = ACPI_EC_BURST_ENABLE,
@@ -380,7 +379,7 @@ int acpi_ec_burst_enable(struct acpi_ec *ec)
380 return acpi_ec_transaction(ec, &t, 0); 379 return acpi_ec_transaction(ec, &t, 0);
381} 380}
382 381
383int acpi_ec_burst_disable(struct acpi_ec *ec) 382static int acpi_ec_burst_disable(struct acpi_ec *ec)
384{ 383{
385 struct transaction t = {.command = ACPI_EC_BURST_DISABLE, 384 struct transaction t = {.command = ACPI_EC_BURST_DISABLE,
386 .wdata = NULL, .rdata = NULL, 385 .wdata = NULL, .rdata = NULL,
@@ -756,10 +755,15 @@ static acpi_status
756acpi_ec_register_query_methods(acpi_handle handle, u32 level, 755acpi_ec_register_query_methods(acpi_handle handle, u32 level,
757 void *context, void **return_value) 756 void *context, void **return_value)
758{ 757{
759 struct acpi_namespace_node *node = handle; 758 char node_name[5];
759 struct acpi_buffer buffer = { sizeof(node_name), node_name };
760 struct acpi_ec *ec = context; 760 struct acpi_ec *ec = context;
761 int value = 0; 761 int value = 0;
762 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) { 762 acpi_status status;
763
764 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
765
766 if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) {
763 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); 767 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
764 } 768 }
765 return AE_OK; 769 return AE_OK;
@@ -978,9 +982,9 @@ static const struct acpi_device_id ec_device_ids[] = {
978 982
979int __init acpi_ec_ecdt_probe(void) 983int __init acpi_ec_ecdt_probe(void)
980{ 984{
981 int ret;
982 acpi_status status; 985 acpi_status status;
983 struct acpi_table_ecdt *ecdt_ptr; 986 struct acpi_table_ecdt *ecdt_ptr;
987 acpi_handle dummy;
984 988
985 boot_ec = make_acpi_ec(); 989 boot_ec = make_acpi_ec();
986 if (!boot_ec) 990 if (!boot_ec)
@@ -1006,30 +1010,31 @@ int __init acpi_ec_ecdt_probe(void)
1006 boot_ec->gpe = ecdt_ptr->gpe; 1010 boot_ec->gpe = ecdt_ptr->gpe;
1007 boot_ec->handle = ACPI_ROOT_OBJECT; 1011 boot_ec->handle = ACPI_ROOT_OBJECT;
1008 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); 1012 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
1009 } else { 1013 /* Add some basic check against completely broken table */
1010 /* This workaround is needed only on some broken machines, 1014 if (boot_ec->data_addr != boot_ec->command_addr)
1011 * which require early EC, but fail to provide ECDT */ 1015 goto install;
1012 acpi_handle x; 1016 /* fall through */
1013 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
1014 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
1015 boot_ec, NULL);
1016 /* Check that acpi_get_devices actually find something */
1017 if (ACPI_FAILURE(status) || !boot_ec->handle)
1018 goto error;
1019 /* We really need to limit this workaround, the only ASUS,
1020 * which needs it, has fake EC._INI method, so use it as flag.
1021 * Keep boot_ec struct as it will be needed soon.
1022 */
1023 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
1024 return -ENODEV;
1025 } 1017 }
1026 1018 /* This workaround is needed only on some broken machines,
1027 ret = ec_install_handlers(boot_ec); 1019 * which require early EC, but fail to provide ECDT */
1028 if (!ret) { 1020 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
1021 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
1022 boot_ec, NULL);
1023 /* Check that acpi_get_devices actually find something */
1024 if (ACPI_FAILURE(status) || !boot_ec->handle)
1025 goto error;
1026 /* We really need to limit this workaround, the only ASUS,
1027 * which needs it, has fake EC._INI method, so use it as flag.
1028 * Keep boot_ec struct as it will be needed soon.
1029 */
1030 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
1031 return -ENODEV;
1032install:
1033 if (!ec_install_handlers(boot_ec)) {
1029 first_ec = boot_ec; 1034 first_ec = boot_ec;
1030 return 0; 1035 return 0;
1031 } 1036 }
1032 error: 1037error:
1033 kfree(boot_ec); 1038 kfree(boot_ec);
1034 boot_ec = NULL; 1039 boot_ec = NULL;
1035 return -ENODEV; 1040 return -ENODEV;
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/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/sleep/main.c b/drivers/acpi/main.c
index 28a691cc625e..7e3c609cbef2 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/main.c
@@ -101,13 +101,26 @@ void __init acpi_old_suspend_ordering(void)
101 * cases. 101 * cases.
102 */ 102 */
103static bool set_sci_en_on_resume; 103static bool set_sci_en_on_resume;
104/*
105 * The ACPI specification wants us to save NVS memory regions during hibernation
106 * and to restore them during the subsequent resume. However, it is not certain
107 * if this mechanism is going to work on all machines, so we allow the user to
108 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
109 * option.
110 */
111static bool s4_no_nvs;
112
113void __init acpi_s4_no_nvs(void)
114{
115 s4_no_nvs = true;
116}
104 117
105/** 118/**
106 * acpi_pm_disable_gpes - Disable the GPEs. 119 * acpi_pm_disable_gpes - Disable the GPEs.
107 */ 120 */
108static int acpi_pm_disable_gpes(void) 121static int acpi_pm_disable_gpes(void)
109{ 122{
110 acpi_hw_disable_all_gpes(); 123 acpi_disable_all_gpes();
111 return 0; 124 return 0;
112} 125}
113 126
@@ -135,7 +148,7 @@ static int acpi_pm_prepare(void)
135 int error = __acpi_pm_prepare(); 148 int error = __acpi_pm_prepare();
136 149
137 if (!error) 150 if (!error)
138 acpi_hw_disable_all_gpes(); 151 acpi_disable_all_gpes();
139 return error; 152 return error;
140} 153}
141 154
@@ -267,7 +280,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
267 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire. 280 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
268 * acpi_leave_sleep_state will reenable specific GPEs later 281 * acpi_leave_sleep_state will reenable specific GPEs later
269 */ 282 */
270 acpi_hw_disable_all_gpes(); 283 acpi_disable_all_gpes();
271 284
272 local_irq_restore(flags); 285 local_irq_restore(flags);
273 printk(KERN_DEBUG "Back to C!\n"); 286 printk(KERN_DEBUG "Back to C!\n");
@@ -394,9 +407,25 @@ void __init acpi_no_s4_hw_signature(void)
394 407
395static int acpi_hibernation_begin(void) 408static int acpi_hibernation_begin(void)
396{ 409{
397 acpi_target_sleep_state = ACPI_STATE_S4; 410 int error;
398 acpi_sleep_tts_switch(acpi_target_sleep_state); 411
399 return 0; 412 error = s4_no_nvs ? 0 : hibernate_nvs_alloc();
413 if (!error) {
414 acpi_target_sleep_state = ACPI_STATE_S4;
415 acpi_sleep_tts_switch(acpi_target_sleep_state);
416 }
417
418 return error;
419}
420
421static int acpi_hibernation_pre_snapshot(void)
422{
423 int error = acpi_pm_prepare();
424
425 if (!error)
426 hibernate_nvs_save();
427
428 return error;
400} 429}
401 430
402static int acpi_hibernation_enter(void) 431static int acpi_hibernation_enter(void)
@@ -417,6 +446,12 @@ static int acpi_hibernation_enter(void)
417 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 446 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
418} 447}
419 448
449static void acpi_hibernation_finish(void)
450{
451 hibernate_nvs_free();
452 acpi_pm_finish();
453}
454
420static void acpi_hibernation_leave(void) 455static void acpi_hibernation_leave(void)
421{ 456{
422 /* 457 /*
@@ -432,18 +467,20 @@ static void acpi_hibernation_leave(void)
432 "cannot resume!\n"); 467 "cannot resume!\n");
433 panic("ACPI S4 hardware signature mismatch"); 468 panic("ACPI S4 hardware signature mismatch");
434 } 469 }
470 /* Restore the NVS memory area */
471 hibernate_nvs_restore();
435} 472}
436 473
437static void acpi_pm_enable_gpes(void) 474static void acpi_pm_enable_gpes(void)
438{ 475{
439 acpi_hw_enable_all_runtime_gpes(); 476 acpi_enable_all_runtime_gpes();
440} 477}
441 478
442static struct platform_hibernation_ops acpi_hibernation_ops = { 479static struct platform_hibernation_ops acpi_hibernation_ops = {
443 .begin = acpi_hibernation_begin, 480 .begin = acpi_hibernation_begin,
444 .end = acpi_pm_end, 481 .end = acpi_pm_end,
445 .pre_snapshot = acpi_pm_prepare, 482 .pre_snapshot = acpi_hibernation_pre_snapshot,
446 .finish = acpi_pm_finish, 483 .finish = acpi_hibernation_finish,
447 .prepare = acpi_pm_prepare, 484 .prepare = acpi_pm_prepare,
448 .enter = acpi_hibernation_enter, 485 .enter = acpi_hibernation_enter,
449 .leave = acpi_hibernation_leave, 486 .leave = acpi_hibernation_leave,
@@ -469,8 +506,22 @@ static int acpi_hibernation_begin_old(void)
469 506
470 error = acpi_sleep_prepare(ACPI_STATE_S4); 507 error = acpi_sleep_prepare(ACPI_STATE_S4);
471 508
509 if (!error) {
510 if (!s4_no_nvs)
511 error = hibernate_nvs_alloc();
512 if (!error)
513 acpi_target_sleep_state = ACPI_STATE_S4;
514 }
515 return error;
516}
517
518static int acpi_hibernation_pre_snapshot_old(void)
519{
520 int error = acpi_pm_disable_gpes();
521
472 if (!error) 522 if (!error)
473 acpi_target_sleep_state = ACPI_STATE_S4; 523 hibernate_nvs_save();
524
474 return error; 525 return error;
475} 526}
476 527
@@ -481,8 +532,8 @@ static int acpi_hibernation_begin_old(void)
481static struct platform_hibernation_ops acpi_hibernation_ops_old = { 532static struct platform_hibernation_ops acpi_hibernation_ops_old = {
482 .begin = acpi_hibernation_begin_old, 533 .begin = acpi_hibernation_begin_old,
483 .end = acpi_pm_end, 534 .end = acpi_pm_end,
484 .pre_snapshot = acpi_pm_disable_gpes, 535 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
485 .finish = acpi_pm_finish, 536 .finish = acpi_hibernation_finish,
486 .prepare = acpi_pm_disable_gpes, 537 .prepare = acpi_pm_disable_gpes,
487 .enter = acpi_hibernation_enter, 538 .enter = acpi_hibernation_enter,
488 .leave = acpi_hibernation_leave, 539 .leave = acpi_hibernation_leave,
@@ -622,7 +673,7 @@ static void acpi_power_off_prepare(void)
622{ 673{
623 /* Prepare to power off the system */ 674 /* Prepare to power off the system */
624 acpi_sleep_prepare(ACPI_STATE_S5); 675 acpi_sleep_prepare(ACPI_STATE_S5);
625 acpi_hw_disable_all_gpes(); 676 acpi_disable_all_gpes();
626} 677}
627 678
628static void acpi_power_off(void) 679static void acpi_power_off(void)
@@ -671,7 +722,7 @@ int __init acpi_sleep_init(void)
671 sleep_states[ACPI_STATE_S4] = 1; 722 sleep_states[ACPI_STATE_S4] = 1;
672 printk(" S4"); 723 printk(" S4");
673 if (!nosigcheck) { 724 if (!nosigcheck) {
674 acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 725 acpi_get_table(ACPI_SIG_FACS, 1,
675 (struct acpi_table_header **)&facs); 726 (struct acpi_table_header **)&facs);
676 if (facs) 727 if (facs)
677 s4_hardware_signature = 728 s4_hardware_signature =
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 c8111424dcb8..6729a4992f2b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -726,7 +726,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
726 726
727 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); 727 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
728 if (!dpc) 728 if (!dpc)
729 return_ACPI_STATUS(AE_NO_MEMORY); 729 return AE_NO_MEMORY;
730 730
731 dpc->function = function; 731 dpc->function = function;
732 dpc->context = context; 732 dpc->context = context;
@@ -747,7 +747,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
747 status = AE_ERROR; 747 status = AE_ERROR;
748 kfree(dpc); 748 kfree(dpc);
749 } 749 }
750 return_ACPI_STATUS(status); 750 return status;
751} 751}
752 752
753acpi_status acpi_os_execute(acpi_execute_type type, 753acpi_status acpi_os_execute(acpi_execute_type type,
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_link.c b/drivers/acpi/pci_link.c
index e52ad91ce2dc..1c6e73c7865e 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -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;
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index bb7d50dd2818..c926e7d4a0d6 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -139,6 +139,8 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
139{ 139{
140 acpi_status status = AE_OK; 140 acpi_status status = AE_OK;
141 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 };
142 144
143 145
144 if (!handle || !state) 146 if (!handle || !state)
@@ -151,8 +153,10 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
151 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: 153 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
152 ACPI_POWER_RESOURCE_STATE_OFF; 154 ACPI_POWER_RESOURCE_STATE_OFF;
153 155
156 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
157
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 158 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
155 acpi_ut_get_node_name(handle), 159 node_name,
156 *state ? "on" : "off")); 160 *state ? "on" : "off"));
157 161
158 return 0; 162 return 0;
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/proc.c
index 4dbc2271acf5..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
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index a6b662c00b67..93f91142d7ad 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -42,7 +42,7 @@ void acpi_reboot(void)
42 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 42 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
43 case ACPI_ADR_SPACE_SYSTEM_IO: 43 case ACPI_ADR_SPACE_SYSTEM_IO:
44 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n"); 44 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
45 acpi_hw_low_level_write(8, reset_value, rr); 45 acpi_reset();
46 break; 46 break;
47 } 47 }
48 /* 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 39b7233c3485..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");
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 6e4107f82403..391d0358a592 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -192,65 +192,6 @@ static struct attribute_group interrupt_stats_attr_group = {
192}; 192};
193static struct kobj_attribute *counter_attrs; 193static struct kobj_attribute *counter_attrs;
194 194
195static int count_num_gpes(void)
196{
197 int count = 0;
198 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
199 struct acpi_gpe_block_info *gpe_block;
200 acpi_cpu_flags flags;
201
202 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
203
204 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
205 while (gpe_xrupt_info) {
206 gpe_block = gpe_xrupt_info->gpe_block_list_head;
207 while (gpe_block) {
208 count += gpe_block->register_count *
209 ACPI_GPE_REGISTER_WIDTH;
210 gpe_block = gpe_block->next;
211 }
212 gpe_xrupt_info = gpe_xrupt_info->next;
213 }
214 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
215
216 return count;
217}
218
219static int get_gpe_device(int index, acpi_handle *handle)
220{
221 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
222 struct acpi_gpe_block_info *gpe_block;
223 acpi_cpu_flags flags;
224 struct acpi_namespace_node *node;
225
226 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
227
228 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
229 while (gpe_xrupt_info) {
230 gpe_block = gpe_xrupt_info->gpe_block_list_head;
231 node = gpe_block->node;
232 while (gpe_block) {
233 index -= gpe_block->register_count *
234 ACPI_GPE_REGISTER_WIDTH;
235 if (index < 0) {
236 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
237 /* return NULL if it's FADT GPE */
238 if (node->type != ACPI_TYPE_DEVICE)
239 *handle = NULL;
240 else
241 *handle = node;
242 return 0;
243 }
244 node = gpe_block->node;
245 gpe_block = gpe_block->next;
246 }
247 gpe_xrupt_info = gpe_xrupt_info->next;
248 }
249 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
250
251 return -ENODEV;
252}
253
254static void delete_gpe_attr_array(void) 195static void delete_gpe_attr_array(void)
255{ 196{
256 struct event_counter *tmp = all_counters; 197 struct event_counter *tmp = all_counters;
@@ -309,7 +250,7 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle)
309 goto end; 250 goto end;
310 251
311 if (index < num_gpes) { 252 if (index < num_gpes) {
312 result = get_gpe_device(index, handle); 253 result = acpi_get_gpe_device(index, handle);
313 if (result) { 254 if (result) {
314 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 255 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
315 "Invalid GPE 0x%x\n", index)); 256 "Invalid GPE 0x%x\n", index));
@@ -436,7 +377,7 @@ void acpi_irq_stats_init(void)
436 if (all_counters) 377 if (all_counters)
437 return; 378 return;
438 379
439 num_gpes = count_num_gpes(); 380 num_gpes = acpi_current_gpe_count;
440 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; 381 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
441 382
442 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/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/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/video.c b/drivers/acpi/video.c
index baa441929720..f261737636da 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -36,6 +36,7 @@
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>
@@ -481,6 +482,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
481 int status = AE_OK; 482 int status = AE_OK;
482 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 483 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
483 struct acpi_object_list args = { 1, &arg0 }; 484 struct acpi_object_list args = { 1, &arg0 };
485 int state;
484 486
485 487
486 arg0.integer.value = level; 488 arg0.integer.value = level;
@@ -489,6 +491,10 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
489 status = acpi_evaluate_object(device->dev->handle, "_BCM", 491 status = acpi_evaluate_object(device->dev->handle, "_BCM",
490 &args, NULL); 492 &args, NULL);
491 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
492 return status; 498 return status;
493} 499}
494 500
@@ -626,6 +632,16 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
626} 632}
627 633
628/* 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/*
629 * Arg: 645 * Arg:
630 * device : video output device (LCD, CRT, ..) 646 * device : video output device (LCD, CRT, ..)
631 * 647 *
@@ -676,6 +692,10 @@ acpi_video_init_brightness(struct acpi_video_device *device)
676 count++; 692 count++;
677 } 693 }
678 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
679 if (count < 2) 699 if (count < 2)
680 goto out_free_levels; 700 goto out_free_levels;
681 701
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index f022eb6f5637..50e3d2dbf3af 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -234,7 +234,7 @@ EXPORT_SYMBOL(acpi_video_display_switch_support);
234 * To force that backlight or display output switching is processed by vendor 234 * To force that backlight or display output switching is processed by vendor
235 * specific acpi drivers or video.ko driver. 235 * specific acpi drivers or video.ko driver.
236 */ 236 */
237int __init acpi_backlight(char *str) 237static int __init acpi_backlight(char *str)
238{ 238{
239 if (str == NULL || *str == '\0') 239 if (str == NULL || *str == '\0')
240 return 1; 240 return 1;
@@ -250,7 +250,7 @@ int __init acpi_backlight(char *str)
250} 250}
251__setup("acpi_backlight=", acpi_backlight); 251__setup("acpi_backlight=", acpi_backlight);
252 252
253int __init acpi_display_output(char *str) 253static int __init acpi_display_output(char *str)
254{ 254{
255 if (str == NULL || *str == '\0') 255 if (str == NULL || *str == '\0')
256 return 1; 256 return 1;
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/wakeup.c
index dea4c23df764..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 =
@@ -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 =
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef02e488d468..6273d98d00eb 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -19,12 +19,6 @@
19#include "libata.h" 19#include "libata.h"
20 20
21#include <acpi/acpi_bus.h> 21#include <acpi/acpi_bus.h>
22#include <acpi/acnames.h>
23#include <acpi/acnamesp.h>
24#include <acpi/acparser.h>
25#include <acpi/acexcep.h>
26#include <acpi/acmacros.h>
27#include <acpi/actypes.h>
28 22
29enum { 23enum {
30 ATA_ACPI_FILTER_SETXFER = 1 << 0, 24 ATA_ACPI_FILTER_SETXFER = 1 << 0,
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index e2e332d8ff95..8b77a9802df1 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -13,12 +13,6 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <scsi/scsi_host.h> 14#include <scsi/scsi_host.h>
15#include <acpi/acpi_bus.h> 15#include <acpi/acpi_bus.h>
16#include <acpi/acnames.h>
17#include <acpi/acnamesp.h>
18#include <acpi/acparser.h>
19#include <acpi/acexcep.h>
20#include <acpi/acmacros.h>
21#include <acpi/actypes.h>
22 16
23#include <linux/libata.h> 17#include <linux/libata.h>
24#include <linux/ata.h> 18#include <linux/ata.h>
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index 68f052b42ed7..ed306eb1057f 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -23,8 +23,6 @@
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <acpi/acpi.h> 25#include <acpi/acpi.h>
26#include <acpi/actypes.h>
27#include <acpi/actbl.h>
28#include "tpm.h" 26#include "tpm.h"
29 27
30#define TCG_EVENT_NAME_LEN_MAX 255 28#define TCG_EVENT_NAME_LEN_MAX 255
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 8d7cf3f31450..f1df59f59a37 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -15,12 +15,14 @@
15#include <linux/tick.h> 15#include <linux/tick.h>
16 16
17#define BREAK_FUZZ 4 /* 4 us */ 17#define BREAK_FUZZ 4 /* 4 us */
18#define PRED_HISTORY_PCT 50
18 19
19struct menu_device { 20struct menu_device {
20 int last_state_idx; 21 int last_state_idx;
21 22
22 unsigned int expected_us; 23 unsigned int expected_us;
23 unsigned int predicted_us; 24 unsigned int predicted_us;
25 unsigned int current_predicted_us;
24 unsigned int last_measured_us; 26 unsigned int last_measured_us;
25 unsigned int elapsed_us; 27 unsigned int elapsed_us;
26}; 28};
@@ -47,6 +49,12 @@ static int menu_select(struct cpuidle_device *dev)
47 data->expected_us = 49 data->expected_us =
48 (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000; 50 (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;
49 51
52 /* Recalculate predicted_us based on prediction_history_pct */
53 data->predicted_us *= PRED_HISTORY_PCT;
54 data->predicted_us += (100 - PRED_HISTORY_PCT) *
55 data->current_predicted_us;
56 data->predicted_us /= 100;
57
50 /* find the deepest idle state that satisfies our constraints */ 58 /* find the deepest idle state that satisfies our constraints */
51 for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) { 59 for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) {
52 struct cpuidle_state *s = &dev->states[i]; 60 struct cpuidle_state *s = &dev->states[i];
@@ -97,7 +105,7 @@ static void menu_reflect(struct cpuidle_device *dev)
97 measured_us = -1; 105 measured_us = -1;
98 106
99 /* Predict time until next break event */ 107 /* Predict time until next break event */
100 data->predicted_us = max(measured_us, data->last_measured_us); 108 data->current_predicted_us = max(measured_us, data->last_measured_us);
101 109
102 if (last_idle_us + BREAK_FUZZ < 110 if (last_idle_us + BREAK_FUZZ <
103 data->expected_us - target->exit_latency) { 111 data->expected_us - target->exit_latency) {
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 2f9e941968d6..d8f295bdad76 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -18,12 +18,6 @@
18#include <linux/dmi.h> 18#include <linux/dmi.h>
19 19
20#include <acpi/acpi_bus.h> 20#include <acpi/acpi_bus.h>
21#include <acpi/acnames.h>
22#include <acpi/acnamesp.h>
23#include <acpi/acparser.h>
24#include <acpi/acexcep.h>
25#include <acpi/acmacros.h>
26#include <acpi/actypes.h>
27 21
28#define REGS_PER_GTF 7 22#define REGS_PER_GTF 7
29struct taskfile_array { 23struct taskfile_array {
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 3949a1c73451..2da1781e85c3 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -428,10 +428,10 @@ config EEEPC_LAPTOP
428 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)" 428 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)"
429 depends on X86 429 depends on X86
430 depends on ACPI 430 depends on ACPI
431 depends on BACKLIGHT_CLASS_DEVICE
432 depends on HWMON
433 depends on EXPERIMENTAL 431 depends on EXPERIMENTAL
434 depends on RFKILL 432 select BACKLIGHT_CLASS_DEVICE
433 select HWMON
434 select RFKILL
435 ---help--- 435 ---help---
436 This driver supports the Fn-Fx keys on Eee PC laptops. 436 This driver supports the Fn-Fx keys on Eee PC laptops.
437 It also adds the ability to switch camera/wlan on/off. 437 It also adds the ability to switch camera/wlan on/off.
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c
index a7dd3e9fb79d..65dc41540c62 100644
--- a/drivers/misc/fujitsu-laptop.c
+++ b/drivers/misc/fujitsu-laptop.c
@@ -3,6 +3,7 @@
3/* 3/*
4 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 4 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
5 Copyright (C) 2008 Peter Gruber <nokos@gmx.net> 5 Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
6 Copyright (C) 2008 Tony Vroon <tony@linx.net>
6 Based on earlier work: 7 Based on earlier work:
7 Copyright (C) 2003 Shane Spencer <shane@bogomip.com> 8 Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
8 Adrian Yee <brewt-fujitsu@brewt.org> 9 Adrian Yee <brewt-fujitsu@brewt.org>
@@ -65,8 +66,11 @@
65#include <linux/kfifo.h> 66#include <linux/kfifo.h>
66#include <linux/video_output.h> 67#include <linux/video_output.h>
67#include <linux/platform_device.h> 68#include <linux/platform_device.h>
69#ifdef CONFIG_LEDS_CLASS
70#include <linux/leds.h>
71#endif
68 72
69#define FUJITSU_DRIVER_VERSION "0.4.3" 73#define FUJITSU_DRIVER_VERSION "0.5.0"
70 74
71#define FUJITSU_LCD_N_LEVELS 8 75#define FUJITSU_LCD_N_LEVELS 8
72 76
@@ -83,6 +87,24 @@
83#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 87#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
84#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 88#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
85 89
90/* FUNC interface - command values */
91#define FUNC_RFKILL 0x1000
92#define FUNC_LEDS 0x1001
93#define FUNC_BUTTONS 0x1002
94#define FUNC_BACKLIGHT 0x1004
95
96/* FUNC interface - responses */
97#define UNSUPPORTED_CMD 0x80000000
98
99#ifdef CONFIG_LEDS_CLASS
100/* FUNC interface - LED control */
101#define FUNC_LED_OFF 0x1
102#define FUNC_LED_ON 0x30001
103#define KEYBOARD_LAMPS 0x100
104#define LOGOLAMP_POWERON 0x2000
105#define LOGOLAMP_ALWAYS 0x4000
106#endif
107
86/* Hotkey details */ 108/* Hotkey details */
87#define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */ 109#define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */
88#define KEY2_CODE 0x411 110#define KEY2_CODE 0x411
@@ -133,7 +155,6 @@ struct fujitsu_t {
133 155
134static struct fujitsu_t *fujitsu; 156static struct fujitsu_t *fujitsu;
135static int use_alt_lcd_levels = -1; 157static int use_alt_lcd_levels = -1;
136static int disable_brightness_keys = -1;
137static int disable_brightness_adjust = -1; 158static int disable_brightness_adjust = -1;
138 159
139/* Device used to access other hotkeys on the laptop */ 160/* Device used to access other hotkeys on the laptop */
@@ -145,8 +166,9 @@ struct fujitsu_hotkey_t {
145 struct platform_device *pf_device; 166 struct platform_device *pf_device;
146 struct kfifo *fifo; 167 struct kfifo *fifo;
147 spinlock_t fifo_lock; 168 spinlock_t fifo_lock;
148 169 int rfkill_state;
149 unsigned int irb; /* info about the pressed buttons */ 170 int logolamp_registered;
171 int kblamps_registered;
150}; 172};
151 173
152static struct fujitsu_hotkey_t *fujitsu_hotkey; 174static struct fujitsu_hotkey_t *fujitsu_hotkey;
@@ -154,12 +176,139 @@ static struct fujitsu_hotkey_t *fujitsu_hotkey;
154static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event, 176static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
155 void *data); 177 void *data);
156 178
179#ifdef CONFIG_LEDS_CLASS
180static enum led_brightness logolamp_get(struct led_classdev *cdev);
181static void logolamp_set(struct led_classdev *cdev,
182 enum led_brightness brightness);
183
184struct led_classdev logolamp_led = {
185 .name = "fujitsu::logolamp",
186 .brightness_get = logolamp_get,
187 .brightness_set = logolamp_set
188};
189
190static enum led_brightness kblamps_get(struct led_classdev *cdev);
191static void kblamps_set(struct led_classdev *cdev,
192 enum led_brightness brightness);
193
194struct led_classdev kblamps_led = {
195 .name = "fujitsu::kblamps",
196 .brightness_get = kblamps_get,
197 .brightness_set = kblamps_set
198};
199#endif
200
157#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG 201#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
158static u32 dbg_level = 0x03; 202static u32 dbg_level = 0x03;
159#endif 203#endif
160 204
161static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data); 205static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data);
162 206
207/* Fujitsu ACPI interface function */
208
209static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
210{
211 acpi_status status = AE_OK;
212 union acpi_object params[4] = {
213 { .type = ACPI_TYPE_INTEGER },
214 { .type = ACPI_TYPE_INTEGER },
215 { .type = ACPI_TYPE_INTEGER },
216 { .type = ACPI_TYPE_INTEGER }
217 };
218 struct acpi_object_list arg_list = { 4, &params[0] };
219 struct acpi_buffer output;
220 union acpi_object out_obj;
221 acpi_handle handle = NULL;
222
223 status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
224 if (ACPI_FAILURE(status)) {
225 vdbg_printk(FUJLAPTOP_DBG_ERROR,
226 "FUNC interface is not present\n");
227 return -ENODEV;
228 }
229
230 params[0].integer.value = cmd;
231 params[1].integer.value = arg0;
232 params[2].integer.value = arg1;
233 params[3].integer.value = arg2;
234
235 output.length = sizeof(out_obj);
236 output.pointer = &out_obj;
237
238 status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
239 if (ACPI_FAILURE(status)) {
240 vdbg_printk(FUJLAPTOP_DBG_WARN,
241 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
242 cmd, arg0, arg1, arg2);
243 return -ENODEV;
244 }
245
246 if (out_obj.type != ACPI_TYPE_INTEGER) {
247 vdbg_printk(FUJLAPTOP_DBG_WARN,
248 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
249 "return an integer\n",
250 cmd, arg0, arg1, arg2);
251 return -ENODEV;
252 }
253
254 vdbg_printk(FUJLAPTOP_DBG_TRACE,
255 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
256 cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
257 return out_obj.integer.value;
258}
259
260#ifdef CONFIG_LEDS_CLASS
261/* LED class callbacks */
262
263static void logolamp_set(struct led_classdev *cdev,
264 enum led_brightness brightness)
265{
266 if (brightness >= LED_FULL) {
267 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
268 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
269 } else if (brightness >= LED_HALF) {
270 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
271 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
272 } else {
273 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
274 }
275}
276
277static void kblamps_set(struct led_classdev *cdev,
278 enum led_brightness brightness)
279{
280 if (brightness >= LED_FULL)
281 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
282 else
283 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
284}
285
286static enum led_brightness logolamp_get(struct led_classdev *cdev)
287{
288 enum led_brightness brightness = LED_OFF;
289 int poweron, always;
290
291 poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
292 if (poweron == FUNC_LED_ON) {
293 brightness = LED_HALF;
294 always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
295 if (always == FUNC_LED_ON)
296 brightness = LED_FULL;
297 }
298 return brightness;
299}
300
301static enum led_brightness kblamps_get(struct led_classdev *cdev)
302{
303 enum led_brightness brightness = LED_OFF;
304
305 if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
306 brightness = LED_FULL;
307
308 return brightness;
309}
310#endif
311
163/* Hardware access for LCD brightness control */ 312/* Hardware access for LCD brightness control */
164 313
165static int set_lcd_level(int level) 314static int set_lcd_level(int level)
@@ -263,44 +412,34 @@ static int get_max_brightness(void)
263 return fujitsu->max_brightness; 412 return fujitsu->max_brightness;
264} 413}
265 414
266static int get_lcd_level_alt(void)
267{
268 unsigned long long state = 0;
269 acpi_status status = AE_OK;
270
271 vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLS\n");
272
273 status =
274 acpi_evaluate_integer(fujitsu->acpi_handle, "GBLS", NULL, &state);
275 if (status < 0)
276 return status;
277
278 fujitsu->brightness_level = state & 0x0fffffff;
279
280 if (state & 0x80000000)
281 fujitsu->brightness_changed = 1;
282 else
283 fujitsu->brightness_changed = 0;
284
285 return fujitsu->brightness_level;
286}
287
288/* Backlight device stuff */ 415/* Backlight device stuff */
289 416
290static int bl_get_brightness(struct backlight_device *b) 417static int bl_get_brightness(struct backlight_device *b)
291{ 418{
292 if (use_alt_lcd_levels) 419 return get_lcd_level();
293 return get_lcd_level_alt();
294 else
295 return get_lcd_level();
296} 420}
297 421
298static int bl_update_status(struct backlight_device *b) 422static int bl_update_status(struct backlight_device *b)
299{ 423{
424 int ret;
425 if (b->props.power == 4)
426 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3);
427 else
428 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0);
429 if (ret != 0)
430 vdbg_printk(FUJLAPTOP_DBG_ERROR,
431 "Unable to adjust backlight power, error code %i\n",
432 ret);
433
300 if (use_alt_lcd_levels) 434 if (use_alt_lcd_levels)
301 return set_lcd_level_alt(b->props.brightness); 435 ret = set_lcd_level_alt(b->props.brightness);
302 else 436 else
303 return set_lcd_level(b->props.brightness); 437 ret = set_lcd_level(b->props.brightness);
438 if (ret != 0)
439 vdbg_printk(FUJLAPTOP_DBG_ERROR,
440 "Unable to adjust LCD brightness, error code %i\n",
441 ret);
442 return ret;
304} 443}
305 444
306static struct backlight_ops fujitsubl_ops = { 445static struct backlight_ops fujitsubl_ops = {
@@ -344,10 +483,7 @@ static ssize_t show_lcd_level(struct device *dev,
344 483
345 int ret; 484 int ret;
346 485
347 if (use_alt_lcd_levels) 486 ret = get_lcd_level();
348 ret = get_lcd_level_alt();
349 else
350 ret = get_lcd_level();
351 if (ret < 0) 487 if (ret < 0)
352 return ret; 488 return ret;
353 489
@@ -372,52 +508,71 @@ static ssize_t store_lcd_level(struct device *dev,
372 if (ret < 0) 508 if (ret < 0)
373 return ret; 509 return ret;
374 510
375 if (use_alt_lcd_levels) 511 ret = get_lcd_level();
376 ret = get_lcd_level_alt();
377 else
378 ret = get_lcd_level();
379 if (ret < 0) 512 if (ret < 0)
380 return ret; 513 return ret;
381 514
382 return count; 515 return count;
383} 516}
384 517
385/* Hardware access for hotkey device */ 518static ssize_t
386 519ignore_store(struct device *dev,
387static int get_irb(void) 520 struct device_attribute *attr, const char *buf, size_t count)
388{ 521{
389 unsigned long long state = 0; 522 return count;
390 acpi_status status = AE_OK; 523}
391
392 vdbg_printk(FUJLAPTOP_DBG_TRACE, "Get irb\n");
393
394 status =
395 acpi_evaluate_integer(fujitsu_hotkey->acpi_handle, "GIRB", NULL,
396 &state);
397 if (status < 0)
398 return status;
399 524
400 fujitsu_hotkey->irb = state; 525static ssize_t
526show_lid_state(struct device *dev,
527 struct device_attribute *attr, char *buf)
528{
529 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
530 return sprintf(buf, "unknown\n");
531 if (fujitsu_hotkey->rfkill_state & 0x100)
532 return sprintf(buf, "open\n");
533 else
534 return sprintf(buf, "closed\n");
535}
401 536
402 return fujitsu_hotkey->irb; 537static ssize_t
538show_dock_state(struct device *dev,
539 struct device_attribute *attr, char *buf)
540{
541 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
542 return sprintf(buf, "unknown\n");
543 if (fujitsu_hotkey->rfkill_state & 0x200)
544 return sprintf(buf, "docked\n");
545 else
546 return sprintf(buf, "undocked\n");
403} 547}
404 548
405static ssize_t 549static ssize_t
406ignore_store(struct device *dev, 550show_radios_state(struct device *dev,
407 struct device_attribute *attr, const char *buf, size_t count) 551 struct device_attribute *attr, char *buf)
408{ 552{
409 return count; 553 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
554 return sprintf(buf, "unknown\n");
555 if (fujitsu_hotkey->rfkill_state & 0x20)
556 return sprintf(buf, "on\n");
557 else
558 return sprintf(buf, "killed\n");
410} 559}
411 560
412static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store); 561static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store);
413static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed, 562static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed,
414 ignore_store); 563 ignore_store);
415static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); 564static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
565static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
566static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
567static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
416 568
417static struct attribute *fujitsupf_attributes[] = { 569static struct attribute *fujitsupf_attributes[] = {
418 &dev_attr_brightness_changed.attr, 570 &dev_attr_brightness_changed.attr,
419 &dev_attr_max_brightness.attr, 571 &dev_attr_max_brightness.attr,
420 &dev_attr_lcd_level.attr, 572 &dev_attr_lcd_level.attr,
573 &dev_attr_lid.attr,
574 &dev_attr_dock.attr,
575 &dev_attr_radios.attr,
421 NULL 576 NULL
422}; 577};
423 578
@@ -435,24 +590,16 @@ static struct platform_driver fujitsupf_driver = {
435static void dmi_check_cb_common(const struct dmi_system_id *id) 590static void dmi_check_cb_common(const struct dmi_system_id *id)
436{ 591{
437 acpi_handle handle; 592 acpi_handle handle;
438 int have_blnf;
439 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n", 593 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
440 id->ident); 594 id->ident);
441 have_blnf = ACPI_SUCCESS
442 (acpi_get_handle(NULL, "\\_SB.PCI0.GFX0.LCD.BLNF", &handle));
443 if (use_alt_lcd_levels == -1) { 595 if (use_alt_lcd_levels == -1) {
444 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detecting usealt\n"); 596 if (ACPI_SUCCESS(acpi_get_handle(NULL,
445 use_alt_lcd_levels = 1; 597 "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
446 } 598 use_alt_lcd_levels = 1;
447 if (disable_brightness_keys == -1) { 599 else
448 vdbg_printk(FUJLAPTOP_DBG_TRACE, 600 use_alt_lcd_levels = 0;
449 "auto-detecting disable_keys\n"); 601 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
450 disable_brightness_keys = have_blnf ? 1 : 0; 602 "%i\n", use_alt_lcd_levels);
451 }
452 if (disable_brightness_adjust == -1) {
453 vdbg_printk(FUJLAPTOP_DBG_TRACE,
454 "auto-detecting disable_adjust\n");
455 disable_brightness_adjust = have_blnf ? 0 : 1;
456 } 603 }
457} 604}
458 605
@@ -581,19 +728,14 @@ static int acpi_fujitsu_add(struct acpi_device *device)
581 728
582 /* do config (detect defaults) */ 729 /* do config (detect defaults) */
583 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; 730 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
584 disable_brightness_keys = disable_brightness_keys == 1 ? 1 : 0;
585 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; 731 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
586 vdbg_printk(FUJLAPTOP_DBG_INFO, 732 vdbg_printk(FUJLAPTOP_DBG_INFO,
587 "config: [alt interface: %d], [key disable: %d], [adjust disable: %d]\n", 733 "config: [alt interface: %d], [adjust disable: %d]\n",
588 use_alt_lcd_levels, disable_brightness_keys, 734 use_alt_lcd_levels, disable_brightness_adjust);
589 disable_brightness_adjust);
590 735
591 if (get_max_brightness() <= 0) 736 if (get_max_brightness() <= 0)
592 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; 737 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
593 if (use_alt_lcd_levels) 738 get_lcd_level();
594 get_lcd_level_alt();
595 else
596 get_lcd_level();
597 739
598 return result; 740 return result;
599 741
@@ -644,43 +786,23 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
644 case ACPI_FUJITSU_NOTIFY_CODE1: 786 case ACPI_FUJITSU_NOTIFY_CODE1:
645 keycode = 0; 787 keycode = 0;
646 oldb = fujitsu->brightness_level; 788 oldb = fujitsu->brightness_level;
647 get_lcd_level(); /* the alt version always yields changed */ 789 get_lcd_level();
648 newb = fujitsu->brightness_level; 790 newb = fujitsu->brightness_level;
649 791
650 vdbg_printk(FUJLAPTOP_DBG_TRACE, 792 vdbg_printk(FUJLAPTOP_DBG_TRACE,
651 "brightness button event [%i -> %i (%i)]\n", 793 "brightness button event [%i -> %i (%i)]\n",
652 oldb, newb, fujitsu->brightness_changed); 794 oldb, newb, fujitsu->brightness_changed);
653 795
654 if (oldb == newb && fujitsu->brightness_changed) { 796 if (oldb < newb) {
655 keycode = 0;
656 if (disable_brightness_keys != 1) {
657 if (oldb == 0) {
658 acpi_bus_generate_proc_event
659 (fujitsu->dev,
660 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS,
661 0);
662 keycode = KEY_BRIGHTNESSDOWN;
663 } else if (oldb ==
664 (fujitsu->max_brightness) - 1) {
665 acpi_bus_generate_proc_event
666 (fujitsu->dev,
667 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS,
668 0);
669 keycode = KEY_BRIGHTNESSUP;
670 }
671 }
672 } else if (oldb < newb) {
673 if (disable_brightness_adjust != 1) { 797 if (disable_brightness_adjust != 1) {
674 if (use_alt_lcd_levels) 798 if (use_alt_lcd_levels)
675 set_lcd_level_alt(newb); 799 set_lcd_level_alt(newb);
676 else 800 else
677 set_lcd_level(newb); 801 set_lcd_level(newb);
678 } 802 }
679 if (disable_brightness_keys != 1) { 803 acpi_bus_generate_proc_event(fujitsu->dev,
680 acpi_bus_generate_proc_event(fujitsu->dev, 804 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
681 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0); 805 keycode = KEY_BRIGHTNESSUP;
682 keycode = KEY_BRIGHTNESSUP;
683 }
684 } else if (oldb > newb) { 806 } else if (oldb > newb) {
685 if (disable_brightness_adjust != 1) { 807 if (disable_brightness_adjust != 1) {
686 if (use_alt_lcd_levels) 808 if (use_alt_lcd_levels)
@@ -688,13 +810,9 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
688 else 810 else
689 set_lcd_level(newb); 811 set_lcd_level(newb);
690 } 812 }
691 if (disable_brightness_keys != 1) { 813 acpi_bus_generate_proc_event(fujitsu->dev,
692 acpi_bus_generate_proc_event(fujitsu->dev, 814 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
693 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0); 815 keycode = KEY_BRIGHTNESSDOWN;
694 keycode = KEY_BRIGHTNESSDOWN;
695 }
696 } else {
697 keycode = KEY_UNKNOWN;
698 } 816 }
699 break; 817 break;
700 default: 818 default:
@@ -771,7 +889,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
771 input->id.bustype = BUS_HOST; 889 input->id.bustype = BUS_HOST;
772 input->id.product = 0x06; 890 input->id.product = 0x06;
773 input->dev.parent = &device->dev; 891 input->dev.parent = &device->dev;
774 input->evbit[0] = BIT(EV_KEY); 892
893 set_bit(EV_KEY, input->evbit);
775 set_bit(fujitsu->keycode1, input->keybit); 894 set_bit(fujitsu->keycode1, input->keybit);
776 set_bit(fujitsu->keycode2, input->keybit); 895 set_bit(fujitsu->keycode2, input->keybit);
777 set_bit(fujitsu->keycode3, input->keybit); 896 set_bit(fujitsu->keycode3, input->keybit);
@@ -803,10 +922,44 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
803 printk(KERN_ERR "_INI Method failed\n"); 922 printk(KERN_ERR "_INI Method failed\n");
804 } 923 }
805 924
806 i = 0; /* Discard hotkey ringbuffer */ 925 i = 0;
807 while (get_irb() != 0 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) ; 926 while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0
927 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE)
928 ; /* No action, result is discarded */
808 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); 929 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
809 930
931 fujitsu_hotkey->rfkill_state =
932 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
933
934 /* Suspect this is a keymap of the application panel, print it */
935 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
936 call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
937
938 #ifdef CONFIG_LEDS_CLASS
939 if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
940 result = led_classdev_register(&fujitsu->pf_device->dev,
941 &logolamp_led);
942 if (result == 0) {
943 fujitsu_hotkey->logolamp_registered = 1;
944 } else {
945 printk(KERN_ERR "fujitsu-laptop: Could not register "
946 "LED handler for logo lamp, error %i\n", result);
947 }
948 }
949
950 if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
951 (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
952 result = led_classdev_register(&fujitsu->pf_device->dev,
953 &kblamps_led);
954 if (result == 0) {
955 fujitsu_hotkey->kblamps_registered = 1;
956 } else {
957 printk(KERN_ERR "fujitsu-laptop: Could not register "
958 "LED handler for keyboard lamps, error %i\n", result);
959 }
960 }
961 #endif
962
810 return result; 963 return result;
811 964
812end: 965end:
@@ -852,16 +1005,15 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
852 1005
853 input = fujitsu_hotkey->input; 1006 input = fujitsu_hotkey->input;
854 1007
855 vdbg_printk(FUJLAPTOP_DBG_TRACE, "Hotkey event\n"); 1008 fujitsu_hotkey->rfkill_state =
1009 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
856 1010
857 switch (event) { 1011 switch (event) {
858 case ACPI_FUJITSU_NOTIFY_CODE1: 1012 case ACPI_FUJITSU_NOTIFY_CODE1:
859 i = 0; 1013 i = 0;
860 while ((irb = get_irb()) != 0 1014 while ((irb =
861 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { 1015 call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0
862 vdbg_printk(FUJLAPTOP_DBG_TRACE, "GIRB result [%x]\n", 1016 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
863 irb);
864
865 switch (irb & 0x4ff) { 1017 switch (irb & 0x4ff) {
866 case KEY1_CODE: 1018 case KEY1_CODE:
867 keycode = fujitsu->keycode1; 1019 keycode = fujitsu->keycode1;
@@ -1035,6 +1187,15 @@ static int __init fujitsu_init(void)
1035 goto fail_hotkey1; 1187 goto fail_hotkey1;
1036 } 1188 }
1037 1189
1190 /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
1191
1192 if (!acpi_video_backlight_support()) {
1193 if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
1194 fujitsu->bl_device->props.power = 4;
1195 else
1196 fujitsu->bl_device->props.power = 0;
1197 }
1198
1038 printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION 1199 printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION
1039 " successfully loaded.\n"); 1200 " successfully loaded.\n");
1040 1201
@@ -1074,6 +1235,14 @@ fail_acpi:
1074 1235
1075static void __exit fujitsu_cleanup(void) 1236static void __exit fujitsu_cleanup(void)
1076{ 1237{
1238 #ifdef CONFIG_LEDS_CLASS
1239 if (fujitsu_hotkey->logolamp_registered != 0)
1240 led_classdev_unregister(&logolamp_led);
1241
1242 if (fujitsu_hotkey->kblamps_registered != 0)
1243 led_classdev_unregister(&kblamps_led);
1244 #endif
1245
1077 sysfs_remove_group(&fujitsu->pf_device->dev.kobj, 1246 sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
1078 &fujitsupf_attribute_group); 1247 &fujitsupf_attribute_group);
1079 platform_device_unregister(fujitsu->pf_device); 1248 platform_device_unregister(fujitsu->pf_device);
@@ -1098,9 +1267,6 @@ module_exit(fujitsu_cleanup);
1098module_param(use_alt_lcd_levels, uint, 0644); 1267module_param(use_alt_lcd_levels, uint, 0644);
1099MODULE_PARM_DESC(use_alt_lcd_levels, 1268MODULE_PARM_DESC(use_alt_lcd_levels,
1100 "Use alternative interface for lcd_levels (needed for Lifebook s6410)."); 1269 "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
1101module_param(disable_brightness_keys, uint, 0644);
1102MODULE_PARM_DESC(disable_brightness_keys,
1103 "Disable brightness keys (eg. if they are already handled by the generic ACPI_VIDEO device).");
1104module_param(disable_brightness_adjust, uint, 0644); 1270module_param(disable_brightness_adjust, uint, 0644);
1105MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); 1271MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
1106#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG 1272#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
@@ -1108,12 +1274,13 @@ module_param_named(debug, dbg_level, uint, 0644);
1108MODULE_PARM_DESC(debug, "Sets debug level bit-mask"); 1274MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
1109#endif 1275#endif
1110 1276
1111MODULE_AUTHOR("Jonathan Woithe, Peter Gruber"); 1277MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
1112MODULE_DESCRIPTION("Fujitsu laptop extras support"); 1278MODULE_DESCRIPTION("Fujitsu laptop extras support");
1113MODULE_VERSION(FUJITSU_DRIVER_VERSION); 1279MODULE_VERSION(FUJITSU_DRIVER_VERSION);
1114MODULE_LICENSE("GPL"); 1280MODULE_LICENSE("GPL");
1115 1281
1116MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*"); 1282MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
1283MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
1117MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*"); 1284MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
1118 1285
1119static struct pnp_device_id pnp_ids[] = { 1286static struct pnp_device_id pnp_ids[] = {
diff --git a/drivers/misc/panasonic-laptop.c b/drivers/misc/panasonic-laptop.c
index 4a1bc64485d5..f30db367c82e 100644
--- a/drivers/misc/panasonic-laptop.c
+++ b/drivers/misc/panasonic-laptop.c
@@ -241,8 +241,6 @@ static int acpi_pcc_write_sset(struct pcc_acpi *pcc, int func, int val)
241 }; 241 };
242 acpi_status status = AE_OK; 242 acpi_status status = AE_OK;
243 243
244 ACPI_FUNCTION_TRACE("acpi_pcc_write_sset");
245
246 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET, 244 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET,
247 &params, NULL); 245 &params, NULL);
248 246
@@ -254,8 +252,6 @@ static inline int acpi_pcc_get_sqty(struct acpi_device *device)
254 unsigned long long s; 252 unsigned long long s;
255 acpi_status status; 253 acpi_status status;
256 254
257 ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty");
258
259 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY, 255 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY,
260 NULL, &s); 256 NULL, &s);
261 if (ACPI_SUCCESS(status)) 257 if (ACPI_SUCCESS(status))
@@ -274,8 +270,6 @@ static int acpi_pcc_retrieve_biosdata(struct pcc_acpi *pcc, u32 *sinf)
274 union acpi_object *hkey = NULL; 270 union acpi_object *hkey = NULL;
275 int i; 271 int i;
276 272
277 ACPI_FUNCTION_TRACE("acpi_pcc_retrieve_biosdata");
278
279 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, 0, 273 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, 0,
280 &buffer); 274 &buffer);
281 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
@@ -501,8 +495,6 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
501 int key_code, hkey_num; 495 int key_code, hkey_num;
502 unsigned long long result; 496 unsigned long long result;
503 497
504 ACPI_FUNCTION_TRACE("acpi_pcc_generate_keyinput");
505
506 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY, 498 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY,
507 NULL, &result); 499 NULL, &result);
508 if (!ACPI_SUCCESS(rc)) { 500 if (!ACPI_SUCCESS(rc)) {
@@ -538,8 +530,6 @@ static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data)
538{ 530{
539 struct pcc_acpi *pcc = (struct pcc_acpi *) data; 531 struct pcc_acpi *pcc = (struct pcc_acpi *) data;
540 532
541 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_notify");
542
543 switch (event) { 533 switch (event) {
544 case HKEY_NOTIFY: 534 case HKEY_NOTIFY:
545 acpi_pcc_generate_keyinput(pcc); 535 acpi_pcc_generate_keyinput(pcc);
@@ -554,8 +544,6 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
554{ 544{
555 int i, rc; 545 int i, rc;
556 546
557 ACPI_FUNCTION_TRACE("acpi_pcc_init_input");
558
559 pcc->input_dev = input_allocate_device(); 547 pcc->input_dev = input_allocate_device();
560 if (!pcc->input_dev) { 548 if (!pcc->input_dev) {
561 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 549 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -597,8 +585,6 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
597 struct pcc_acpi *pcc = acpi_driver_data(device); 585 struct pcc_acpi *pcc = acpi_driver_data(device);
598 acpi_status status = AE_OK; 586 acpi_status status = AE_OK;
599 587
600 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_resume");
601
602 if (device == NULL || pcc == NULL) 588 if (device == NULL || pcc == NULL)
603 return -EINVAL; 589 return -EINVAL;
604 590
@@ -616,8 +602,6 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
616 struct pcc_acpi *pcc; 602 struct pcc_acpi *pcc;
617 int num_sifr, result; 603 int num_sifr, result;
618 604
619 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_add");
620
621 if (!device) 605 if (!device)
622 return -EINVAL; 606 return -EINVAL;
623 607
@@ -714,8 +698,6 @@ static int __init acpi_pcc_init(void)
714{ 698{
715 int result = 0; 699 int result = 0;
716 700
717 ACPI_FUNCTION_TRACE("acpi_pcc_init");
718
719 if (acpi_disabled) 701 if (acpi_disabled)
720 return -ENODEV; 702 return -ENODEV;
721 703
@@ -733,8 +715,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
733{ 715{
734 struct pcc_acpi *pcc = acpi_driver_data(device); 716 struct pcc_acpi *pcc = acpi_driver_data(device);
735 717
736 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_remove");
737
738 if (!device || !pcc) 718 if (!device || !pcc)
739 return -EINVAL; 719 return -EINVAL;
740 720
@@ -757,8 +737,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
757 737
758static void __exit acpi_pcc_exit(void) 738static void __exit acpi_pcc_exit(void)
759{ 739{
760 ACPI_FUNCTION_TRACE("acpi_pcc_exit");
761
762 acpi_bus_unregister_driver(&acpi_pcc_driver); 740 acpi_bus_unregister_driver(&acpi_pcc_driver);
763} 741}
764 742
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 571b211608d1..537959d07148 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -935,14 +935,17 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
935static acpi_status sony_walk_callback(acpi_handle handle, u32 level, 935static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
936 void *context, void **return_value) 936 void *context, void **return_value)
937{ 937{
938 struct acpi_namespace_node *node; 938 struct acpi_device_info *info;
939 union acpi_operand_object *operand; 939 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
940 940
941 node = (struct acpi_namespace_node *)handle; 941 if (ACPI_SUCCESS(acpi_get_object_info(handle, &buffer))) {
942 operand = (union acpi_operand_object *)node->object; 942 info = buffer.pointer;
943 943
944 printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii, 944 printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n",
945 (u32) operand->method.param_count); 945 (char *)&info->name, info->param_count);
946
947 kfree(buffer.pointer);
948 }
946 949
947 return AE_OK; 950 return AE_OK;
948} 951}
diff --git a/drivers/misc/tc1100-wmi.c b/drivers/misc/tc1100-wmi.c
index f25e4c974dcf..b4a4aa9ee482 100644
--- a/drivers/misc/tc1100-wmi.c
+++ b/drivers/misc/tc1100-wmi.c
@@ -30,7 +30,6 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <acpi/acpi.h> 32#include <acpi/acpi.h>
33#include <acpi/actypes.h>
34#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
36#include <linux/platform_device.h> 35#include <linux/platform_device.h>
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 899766e16fa8..3478453eba7a 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -76,7 +76,6 @@
76#include <linux/workqueue.h> 76#include <linux/workqueue.h>
77 77
78#include <acpi/acpi_drivers.h> 78#include <acpi/acpi_drivers.h>
79#include <acpi/acnamesp.h>
80 79
81#include <linux/pci_ids.h> 80#include <linux/pci_ids.h>
82 81
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index c62ab8d240aa..1c1141801060 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -33,7 +33,6 @@
33#include <linux/pci-acpi.h> 33#include <linux/pci-acpi.h>
34#include <acpi/acpi.h> 34#include <acpi/acpi.h>
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/actypes.h>
37 36
38#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
39 38
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 27fd18f019f8..db85284ffb62 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -217,7 +217,6 @@ struct hpc_ops {
217#ifdef CONFIG_ACPI 217#ifdef CONFIG_ACPI
218#include <acpi/acpi.h> 218#include <acpi/acpi.h>
219#include <acpi/acpi_bus.h> 219#include <acpi/acpi_bus.h>
220#include <acpi/actypes.h>
221#include <linux/pci-acpi.h> 220#include <linux/pci-acpi.h>
222 221
223extern void __init pciehp_acpi_slot_detection_init(void); 222extern void __init pciehp_acpi_slot_detection_init(void);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 3582512e7226..deea8a187eb8 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -13,8 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pci-aspm.h> 14#include <linux/pci-aspm.h>
15#include <acpi/acpi.h> 15#include <acpi/acpi.h>
16#include <acpi/acnamesp.h>
17#include <acpi/acresrc.h>
18#include <acpi/acpi_bus.h> 16#include <acpi/acpi_bus.h>
19 17
20#include <linux/pci-acpi.h> 18#include <linux/pci-acpi.h>
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 383e47c392a4..2834846a185d 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -23,7 +23,6 @@
23#include <linux/pnp.h> 23#include <linux/pnp.h>
24#include <linux/mod_devicetable.h> 24#include <linux/mod_devicetable.h>
25#include <acpi/acpi_bus.h> 25#include <acpi/acpi_bus.h>
26#include <acpi/actypes.h>
27 26
28#include "../base.h" 27#include "../base.h"
29#include "pnpacpi.h" 28#include "pnpacpi.h"
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
deleted file mode 100644
index 0c1ed387073c..000000000000
--- a/include/acpi/acdisasm.h
+++ /dev/null
@@ -1,445 +0,0 @@
1/******************************************************************************
2 *
3 * Name: acdisasm.h - AML disassembler
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 __ACDISASM_H__
45#define __ACDISASM_H__
46
47#include "amlresrc.h"
48
49#define BLOCK_NONE 0
50#define BLOCK_PAREN 1
51#define BLOCK_BRACE 2
52#define BLOCK_COMMA_LIST 4
53#define ACPI_DEFAULT_RESNAME *(u32 *) "__RD"
54
55struct acpi_external_list {
56 char *path;
57 char *internal_path;
58 struct acpi_external_list *next;
59 u32 value;
60 u16 length;
61 u8 type;
62};
63
64extern struct acpi_external_list *acpi_gbl_external_list;
65
66typedef const struct acpi_dmtable_info {
67 u8 opcode;
68 u8 offset;
69 char *name;
70
71} acpi_dmtable_info;
72
73/*
74 * Values for Opcode above.
75 * Note: 0-7 must not change, used as a flag shift value
76 */
77#define ACPI_DMT_FLAG0 0
78#define ACPI_DMT_FLAG1 1
79#define ACPI_DMT_FLAG2 2
80#define ACPI_DMT_FLAG3 3
81#define ACPI_DMT_FLAG4 4
82#define ACPI_DMT_FLAG5 5
83#define ACPI_DMT_FLAG6 6
84#define ACPI_DMT_FLAG7 7
85#define ACPI_DMT_FLAGS0 8
86#define ACPI_DMT_FLAGS2 9
87#define ACPI_DMT_UINT8 10
88#define ACPI_DMT_UINT16 11
89#define ACPI_DMT_UINT24 12
90#define ACPI_DMT_UINT32 13
91#define ACPI_DMT_UINT56 14
92#define ACPI_DMT_UINT64 15
93#define ACPI_DMT_STRING 16
94#define ACPI_DMT_NAME4 17
95#define ACPI_DMT_NAME6 18
96#define ACPI_DMT_NAME8 19
97#define ACPI_DMT_CHKSUM 20
98#define ACPI_DMT_SPACEID 21
99#define ACPI_DMT_GAS 22
100#define ACPI_DMT_ASF 23
101#define ACPI_DMT_DMAR 24
102#define ACPI_DMT_HEST 25
103#define ACPI_DMT_HESTNTFY 26
104#define ACPI_DMT_HESTNTYP 27
105#define ACPI_DMT_MADT 28
106#define ACPI_DMT_SRAT 29
107#define ACPI_DMT_EXIT 30
108#define ACPI_DMT_SIG 31
109
110typedef
111void (*acpi_dmtable_handler) (struct acpi_table_header * table);
112
113struct acpi_dmtable_data {
114 char *signature;
115 struct acpi_dmtable_info *table_info;
116 acpi_dmtable_handler table_handler;
117 char *name;
118};
119
120struct acpi_op_walk_info {
121 u32 level;
122 u32 last_level;
123 u32 count;
124 u32 bit_offset;
125 u32 flags;
126 struct acpi_walk_state *walk_state;
127};
128
129typedef
130acpi_status(*asl_walk_callback) (union acpi_parse_object * op,
131 u32 level, void *context);
132
133struct acpi_resource_tag {
134 u32 bit_index;
135 char *tag;
136};
137
138/* Strings used for decoding flags to ASL keywords */
139
140extern const char *acpi_gbl_word_decode[];
141extern const char *acpi_gbl_irq_decode[];
142extern const char *acpi_gbl_lock_rule[];
143extern const char *acpi_gbl_access_types[];
144extern const char *acpi_gbl_update_rules[];
145extern const char *acpi_gbl_match_ops[];
146
147extern struct acpi_dmtable_info acpi_dm_table_info_asf0[];
148extern struct acpi_dmtable_info acpi_dm_table_info_asf1[];
149extern struct acpi_dmtable_info acpi_dm_table_info_asf1a[];
150extern struct acpi_dmtable_info acpi_dm_table_info_asf2[];
151extern struct acpi_dmtable_info acpi_dm_table_info_asf2a[];
152extern struct acpi_dmtable_info acpi_dm_table_info_asf3[];
153extern struct acpi_dmtable_info acpi_dm_table_info_asf4[];
154extern struct acpi_dmtable_info acpi_dm_table_info_asf_hdr[];
155extern struct acpi_dmtable_info acpi_dm_table_info_boot[];
156extern struct acpi_dmtable_info acpi_dm_table_info_bert[];
157extern struct acpi_dmtable_info acpi_dm_table_info_cpep[];
158extern struct acpi_dmtable_info acpi_dm_table_info_cpep0[];
159extern struct acpi_dmtable_info acpi_dm_table_info_dbgp[];
160extern struct acpi_dmtable_info acpi_dm_table_info_dmar[];
161extern struct acpi_dmtable_info acpi_dm_table_info_dmar_hdr[];
162extern struct acpi_dmtable_info acpi_dm_table_info_dmar_scope[];
163extern struct acpi_dmtable_info acpi_dm_table_info_dmar0[];
164extern struct acpi_dmtable_info acpi_dm_table_info_dmar1[];
165extern struct acpi_dmtable_info acpi_dm_table_info_dmar2[];
166extern struct acpi_dmtable_info acpi_dm_table_info_ecdt[];
167extern struct acpi_dmtable_info acpi_dm_table_info_einj[];
168extern struct acpi_dmtable_info acpi_dm_table_info_einj0[];
169extern struct acpi_dmtable_info acpi_dm_table_info_erst[];
170extern struct acpi_dmtable_info acpi_dm_table_info_facs[];
171extern struct acpi_dmtable_info acpi_dm_table_info_fadt1[];
172extern struct acpi_dmtable_info acpi_dm_table_info_fadt2[];
173extern struct acpi_dmtable_info acpi_dm_table_info_gas[];
174extern struct acpi_dmtable_info acpi_dm_table_info_header[];
175extern struct acpi_dmtable_info acpi_dm_table_info_hest[];
176extern struct acpi_dmtable_info acpi_dm_table_info_hest9[];
177extern struct acpi_dmtable_info acpi_dm_table_info_hest_notify[];
178extern struct acpi_dmtable_info acpi_dm_table_info_hpet[];
179extern struct acpi_dmtable_info acpi_dm_table_info_madt[];
180extern struct acpi_dmtable_info acpi_dm_table_info_madt0[];
181extern struct acpi_dmtable_info acpi_dm_table_info_madt1[];
182extern struct acpi_dmtable_info acpi_dm_table_info_madt2[];
183extern struct acpi_dmtable_info acpi_dm_table_info_madt3[];
184extern struct acpi_dmtable_info acpi_dm_table_info_madt4[];
185extern struct acpi_dmtable_info acpi_dm_table_info_madt5[];
186extern struct acpi_dmtable_info acpi_dm_table_info_madt6[];
187extern struct acpi_dmtable_info acpi_dm_table_info_madt7[];
188extern struct acpi_dmtable_info acpi_dm_table_info_madt8[];
189extern struct acpi_dmtable_info acpi_dm_table_info_madt9[];
190extern struct acpi_dmtable_info acpi_dm_table_info_madt10[];
191extern struct acpi_dmtable_info acpi_dm_table_info_madt_hdr[];
192extern struct acpi_dmtable_info acpi_dm_table_info_mcfg[];
193extern struct acpi_dmtable_info acpi_dm_table_info_mcfg0[];
194extern struct acpi_dmtable_info acpi_dm_table_info_rsdp1[];
195extern struct acpi_dmtable_info acpi_dm_table_info_rsdp2[];
196extern struct acpi_dmtable_info acpi_dm_table_info_sbst[];
197extern struct acpi_dmtable_info acpi_dm_table_info_slic[];
198extern struct acpi_dmtable_info acpi_dm_table_info_slit[];
199extern struct acpi_dmtable_info acpi_dm_table_info_spcr[];
200extern struct acpi_dmtable_info acpi_dm_table_info_spmi[];
201extern struct acpi_dmtable_info acpi_dm_table_info_srat[];
202extern struct acpi_dmtable_info acpi_dm_table_info_srat_hdr[];
203extern struct acpi_dmtable_info acpi_dm_table_info_srat0[];
204extern struct acpi_dmtable_info acpi_dm_table_info_srat1[];
205extern struct acpi_dmtable_info acpi_dm_table_info_srat2[];
206extern struct acpi_dmtable_info acpi_dm_table_info_tcpa[];
207extern struct acpi_dmtable_info acpi_dm_table_info_wdrt[];
208
209/*
210 * dmtable
211 */
212void acpi_dm_dump_data_table(struct acpi_table_header *table);
213
214acpi_status
215acpi_dm_dump_table(u32 table_length,
216 u32 table_offset,
217 void *table,
218 u32 sub_table_length, struct acpi_dmtable_info *info);
219
220void acpi_dm_line_header(u32 offset, u32 byte_length, char *name);
221
222void acpi_dm_line_header2(u32 offset, u32 byte_length, char *name, u32 value);
223
224/*
225 * dmtbdump
226 */
227void acpi_dm_dump_asf(struct acpi_table_header *table);
228
229void acpi_dm_dump_cpep(struct acpi_table_header *table);
230
231void acpi_dm_dump_dmar(struct acpi_table_header *table);
232
233void acpi_dm_dump_einj(struct acpi_table_header *table);
234
235void acpi_dm_dump_erst(struct acpi_table_header *table);
236
237void acpi_dm_dump_fadt(struct acpi_table_header *table);
238
239void acpi_dm_dump_hest(struct acpi_table_header *table);
240
241void acpi_dm_dump_mcfg(struct acpi_table_header *table);
242
243void acpi_dm_dump_madt(struct acpi_table_header *table);
244
245u32 acpi_dm_dump_rsdp(struct acpi_table_header *table);
246
247void acpi_dm_dump_rsdt(struct acpi_table_header *table);
248
249void acpi_dm_dump_slit(struct acpi_table_header *table);
250
251void acpi_dm_dump_srat(struct acpi_table_header *table);
252
253void acpi_dm_dump_xsdt(struct acpi_table_header *table);
254
255/*
256 * dmwalk
257 */
258void
259acpi_dm_disassemble(struct acpi_walk_state *walk_state,
260 union acpi_parse_object *origin, u32 num_opcodes);
261
262void
263acpi_dm_walk_parse_tree(union acpi_parse_object *op,
264 asl_walk_callback descending_callback,
265 asl_walk_callback ascending_callback, void *context);
266
267/*
268 * dmopcode
269 */
270void
271acpi_dm_disassemble_one_op(struct acpi_walk_state *walk_state,
272 struct acpi_op_walk_info *info,
273 union acpi_parse_object *op);
274
275void acpi_dm_decode_internal_object(union acpi_operand_object *obj_desc);
276
277u32 acpi_dm_list_type(union acpi_parse_object *op);
278
279void acpi_dm_method_flags(union acpi_parse_object *op);
280
281void acpi_dm_field_flags(union acpi_parse_object *op);
282
283void acpi_dm_address_space(u8 space_id);
284
285void acpi_dm_region_flags(union acpi_parse_object *op);
286
287void acpi_dm_match_op(union acpi_parse_object *op);
288
289u8 acpi_dm_comma_if_list_member(union acpi_parse_object *op);
290
291void acpi_dm_comma_if_field_member(union acpi_parse_object *op);
292
293/*
294 * dmnames
295 */
296u32 acpi_dm_dump_name(char *name);
297
298acpi_status
299acpi_ps_display_object_pathname(struct acpi_walk_state *walk_state,
300 union acpi_parse_object *op);
301
302void acpi_dm_namestring(char *name);
303
304/*
305 * dmobject
306 */
307void
308acpi_dm_display_internal_object(union acpi_operand_object *obj_desc,
309 struct acpi_walk_state *walk_state);
310
311void acpi_dm_display_arguments(struct acpi_walk_state *walk_state);
312
313void acpi_dm_display_locals(struct acpi_walk_state *walk_state);
314
315void
316acpi_dm_dump_method_info(acpi_status status,
317 struct acpi_walk_state *walk_state,
318 union acpi_parse_object *op);
319
320/*
321 * dmbuffer
322 */
323void acpi_dm_disasm_byte_list(u32 level, u8 * byte_data, u32 byte_count);
324
325void
326acpi_dm_byte_list(struct acpi_op_walk_info *info, union acpi_parse_object *op);
327
328void acpi_dm_is_eisa_id(union acpi_parse_object *op);
329
330void acpi_dm_eisa_id(u32 encoded_id);
331
332u8 acpi_dm_is_unicode_buffer(union acpi_parse_object *op);
333
334u8 acpi_dm_is_string_buffer(union acpi_parse_object *op);
335
336/*
337 * dmresrc
338 */
339void acpi_dm_dump_integer8(u8 value, char *name);
340
341void acpi_dm_dump_integer16(u16 value, char *name);
342
343void acpi_dm_dump_integer32(u32 value, char *name);
344
345void acpi_dm_dump_integer64(u64 value, char *name);
346
347void
348acpi_dm_resource_template(struct acpi_op_walk_info *info,
349 union acpi_parse_object *op,
350 u8 * byte_data, u32 byte_count);
351
352acpi_status acpi_dm_is_resource_template(union acpi_parse_object *op);
353
354void acpi_dm_indent(u32 level);
355
356void acpi_dm_bit_list(u16 mask);
357
358void acpi_dm_decode_attribute(u8 attribute);
359
360void acpi_dm_descriptor_name(void);
361
362/*
363 * dmresrcl
364 */
365void
366acpi_dm_word_descriptor(union aml_resource *resource, u32 length, u32 level);
367
368void
369acpi_dm_dword_descriptor(union aml_resource *resource, u32 length, u32 level);
370
371void
372acpi_dm_extended_descriptor(union aml_resource *resource,
373 u32 length, u32 level);
374
375void
376acpi_dm_qword_descriptor(union aml_resource *resource, u32 length, u32 level);
377
378void
379acpi_dm_memory24_descriptor(union aml_resource *resource,
380 u32 length, u32 level);
381
382void
383acpi_dm_memory32_descriptor(union aml_resource *resource,
384 u32 length, u32 level);
385
386void
387acpi_dm_fixed_memory32_descriptor(union aml_resource *resource,
388 u32 length, u32 level);
389
390void
391acpi_dm_generic_register_descriptor(union aml_resource *resource,
392 u32 length, u32 level);
393
394void
395acpi_dm_interrupt_descriptor(union aml_resource *resource,
396 u32 length, u32 level);
397
398void
399acpi_dm_vendor_large_descriptor(union aml_resource *resource,
400 u32 length, u32 level);
401
402void acpi_dm_vendor_common(char *name, u8 * byte_data, u32 length, u32 level);
403
404/*
405 * dmresrcs
406 */
407void
408acpi_dm_irq_descriptor(union aml_resource *resource, u32 length, u32 level);
409
410void
411acpi_dm_dma_descriptor(union aml_resource *resource, u32 length, u32 level);
412
413void acpi_dm_io_descriptor(union aml_resource *resource, u32 length, u32 level);
414
415void
416acpi_dm_fixed_io_descriptor(union aml_resource *resource,
417 u32 length, u32 level);
418
419void
420acpi_dm_start_dependent_descriptor(union aml_resource *resource,
421 u32 length, u32 level);
422
423void
424acpi_dm_end_dependent_descriptor(union aml_resource *resource,
425 u32 length, u32 level);
426
427void
428acpi_dm_vendor_small_descriptor(union aml_resource *resource,
429 u32 length, u32 level);
430
431/*
432 * dmutils
433 */
434void acpi_dm_add_to_external_list(char *path, u8 type, u32 value);
435
436/*
437 * dmrestag
438 */
439void acpi_dm_find_resources(union acpi_parse_object *root);
440
441void
442acpi_dm_check_resource_reference(union acpi_parse_object *op,
443 struct acpi_walk_state *walk_state);
444
445#endif /* __ACDISASM_H__ */
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 84f5cb242863..eda04546cdf6 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -153,8 +153,9 @@
153#define AE_AML_CIRCULAR_REFERENCE (acpi_status) (0x001E | AE_CODE_AML) 153#define AE_AML_CIRCULAR_REFERENCE (acpi_status) (0x001E | AE_CODE_AML)
154#define AE_AML_BAD_RESOURCE_LENGTH (acpi_status) (0x001F | AE_CODE_AML) 154#define AE_AML_BAD_RESOURCE_LENGTH (acpi_status) (0x001F | AE_CODE_AML)
155#define AE_AML_ILLEGAL_ADDRESS (acpi_status) (0x0020 | AE_CODE_AML) 155#define AE_AML_ILLEGAL_ADDRESS (acpi_status) (0x0020 | AE_CODE_AML)
156#define AE_AML_INFINITE_LOOP (acpi_status) (0x0021 | AE_CODE_AML)
156 157
157#define AE_CODE_AML_MAX 0x0020 158#define AE_CODE_AML_MAX 0x0021
158 159
159/* 160/*
160 * Internal exceptions used for control 161 * Internal exceptions used for control
@@ -175,6 +176,8 @@
175 176
176#define AE_CODE_CTRL_MAX 0x000D 177#define AE_CODE_CTRL_MAX 0x000D
177 178
179/* Exception strings for acpi_format_exception */
180
178#ifdef DEFINE_ACPI_GLOBALS 181#ifdef DEFINE_ACPI_GLOBALS
179 182
180/* 183/*
@@ -267,6 +270,7 @@ char const *acpi_gbl_exception_names_aml[] = {
267 "AE_AML_CIRCULAR_REFERENCE", 270 "AE_AML_CIRCULAR_REFERENCE",
268 "AE_AML_BAD_RESOURCE_LENGTH", 271 "AE_AML_BAD_RESOURCE_LENGTH",
269 "AE_AML_ILLEGAL_ADDRESS", 272 "AE_AML_ILLEGAL_ADDRESS",
273 "AE_AML_INFINITE_LOOP"
270}; 274};
271 275
272char const *acpi_gbl_exception_names_ctrl[] = { 276char const *acpi_gbl_exception_names_ctrl[] = {
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index db8852d8bcf7..5c823d5ab783 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -45,9 +45,9 @@
45#define __ACOUTPUT_H__ 45#define __ACOUTPUT_H__
46 46
47/* 47/*
48 * Debug levels and component IDs. These are used to control the 48 * Debug levels and component IDs. These are used to control the
49 * granularity of the output of the DEBUG_PRINT macro -- on a per- 49 * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a
50 * component basis and a per-exception-type basis. 50 * per-component basis and a per-exception-type basis.
51 */ 51 */
52 52
53/* Component IDs are used in the global "DebugLayer" */ 53/* Component IDs are used in the global "DebugLayer" */
@@ -69,8 +69,10 @@
69 69
70#define ACPI_COMPILER 0x00001000 70#define ACPI_COMPILER 0x00001000
71#define ACPI_TOOLS 0x00002000 71#define ACPI_TOOLS 0x00002000
72#define ACPI_EXAMPLE 0x00004000
73#define ACPI_DRIVER 0x00008000
72 74
73#define ACPI_ALL_COMPONENTS 0x00003FFF 75#define ACPI_ALL_COMPONENTS 0x0000FFFF
74#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) 76#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS)
75 77
76/* Component IDs reserved for ACPI drivers */ 78/* Component IDs reserved for ACPI drivers */
@@ -78,7 +80,7 @@
78#define ACPI_ALL_DRIVERS 0xFFFF0000 80#define ACPI_ALL_DRIVERS 0xFFFF0000
79 81
80/* 82/*
81 * Raw debug output levels, do not use these in the DEBUG_PRINT macros 83 * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros
82 */ 84 */
83#define ACPI_LV_INIT 0x00000001 85#define ACPI_LV_INIT 0x00000001
84#define ACPI_LV_DEBUG_OBJECT 0x00000002 86#define ACPI_LV_DEBUG_OBJECT 0x00000002
@@ -176,4 +178,95 @@
176#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT) 178#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT)
177#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) 179#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
178 180
181#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
182/*
183 * Module name is included in both debug and non-debug versions primarily for
184 * error messages. The __FILE__ macro is not very useful for this, because it
185 * often includes the entire pathname to the module
186 */
187#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name;
188#else
189#define ACPI_MODULE_NAME(name)
190#endif
191
192/*
193 * Ascii error messages can be configured out
194 */
195#ifndef ACPI_NO_ERROR_MESSAGES
196#define AE_INFO _acpi_module_name, __LINE__
197
198/*
199 * Error reporting. Callers module and line number are inserted by AE_INFO,
200 * the plist contains a set of parens to allow variable-length lists.
201 * These macros are used for both the debug and non-debug versions of the code.
202 */
203#define ACPI_INFO(plist) acpi_info plist
204#define ACPI_WARNING(plist) acpi_warning plist
205#define ACPI_EXCEPTION(plist) acpi_exception plist
206#define ACPI_ERROR(plist) acpi_error plist
207
208#else
209
210/* No error messages */
211
212#define ACPI_INFO(plist)
213#define ACPI_WARNING(plist)
214#define ACPI_EXCEPTION(plist)
215#define ACPI_ERROR(plist)
216
217#endif /* ACPI_NO_ERROR_MESSAGES */
218
219/*
220 * Debug macros that are conditionally compiled
221 */
222#ifdef ACPI_DEBUG_OUTPUT
223
224/*
225 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
226 * define it now. This is the case where there the compiler does not support
227 * a __FUNCTION__ macro or equivalent.
228 */
229#ifndef ACPI_GET_FUNCTION_NAME
230#define ACPI_GET_FUNCTION_NAME _acpi_function_name
231
232/*
233 * The Name parameter should be the procedure name as a quoted string.
234 * The function name is also used by the function exit macros below.
235 * Note: (const char) is used to be compatible with the debug interfaces
236 * and macros such as __FUNCTION__.
237 */
238#define ACPI_FUNCTION_NAME(name) static const char _acpi_function_name[] = #name;
239
240#else
241/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
242
243#define ACPI_FUNCTION_NAME(name)
244#endif /* ACPI_GET_FUNCTION_NAME */
245
246/*
247 * Common parameters used for debug output functions:
248 * line number, function name, module(file) name, component ID
249 */
250#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
251
252/*
253 * Master debug print macros
254 * Print message if and only if:
255 * 1) Debug print for the current component is enabled
256 * 2) Debug error level or trace level for the print statement is enabled
257 */
258#define ACPI_DEBUG_PRINT(plist) acpi_debug_print plist
259#define ACPI_DEBUG_PRINT_RAW(plist) acpi_debug_print_raw plist
260
261#else
262/*
263 * This is the non-debug case -- make everything go away,
264 * leaving no executable debug code!
265 */
266#define ACPI_FUNCTION_NAME(a)
267#define ACPI_DEBUG_PRINT(pl)
268#define ACPI_DEBUG_PRINT_RAW(pl)
269
270#endif /* ACPI_DEBUG_OUTPUT */
271
179#endif /* __ACOUTPUT_H__ */ 272#endif /* __ACOUTPUT_H__ */
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index c515ef6cc89e..472b7bf0c5d4 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: acpi.h - Master include file, Publics and external data. 3 * Name: acpi.h - Master public include file used to interface to ACPICA
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -45,25 +45,22 @@
45#define __ACPI_H__ 45#define __ACPI_H__
46 46
47/* 47/*
48 * Common includes for all ACPI driver files 48 * Public include files for use by code that will interface to ACPICA.
49 * We put them here because we don't want to duplicate them 49 *
50 * in the rest of the source code again and again. 50 * Information includes the ACPICA data types, names, exceptions, and
51 * external interface prototypes. Also included are the definitions for
52 * all ACPI tables (FADT, MADT, etc.)
53 *
54 * Note: The order of these include files is important.
51 */ 55 */
52#include "acnames.h" /* Global ACPI names and strings */ 56#include "platform/acenv.h" /* Environment-specific items */
53#include "acconfig.h" /* Configuration constants */ 57#include "acnames.h" /* Common ACPI names and strings */
54#include "platform/acenv.h" /* Target environment specific items */ 58#include "actypes.h" /* ACPICA data types and structures */
55#include "actypes.h" /* Fundamental common data types */ 59#include "acexcep.h" /* ACPICA exceptions */
56#include "acexcep.h" /* ACPI exception codes */
57#include "acmacros.h" /* C macros */
58#include "actbl.h" /* ACPI table definitions */ 60#include "actbl.h" /* ACPI table definitions */
59#include "aclocal.h" /* Internal data types */
60#include "acoutput.h" /* Error output and Debug macros */ 61#include "acoutput.h" /* Error output and Debug macros */
61#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer */ 62#include "acrestyp.h" /* Resource Descriptor structs */
63#include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */
62#include "acpixf.h" /* ACPI core subsystem external interfaces */ 64#include "acpixf.h" /* ACPI core subsystem external interfaces */
63#include "acobject.h" /* ACPI internal object */
64#include "acstruct.h" /* Common structures */
65#include "acglobal.h" /* All global variables */
66#include "achware.h" /* Hardware defines and interfaces */
67#include "acutils.h" /* Utility interfaces */
68 65
69#endif /* __ACPI_H__ */ 66#endif /* __ACPI_H__ */
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index b91440ac0d16..a62720a7edc0 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -121,8 +121,11 @@ acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
121acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units); 121acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
122 122
123/* 123/*
124 * Mutex primitives 124 * Mutex primitives. May be configured to use semaphores instead via
125 * ACPI_MUTEX_TYPE (see platform/acenv.h)
125 */ 126 */
127#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
128
126acpi_status acpi_os_create_mutex(acpi_mutex * out_handle); 129acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
127 130
128void acpi_os_delete_mutex(acpi_mutex handle); 131void acpi_os_delete_mutex(acpi_mutex handle);
@@ -130,13 +133,7 @@ void acpi_os_delete_mutex(acpi_mutex handle);
130acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout); 133acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
131 134
132void acpi_os_release_mutex(acpi_mutex handle); 135void acpi_os_release_mutex(acpi_mutex handle);
133 136#endif
134/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */
135
136#define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle)
137#define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle)
138#define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time)
139#define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1)
140 137
141/* 138/*
142 * Memory allocation and mapping 139 * Memory allocation and mapping
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 33bc0e3b1954..c8e8cf45830f 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -45,9 +45,32 @@
45#ifndef __ACXFACE_H__ 45#ifndef __ACXFACE_H__
46#define __ACXFACE_H__ 46#define __ACXFACE_H__
47 47
48/* Current ACPICA subsystem version in YYYYMMDD format */
49
50#define ACPI_CA_VERSION 0x20081204
51
48#include "actypes.h" 52#include "actypes.h"
49#include "actbl.h" 53#include "actbl.h"
50 54
55extern u8 acpi_gbl_permanent_mmap;
56
57/*
58 * Globals that are publically available, allowing for
59 * run time configuration
60 */
61extern u32 acpi_dbg_level;
62extern u32 acpi_dbg_layer;
63extern u8 acpi_gbl_enable_interpreter_slack;
64extern u8 acpi_gbl_all_methods_serialized;
65extern u8 acpi_gbl_create_osi_method;
66extern u8 acpi_gbl_leave_wake_gpes_disabled;
67extern acpi_name acpi_gbl_trace_method_name;
68extern u32 acpi_gbl_trace_flags;
69
70extern u32 acpi_current_gpe_count;
71extern struct acpi_table_fadt acpi_gbl_FADT;
72
73extern u32 acpi_rsdt_forced;
51/* 74/*
52 * Global interfaces 75 * Global interfaces
53 */ 76 */
@@ -79,11 +102,6 @@ const char *acpi_format_exception(acpi_status exception);
79 102
80acpi_status acpi_purge_cached_objects(void); 103acpi_status acpi_purge_cached_objects(void);
81 104
82#ifdef ACPI_FUTURE_USAGE
83acpi_status
84acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
85#endif
86
87/* 105/*
88 * ACPI Memory management 106 * ACPI Memory management
89 */ 107 */
@@ -193,9 +211,12 @@ acpi_status acpi_get_id(acpi_handle object, acpi_owner_id * out_type);
193acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle); 211acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
194 212
195/* 213/*
196 * Event handler interfaces 214 * Handler interfaces
197 */ 215 */
198acpi_status 216acpi_status
217acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
218
219acpi_status
199acpi_install_fixed_event_handler(u32 acpi_event, 220acpi_install_fixed_event_handler(u32 acpi_event,
200 acpi_event_handler handler, void *context); 221 acpi_event_handler handler, void *context);
201 222
@@ -227,6 +248,10 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
227 u32 gpe_number, 248 u32 gpe_number,
228 u32 type, acpi_event_handler address, void *context); 249 u32 type, acpi_event_handler address, void *context);
229 250
251acpi_status
252acpi_remove_gpe_handler(acpi_handle gpe_device,
253 u32 gpe_number, acpi_event_handler address);
254
230#ifdef ACPI_FUTURE_USAGE 255#ifdef ACPI_FUTURE_USAGE
231acpi_status acpi_install_exception_handler(acpi_exception_handler handler); 256acpi_status acpi_install_exception_handler(acpi_exception_handler handler);
232#endif 257#endif
@@ -238,10 +263,6 @@ acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle);
238 263
239acpi_status acpi_release_global_lock(u32 handle); 264acpi_status acpi_release_global_lock(u32 handle);
240 265
241acpi_status
242acpi_remove_gpe_handler(acpi_handle gpe_device,
243 u32 gpe_number, acpi_event_handler address);
244
245acpi_status acpi_enable_event(u32 event, u32 flags); 266acpi_status acpi_enable_event(u32 event, u32 flags);
246 267
247acpi_status acpi_disable_event(u32 event, u32 flags); 268acpi_status acpi_disable_event(u32 event, u32 flags);
@@ -250,6 +271,9 @@ acpi_status acpi_clear_event(u32 event);
250 271
251acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status); 272acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status);
252 273
274/*
275 * GPE Interfaces
276 */
253acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type); 277acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type);
254 278
255acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number); 279acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number);
@@ -263,6 +287,12 @@ acpi_get_gpe_status(acpi_handle gpe_device,
263 u32 gpe_number, 287 u32 gpe_number,
264 u32 flags, acpi_event_status * event_status); 288 u32 flags, acpi_event_status * event_status);
265 289
290acpi_status acpi_disable_all_gpes(void);
291
292acpi_status acpi_enable_all_runtime_gpes(void);
293
294acpi_status acpi_get_gpe_device(u32 gpe_index, acpi_handle *gpe_device);
295
266acpi_status 296acpi_status
267acpi_install_gpe_block(acpi_handle gpe_device, 297acpi_install_gpe_block(acpi_handle gpe_device,
268 struct acpi_generic_address *gpe_block_address, 298 struct acpi_generic_address *gpe_block_address,
@@ -313,6 +343,8 @@ acpi_resource_to_address64(struct acpi_resource *resource,
313/* 343/*
314 * Hardware (ACPI device) interfaces 344 * Hardware (ACPI device) interfaces
315 */ 345 */
346acpi_status acpi_reset(void);
347
316acpi_status acpi_get_register(u32 register_id, u32 * return_value); 348acpi_status acpi_get_register(u32 register_id, u32 * return_value);
317 349
318acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value); 350acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value);
@@ -320,12 +352,14 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value);
320acpi_status acpi_set_register(u32 register_id, u32 value); 352acpi_status acpi_set_register(u32 register_id, u32 value);
321 353
322acpi_status 354acpi_status
323acpi_set_firmware_waking_vector(acpi_physical_address physical_address); 355acpi_set_firmware_waking_vector(u32 physical_address);
324 356
325#ifdef ACPI_FUTURE_USAGE
326acpi_status 357acpi_status
327acpi_get_firmware_waking_vector(acpi_physical_address * physical_address); 358acpi_set_firmware_waking_vector64(u64 physical_address);
328#endif 359
360acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg);
361
362acpi_status acpi_write(u32 value, struct acpi_generic_address *reg);
329 363
330acpi_status 364acpi_status
331acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b); 365acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b);
@@ -340,4 +374,42 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
340 374
341acpi_status acpi_leave_sleep_state(u8 sleep_state); 375acpi_status acpi_leave_sleep_state(u8 sleep_state);
342 376
377/*
378 * Debug output
379 */
380void ACPI_INTERNAL_VAR_XFACE
381acpi_error(const char *module_name,
382 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
383
384void ACPI_INTERNAL_VAR_XFACE
385acpi_exception(const char *module_name,
386 u32 line_number,
387 acpi_status status, const char *format, ...) ACPI_PRINTF_LIKE(4);
388
389void ACPI_INTERNAL_VAR_XFACE
390acpi_warning(const char *module_name,
391 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
392
393void ACPI_INTERNAL_VAR_XFACE
394acpi_info(const char *module_name,
395 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
396
397#ifdef ACPI_DEBUG_OUTPUT
398
399void ACPI_INTERNAL_VAR_XFACE
400acpi_debug_print(u32 requested_debug_level,
401 u32 line_number,
402 const char *function_name,
403 const char *module_name,
404 u32 component_id, const char *format, ...) ACPI_PRINTF_LIKE(6);
405
406void ACPI_INTERNAL_VAR_XFACE
407acpi_debug_print_raw(u32 requested_debug_level,
408 u32 line_number,
409 const char *function_name,
410 const char *module_name,
411 u32 component_id,
412 const char *format, ...) ACPI_PRINTF_LIKE(6);
413#endif
414
343#endif /* __ACXFACE_H__ */ 415#endif /* __ACXFACE_H__ */
diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
new file mode 100644
index 000000000000..9ffe00feada6
--- /dev/null
+++ b/include/acpi/acrestyp.h
@@ -0,0 +1,405 @@
1/******************************************************************************
2 *
3 * Name: acrestyp.h - Defines, types, and structures for resource descriptors
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 __ACRESTYP_H__
45#define __ACRESTYP_H__
46
47/*
48 * Definitions for Resource Attributes
49 */
50typedef u16 acpi_rs_length; /* Resource Length field is fixed at 16 bits */
51typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (64_k-1)+3 */
52
53/*
54 * Memory Attributes
55 */
56#define ACPI_READ_ONLY_MEMORY (u8) 0x00
57#define ACPI_READ_WRITE_MEMORY (u8) 0x01
58
59#define ACPI_NON_CACHEABLE_MEMORY (u8) 0x00
60#define ACPI_CACHABLE_MEMORY (u8) 0x01
61#define ACPI_WRITE_COMBINING_MEMORY (u8) 0x02
62#define ACPI_PREFETCHABLE_MEMORY (u8) 0x03
63
64/*
65 * IO Attributes
66 * The ISA IO ranges are: n000-n0_fFh, n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
67 * The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cd0-n_fFFh.
68 */
69#define ACPI_NON_ISA_ONLY_RANGES (u8) 0x01
70#define ACPI_ISA_ONLY_RANGES (u8) 0x02
71#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
72
73/* Type of translation - 1=Sparse, 0=Dense */
74
75#define ACPI_SPARSE_TRANSLATION (u8) 0x01
76
77/*
78 * IO Port Descriptor Decode
79 */
80#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */
81#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */
82
83/*
84 * IRQ Attributes
85 */
86#define ACPI_LEVEL_SENSITIVE (u8) 0x00
87#define ACPI_EDGE_SENSITIVE (u8) 0x01
88
89#define ACPI_ACTIVE_HIGH (u8) 0x00
90#define ACPI_ACTIVE_LOW (u8) 0x01
91
92#define ACPI_EXCLUSIVE (u8) 0x00
93#define ACPI_SHARED (u8) 0x01
94
95/*
96 * DMA Attributes
97 */
98#define ACPI_COMPATIBILITY (u8) 0x00
99#define ACPI_TYPE_A (u8) 0x01
100#define ACPI_TYPE_B (u8) 0x02
101#define ACPI_TYPE_F (u8) 0x03
102
103#define ACPI_NOT_BUS_MASTER (u8) 0x00
104#define ACPI_BUS_MASTER (u8) 0x01
105
106#define ACPI_TRANSFER_8 (u8) 0x00
107#define ACPI_TRANSFER_8_16 (u8) 0x01
108#define ACPI_TRANSFER_16 (u8) 0x02
109
110/*
111 * Start Dependent Functions Priority definitions
112 */
113#define ACPI_GOOD_CONFIGURATION (u8) 0x00
114#define ACPI_ACCEPTABLE_CONFIGURATION (u8) 0x01
115#define ACPI_SUB_OPTIMAL_CONFIGURATION (u8) 0x02
116
117/*
118 * 16, 32 and 64-bit Address Descriptor resource types
119 */
120#define ACPI_MEMORY_RANGE (u8) 0x00
121#define ACPI_IO_RANGE (u8) 0x01
122#define ACPI_BUS_NUMBER_RANGE (u8) 0x02
123
124#define ACPI_ADDRESS_NOT_FIXED (u8) 0x00
125#define ACPI_ADDRESS_FIXED (u8) 0x01
126
127#define ACPI_POS_DECODE (u8) 0x00
128#define ACPI_SUB_DECODE (u8) 0x01
129
130#define ACPI_PRODUCER (u8) 0x00
131#define ACPI_CONSUMER (u8) 0x01
132
133/*
134 * If possible, pack the following structures to byte alignment
135 */
136#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
137#pragma pack(1)
138#endif
139
140/* UUID data structures for use in vendor-defined resource descriptors */
141
142struct acpi_uuid {
143 u8 data[ACPI_UUID_LENGTH];
144};
145
146struct acpi_vendor_uuid {
147 u8 subtype;
148 u8 data[ACPI_UUID_LENGTH];
149};
150
151/*
152 * Structures used to describe device resources
153 */
154struct acpi_resource_irq {
155 u8 descriptor_length;
156 u8 triggering;
157 u8 polarity;
158 u8 sharable;
159 u8 interrupt_count;
160 u8 interrupts[1];
161};
162
163struct acpi_resource_dma {
164 u8 type;
165 u8 bus_master;
166 u8 transfer;
167 u8 channel_count;
168 u8 channels[1];
169};
170
171struct acpi_resource_start_dependent {
172 u8 descriptor_length;
173 u8 compatibility_priority;
174 u8 performance_robustness;
175};
176
177/*
178 * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
179 * needed because it has no fields
180 */
181
182struct acpi_resource_io {
183 u8 io_decode;
184 u8 alignment;
185 u8 address_length;
186 u16 minimum;
187 u16 maximum;
188};
189
190struct acpi_resource_fixed_io {
191 u16 address;
192 u8 address_length;
193};
194
195struct acpi_resource_vendor {
196 u16 byte_length;
197 u8 byte_data[1];
198};
199
200/* Vendor resource with UUID info (introduced in ACPI 3.0) */
201
202struct acpi_resource_vendor_typed {
203 u16 byte_length;
204 u8 uuid_subtype;
205 u8 uuid[ACPI_UUID_LENGTH];
206 u8 byte_data[1];
207};
208
209struct acpi_resource_end_tag {
210 u8 checksum;
211};
212
213struct acpi_resource_memory24 {
214 u8 write_protect;
215 u16 minimum;
216 u16 maximum;
217 u16 alignment;
218 u16 address_length;
219};
220
221struct acpi_resource_memory32 {
222 u8 write_protect;
223 u32 minimum;
224 u32 maximum;
225 u32 alignment;
226 u32 address_length;
227};
228
229struct acpi_resource_fixed_memory32 {
230 u8 write_protect;
231 u32 address;
232 u32 address_length;
233};
234
235struct acpi_memory_attribute {
236 u8 write_protect;
237 u8 caching;
238 u8 range_type;
239 u8 translation;
240};
241
242struct acpi_io_attribute {
243 u8 range_type;
244 u8 translation;
245 u8 translation_type;
246 u8 reserved1;
247};
248
249union acpi_resource_attribute {
250 struct acpi_memory_attribute mem;
251 struct acpi_io_attribute io;
252
253 /* Used for the *word_space macros */
254
255 u8 type_specific;
256};
257
258struct acpi_resource_source {
259 u8 index;
260 u16 string_length;
261 char *string_ptr;
262};
263
264/* Fields common to all address descriptors, 16/32/64 bit */
265
266#define ACPI_RESOURCE_ADDRESS_COMMON \
267 u8 resource_type; \
268 u8 producer_consumer; \
269 u8 decode; \
270 u8 min_address_fixed; \
271 u8 max_address_fixed; \
272 union acpi_resource_attribute info;
273
274struct acpi_resource_address {
275ACPI_RESOURCE_ADDRESS_COMMON};
276
277struct acpi_resource_address16 {
278 ACPI_RESOURCE_ADDRESS_COMMON u16 granularity;
279 u16 minimum;
280 u16 maximum;
281 u16 translation_offset;
282 u16 address_length;
283 struct acpi_resource_source resource_source;
284};
285
286struct acpi_resource_address32 {
287 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
288 u32 minimum;
289 u32 maximum;
290 u32 translation_offset;
291 u32 address_length;
292 struct acpi_resource_source resource_source;
293};
294
295struct acpi_resource_address64 {
296 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity;
297 u64 minimum;
298 u64 maximum;
299 u64 translation_offset;
300 u64 address_length;
301 struct acpi_resource_source resource_source;
302};
303
304struct acpi_resource_extended_address64 {
305 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_iD;
306 u64 granularity;
307 u64 minimum;
308 u64 maximum;
309 u64 translation_offset;
310 u64 address_length;
311 u64 type_specific;
312};
313
314struct acpi_resource_extended_irq {
315 u8 producer_consumer;
316 u8 triggering;
317 u8 polarity;
318 u8 sharable;
319 u8 interrupt_count;
320 struct acpi_resource_source resource_source;
321 u32 interrupts[1];
322};
323
324struct acpi_resource_generic_register {
325 u8 space_id;
326 u8 bit_width;
327 u8 bit_offset;
328 u8 access_size;
329 u64 address;
330};
331
332/* ACPI_RESOURCE_TYPEs */
333
334#define ACPI_RESOURCE_TYPE_IRQ 0
335#define ACPI_RESOURCE_TYPE_DMA 1
336#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
337#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
338#define ACPI_RESOURCE_TYPE_IO 4
339#define ACPI_RESOURCE_TYPE_FIXED_IO 5
340#define ACPI_RESOURCE_TYPE_VENDOR 6
341#define ACPI_RESOURCE_TYPE_END_TAG 7
342#define ACPI_RESOURCE_TYPE_MEMORY24 8
343#define ACPI_RESOURCE_TYPE_MEMORY32 9
344#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
345#define ACPI_RESOURCE_TYPE_ADDRESS16 11
346#define ACPI_RESOURCE_TYPE_ADDRESS32 12
347#define ACPI_RESOURCE_TYPE_ADDRESS64 13
348#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
349#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
350#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
351#define ACPI_RESOURCE_TYPE_MAX 16
352
353/* Master union for resource descriptors */
354
355union acpi_resource_data {
356 struct acpi_resource_irq irq;
357 struct acpi_resource_dma dma;
358 struct acpi_resource_start_dependent start_dpf;
359 struct acpi_resource_io io;
360 struct acpi_resource_fixed_io fixed_io;
361 struct acpi_resource_vendor vendor;
362 struct acpi_resource_vendor_typed vendor_typed;
363 struct acpi_resource_end_tag end_tag;
364 struct acpi_resource_memory24 memory24;
365 struct acpi_resource_memory32 memory32;
366 struct acpi_resource_fixed_memory32 fixed_memory32;
367 struct acpi_resource_address16 address16;
368 struct acpi_resource_address32 address32;
369 struct acpi_resource_address64 address64;
370 struct acpi_resource_extended_address64 ext_address64;
371 struct acpi_resource_extended_irq extended_irq;
372 struct acpi_resource_generic_register generic_reg;
373
374 /* Common fields */
375
376 struct acpi_resource_address address; /* Common 16/32/64 address fields */
377};
378
379/* Common resource header */
380
381struct acpi_resource {
382 u32 type;
383 u32 length;
384 union acpi_resource_data data;
385};
386
387/* restore default alignment */
388
389#pragma pack()
390
391#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
392#define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
393#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
394
395#define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length)
396
397struct acpi_pci_routing_table {
398 u32 length;
399 u32 pin;
400 acpi_integer address; /* here for 64-bit alignment */
401 u32 source_index;
402 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
403};
404
405#endif /* __ACRESTYP_H__ */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 13a3d9ad92db..813e4b6c2c0d 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -288,6 +288,31 @@ enum acpi_prefered_pm_profiles {
288 288
289#define ACPI_FADT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_table_fadt, f) 289#define ACPI_FADT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_table_fadt, f)
290 290
291union acpi_name_union {
292 u32 integer;
293 char ascii[4];
294};
295
296/*
297 * Internal ACPI Table Descriptor. One per ACPI table
298 */
299struct acpi_table_desc {
300 acpi_physical_address address;
301 struct acpi_table_header *pointer;
302 u32 length; /* Length fixed at 32 bits */
303 union acpi_name_union signature;
304 acpi_owner_id owner_id;
305 u8 flags;
306};
307
308/* Flags for above */
309
310#define ACPI_TABLE_ORIGIN_UNKNOWN (0)
311#define ACPI_TABLE_ORIGIN_MAPPED (1)
312#define ACPI_TABLE_ORIGIN_ALLOCATED (2)
313#define ACPI_TABLE_ORIGIN_MASK (3)
314#define ACPI_TABLE_IS_LOADED (4)
315
291/* 316/*
292 * Get the remaining ACPI tables 317 * Get the remaining ACPI tables
293 */ 318 */
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 63f5b4cf4de1..18963b968114 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -627,7 +627,7 @@ struct acpi_hest_aer_common {
627 u32 uncorrectable_error_mask; 627 u32 uncorrectable_error_mask;
628 u32 uncorrectable_error_severity; 628 u32 uncorrectable_error_severity;
629 u32 correctable_error_mask; 629 u32 correctable_error_mask;
630 u32 advanced_error_cababilities; 630 u32 advanced_error_capabilities;
631}; 631};
632 632
633/* Hardware Error Notification */ 633/* Hardware Error Notification */
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 8222e8de0d1c..a20aab510173 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -204,11 +204,10 @@ typedef u32 acpi_physical_address;
204 204
205/******************************************************************************* 205/*******************************************************************************
206 * 206 *
207 * OS-dependent and compiler-dependent types 207 * OS-dependent types
208 * 208 *
209 * If the defaults below are not appropriate for the host system, they can 209 * If the defaults below are not appropriate for the host system, they can
210 * be defined in the compiler-specific or OS-specific header, and this will 210 * be defined in the OS-specific header, and this will take precedence.
211 * take precedence.
212 * 211 *
213 ******************************************************************************/ 212 ******************************************************************************/
214 213
@@ -218,12 +217,6 @@ typedef u32 acpi_physical_address;
218#define acpi_thread_id acpi_size 217#define acpi_thread_id acpi_size
219#endif 218#endif
220 219
221/* Object returned from acpi_os_create_lock */
222
223#ifndef acpi_spinlock
224#define acpi_spinlock void *
225#endif
226
227/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ 220/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */
228 221
229#ifndef acpi_cpu_flags 222#ifndef acpi_cpu_flags
@@ -233,9 +226,51 @@ typedef u32 acpi_physical_address;
233/* Object returned from acpi_os_create_cache */ 226/* Object returned from acpi_os_create_cache */
234 227
235#ifndef acpi_cache_t 228#ifndef acpi_cache_t
229#ifdef ACPI_USE_LOCAL_CACHE
236#define acpi_cache_t struct acpi_memory_list 230#define acpi_cache_t struct acpi_memory_list
231#else
232#define acpi_cache_t void *
233#endif
234#endif
235
236/*
237 * Synchronization objects - Mutexes, Semaphores, and spin_locks
238 */
239#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE)
240/*
241 * These macros are used if the host OS does not support a mutex object.
242 * Map the OSL Mutex interfaces to binary semaphores.
243 */
244#define acpi_mutex acpi_semaphore
245#define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle)
246#define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle)
247#define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time)
248#define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1)
249#endif
250
251/* Configurable types for synchronization objects */
252
253#ifndef acpi_spinlock
254#define acpi_spinlock void *
255#endif
256
257#ifndef acpi_semaphore
258#define acpi_semaphore void *
259#endif
260
261#ifndef acpi_mutex
262#define acpi_mutex void *
237#endif 263#endif
238 264
265/*******************************************************************************
266 *
267 * Compiler-dependent types
268 *
269 * If the defaults below are not appropriate for the host compiler, they can
270 * be defined in the compiler-specific header, and this will take precedence.
271 *
272 ******************************************************************************/
273
239/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ 274/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
240 275
241#ifndef acpi_uintptr_t 276#ifndef acpi_uintptr_t
@@ -268,6 +303,43 @@ typedef u32 acpi_physical_address;
268#define ACPI_EXPORT_SYMBOL(symbol) 303#define ACPI_EXPORT_SYMBOL(symbol)
269#endif 304#endif
270 305
306/******************************************************************************
307 *
308 * ACPI Specification constants (Do not change unless the specification changes)
309 *
310 *****************************************************************************/
311
312/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */
313
314#define ACPI_MAX_GPE_BLOCKS 2
315
316/* Default ACPI register widths */
317
318#define ACPI_GPE_REGISTER_WIDTH 8
319#define ACPI_PM1_REGISTER_WIDTH 16
320#define ACPI_PM2_REGISTER_WIDTH 8
321#define ACPI_PM_TIMER_WIDTH 32
322
323/* Names within the namespace are 4 bytes long */
324
325#define ACPI_NAME_SIZE 4
326#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
327#define ACPI_PATH_SEPARATOR '.'
328
329/* Sizes for ACPI table headers */
330
331#define ACPI_OEM_ID_SIZE 6
332#define ACPI_OEM_TABLE_ID_SIZE 8
333
334/* ACPI/PNP hardware IDs */
335
336#define PCI_ROOT_HID_STRING "PNP0A03"
337#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
338
339/* PM Timer ticks per second (HZ) */
340
341#define PM_TIMER_FREQUENCY 3579545
342
271/******************************************************************************* 343/*******************************************************************************
272 * 344 *
273 * Independent types 345 * Independent types
@@ -291,13 +363,18 @@ typedef u32 acpi_physical_address;
291#endif 363#endif
292 364
293/* 365/*
294 * Mescellaneous types 366 * Miscellaneous types
295 */ 367 */
296typedef u32 acpi_status; /* All ACPI Exceptions */ 368typedef u32 acpi_status; /* All ACPI Exceptions */
297typedef u32 acpi_name; /* 4-byte ACPI name */ 369typedef u32 acpi_name; /* 4-byte ACPI name */
298typedef char *acpi_string; /* Null terminated ASCII string */ 370typedef char *acpi_string; /* Null terminated ASCII string */
299typedef void *acpi_handle; /* Actually a ptr to a NS Node */ 371typedef void *acpi_handle; /* Actually a ptr to a NS Node */
300 372
373/* Owner IDs are used to track namespace nodes for selective deletion */
374
375typedef u8 acpi_owner_id;
376#define ACPI_OWNER_ID_MAX 0xFF
377
301struct uint64_struct { 378struct uint64_struct {
302 u32 lo; 379 u32 lo;
303 u32 hi; 380 u32 hi;
@@ -313,13 +390,8 @@ struct uint32_struct {
313 u32 hi; 390 u32 hi;
314}; 391};
315 392
316/* Synchronization objects */
317
318#define acpi_mutex void *
319#define acpi_semaphore void *
320
321/* 393/*
322 * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI 394 * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI
323 * version 2, integers are 64 bits. Note that this pertains to the ACPI integer 395 * version 2, integers are 64 bits. Note that this pertains to the ACPI integer
324 * type only, not other integers used in the implementation of the ACPI CA 396 * type only, not other integers used in the implementation of the ACPI CA
325 * subsystem. 397 * subsystem.
@@ -338,10 +410,75 @@ typedef unsigned long long acpi_integer;
338#define ACPI_MAX16_DECIMAL_DIGITS 5 410#define ACPI_MAX16_DECIMAL_DIGITS 5
339#define ACPI_MAX8_DECIMAL_DIGITS 3 411#define ACPI_MAX8_DECIMAL_DIGITS 3
340 412
413/* PM Timer ticks per second (HZ) */
414
415#define PM_TIMER_FREQUENCY 3579545
416
341/* 417/*
342 * Constants with special meanings 418 * Constants with special meanings
343 */ 419 */
344#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR) 420#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
421#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
422#define ACPI_DO_NOT_WAIT 0
423
424/*******************************************************************************
425 *
426 * Commonly used macros
427 *
428 ******************************************************************************/
429
430/* Data manipulation */
431
432#define ACPI_LOWORD(l) ((u16)(u32)(l))
433#define ACPI_HIWORD(l) ((u16)((((u32)(l)) >> 16) & 0xFFFF))
434#define ACPI_LOBYTE(l) ((u8)(u16)(l))
435#define ACPI_HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF))
436
437/* Full 64-bit integer must be available on both 32-bit and 64-bit platforms */
438
439struct acpi_integer_overlay {
440 u32 lo_dword;
441 u32 hi_dword;
442};
443
444#define ACPI_LODWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->lo_dword)
445#define ACPI_HIDWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->hi_dword)
446
447#define ACPI_SET_BIT(target,bit) ((target) |= (bit))
448#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit))
449#define ACPI_MIN(a,b) (((a)<(b))?(a):(b))
450#define ACPI_MAX(a,b) (((a)>(b))?(a):(b))
451
452/* Size calculation */
453
454#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
455
456/* Pointer manipulation */
457
458#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p))
459#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p))
460#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b)))
461#define ACPI_PTR_DIFF(a, b) (acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))
462
463/* Pointer/Integer type conversions */
464
465#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_size) i)
466#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL)
467#define ACPI_OFFSET(d, f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL)
468#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i)
469#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
470
471#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
472#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (u32, (a)) == *ACPI_CAST_PTR (u32, (b)))
473#else
474#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
475#endif
476
477/*******************************************************************************
478 *
479 * Miscellaneous constants
480 *
481 ******************************************************************************/
345 482
346/* 483/*
347 * Initialization sequence 484 * Initialization sequence
@@ -414,7 +551,7 @@ typedef unsigned long long acpi_integer;
414#define ACPI_NOTIFY_MAX 0x0B 551#define ACPI_NOTIFY_MAX 0x0B
415 552
416/* 553/*
417 * Types associated with ACPI names and objects. The first group of 554 * Types associated with ACPI names and objects. The first group of
418 * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition 555 * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
419 * of the ACPI object_type() operator (See the ACPI Spec). Therefore, 556 * of the ACPI object_type() operator (See the ACPI Spec). Therefore,
420 * only add to the first group if the spec changes. 557 * only add to the first group if the spec changes.
@@ -732,6 +869,15 @@ struct acpi_buffer {
732#define ACPI_NAME_TYPE_MAX 1 869#define ACPI_NAME_TYPE_MAX 1
733 870
734/* 871/*
872 * Predefined Namespace items
873 */
874struct acpi_predefined_names {
875 char *name;
876 u8 type;
877 char *val;
878};
879
880/*
735 * Structure and flags for acpi_get_system_info 881 * Structure and flags for acpi_get_system_info
736 */ 882 */
737#define ACPI_SYS_MODE_UNKNOWN 0x0000 883#define ACPI_SYS_MODE_UNKNOWN 0x0000
@@ -787,7 +933,7 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status,
787 u16 opcode, 933 u16 opcode,
788 u32 aml_offset, void *context); 934 u32 aml_offset, void *context);
789 935
790/* Table Event handler (Load, load_table etc) and types */ 936/* Table Event handler (Load, load_table, etc.) and types */
791 937
792typedef 938typedef
793acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context); 939acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context);
@@ -823,6 +969,12 @@ acpi_status(*acpi_walk_callback) (acpi_handle obj_handle,
823#define ACPI_INTERRUPT_NOT_HANDLED 0x00 969#define ACPI_INTERRUPT_NOT_HANDLED 0x00
824#define ACPI_INTERRUPT_HANDLED 0x01 970#define ACPI_INTERRUPT_HANDLED 0x01
825 971
972/* Length of _HID, _UID, _CID, and UUID values */
973
974#define ACPI_DEVICE_ID_LENGTH 0x09
975#define ACPI_MAX_CID_LENGTH 48
976#define ACPI_UUID_LENGTH 16
977
826/* Common string version of device HIDs and UIDs */ 978/* Common string version of device HIDs and UIDs */
827 979
828struct acpica_device_id { 980struct acpica_device_id {
@@ -900,357 +1052,28 @@ struct acpi_mem_space_context {
900}; 1052};
901 1053
902/* 1054/*
903 * Definitions for Resource Attributes 1055 * struct acpi_memory_list is used only if the ACPICA local cache is enabled
904 */
905typedef u16 acpi_rs_length; /* Resource Length field is fixed at 16 bits */
906typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (64_k-1)+3 */
907
908/*
909 * Memory Attributes
910 */
911#define ACPI_READ_ONLY_MEMORY (u8) 0x00
912#define ACPI_READ_WRITE_MEMORY (u8) 0x01
913
914#define ACPI_NON_CACHEABLE_MEMORY (u8) 0x00
915#define ACPI_CACHABLE_MEMORY (u8) 0x01
916#define ACPI_WRITE_COMBINING_MEMORY (u8) 0x02
917#define ACPI_PREFETCHABLE_MEMORY (u8) 0x03
918
919/*
920 * IO Attributes
921 * The ISA IO ranges are: n000-n0_fFh, n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
922 * The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cd0-n_fFFh.
923 */ 1056 */
924#define ACPI_NON_ISA_ONLY_RANGES (u8) 0x01 1057struct acpi_memory_list {
925#define ACPI_ISA_ONLY_RANGES (u8) 0x02 1058 char *list_name;
926#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) 1059 void *list_head;
927 1060 u16 object_size;
928/* Type of translation - 1=Sparse, 0=Dense */ 1061 u16 max_depth;
929 1062 u16 current_depth;
930#define ACPI_SPARSE_TRANSLATION (u8) 0x01 1063 u16 link_offset;
931 1064
932/* 1065#ifdef ACPI_DBG_TRACK_ALLOCATIONS
933 * IO Port Descriptor Decode 1066
934 */ 1067 /* Statistics for debug memory tracking only */
935#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ 1068
936#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ 1069 u32 total_allocated;
937 1070 u32 total_freed;
938/* 1071 u32 max_occupied;
939 * IRQ Attributes 1072 u32 total_size;
940 */ 1073 u32 current_total_size;
941#define ACPI_LEVEL_SENSITIVE (u8) 0x00 1074 u32 requests;
942#define ACPI_EDGE_SENSITIVE (u8) 0x01 1075 u32 hits;
943
944#define ACPI_ACTIVE_HIGH (u8) 0x00
945#define ACPI_ACTIVE_LOW (u8) 0x01
946
947#define ACPI_EXCLUSIVE (u8) 0x00
948#define ACPI_SHARED (u8) 0x01
949
950/*
951 * DMA Attributes
952 */
953#define ACPI_COMPATIBILITY (u8) 0x00
954#define ACPI_TYPE_A (u8) 0x01
955#define ACPI_TYPE_B (u8) 0x02
956#define ACPI_TYPE_F (u8) 0x03
957
958#define ACPI_NOT_BUS_MASTER (u8) 0x00
959#define ACPI_BUS_MASTER (u8) 0x01
960
961#define ACPI_TRANSFER_8 (u8) 0x00
962#define ACPI_TRANSFER_8_16 (u8) 0x01
963#define ACPI_TRANSFER_16 (u8) 0x02
964
965/*
966 * Start Dependent Functions Priority definitions
967 */
968#define ACPI_GOOD_CONFIGURATION (u8) 0x00
969#define ACPI_ACCEPTABLE_CONFIGURATION (u8) 0x01
970#define ACPI_SUB_OPTIMAL_CONFIGURATION (u8) 0x02
971
972/*
973 * 16, 32 and 64-bit Address Descriptor resource types
974 */
975#define ACPI_MEMORY_RANGE (u8) 0x00
976#define ACPI_IO_RANGE (u8) 0x01
977#define ACPI_BUS_NUMBER_RANGE (u8) 0x02
978
979#define ACPI_ADDRESS_NOT_FIXED (u8) 0x00
980#define ACPI_ADDRESS_FIXED (u8) 0x01
981
982#define ACPI_POS_DECODE (u8) 0x00
983#define ACPI_SUB_DECODE (u8) 0x01
984
985#define ACPI_PRODUCER (u8) 0x00
986#define ACPI_CONSUMER (u8) 0x01
987
988/*
989 * If possible, pack the following structures to byte alignment
990 */
991#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
992#pragma pack(1)
993#endif 1076#endif
994
995/* UUID data structures for use in vendor-defined resource descriptors */
996
997struct acpi_uuid {
998 u8 data[ACPI_UUID_LENGTH];
999};
1000
1001struct acpi_vendor_uuid {
1002 u8 subtype;
1003 u8 data[ACPI_UUID_LENGTH];
1004};
1005
1006/*
1007 * Structures used to describe device resources
1008 */
1009struct acpi_resource_irq {
1010 u8 descriptor_length;
1011 u8 triggering;
1012 u8 polarity;
1013 u8 sharable;
1014 u8 interrupt_count;
1015 u8 interrupts[1];
1016};
1017
1018struct acpi_resource_dma {
1019 u8 type;
1020 u8 bus_master;
1021 u8 transfer;
1022 u8 channel_count;
1023 u8 channels[1];
1024};
1025
1026struct acpi_resource_start_dependent {
1027 u8 descriptor_length;
1028 u8 compatibility_priority;
1029 u8 performance_robustness;
1030};
1031
1032/*
1033 * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
1034 * needed because it has no fields
1035 */
1036
1037struct acpi_resource_io {
1038 u8 io_decode;
1039 u8 alignment;
1040 u8 address_length;
1041 u16 minimum;
1042 u16 maximum;
1043};
1044
1045struct acpi_resource_fixed_io {
1046 u16 address;
1047 u8 address_length;
1048};
1049
1050struct acpi_resource_vendor {
1051 u16 byte_length;
1052 u8 byte_data[1];
1053};
1054
1055/* Vendor resource with UUID info (introduced in ACPI 3.0) */
1056
1057struct acpi_resource_vendor_typed {
1058 u16 byte_length;
1059 u8 uuid_subtype;
1060 u8 uuid[ACPI_UUID_LENGTH];
1061 u8 byte_data[1];
1062};
1063
1064struct acpi_resource_end_tag {
1065 u8 checksum;
1066};
1067
1068struct acpi_resource_memory24 {
1069 u8 write_protect;
1070 u16 minimum;
1071 u16 maximum;
1072 u16 alignment;
1073 u16 address_length;
1074};
1075
1076struct acpi_resource_memory32 {
1077 u8 write_protect;
1078 u32 minimum;
1079 u32 maximum;
1080 u32 alignment;
1081 u32 address_length;
1082};
1083
1084struct acpi_resource_fixed_memory32 {
1085 u8 write_protect;
1086 u32 address;
1087 u32 address_length;
1088};
1089
1090struct acpi_memory_attribute {
1091 u8 write_protect;
1092 u8 caching;
1093 u8 range_type;
1094 u8 translation;
1095};
1096
1097struct acpi_io_attribute {
1098 u8 range_type;
1099 u8 translation;
1100 u8 translation_type;
1101 u8 reserved1;
1102};
1103
1104union acpi_resource_attribute {
1105 struct acpi_memory_attribute mem;
1106 struct acpi_io_attribute io;
1107
1108 /* Used for the *word_space macros */
1109
1110 u8 type_specific;
1111};
1112
1113struct acpi_resource_source {
1114 u8 index;
1115 u16 string_length;
1116 char *string_ptr;
1117};
1118
1119/* Fields common to all address descriptors, 16/32/64 bit */
1120
1121#define ACPI_RESOURCE_ADDRESS_COMMON \
1122 u8 resource_type; \
1123 u8 producer_consumer; \
1124 u8 decode; \
1125 u8 min_address_fixed; \
1126 u8 max_address_fixed; \
1127 union acpi_resource_attribute info;
1128
1129struct acpi_resource_address {
1130ACPI_RESOURCE_ADDRESS_COMMON};
1131
1132struct acpi_resource_address16 {
1133 ACPI_RESOURCE_ADDRESS_COMMON u16 granularity;
1134 u16 minimum;
1135 u16 maximum;
1136 u16 translation_offset;
1137 u16 address_length;
1138 struct acpi_resource_source resource_source;
1139};
1140
1141struct acpi_resource_address32 {
1142 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
1143 u32 minimum;
1144 u32 maximum;
1145 u32 translation_offset;
1146 u32 address_length;
1147 struct acpi_resource_source resource_source;
1148};
1149
1150struct acpi_resource_address64 {
1151 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity;
1152 u64 minimum;
1153 u64 maximum;
1154 u64 translation_offset;
1155 u64 address_length;
1156 struct acpi_resource_source resource_source;
1157};
1158
1159struct acpi_resource_extended_address64 {
1160 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_iD;
1161 u64 granularity;
1162 u64 minimum;
1163 u64 maximum;
1164 u64 translation_offset;
1165 u64 address_length;
1166 u64 type_specific;
1167};
1168
1169struct acpi_resource_extended_irq {
1170 u8 producer_consumer;
1171 u8 triggering;
1172 u8 polarity;
1173 u8 sharable;
1174 u8 interrupt_count;
1175 struct acpi_resource_source resource_source;
1176 u32 interrupts[1];
1177};
1178
1179struct acpi_resource_generic_register {
1180 u8 space_id;
1181 u8 bit_width;
1182 u8 bit_offset;
1183 u8 access_size;
1184 u64 address;
1185};
1186
1187/* ACPI_RESOURCE_TYPEs */
1188
1189#define ACPI_RESOURCE_TYPE_IRQ 0
1190#define ACPI_RESOURCE_TYPE_DMA 1
1191#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
1192#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
1193#define ACPI_RESOURCE_TYPE_IO 4
1194#define ACPI_RESOURCE_TYPE_FIXED_IO 5
1195#define ACPI_RESOURCE_TYPE_VENDOR 6
1196#define ACPI_RESOURCE_TYPE_END_TAG 7
1197#define ACPI_RESOURCE_TYPE_MEMORY24 8
1198#define ACPI_RESOURCE_TYPE_MEMORY32 9
1199#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
1200#define ACPI_RESOURCE_TYPE_ADDRESS16 11
1201#define ACPI_RESOURCE_TYPE_ADDRESS32 12
1202#define ACPI_RESOURCE_TYPE_ADDRESS64 13
1203#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
1204#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
1205#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
1206#define ACPI_RESOURCE_TYPE_MAX 16
1207
1208union acpi_resource_data {
1209 struct acpi_resource_irq irq;
1210 struct acpi_resource_dma dma;
1211 struct acpi_resource_start_dependent start_dpf;
1212 struct acpi_resource_io io;
1213 struct acpi_resource_fixed_io fixed_io;
1214 struct acpi_resource_vendor vendor;
1215 struct acpi_resource_vendor_typed vendor_typed;
1216 struct acpi_resource_end_tag end_tag;
1217 struct acpi_resource_memory24 memory24;
1218 struct acpi_resource_memory32 memory32;
1219 struct acpi_resource_fixed_memory32 fixed_memory32;
1220 struct acpi_resource_address16 address16;
1221 struct acpi_resource_address32 address32;
1222 struct acpi_resource_address64 address64;
1223 struct acpi_resource_extended_address64 ext_address64;
1224 struct acpi_resource_extended_irq extended_irq;
1225 struct acpi_resource_generic_register generic_reg;
1226
1227 /* Common fields */
1228
1229 struct acpi_resource_address address; /* Common 16/32/64 address fields */
1230};
1231
1232struct acpi_resource {
1233 u32 type;
1234 u32 length;
1235 union acpi_resource_data data;
1236};
1237
1238/* restore default alignment */
1239
1240#pragma pack()
1241
1242#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
1243#define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
1244#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
1245
1246#define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length)
1247
1248struct acpi_pci_routing_table {
1249 u32 length;
1250 u32 pin;
1251 acpi_integer address; /* here for 64-bit alignment */
1252 u32 source_index;
1253 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
1254}; 1077};
1255 1078
1256#endif /* __ACTYPES_H__ */ 1079#endif /* __ACTYPES_H__ */
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index fcd2572e428c..e62f10d9a7d8 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -44,14 +44,26 @@
44#ifndef __ACENV_H__ 44#ifndef __ACENV_H__
45#define __ACENV_H__ 45#define __ACENV_H__
46 46
47/* 47/* Types for ACPI_MUTEX_TYPE */
48
49#define ACPI_BINARY_SEMAPHORE 0
50#define ACPI_OSL_MUTEX 1
51
52/* Types for DEBUGGER_THREADING */
53
54#define DEBUGGER_SINGLE_THREADED 0
55#define DEBUGGER_MULTI_THREADED 1
56
57/******************************************************************************
58 *
48 * Configuration for ACPI tools and utilities 59 * Configuration for ACPI tools and utilities
49 */ 60 *
61 *****************************************************************************/
50 62
51#ifdef ACPI_LIBRARY 63#ifdef ACPI_LIBRARY
52/* 64/*
53 * Note: The non-debug version of the acpi_library does not contain any 65 * Note: The non-debug version of the acpi_library does not contain any
54 * debug support, for minimimal size. The debug version uses ACPI_FULL_DEBUG 66 * debug support, for minimal size. The debug version uses ACPI_FULL_DEBUG
55 */ 67 */
56#define ACPI_USE_LOCAL_CACHE 68#define ACPI_USE_LOCAL_CACHE
57#endif 69#endif
@@ -75,17 +87,6 @@
75#define ACPI_DBG_TRACK_ALLOCATIONS 87#define ACPI_DBG_TRACK_ALLOCATIONS
76#endif 88#endif
77 89
78#ifdef ACPI_DASM_APP
79#ifndef MSDOS
80#define ACPI_DEBUG_OUTPUT
81#endif
82#define ACPI_APPLICATION
83#define ACPI_DISASSEMBLER
84#define ACPI_NO_METHOD_EXECUTION
85#define ACPI_LARGE_NAMESPACE_NODE
86#define ACPI_DATA_TABLE_DISASSEMBLY
87#endif
88
89#ifdef ACPI_APPLICATION 90#ifdef ACPI_APPLICATION
90#define ACPI_USE_SYSTEM_CLIBRARY 91#define ACPI_USE_SYSTEM_CLIBRARY
91#define ACPI_USE_LOCAL_CACHE 92#define ACPI_USE_LOCAL_CACHE
@@ -179,6 +180,19 @@
179 180
180/*! [End] no source code translation !*/ 181/*! [End] no source code translation !*/
181 182
183/******************************************************************************
184 *
185 * Miscellaneous configuration
186 *
187 *****************************************************************************/
188
189/*
190 * Are mutexes supported by the host? default is no, use binary semaphores.
191 */
192#ifndef ACPI_MUTEX_TYPE
193#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
194#endif
195
182/* 196/*
183 * Debugger threading model 197 * Debugger threading model
184 * Use single threaded if the entire subsystem is contained in an application 198 * Use single threaded if the entire subsystem is contained in an application
@@ -187,9 +201,6 @@
187 * By default the model is single threaded if ACPI_APPLICATION is set, 201 * By default the model is single threaded if ACPI_APPLICATION is set,
188 * multi-threaded if ACPI_APPLICATION is not set. 202 * multi-threaded if ACPI_APPLICATION is not set.
189 */ 203 */
190#define DEBUGGER_SINGLE_THREADED 0
191#define DEBUGGER_MULTI_THREADED 1
192
193#ifndef DEBUGGER_THREADING 204#ifndef DEBUGGER_THREADING
194#ifdef ACPI_APPLICATION 205#ifdef ACPI_APPLICATION
195#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED 206#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 0515e754449d..3cabf888c8af 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -46,6 +46,7 @@
46 46
47#define ACPI_USE_SYSTEM_CLIBRARY 47#define ACPI_USE_SYSTEM_CLIBRARY
48#define ACPI_USE_DO_WHILE_0 48#define ACPI_USE_DO_WHILE_0
49#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
49 50
50#ifdef __KERNEL__ 51#ifdef __KERNEL__
51 52
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index fba8051fb297..dfa0a5356c53 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -270,6 +270,7 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n,
270#ifdef CONFIG_PM_SLEEP 270#ifdef CONFIG_PM_SLEEP
271void __init acpi_no_s4_hw_signature(void); 271void __init acpi_no_s4_hw_signature(void);
272void __init acpi_old_suspend_ordering(void); 272void __init acpi_old_suspend_ordering(void);
273void __init acpi_s4_no_nvs(void);
273#endif /* CONFIG_PM_SLEEP */ 274#endif /* CONFIG_PM_SLEEP */
274#else /* CONFIG_ACPI */ 275#else /* CONFIG_ACPI */
275 276
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index f7cc204fab07..20998746518e 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -223,7 +223,6 @@ struct hotplug_params {
223#ifdef CONFIG_ACPI 223#ifdef CONFIG_ACPI
224#include <acpi/acpi.h> 224#include <acpi/acpi.h>
225#include <acpi/acpi_bus.h> 225#include <acpi/acpi_bus.h>
226#include <acpi/actypes.h>
227extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, 226extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus,
228 struct hotplug_params *hpp); 227 struct hotplug_params *hpp);
229int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); 228int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 2ce8207686e2..2b409c44db83 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -232,6 +232,11 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
232 232
233extern void hibernation_set_ops(struct platform_hibernation_ops *ops); 233extern void hibernation_set_ops(struct platform_hibernation_ops *ops);
234extern int hibernate(void); 234extern int hibernate(void);
235extern int hibernate_nvs_register(unsigned long start, unsigned long size);
236extern int hibernate_nvs_alloc(void);
237extern void hibernate_nvs_free(void);
238extern void hibernate_nvs_save(void);
239extern void hibernate_nvs_restore(void);
235#else /* CONFIG_HIBERNATION */ 240#else /* CONFIG_HIBERNATION */
236static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } 241static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
237static inline void swsusp_set_page_free(struct page *p) {} 242static inline void swsusp_set_page_free(struct page *p) {}
@@ -239,6 +244,14 @@ static inline void swsusp_unset_page_free(struct page *p) {}
239 244
240static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {} 245static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
241static inline int hibernate(void) { return -ENOSYS; } 246static inline int hibernate(void) { return -ENOSYS; }
247static inline int hibernate_nvs_register(unsigned long a, unsigned long b)
248{
249 return 0;
250}
251static inline int hibernate_nvs_alloc(void) { return 0; }
252static inline void hibernate_nvs_free(void) {}
253static inline void hibernate_nvs_save(void) {}
254static inline void hibernate_nvs_restore(void) {}
242#endif /* CONFIG_HIBERNATION */ 255#endif /* CONFIG_HIBERNATION */
243 256
244#ifdef CONFIG_PM_SLEEP 257#ifdef CONFIG_PM_SLEEP
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index f77d3819ef57..45e8541ab7e3 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -258,12 +258,12 @@ int hibernation_snapshot(int platform_mode)
258{ 258{
259 int error; 259 int error;
260 260
261 /* Free memory before shutting down devices. */ 261 error = platform_begin(platform_mode);
262 error = swsusp_shrink_memory();
263 if (error) 262 if (error)
264 return error; 263 return error;
265 264
266 error = platform_begin(platform_mode); 265 /* Free memory before shutting down devices. */
266 error = swsusp_shrink_memory();
267 if (error) 267 if (error)
268 goto Close; 268 goto Close;
269 269
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 5d2ab836e998..f5fc2d7680f2 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -25,6 +25,7 @@
25#include <linux/syscalls.h> 25#include <linux/syscalls.h>
26#include <linux/console.h> 26#include <linux/console.h>
27#include <linux/highmem.h> 27#include <linux/highmem.h>
28#include <linux/list.h>
28 29
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
30#include <asm/mmu_context.h> 31#include <asm/mmu_context.h>
@@ -192,12 +193,6 @@ static void *chain_alloc(struct chain_allocator *ca, unsigned int size)
192 return ret; 193 return ret;
193} 194}
194 195
195static void chain_free(struct chain_allocator *ca, int clear_page_nosave)
196{
197 free_list_of_pages(ca->chain, clear_page_nosave);
198 memset(ca, 0, sizeof(struct chain_allocator));
199}
200
201/** 196/**
202 * Data types related to memory bitmaps. 197 * Data types related to memory bitmaps.
203 * 198 *
@@ -233,7 +228,7 @@ static void chain_free(struct chain_allocator *ca, int clear_page_nosave)
233#define BM_BITS_PER_BLOCK (PAGE_SIZE << 3) 228#define BM_BITS_PER_BLOCK (PAGE_SIZE << 3)
234 229
235struct bm_block { 230struct bm_block {
236 struct bm_block *next; /* next element of the list */ 231 struct list_head hook; /* hook into a list of bitmap blocks */
237 unsigned long start_pfn; /* pfn represented by the first bit */ 232 unsigned long start_pfn; /* pfn represented by the first bit */
238 unsigned long end_pfn; /* pfn represented by the last bit plus 1 */ 233 unsigned long end_pfn; /* pfn represented by the last bit plus 1 */
239 unsigned long *data; /* bitmap representing pages */ 234 unsigned long *data; /* bitmap representing pages */
@@ -244,24 +239,15 @@ static inline unsigned long bm_block_bits(struct bm_block *bb)
244 return bb->end_pfn - bb->start_pfn; 239 return bb->end_pfn - bb->start_pfn;
245} 240}
246 241
247struct zone_bitmap {
248 struct zone_bitmap *next; /* next element of the list */
249 unsigned long start_pfn; /* minimal pfn in this zone */
250 unsigned long end_pfn; /* maximal pfn in this zone plus 1 */
251 struct bm_block *bm_blocks; /* list of bitmap blocks */
252 struct bm_block *cur_block; /* recently used bitmap block */
253};
254
255/* strcut bm_position is used for browsing memory bitmaps */ 242/* strcut bm_position is used for browsing memory bitmaps */
256 243
257struct bm_position { 244struct bm_position {
258 struct zone_bitmap *zone_bm;
259 struct bm_block *block; 245 struct bm_block *block;
260 int bit; 246 int bit;
261}; 247};
262 248
263struct memory_bitmap { 249struct memory_bitmap {
264 struct zone_bitmap *zone_bm_list; /* list of zone bitmaps */ 250 struct list_head blocks; /* list of bitmap blocks */
265 struct linked_page *p_list; /* list of pages used to store zone 251 struct linked_page *p_list; /* list of pages used to store zone
266 * bitmap objects and bitmap block 252 * bitmap objects and bitmap block
267 * objects 253 * objects
@@ -273,11 +259,7 @@ struct memory_bitmap {
273 259
274static void memory_bm_position_reset(struct memory_bitmap *bm) 260static void memory_bm_position_reset(struct memory_bitmap *bm)
275{ 261{
276 struct zone_bitmap *zone_bm; 262 bm->cur.block = list_entry(bm->blocks.next, struct bm_block, hook);
277
278 zone_bm = bm->zone_bm_list;
279 bm->cur.zone_bm = zone_bm;
280 bm->cur.block = zone_bm->bm_blocks;
281 bm->cur.bit = 0; 263 bm->cur.bit = 0;
282} 264}
283 265
@@ -285,151 +267,184 @@ static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free);
285 267
286/** 268/**
287 * create_bm_block_list - create a list of block bitmap objects 269 * create_bm_block_list - create a list of block bitmap objects
270 * @nr_blocks - number of blocks to allocate
271 * @list - list to put the allocated blocks into
272 * @ca - chain allocator to be used for allocating memory
288 */ 273 */
289 274static int create_bm_block_list(unsigned long pages,
290static inline struct bm_block * 275 struct list_head *list,
291create_bm_block_list(unsigned int nr_blocks, struct chain_allocator *ca) 276 struct chain_allocator *ca)
292{ 277{
293 struct bm_block *bblist = NULL; 278 unsigned int nr_blocks = DIV_ROUND_UP(pages, BM_BITS_PER_BLOCK);
294 279
295 while (nr_blocks-- > 0) { 280 while (nr_blocks-- > 0) {
296 struct bm_block *bb; 281 struct bm_block *bb;
297 282
298 bb = chain_alloc(ca, sizeof(struct bm_block)); 283 bb = chain_alloc(ca, sizeof(struct bm_block));
299 if (!bb) 284 if (!bb)
300 return NULL; 285 return -ENOMEM;
301 286 list_add(&bb->hook, list);
302 bb->next = bblist;
303 bblist = bb;
304 } 287 }
305 return bblist; 288
289 return 0;
306} 290}
307 291
292struct mem_extent {
293 struct list_head hook;
294 unsigned long start;
295 unsigned long end;
296};
297
308/** 298/**
309 * create_zone_bm_list - create a list of zone bitmap objects 299 * free_mem_extents - free a list of memory extents
300 * @list - list of extents to empty
310 */ 301 */
302static void free_mem_extents(struct list_head *list)
303{
304 struct mem_extent *ext, *aux;
311 305
312static inline struct zone_bitmap * 306 list_for_each_entry_safe(ext, aux, list, hook) {
313create_zone_bm_list(unsigned int nr_zones, struct chain_allocator *ca) 307 list_del(&ext->hook);
308 kfree(ext);
309 }
310}
311
312/**
313 * create_mem_extents - create a list of memory extents representing
314 * contiguous ranges of PFNs
315 * @list - list to put the extents into
316 * @gfp_mask - mask to use for memory allocations
317 */
318static int create_mem_extents(struct list_head *list, gfp_t gfp_mask)
314{ 319{
315 struct zone_bitmap *zbmlist = NULL; 320 struct zone *zone;
316 321
317 while (nr_zones-- > 0) { 322 INIT_LIST_HEAD(list);
318 struct zone_bitmap *zbm;
319 323
320 zbm = chain_alloc(ca, sizeof(struct zone_bitmap)); 324 for_each_zone(zone) {
321 if (!zbm) 325 unsigned long zone_start, zone_end;
322 return NULL; 326 struct mem_extent *ext, *cur, *aux;
327
328 if (!populated_zone(zone))
329 continue;
323 330
324 zbm->next = zbmlist; 331 zone_start = zone->zone_start_pfn;
325 zbmlist = zbm; 332 zone_end = zone->zone_start_pfn + zone->spanned_pages;
333
334 list_for_each_entry(ext, list, hook)
335 if (zone_start <= ext->end)
336 break;
337
338 if (&ext->hook == list || zone_end < ext->start) {
339 /* New extent is necessary */
340 struct mem_extent *new_ext;
341
342 new_ext = kzalloc(sizeof(struct mem_extent), gfp_mask);
343 if (!new_ext) {
344 free_mem_extents(list);
345 return -ENOMEM;
346 }
347 new_ext->start = zone_start;
348 new_ext->end = zone_end;
349 list_add_tail(&new_ext->hook, &ext->hook);
350 continue;
351 }
352
353 /* Merge this zone's range of PFNs with the existing one */
354 if (zone_start < ext->start)
355 ext->start = zone_start;
356 if (zone_end > ext->end)
357 ext->end = zone_end;
358
359 /* More merging may be possible */
360 cur = ext;
361 list_for_each_entry_safe_continue(cur, aux, list, hook) {
362 if (zone_end < cur->start)
363 break;
364 if (zone_end < cur->end)
365 ext->end = cur->end;
366 list_del(&cur->hook);
367 kfree(cur);
368 }
326 } 369 }
327 return zbmlist; 370
371 return 0;
328} 372}
329 373
330/** 374/**
331 * memory_bm_create - allocate memory for a memory bitmap 375 * memory_bm_create - allocate memory for a memory bitmap
332 */ 376 */
333
334static int 377static int
335memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed) 378memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
336{ 379{
337 struct chain_allocator ca; 380 struct chain_allocator ca;
338 struct zone *zone; 381 struct list_head mem_extents;
339 struct zone_bitmap *zone_bm; 382 struct mem_extent *ext;
340 struct bm_block *bb; 383 int error;
341 unsigned int nr;
342 384
343 chain_init(&ca, gfp_mask, safe_needed); 385 chain_init(&ca, gfp_mask, safe_needed);
386 INIT_LIST_HEAD(&bm->blocks);
344 387
345 /* Compute the number of zones */ 388 error = create_mem_extents(&mem_extents, gfp_mask);
346 nr = 0; 389 if (error)
347 for_each_zone(zone) 390 return error;
348 if (populated_zone(zone))
349 nr++;
350
351 /* Allocate the list of zones bitmap objects */
352 zone_bm = create_zone_bm_list(nr, &ca);
353 bm->zone_bm_list = zone_bm;
354 if (!zone_bm) {
355 chain_free(&ca, PG_UNSAFE_CLEAR);
356 return -ENOMEM;
357 }
358
359 /* Initialize the zone bitmap objects */
360 for_each_zone(zone) {
361 unsigned long pfn;
362 391
363 if (!populated_zone(zone)) 392 list_for_each_entry(ext, &mem_extents, hook) {
364 continue; 393 struct bm_block *bb;
394 unsigned long pfn = ext->start;
395 unsigned long pages = ext->end - ext->start;
365 396
366 zone_bm->start_pfn = zone->zone_start_pfn; 397 bb = list_entry(bm->blocks.prev, struct bm_block, hook);
367 zone_bm->end_pfn = zone->zone_start_pfn + zone->spanned_pages;
368 /* Allocate the list of bitmap block objects */
369 nr = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK);
370 bb = create_bm_block_list(nr, &ca);
371 zone_bm->bm_blocks = bb;
372 zone_bm->cur_block = bb;
373 if (!bb)
374 goto Free;
375 398
376 nr = zone->spanned_pages; 399 error = create_bm_block_list(pages, bm->blocks.prev, &ca);
377 pfn = zone->zone_start_pfn; 400 if (error)
378 /* Initialize the bitmap block objects */ 401 goto Error;
379 while (bb) {
380 unsigned long *ptr;
381 402
382 ptr = get_image_page(gfp_mask, safe_needed); 403 list_for_each_entry_continue(bb, &bm->blocks, hook) {
383 bb->data = ptr; 404 bb->data = get_image_page(gfp_mask, safe_needed);
384 if (!ptr) 405 if (!bb->data) {
385 goto Free; 406 error = -ENOMEM;
407 goto Error;
408 }
386 409
387 bb->start_pfn = pfn; 410 bb->start_pfn = pfn;
388 if (nr >= BM_BITS_PER_BLOCK) { 411 if (pages >= BM_BITS_PER_BLOCK) {
389 pfn += BM_BITS_PER_BLOCK; 412 pfn += BM_BITS_PER_BLOCK;
390 nr -= BM_BITS_PER_BLOCK; 413 pages -= BM_BITS_PER_BLOCK;
391 } else { 414 } else {
392 /* This is executed only once in the loop */ 415 /* This is executed only once in the loop */
393 pfn += nr; 416 pfn += pages;
394 } 417 }
395 bb->end_pfn = pfn; 418 bb->end_pfn = pfn;
396 bb = bb->next;
397 } 419 }
398 zone_bm = zone_bm->next;
399 } 420 }
421
400 bm->p_list = ca.chain; 422 bm->p_list = ca.chain;
401 memory_bm_position_reset(bm); 423 memory_bm_position_reset(bm);
402 return 0; 424 Exit:
425 free_mem_extents(&mem_extents);
426 return error;
403 427
404 Free: 428 Error:
405 bm->p_list = ca.chain; 429 bm->p_list = ca.chain;
406 memory_bm_free(bm, PG_UNSAFE_CLEAR); 430 memory_bm_free(bm, PG_UNSAFE_CLEAR);
407 return -ENOMEM; 431 goto Exit;
408} 432}
409 433
410/** 434/**
411 * memory_bm_free - free memory occupied by the memory bitmap @bm 435 * memory_bm_free - free memory occupied by the memory bitmap @bm
412 */ 436 */
413
414static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free) 437static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free)
415{ 438{
416 struct zone_bitmap *zone_bm; 439 struct bm_block *bb;
417 440
418 /* Free the list of bit blocks for each zone_bitmap object */ 441 list_for_each_entry(bb, &bm->blocks, hook)
419 zone_bm = bm->zone_bm_list; 442 if (bb->data)
420 while (zone_bm) { 443 free_image_page(bb->data, clear_nosave_free);
421 struct bm_block *bb;
422 444
423 bb = zone_bm->bm_blocks;
424 while (bb) {
425 if (bb->data)
426 free_image_page(bb->data, clear_nosave_free);
427 bb = bb->next;
428 }
429 zone_bm = zone_bm->next;
430 }
431 free_list_of_pages(bm->p_list, clear_nosave_free); 445 free_list_of_pages(bm->p_list, clear_nosave_free);
432 bm->zone_bm_list = NULL; 446
447 INIT_LIST_HEAD(&bm->blocks);
433} 448}
434 449
435/** 450/**
@@ -437,38 +452,33 @@ static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free)
437 * to given pfn. The cur_zone_bm member of @bm and the cur_block member 452 * to given pfn. The cur_zone_bm member of @bm and the cur_block member
438 * of @bm->cur_zone_bm are updated. 453 * of @bm->cur_zone_bm are updated.
439 */ 454 */
440
441static int memory_bm_find_bit(struct memory_bitmap *bm, unsigned long pfn, 455static int memory_bm_find_bit(struct memory_bitmap *bm, unsigned long pfn,
442 void **addr, unsigned int *bit_nr) 456 void **addr, unsigned int *bit_nr)
443{ 457{
444 struct zone_bitmap *zone_bm;
445 struct bm_block *bb; 458 struct bm_block *bb;
446 459
447 /* Check if the pfn is from the current zone */ 460 /*
448 zone_bm = bm->cur.zone_bm; 461 * Check if the pfn corresponds to the current bitmap block and find
449 if (pfn < zone_bm->start_pfn || pfn >= zone_bm->end_pfn) { 462 * the block where it fits if this is not the case.
450 zone_bm = bm->zone_bm_list; 463 */
451 /* We don't assume that the zones are sorted by pfns */ 464 bb = bm->cur.block;
452 while (pfn < zone_bm->start_pfn || pfn >= zone_bm->end_pfn) {
453 zone_bm = zone_bm->next;
454
455 if (!zone_bm)
456 return -EFAULT;
457 }
458 bm->cur.zone_bm = zone_bm;
459 }
460 /* Check if the pfn corresponds to the current bitmap block */
461 bb = zone_bm->cur_block;
462 if (pfn < bb->start_pfn) 465 if (pfn < bb->start_pfn)
463 bb = zone_bm->bm_blocks; 466 list_for_each_entry_continue_reverse(bb, &bm->blocks, hook)
467 if (pfn >= bb->start_pfn)
468 break;
464 469
465 while (pfn >= bb->end_pfn) { 470 if (pfn >= bb->end_pfn)
466 bb = bb->next; 471 list_for_each_entry_continue(bb, &bm->blocks, hook)
472 if (pfn >= bb->start_pfn && pfn < bb->end_pfn)
473 break;
467 474
468 BUG_ON(!bb); 475 if (&bb->hook == &bm->blocks)
469 } 476 return -EFAULT;
470 zone_bm->cur_block = bb; 477
478 /* The block has been found */
479 bm->cur.block = bb;
471 pfn -= bb->start_pfn; 480 pfn -= bb->start_pfn;
481 bm->cur.bit = pfn + 1;
472 *bit_nr = pfn; 482 *bit_nr = pfn;
473 *addr = bb->data; 483 *addr = bb->data;
474 return 0; 484 return 0;
@@ -519,6 +529,14 @@ static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn)
519 return test_bit(bit, addr); 529 return test_bit(bit, addr);
520} 530}
521 531
532static bool memory_bm_pfn_present(struct memory_bitmap *bm, unsigned long pfn)
533{
534 void *addr;
535 unsigned int bit;
536
537 return !memory_bm_find_bit(bm, pfn, &addr, &bit);
538}
539
522/** 540/**
523 * memory_bm_next_pfn - find the pfn that corresponds to the next set bit 541 * memory_bm_next_pfn - find the pfn that corresponds to the next set bit
524 * in the bitmap @bm. If the pfn cannot be found, BM_END_OF_MAP is 542 * in the bitmap @bm. If the pfn cannot be found, BM_END_OF_MAP is
@@ -530,29 +548,21 @@ static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn)
530 548
531static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm) 549static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm)
532{ 550{
533 struct zone_bitmap *zone_bm;
534 struct bm_block *bb; 551 struct bm_block *bb;
535 int bit; 552 int bit;
536 553
554 bb = bm->cur.block;
537 do { 555 do {
538 bb = bm->cur.block; 556 bit = bm->cur.bit;
539 do { 557 bit = find_next_bit(bb->data, bm_block_bits(bb), bit);
540 bit = bm->cur.bit; 558 if (bit < bm_block_bits(bb))
541 bit = find_next_bit(bb->data, bm_block_bits(bb), bit); 559 goto Return_pfn;
542 if (bit < bm_block_bits(bb)) 560
543 goto Return_pfn; 561 bb = list_entry(bb->hook.next, struct bm_block, hook);
544 562 bm->cur.block = bb;
545 bb = bb->next; 563 bm->cur.bit = 0;
546 bm->cur.block = bb; 564 } while (&bb->hook != &bm->blocks);
547 bm->cur.bit = 0; 565
548 } while (bb);
549 zone_bm = bm->cur.zone_bm->next;
550 if (zone_bm) {
551 bm->cur.zone_bm = zone_bm;
552 bm->cur.block = zone_bm->bm_blocks;
553 bm->cur.bit = 0;
554 }
555 } while (zone_bm);
556 memory_bm_position_reset(bm); 566 memory_bm_position_reset(bm);
557 return BM_END_OF_MAP; 567 return BM_END_OF_MAP;
558 568
@@ -808,8 +818,7 @@ static unsigned int count_free_highmem_pages(void)
808 * We should save the page if it isn't Nosave or NosaveFree, or Reserved, 818 * We should save the page if it isn't Nosave or NosaveFree, or Reserved,
809 * and it isn't a part of a free chunk of pages. 819 * and it isn't a part of a free chunk of pages.
810 */ 820 */
811 821static struct page *saveable_highmem_page(struct zone *zone, unsigned long pfn)
812static struct page *saveable_highmem_page(unsigned long pfn)
813{ 822{
814 struct page *page; 823 struct page *page;
815 824
@@ -817,6 +826,8 @@ static struct page *saveable_highmem_page(unsigned long pfn)
817 return NULL; 826 return NULL;
818 827
819 page = pfn_to_page(pfn); 828 page = pfn_to_page(pfn);
829 if (page_zone(page) != zone)
830 return NULL;
820 831
821 BUG_ON(!PageHighMem(page)); 832 BUG_ON(!PageHighMem(page));
822 833
@@ -846,13 +857,16 @@ unsigned int count_highmem_pages(void)
846 mark_free_pages(zone); 857 mark_free_pages(zone);
847 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 858 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
848 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 859 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
849 if (saveable_highmem_page(pfn)) 860 if (saveable_highmem_page(zone, pfn))
850 n++; 861 n++;
851 } 862 }
852 return n; 863 return n;
853} 864}
854#else 865#else
855static inline void *saveable_highmem_page(unsigned long pfn) { return NULL; } 866static inline void *saveable_highmem_page(struct zone *z, unsigned long p)
867{
868 return NULL;
869}
856#endif /* CONFIG_HIGHMEM */ 870#endif /* CONFIG_HIGHMEM */
857 871
858/** 872/**
@@ -863,8 +877,7 @@ static inline void *saveable_highmem_page(unsigned long pfn) { return NULL; }
863 * of pages statically defined as 'unsaveable', and it isn't a part of 877 * of pages statically defined as 'unsaveable', and it isn't a part of
864 * a free chunk of pages. 878 * a free chunk of pages.
865 */ 879 */
866 880static struct page *saveable_page(struct zone *zone, unsigned long pfn)
867static struct page *saveable_page(unsigned long pfn)
868{ 881{
869 struct page *page; 882 struct page *page;
870 883
@@ -872,6 +885,8 @@ static struct page *saveable_page(unsigned long pfn)
872 return NULL; 885 return NULL;
873 886
874 page = pfn_to_page(pfn); 887 page = pfn_to_page(pfn);
888 if (page_zone(page) != zone)
889 return NULL;
875 890
876 BUG_ON(PageHighMem(page)); 891 BUG_ON(PageHighMem(page));
877 892
@@ -903,7 +918,7 @@ unsigned int count_data_pages(void)
903 mark_free_pages(zone); 918 mark_free_pages(zone);
904 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 919 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
905 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 920 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
906 if(saveable_page(pfn)) 921 if (saveable_page(zone, pfn))
907 n++; 922 n++;
908 } 923 }
909 return n; 924 return n;
@@ -944,7 +959,7 @@ static inline struct page *
944page_is_saveable(struct zone *zone, unsigned long pfn) 959page_is_saveable(struct zone *zone, unsigned long pfn)
945{ 960{
946 return is_highmem(zone) ? 961 return is_highmem(zone) ?
947 saveable_highmem_page(pfn) : saveable_page(pfn); 962 saveable_highmem_page(zone, pfn) : saveable_page(zone, pfn);
948} 963}
949 964
950static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn) 965static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
@@ -966,7 +981,7 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
966 * data modified by kmap_atomic() 981 * data modified by kmap_atomic()
967 */ 982 */
968 safe_copy_page(buffer, s_page); 983 safe_copy_page(buffer, s_page);
969 dst = kmap_atomic(pfn_to_page(dst_pfn), KM_USER0); 984 dst = kmap_atomic(d_page, KM_USER0);
970 memcpy(dst, buffer, PAGE_SIZE); 985 memcpy(dst, buffer, PAGE_SIZE);
971 kunmap_atomic(dst, KM_USER0); 986 kunmap_atomic(dst, KM_USER0);
972 } else { 987 } else {
@@ -975,7 +990,7 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
975 } 990 }
976} 991}
977#else 992#else
978#define page_is_saveable(zone, pfn) saveable_page(pfn) 993#define page_is_saveable(zone, pfn) saveable_page(zone, pfn)
979 994
980static inline void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn) 995static inline void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
981{ 996{
@@ -1459,9 +1474,7 @@ load_header(struct swsusp_info *info)
1459 * unpack_orig_pfns - for each element of @buf[] (1 page at a time) set 1474 * unpack_orig_pfns - for each element of @buf[] (1 page at a time) set
1460 * the corresponding bit in the memory bitmap @bm 1475 * the corresponding bit in the memory bitmap @bm
1461 */ 1476 */
1462 1477static int unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1463static inline void
1464unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1465{ 1478{
1466 int j; 1479 int j;
1467 1480
@@ -1469,8 +1482,13 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1469 if (unlikely(buf[j] == BM_END_OF_MAP)) 1482 if (unlikely(buf[j] == BM_END_OF_MAP))
1470 break; 1483 break;
1471 1484
1472 memory_bm_set_bit(bm, buf[j]); 1485 if (memory_bm_pfn_present(bm, buf[j]))
1486 memory_bm_set_bit(bm, buf[j]);
1487 else
1488 return -EFAULT;
1473 } 1489 }
1490
1491 return 0;
1474} 1492}
1475 1493
1476/* List of "safe" pages that may be used to store data loaded from the suspend 1494/* List of "safe" pages that may be used to store data loaded from the suspend
@@ -1608,7 +1626,7 @@ get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1608 pbe = chain_alloc(ca, sizeof(struct highmem_pbe)); 1626 pbe = chain_alloc(ca, sizeof(struct highmem_pbe));
1609 if (!pbe) { 1627 if (!pbe) {
1610 swsusp_free(); 1628 swsusp_free();
1611 return NULL; 1629 return ERR_PTR(-ENOMEM);
1612 } 1630 }
1613 pbe->orig_page = page; 1631 pbe->orig_page = page;
1614 if (safe_highmem_pages > 0) { 1632 if (safe_highmem_pages > 0) {
@@ -1677,7 +1695,7 @@ prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
1677static inline void * 1695static inline void *
1678get_highmem_page_buffer(struct page *page, struct chain_allocator *ca) 1696get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1679{ 1697{
1680 return NULL; 1698 return ERR_PTR(-EINVAL);
1681} 1699}
1682 1700
1683static inline void copy_last_highmem_page(void) {} 1701static inline void copy_last_highmem_page(void) {}
@@ -1788,8 +1806,13 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1788static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca) 1806static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1789{ 1807{
1790 struct pbe *pbe; 1808 struct pbe *pbe;
1791 struct page *page = pfn_to_page(memory_bm_next_pfn(bm)); 1809 struct page *page;
1810 unsigned long pfn = memory_bm_next_pfn(bm);
1792 1811
1812 if (pfn == BM_END_OF_MAP)
1813 return ERR_PTR(-EFAULT);
1814
1815 page = pfn_to_page(pfn);
1793 if (PageHighMem(page)) 1816 if (PageHighMem(page))
1794 return get_highmem_page_buffer(page, ca); 1817 return get_highmem_page_buffer(page, ca);
1795 1818
@@ -1805,7 +1828,7 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1805 pbe = chain_alloc(ca, sizeof(struct pbe)); 1828 pbe = chain_alloc(ca, sizeof(struct pbe));
1806 if (!pbe) { 1829 if (!pbe) {
1807 swsusp_free(); 1830 swsusp_free();
1808 return NULL; 1831 return ERR_PTR(-ENOMEM);
1809 } 1832 }
1810 pbe->orig_address = page_address(page); 1833 pbe->orig_address = page_address(page);
1811 pbe->address = safe_pages_list; 1834 pbe->address = safe_pages_list;
@@ -1868,7 +1891,10 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1868 return error; 1891 return error;
1869 1892
1870 } else if (handle->prev <= nr_meta_pages) { 1893 } else if (handle->prev <= nr_meta_pages) {
1871 unpack_orig_pfns(buffer, &copy_bm); 1894 error = unpack_orig_pfns(buffer, &copy_bm);
1895 if (error)
1896 return error;
1897
1872 if (handle->prev == nr_meta_pages) { 1898 if (handle->prev == nr_meta_pages) {
1873 error = prepare_image(&orig_bm, &copy_bm); 1899 error = prepare_image(&orig_bm, &copy_bm);
1874 if (error) 1900 if (error)
@@ -1879,12 +1905,14 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1879 restore_pblist = NULL; 1905 restore_pblist = NULL;
1880 handle->buffer = get_buffer(&orig_bm, &ca); 1906 handle->buffer = get_buffer(&orig_bm, &ca);
1881 handle->sync_read = 0; 1907 handle->sync_read = 0;
1882 if (!handle->buffer) 1908 if (IS_ERR(handle->buffer))
1883 return -ENOMEM; 1909 return PTR_ERR(handle->buffer);
1884 } 1910 }
1885 } else { 1911 } else {
1886 copy_last_highmem_page(); 1912 copy_last_highmem_page();
1887 handle->buffer = get_buffer(&orig_bm, &ca); 1913 handle->buffer = get_buffer(&orig_bm, &ca);
1914 if (IS_ERR(handle->buffer))
1915 return PTR_ERR(handle->buffer);
1888 if (handle->buffer != buffer) 1916 if (handle->buffer != buffer)
1889 handle->sync_read = 0; 1917 handle->sync_read = 0;
1890 } 1918 }
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 023ff2a31d89..a92c91451559 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -262,3 +262,125 @@ int swsusp_shrink_memory(void)
262 262
263 return 0; 263 return 0;
264} 264}
265
266/*
267 * Platforms, like ACPI, may want us to save some memory used by them during
268 * hibernation and to restore the contents of this memory during the subsequent
269 * resume. The code below implements a mechanism allowing us to do that.
270 */
271
272struct nvs_page {
273 unsigned long phys_start;
274 unsigned int size;
275 void *kaddr;
276 void *data;
277 struct list_head node;
278};
279
280static LIST_HEAD(nvs_list);
281
282/**
283 * hibernate_nvs_register - register platform NVS memory region to save
284 * @start - physical address of the region
285 * @size - size of the region
286 *
287 * The NVS region need not be page-aligned (both ends) and we arrange
288 * things so that the data from page-aligned addresses in this region will
289 * be copied into separate RAM pages.
290 */
291int hibernate_nvs_register(unsigned long start, unsigned long size)
292{
293 struct nvs_page *entry, *next;
294
295 while (size > 0) {
296 unsigned int nr_bytes;
297
298 entry = kzalloc(sizeof(struct nvs_page), GFP_KERNEL);
299 if (!entry)
300 goto Error;
301
302 list_add_tail(&entry->node, &nvs_list);
303 entry->phys_start = start;
304 nr_bytes = PAGE_SIZE - (start & ~PAGE_MASK);
305 entry->size = (size < nr_bytes) ? size : nr_bytes;
306
307 start += entry->size;
308 size -= entry->size;
309 }
310 return 0;
311
312 Error:
313 list_for_each_entry_safe(entry, next, &nvs_list, node) {
314 list_del(&entry->node);
315 kfree(entry);
316 }
317 return -ENOMEM;
318}
319
320/**
321 * hibernate_nvs_free - free data pages allocated for saving NVS regions
322 */
323void hibernate_nvs_free(void)
324{
325 struct nvs_page *entry;
326
327 list_for_each_entry(entry, &nvs_list, node)
328 if (entry->data) {
329 free_page((unsigned long)entry->data);
330 entry->data = NULL;
331 if (entry->kaddr) {
332 iounmap(entry->kaddr);
333 entry->kaddr = NULL;
334 }
335 }
336}
337
338/**
339 * hibernate_nvs_alloc - allocate memory necessary for saving NVS regions
340 */
341int hibernate_nvs_alloc(void)
342{
343 struct nvs_page *entry;
344
345 list_for_each_entry(entry, &nvs_list, node) {
346 entry->data = (void *)__get_free_page(GFP_KERNEL);
347 if (!entry->data) {
348 hibernate_nvs_free();
349 return -ENOMEM;
350 }
351 }
352 return 0;
353}
354
355/**
356 * hibernate_nvs_save - save NVS memory regions
357 */
358void hibernate_nvs_save(void)
359{
360 struct nvs_page *entry;
361
362 printk(KERN_INFO "PM: Saving platform NVS memory\n");
363
364 list_for_each_entry(entry, &nvs_list, node)
365 if (entry->data) {
366 entry->kaddr = ioremap(entry->phys_start, entry->size);
367 memcpy(entry->data, entry->kaddr, entry->size);
368 }
369}
370
371/**
372 * hibernate_nvs_restore - restore NVS memory regions
373 *
374 * This function is going to be called with interrupts disabled, so it
375 * cannot iounmap the virtual addresses used to access the NVS region.
376 */
377void hibernate_nvs_restore(void)
378{
379 struct nvs_page *entry;
380
381 printk(KERN_INFO "PM: Restoring platform NVS memory\n");
382
383 list_for_each_entry(entry, &nvs_list, node)
384 if (entry->data)
385 memcpy(entry->kaddr, entry->data, entry->size);
386}